This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new a965bce37 Add e2e traits test for cron
a965bce37 is described below
commit a965bce37d4013a0ce44a18812bcdff024b3c582
Author: Thomas Diesler <[email protected]>
AuthorDate: Wed Apr 24 12:24:36 2024 +0200
Add e2e traits test for cron
---
e2e/common/misc/cron_test.go | 24 +++++++++++++++-------
.../misc/files/{cron.yaml => cron-trait-yaml.yaml} | 3 ++-
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/e2e/common/misc/cron_test.go b/e2e/common/misc/cron_test.go
index 256ef653c..5337988a4 100644
--- a/e2e/common/misc/cron_test.go
+++ b/e2e/common/misc/cron_test.go
@@ -32,6 +32,8 @@ import (
. "github.com/apache/camel-k/v2/e2e/support"
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
+
+ "github.com/stretchr/testify/assert"
)
func TestRunCronExample(t *testing.T) {
@@ -45,13 +47,6 @@ func TestRunCronExample(t *testing.T) {
g.Eventually(SelectedPlatformPhase(t, ctx, ns, operatorID),
TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
- t.Run("cron", func(t *testing.T) {
- g.Expect(KamelRunWithID(t, ctx, operatorID, ns,
"files/cron.yaml").Execute()).To(Succeed())
- g.Eventually(IntegrationCronJob(t, ctx, ns, "cron"),
TestTimeoutLong).ShouldNot(BeNil())
- g.Eventually(IntegrationConditionStatus(t, ctx, ns,
"cron", v1.IntegrationConditionReady),
TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
- g.Eventually(IntegrationLogs(t, ctx, ns, "cron"),
TestTimeoutMedium).Should(ContainSubstring("Magicstring!"))
- })
-
t.Run("cron-yaml", func(t *testing.T) {
g.Expect(KamelRunWithID(t, ctx, operatorID, ns,
"files/cron-yaml.yaml").Execute()).To(Succeed())
g.Eventually(IntegrationCronJob(t, ctx, ns,
"cron-yaml"), TestTimeoutLong).ShouldNot(BeNil())
@@ -80,6 +75,21 @@ func TestRunCronExample(t *testing.T) {
g.Eventually(IntegrationLogs(t, ctx, ns,
"cron-quartz"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
})
+ t.Run("cron-trait-yaml", func(t *testing.T) {
+ g.Expect(KamelRunWithID(t, ctx, operatorID, ns,
"files/cron-trait-yaml.yaml", "-t", "cron.enabled=true", "-t",
"cron.schedule=0/2 * * * *").Execute()).To(Succeed())
+ g.Eventually(IntegrationConditionStatus(t, ctx, ns,
"cron-trait-yaml", v1.IntegrationConditionReady),
TestTimeoutMedium).Should(Equal(corev1.ConditionTrue))
+ g.Eventually(IntegrationCronJob(t, ctx, ns,
"cron-trait-yaml"), TestTimeoutLong).ShouldNot(BeNil())
+
+ // Verify that `-t cron.schedule` overrides the
schedule in the yaml
+ //
+ // kubectl get cronjobs -n
test-de619ae2-eddc-4bac-86a6-53d80be030ea
+ // NAME SCHEDULE SUSPEND ACTIVE
LAST SCHEDULE AGE
+ // cron-trait-yaml 0/2 * * * * False 0
<none> 38s
+
+ cronJob := IntegrationCronJob(t, ctx, ns,
"cron-trait-yaml")()
+ assert.Equal(t, "0/2 * * * *", cronJob.Spec.Schedule)
+ })
+
g.Expect(Kamel(t, ctx, "delete", "--all", "-n",
ns).Execute()).To(Succeed())
})
}
diff --git a/e2e/common/misc/files/cron.yaml
b/e2e/common/misc/files/cron-trait-yaml.yaml
similarity index 96%
rename from e2e/common/misc/files/cron.yaml
rename to e2e/common/misc/files/cron-trait-yaml.yaml
index 9b6735053..464579ee7 100644
--- a/e2e/common/misc/files/cron.yaml
+++ b/e2e/common/misc/files/cron-trait-yaml.yaml
@@ -18,7 +18,8 @@
- from:
uri: "cron:tab"
parameters:
- schedule: "* * * * ?"
+ # Every minute
+ schedule: "* * * * *"
steps:
- setHeader:
name: "m"