Skip to content

Commit

Permalink
chore(e2e): Randomize integration names in e2e tests
Browse files Browse the repository at this point in the history
Add lower case random suffix on integration names to avoid test collisions
  • Loading branch information
gansheer authored and squakez committed Oct 27, 2023
1 parent 7c2a8af commit e5372dd
Show file tree
Hide file tree
Showing 40 changed files with 147 additions and 124 deletions.
6 changes: 3 additions & 3 deletions e2e/common/cli/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestKamelCLIRun(t *testing.T) {
os.Unsetenv("GITHUB_TOKEN")

t.Run("Gist (ID)", func(t *testing.T) {
name := "github-gist-id"
name := RandomizedSuffixName("github-gist-id")
Expect(KamelRunWithID(operatorID, ns, "--name", name,
"gist:e2c3f9a5fd0d9e79b21b04809786f17a").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Expand All @@ -90,7 +90,7 @@ func TestKamelCLIRun(t *testing.T) {
})

t.Run("Gist (URL)", func(t *testing.T) {
name := "github-gist-url"
name := RandomizedSuffixName("github-gist-url")
Expect(KamelRunWithID(operatorID, ns, "--name", name,
"https://gist.github.com/lburgazzoli/e2c3f9a5fd0d9e79b21b04809786f17a").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Expand All @@ -110,7 +110,7 @@ func TestKamelCLIRun(t *testing.T) {
})

t.Run("Run and update", func(t *testing.T) {
name := "run"
name := RandomizedSuffixName("run")
Expect(KamelRunWithID(operatorID, ns, "files/run.yaml", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
Expand Down
24 changes: 12 additions & 12 deletions e2e/common/config/kamelet_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestKameletImplicitConfigDefaultUserPropery(t *testing.T) {

Expect(CreateTimerKamelet(ns, "iconfig01-timer-source")()).To(Succeed())

name := "iconfig-test-timer-source-int01"
name := RandomizedSuffixName("iconfig-test-timer-source-int01")
Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationConfiguration01.java",
"-p", "camel.kamelet.iconfig01-timer-source.message='Default message 01'",
"--name", name).Execute()).To(Succeed())
Expand All @@ -62,7 +62,7 @@ func TestKameletImplicitConfigDefaultMountedSecret(t *testing.T) {

Expect(CreateTimerKamelet(ns, "iconfig03-timer-source")()).To(Succeed())

name := "iconfig-test-timer-source-int3"
name := RandomizedSuffixName("iconfig-test-timer-source-int3")
secretName := "my-iconfig-int3-secret"

var secData = make(map[string]string)
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestKameletImplicitConfigDefaultMountedConfigmap(t *testing.T) {

Expect(CreateTimerKamelet(ns, "iconfig04-timer-source")()).To(Succeed())

name := "iconfig-test-timer-source-int4"
name := RandomizedSuffixName("iconfig-test-timer-source-int4")
cmName := "my-iconfig-int4-configmap"

var cmData = make(map[string]string)
Expand Down Expand Up @@ -121,7 +121,7 @@ func TestKameletImplicitConfigNamedUserPropery(t *testing.T) {

Expect(CreateTimerKamelet(ns, "iconfig05-timer-source")()).To(Succeed())

name := "iconfig-test-timer-source-int5"
name := RandomizedSuffixName("iconfig-test-timer-source-int5")
Expect(KamelRunWithID(operatorID, ns, "files/TimerKameletIntegrationNamedConfiguration05.java",
"-p", "camel.kamelet.iconfig05-timer-source.message='Default message 05'",
"-p", "camel.kamelet.iconfig05-timer-source.mynamedconfig.message='My Named Config message'",
Expand All @@ -144,7 +144,7 @@ func TestKameletImplicitConfigNamedLabeledSecret(t *testing.T) {

Expect(CreateTimerKamelet(ns, "iconfig06-timer-source")()).To(Succeed())

name := "iconfig-test-timer-source-int6"
name := RandomizedSuffixName("iconfig-test-timer-source-int6")
secretName := "my-iconfig-int6-secret"

var secData = make(map[string]string)
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestKameletImplicitConfigNamedMountedSecret(t *testing.T) {

Expect(CreateTimerKamelet(ns, "iconfig07-timer-source")()).To(Succeed())

name := "iconfig-test-timer-source-int7"
name := RandomizedSuffixName("iconfig-test-timer-source-int7")
secretName := "my-iconfig-int7-secret"

var secData = make(map[string]string)
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestKameletImplicitConfigNamedMountedConfigmap(t *testing.T) {

Expect(CreateTimerKamelet(ns, "iconfig08-timer-source")()).To(Succeed())

name := "iconfig-test-timer-source-int8"
name := RandomizedSuffixName("iconfig-test-timer-source-int8")
cmName := "my-iconfig-int8-configmap"

var cmData = make(map[string]string)
Expand Down Expand Up @@ -240,7 +240,7 @@ func TestKameletImplicitConfigDefaultLabeledSecret(t *testing.T) {

Expect(CreateTimerKamelet(ns, "iconfig09-timer-source")()).To(Succeed())

name := "iconfig-test-timer-source-int9"
name := RandomizedSuffixName("iconfig-test-timer-source-int9")
secretName := "my-iconfig-int9-secret"

var secData = make(map[string]string)
Expand Down Expand Up @@ -274,7 +274,7 @@ func TestKameletConfigInlinedUserPropery(t *testing.T) {
Expect(CreateTimerKamelet(ns, "config01-timer-source")()).To(Succeed())
Expect(CreateLogKamelet(ns, "config01-log-sink")()).To(Succeed())

name := "config-test-timer-source-int1"
name := RandomizedSuffixName("config-test-timer-source-int1")

Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-inlined-configuration-01.yaml",
"--name", name).Execute()).To(Succeed())
Expand All @@ -298,7 +298,7 @@ func TestKameletConfigDefaultParamUserPropery(t *testing.T) {
Expect(CreateTimerKamelet(ns, "config02-timer-source")()).To(Succeed())
Expect(CreateLogKamelet(ns, "config02-log-sink")()).To(Succeed())

name := "config-test-timer-source-int2"
name := RandomizedSuffixName("config-test-timer-source-int2")

Expect(KamelRunWithID(operatorID, ns, "files/timer-kamelet-integration-parameters-configuration-02.yaml",
"-p", "my-message='My parameter message 02'",
Expand All @@ -324,7 +324,7 @@ func TestKameletConfigDefaultParamMountedSecret(t *testing.T) {
Expect(CreateTimerKamelet(ns, "config03-timer-source")()).To(Succeed())
Expect(CreateLogKamelet(ns, "config03-log-sink")()).To(Succeed())

name := "config-test-timer-source-int3"
name := RandomizedSuffixName("config-test-timer-source-int3")
secretName := "my-config-int3-secret"

var secData = make(map[string]string)
Expand Down Expand Up @@ -356,7 +356,7 @@ func TestKameletConfigDefaultParamMountedConfigmap(t *testing.T) {
Expect(CreateTimerKamelet(ns, "config04-timer-source")()).To(Succeed())
Expect(CreateLogKamelet(ns, "config04-log-sink")()).To(Succeed())

name := "config-test-timer-source-int4"
name := RandomizedSuffixName("config-test-timer-source-int4")
cmName := "my-config-int4-configmap"

var cmData = make(map[string]string)
Expand Down
16 changes: 8 additions & 8 deletions e2e/common/config/pipe_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestPipeConfig(t *testing.T) {
Expect(CreateTimerKamelet(ns, "my-pipe-timer-source")()).To(Succeed())
Expect(CreateLogKamelet(ns, "my-pipe-log-sink")()).To(Succeed())
t.Run("run test default config using properties", func(t *testing.T) {
name := "my-pipe-with-properties"
name := RandomizedSuffixName("my-pipe-with-properties")

Expect(KamelBindWithID(operatorID, ns,
"my-pipe-timer-source",
Expand All @@ -55,7 +55,7 @@ func TestPipeConfig(t *testing.T) {
})

t.Run("run test implicit default config using labeled secret", func(t *testing.T) {
name := "my-pipe-with-default-implicit-secret"
name := RandomizedSuffixName("my-pipe-with-default-implicit-secret")
secretName := "my-pipe-default-implicit-secret"

var secData = make(map[string]string)
Expand All @@ -79,7 +79,7 @@ func TestPipeConfig(t *testing.T) {
})

t.Run("run test implicit default config using mounted secret", func(t *testing.T) {
name := "my-pipe-with-default-implicit-secret"
name := RandomizedSuffixName("my-pipe-with-default-implicit-secret")
secretName := "my-pipe-default-implicit-secret"

var secData = make(map[string]string)
Expand All @@ -102,7 +102,7 @@ func TestPipeConfig(t *testing.T) {
})

t.Run("run test implicit default config using mounted configmap", func(t *testing.T) {
name := "my-pipe-with-default-implicit-configmap"
name := RandomizedSuffixName("my-pipe-with-default-implicit-configmap")
cmName := "my-pipe-default-implicit-configmap"

var cmData = make(map[string]string)
Expand All @@ -125,7 +125,7 @@ func TestPipeConfig(t *testing.T) {
})

t.Run("run test implicit named config using mounted secret", func(t *testing.T) {
name := "my-pipe-with-named-implicit-secret"
name := RandomizedSuffixName("my-pipe-with-named-implicit-secret")
secretName := "my-pipe-named-implicit-secret"

var secData = make(map[string]string)
Expand All @@ -151,7 +151,7 @@ func TestPipeConfig(t *testing.T) {
})

t.Run("run test implicit named config using mounted configmap", func(t *testing.T) {
name := "my-pipe-with-named-implicit-configmap"
name := RandomizedSuffixName("my-pipe-with-named-implicit-configmap")
cmName := "my-pipe-named-implicit-configmap"

var cmData = make(map[string]string)
Expand All @@ -176,7 +176,7 @@ func TestPipeConfig(t *testing.T) {
Expect(DeleteConfigmap(ns, cmName)).To(Succeed())
})
t.Run("run test implicit specific config using mounted secret", func(t *testing.T) {
name := "my-pipe-with-specific-secret"
name := RandomizedSuffixName("my-pipe-with-specific-secret")
secretName := "my-pipe-specific-secret"

var secData = make(map[string]string)
Expand All @@ -201,7 +201,7 @@ func TestPipeConfig(t *testing.T) {
Expect(DeleteSecret(ns, secretName)).To(Succeed())
})
t.Run("run test implicit specific config using mounted configmap", func(t *testing.T) {
name := "my-pipe-with-specific-configmap"
name := RandomizedSuffixName("my-pipe-with-specific-configmap")
cmName := "my-pipe-specific-configmap"

var cmData = make(map[string]string)
Expand Down
10 changes: 5 additions & 5 deletions e2e/common/misc/integration_fail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestBadRouteIntegration(t *testing.T) {
RegisterTestingT(t)

t.Run("run bad java route", func(t *testing.T) {
name := "bad-route"
name := RandomizedSuffixName("bad-route")
Expect(KamelRunWithID(operatorID, ns, "files/BadRoute.java", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
Expand All @@ -62,7 +62,7 @@ func TestBadRouteIntegration(t *testing.T) {
})

t.Run("run missing dependency java route", func(t *testing.T) {
name := "java-route"
name := RandomizedSuffixName("java-route")
Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
"-d", "mvn:com.example:nonexistent:1.0").Execute()).To(Succeed())
// Integration in error
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestBadRouteIntegration(t *testing.T) {
})

t.Run("run invalid dependency java route", func(t *testing.T) {
name := "invalid-dependency"
name := RandomizedSuffixName("invalid-dependency")
Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name,
"-d", "camel:non-existent").Execute()).To(Succeed())
// Integration in error with Initialization Failed condition
Expand Down Expand Up @@ -126,7 +126,7 @@ func TestBadRouteIntegration(t *testing.T) {
})

t.Run("run unresolvable component java route", func(t *testing.T) {
name := "unresolvable-route"
name := RandomizedSuffixName("unresolvable-route")
Expect(KamelRunWithID(operatorID, ns, "files/Unresolvable.java", "--name", name).Execute()).To(Succeed())
// Integration in error with Initialization Failed condition
Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
Expand Down Expand Up @@ -155,7 +155,7 @@ func TestBadRouteIntegration(t *testing.T) {
})

t.Run("run invalid java route", func(t *testing.T) {
name := "invalid-java-route"
name := RandomizedSuffixName("invalid-java-route")
Expect(KamelRunWithID(operatorID, ns, "files/InvalidJava.java", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
Expand Down
2 changes: 1 addition & 1 deletion e2e/common/misc/maven_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

func TestRunExtraRepository(t *testing.T) {
RegisterTestingT(t)
name := "java"
name := RandomizedSuffixName("java")
Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--maven-repository", "https://maven.repository.redhat.com/ga@id=redhat",
"--dependency", "mvn:org.jolokia:jolokia-core:1.7.1.redhat-00001",
Expand Down
2 changes: 1 addition & 1 deletion e2e/common/misc/pipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestPipe(t *testing.T) {

// Pipe with wrong spec
t.Run("test Pipe with wrong spec", func(t *testing.T) {
name := "bad-klb"
name := RandomizedSuffixName("bad-klb")
kb := v1.NewPipe(ns, name)
kb.Spec = v1.PipeSpec{}
_, err := kubernetes.ReplaceResource(TestContext, TestClient(), &kb)
Expand Down
12 changes: 6 additions & 6 deletions e2e/common/misc/registry_maven_wagon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {

t.Run("image registry is a maven repository", func(t *testing.T) {
// Create integration that should decrypt an encrypted message to "foobar" and log it
name := "foobar-decryption"
name := RandomizedSuffixName("foobar-decryption")
jar, err := filepath.Abs("files/registry/sample-decryption-1.0.jar?skipPOM=true")
assert.Nil(t, err)
pom, err := filepath.Abs("files/registry/sample-decryption-1.0.pom")
Expand All @@ -66,7 +66,7 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {
})

t.Run("local files are mounted in the integration container at the default path", func(t *testing.T) {
name := "laughing-route-default-path"
name := RandomizedSuffixName("laughing-route-default-path")

Expect(KamelRunWithID(operatorID, ns, "files/registry/LaughingRoute.java",
"--name", name,
Expand All @@ -80,7 +80,7 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {
})

t.Run("local files are mounted in the integration container at a custom path", func(t *testing.T) {
name := "laughing-route-custom-path"
name := RandomizedSuffixName("laughing-route-custom-path")
customPath := "this/is/a/custom/path/"

Expect(KamelRunWithID(operatorID, ns, "files/registry/LaughingRoute.java",
Expand All @@ -95,7 +95,7 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {
})

t.Run("local directory is mounted in the integration container", func(t *testing.T) {
name := "laughing-route-directory"
name := RandomizedSuffixName("laughing-route-directory")

Expect(KamelRunWithID(operatorID, ns, "files/registry/LaughingRoute.java",
"--name", name,
Expand All @@ -111,7 +111,7 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {

t.Run("pom file is extracted from JAR", func(t *testing.T) {
// Create integration that should decrypt foobar and log it
name := "foobar-decryption-pom-extraction"
name := RandomizedSuffixName("foobar-decryption-pom-extraction")
jar, err := filepath.Abs("files/registry/sample-decryption-1.0.jar")
assert.Nil(t, err)

Expand All @@ -126,7 +126,7 @@ func TestImageRegistryIsAMavenRepository(t *testing.T) {
})
t.Run("dependency can be used at build time", func(t *testing.T) {
// Create integration that should run an Xslt transformation whose template needs to be present at build time
name := "xslt"
name := RandomizedSuffixName("xslt")
Expect(KamelRunWithID(operatorID, ns, "files/registry/classpath/Xslt.java", "--name", name,
"-d", "file://files/registry/classpath/cheese.xsl?targetPath=xslt/cheese.xsl&classpath=true",
).Execute()).To(Succeed())
Expand Down
4 changes: 2 additions & 2 deletions e2e/common/misc/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestRunRest(t *testing.T) {
Eventually(IntegrationPodPhase(ns, "rest-consumer"), TestTimeoutLong).Should(Equal(corev1.PodRunning))

t.Run("Service works", func(t *testing.T) {
name := "John"
name := RandomizedSuffixName("John")
service := Service(ns, "rest-consumer")
Eventually(service, TestTimeoutShort).ShouldNot(BeNil())
Expect(KamelRunWithID(operatorID, ns, "files/rest-producer.yaml", "-p", "serviceName=rest-consumer", "-p", "name="+name).Execute()).To(Succeed())
Expand All @@ -59,7 +59,7 @@ func TestRunRest(t *testing.T) {

if ocp {
t.Run("Route works", func(t *testing.T) {
name := "Peter"
name := RandomizedSuffixName("Peter")
route := Route(ns, "rest-consumer")
Eventually(route, TestTimeoutShort).ShouldNot(BeNil())
Eventually(RouteStatus(ns, "rest-consumer"), TestTimeoutMedium).Should(Equal("True"))
Expand Down
2 changes: 1 addition & 1 deletion e2e/common/misc/scale_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestPipeScale(t *testing.T) {
return
}

name := "timer2log"
name := RandomizedSuffixName("timer2log")
Expect(KamelBindWithID(operatorID, ns, "timer-source?message=HelloPipe", "log-sink", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Expand Down
2 changes: 1 addition & 1 deletion e2e/common/misc/scale_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
func TestIntegrationScale(t *testing.T) {
RegisterTestingT(t)

name := "java"
name := RandomizedSuffixName("java")
Expect(KamelRunWithID(operatorID, ns, "files/Java.java", "--name", name).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Expand Down
3 changes: 2 additions & 1 deletion e2e/common/misc/structured_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ import (
func TestStructuredLogs(t *testing.T) {
RegisterTestingT(t)

name := "java"
name := RandomizedSuffixName("java")
Expect(KamelRunWithID(operatorID, ns, "files/Java.java",
"--name", name,
"-t", "logging.format=json").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
Expand Down
Loading

0 comments on commit e5372dd

Please sign in to comment.