57 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
	
| package e2e
 | |
| 
 | |
| import (
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/VirtusLab/jenkins-operator/pkg/apis"
 | |
| 	virtuslabv1alpha1 "github.com/VirtusLab/jenkins-operator/pkg/apis/virtuslab/v1alpha1"
 | |
| 
 | |
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | |
| 
 | |
| 	framework "github.com/operator-framework/operator-sdk/pkg/test"
 | |
| 	"github.com/operator-framework/operator-sdk/pkg/test/e2eutil"
 | |
| 
 | |
| 	f "github.com/operator-framework/operator-sdk/pkg/test"
 | |
| )
 | |
| 
 | |
| const (
 | |
| 	jenkinsOperatorDeploymentName = "jenkins-operator"
 | |
| )
 | |
| 
 | |
| func TestMain(m *testing.M) {
 | |
| 	f.MainEntry(m)
 | |
| }
 | |
| 
 | |
| func setupTest(t *testing.T) (string, *framework.TestCtx) {
 | |
| 	ctx := framework.NewTestCtx(t)
 | |
| 	err := ctx.InitializeClusterResources(nil)
 | |
| 	if err != nil {
 | |
| 		t.Fatalf("could not initialize cluster resources: %v", err)
 | |
| 	}
 | |
| 
 | |
| 	jenkinsServiceList := &virtuslabv1alpha1.JenkinsList{
 | |
| 		TypeMeta: metav1.TypeMeta{
 | |
| 			Kind:       virtuslabv1alpha1.Kind,
 | |
| 			APIVersion: virtuslabv1alpha1.SchemeGroupVersion.String(),
 | |
| 		},
 | |
| 	}
 | |
| 	err = framework.AddToFrameworkScheme(apis.AddToScheme, jenkinsServiceList)
 | |
| 	if err != nil {
 | |
| 		t.Fatalf("could not add scheme to framework scheme: %v", err)
 | |
| 	}
 | |
| 
 | |
| 	namespace, err := ctx.GetNamespace()
 | |
| 	if err != nil {
 | |
| 		t.Fatalf("could not get namespace: %v", err)
 | |
| 	}
 | |
| 	t.Logf("Test namespace '%s'", namespace)
 | |
| 
 | |
| 	// wait for jenkins-operator to be ready
 | |
| 	err = e2eutil.WaitForDeployment(t, framework.Global.KubeClient, namespace, jenkinsOperatorDeploymentName, 1, retryInterval, timeout)
 | |
| 	if err != nil {
 | |
| 		t.Fatal(err)
 | |
| 	}
 | |
| 
 | |
| 	return namespace, ctx
 | |
| }
 |