Skip to content

Commit 26384f9

Browse files
authored
Improvements to the E2E Test utilities (#1853)
* Enable specifying a K8S context for the E2E tests Signed-off-by: Shmuel Kallner <[email protected]> * Return kind/name for created objects Signed-off-by: Shmuel Kallner <[email protected]> --------- Signed-off-by: Shmuel Kallner <[email protected]>
1 parent e26d0cd commit 26384f9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

test/e2e/epp/e2e_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ var _ = ginkgo.BeforeSuite(func() {
103103
if nsName == "" {
104104
nsName = defaultNsName
105105
}
106-
testConfig = testutils.NewTestConfig(nsName)
106+
testConfig = testutils.NewTestConfig(nsName, "")
107107

108108
e2eImage = os.Getenv("E2E_IMAGE")
109109
gomega.Expect(e2eImage).NotTo(gomega.BeEmpty(), "E2E_IMAGE environment variable is not set")

test/utils/utils.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ type TestConfig struct {
7373
}
7474

7575
// NewTestConfig creates a new TestConfig instance
76-
func NewTestConfig(nsName string) *TestConfig {
77-
cfg := config.GetConfigOrDie()
76+
func NewTestConfig(nsName string, k8sContext string) *TestConfig {
77+
cfg, err := config.GetConfigWithContext(k8sContext)
78+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
7879
gomega.Expect(cfg).NotTo(gomega.BeNil())
7980

8081
kubeCli, err := kubernetes.NewForConfig(cfg)
@@ -458,11 +459,11 @@ func DeleteObjects(testConfig *TestConfig, kindAndNames []string) {
458459
}
459460
}
460461

461-
// applyYAMLFile reads a file containing YAML (possibly multiple docs)
462+
// ApplyYAMLFile reads a file containing YAML (possibly multiple docs)
462463
// and applies each object to the cluster.
463-
func ApplyYAMLFile(testConfig *TestConfig, filePath string) {
464+
func ApplyYAMLFile(testConfig *TestConfig, filePath string) []string {
464465
// Create the resources from the manifest file
465-
CreateObjsFromYaml(testConfig, ReadYaml(filePath))
466+
return CreateObjsFromYaml(testConfig, ReadYaml(filePath))
466467
}
467468

468469
// ReadYaml is a helper function to read in K8S YAML files and split by the --- separator

0 commit comments

Comments
 (0)