@@ -11,32 +11,35 @@ import (
1111 appsv1 "k8s.io/api/apps/v1"
1212 v1 "k8s.io/api/core/v1"
1313 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14+ "sigs.k8s.io/e2e-framework/klient/conf"
1415 "sigs.k8s.io/e2e-framework/klient/wait"
1516 "sigs.k8s.io/e2e-framework/klient/wait/conditions"
1617 "sigs.k8s.io/e2e-framework/pkg/env"
1718 "sigs.k8s.io/e2e-framework/pkg/envconf"
1819 "sigs.k8s.io/e2e-framework/pkg/envfuncs"
19- "sigs.k8s.io/e2e-framework/support/kind"
2020 "sigs.k8s.io/e2e-framework/support/utils"
2121)
2222
2323var (
24- testEnv env.Environment
25- dockerImage = os .Getenv ("E2E_DOCKER_IMAGE" ) //"ml-marklogic-operator-dev.bed-artifactory.bedford.progress.com/marklogic-kubernetes-operator:0.0.2"
26- kustomizeVer = os .Getenv ("E2E_KUSTOMIZE_VERSION" )
24+ testEnv env.Environment
25+ dockerImage = os .Getenv ("E2E_DOCKER_IMAGE" )
26+ kustomizeVer = os .Getenv ("E2E_KUSTOMIZE_VERSION" )
2727 ctrlgenVer = os .Getenv ("E2E_CONTROLLER_TOOLS_VERSION" )
2828 marklogicImage = os .Getenv ("E2E_MARKLOGIC_IMAGE_VERSION" )
2929 kubernetesVer = os .Getenv ("E2E_KUBERNETES_VERSION" )
3030)
3131
3232const (
33- namespace = "marklogic-operator-system"
33+ namespace = "marklogic-operator-system"
3434)
3535
3636func TestMain (m * testing.M ) {
3737 testEnv = env .New ()
38- kindClusterName := "test-cluster"
39- kindCluster := kind .NewCluster (kindClusterName )
38+ path := conf .ResolveKubeConfigFile ()
39+ cfg := envconf .NewWithKubeConfig (path )
40+ testEnv = env .NewWithConfig (cfg )
41+
42+ log .Printf ("Running tests with the following configurations: path=%s" , path )
4043
4144 log .Printf ("Docker image: %s" , dockerImage )
4245 log .Printf ("Kustomize version: %s" , kustomizeVer )
@@ -46,7 +49,6 @@ func TestMain(m *testing.M) {
4649
4750 // Use Environment.Setup to configure pre-test setup
4851 testEnv .Setup (
49- envfuncs .CreateClusterWithConfig (kindCluster , kindClusterName , "kind-config.yaml" , kind .WithImage ("kindest/node:" + kubernetesVer )),
5052 envfuncs .CreateNamespace (namespace ),
5153
5254 // install tool dependencies
@@ -83,43 +85,6 @@ func TestMain(m *testing.M) {
8385 c := utils .RunCommand ("controller-gen --version" )
8486 log .Printf ("controller-gen: %s" , c .Result ())
8587
86- // generate manifest files
87- log .Println ("Generate manifests..." )
88- wd , _ := os .Getwd ()
89- log .Print (wd ) // Output current working directory
90- if p := utils .RunCommand (`controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases` ); p .Err () != nil {
91- log .Printf ("Failed to generate manifests: %s: %s" , p .Err (), p .Result ())
92- return ctx , p .Err ()
93- }
94-
95- // generate api objects
96- log .Println ("Generate API objects..." )
97- if p := utils .RunCommand (`controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."` ); p .Err () != nil {
98- log .Printf ("Failed to generate API objects: %s: %s" , p .Err (), p .Result ())
99- return ctx , p .Err ()
100- }
101-
102- // Build docker image
103- log .Println ("Building docker image..." )
104- if p := utils .RunCommand (fmt .Sprintf ("docker build -t %s ." , dockerImage )); p .Err () != nil {
105- log .Printf ("Failed to build docker image: %s: %s" , p .Err (), p .Result ())
106- return ctx , p .Err ()
107- }
108-
109- // Load docker image into kind
110- log .Println ("Loading docker image into kind cluster..." )
111- if err := kindCluster .LoadImage (ctx , dockerImage ); err != nil {
112- log .Printf ("Failed to load image into kind: %s" , err )
113- return ctx , err
114- }
115-
116- // Load MarkLogic image into kind
117- log .Println ("Loading marklogic image into kind cluster..." )
118- if err := kindCluster .LoadImage (ctx , marklogicImage ); err != nil {
119- log .Printf ("Failed to load image into kind: %s" , err )
120- return ctx , err
121- }
122-
12388 // Deploy components
12489 log .Println ("Deploying controller-manager resources..." )
12590 p := utils .RunCommand (`kubectl version` )
@@ -160,8 +125,6 @@ func TestMain(m *testing.M) {
160125 return ctx , nil
161126 },
162127 envfuncs .DeleteNamespace (namespace ),
163- // envfuncs.ExportClusterLogs(kindClusterName, "../../logs"),
164- envfuncs .DestroyCluster (kindClusterName ),
165128 )
166129
167130 // Use Environment.Run to launch the test
0 commit comments