Refactored e2e user reconciliation tests
This commit is contained in:
		
							parent
							
								
									39eeefd990
								
							
						
					
					
						commit
						b30fb17705
					
				|  | @ -1,18 +1,17 @@ | ||||||
| package e2e | package e2e | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
|  | 	"context" | ||||||
| 	"testing" | 	"testing" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	virtuslabv1alpha1 "github.com/VirtusLab/jenkins-operator/pkg/apis/virtuslab/v1alpha1" | 	virtuslabv1alpha1 "github.com/VirtusLab/jenkins-operator/pkg/apis/virtuslab/v1alpha1" | ||||||
| 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/configuration/user/seedjobs" | 	"github.com/VirtusLab/jenkins-operator/pkg/controller/jenkins/configuration/user/seedjobs" | ||||||
| 
 |  | ||||||
| 	"github.com/bndr/gojenkins" | 	"github.com/bndr/gojenkins" | ||||||
| 	framework "github.com/operator-framework/operator-sdk/pkg/test" | 	framework "github.com/operator-framework/operator-sdk/pkg/test" | ||||||
|  | 	"github.com/stretchr/testify/assert" | ||||||
| 	"k8s.io/apimachinery/pkg/types" | 	"k8s.io/apimachinery/pkg/types" | ||||||
| 	"k8s.io/apimachinery/pkg/util/wait" | 	"k8s.io/apimachinery/pkg/util/wait" | ||||||
| 
 |  | ||||||
| 	"context" |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func TestUserConfiguration(t *testing.T) { | func TestUserConfiguration(t *testing.T) { | ||||||
|  | @ -45,9 +44,7 @@ func verifyJenkinsSeedJobs(t *testing.T, client *gojenkins.Jenkins, jenkins *vir | ||||||
| 		} | 		} | ||||||
| 		return true, nil | 		return true, nil | ||||||
| 	}) | 	}) | ||||||
| 	if err != nil { | 	assert.NoError(t, err, "couldn't get jenkins job") | ||||||
| 		t.Fatalf("couldn't get configure seed job '%v'", err) |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	// WARNING this use case depends on changes in https://github.com/VirtusLab/jenkins-operator-e2e/tree/master/cicd
 | 	// WARNING this use case depends on changes in https://github.com/VirtusLab/jenkins-operator-e2e/tree/master/cicd
 | ||||||
| 	seedJobName := "jenkins-operator-e2e-job-dsl-seed" // https://github.com/VirtusLab/jenkins-operator-e2e/blob/master/cicd/jobs/e2e_test_job.jenkins
 | 	seedJobName := "jenkins-operator-e2e-job-dsl-seed" // https://github.com/VirtusLab/jenkins-operator-e2e/blob/master/cicd/jobs/e2e_test_job.jenkins
 | ||||||
|  | @ -59,24 +56,16 @@ func verifyJenkinsSeedJobs(t *testing.T, client *gojenkins.Jenkins, jenkins *vir | ||||||
| 		} | 		} | ||||||
| 		return true, nil | 		return true, nil | ||||||
| 	}) | 	}) | ||||||
| 	if err != nil { | 	assert.NoError(t, err, "couldn't verify if seed job has been created") | ||||||
| 		t.Fatalf("couldn't verify if seed job has been created '%v'", err) |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	// verify Jenkins.Status.Builds
 | 	// verify Jenkins.Status.Builds
 | ||||||
| 	// WARNING this use case depends on changes in https://github.com/VirtusLab/jenkins-operator-e2e/tree/master/cicd
 | 	// WARNING this use case depends on changes in https://github.com/VirtusLab/jenkins-operator-e2e/tree/master/cicd
 | ||||||
| 	namespacedName := types.NamespacedName{Namespace: jenkins.Namespace, Name: jenkins.Name} | 	err = framework.Global.Client.Get(context.TODO(), types.NamespacedName{Namespace: jenkins.Namespace, Name: jenkins.Name}, jenkins) | ||||||
| 	err = framework.Global.Client.Get(context.TODO(), namespacedName, jenkins) | 	assert.NoError(t, err, "couldn't get jenkins custom resource") | ||||||
| 	if err != nil { |  | ||||||
| 		t.Fatalf("couldn't get jenkins CR '%v'", err) |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if len(jenkins.Status.Builds) != 1 { |  | ||||||
| 		t.Fatalf("couldn't get build status from cr '%v'", jenkins.Status.Builds) |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
|  | 	assert.NotNil(t, jenkins.Status.Builds) | ||||||
|  | 	assert.NotEmpty(t, jenkins.Status.Builds) | ||||||
|  | 	assert.Equal(t, len(jenkins.Status.Builds), 1) | ||||||
| 	build := jenkins.Status.Builds[0] | 	build := jenkins.Status.Builds[0] | ||||||
| 	if build.Name != seedjobs.ConfigureSeedJobsName { | 	assert.Equal(t, build.Name, seedjobs.ConfigureSeedJobsName) | ||||||
| 		t.Fatalf("invalid cr status - wrong seed job name '%v'", build.Name) |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue