Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e traits test for cron #5414

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions e2e/common/misc/cron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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())
Expand Down Expand Up @@ -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())
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
- from:
uri: "cron:tab"
parameters:
schedule: "* * * * ?"
# Every minute
schedule: "* * * * *"
steps:
- setHeader:
name: "m"
Expand Down
Loading