Skip to content

Commit ab6b8d1

Browse files
committed
feat: dependencies default order strategy
1 parent 659063f commit ab6b8d1

File tree

7 files changed

+41
-22
lines changed

7 files changed

+41
-22
lines changed

e2e/common/misc/rest_test.go

+13-8
Original file line numberDiff line numberDiff line change
@@ -48,30 +48,35 @@ func TestRunRest(t *testing.T) {
4848
g.Expect(CopyIntegrationKits(t, ctx, ns, operatorID)).To(Succeed())
4949
g.Expect(KamelInstallWithID(t, ctx, operatorID, ns)).To(Succeed())
5050

51-
g.Eventually(SelectedPlatformPhase(t, ctx, ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
51+
g.Eventually(SelectedPlatformPhase(t, ctx, ns, operatorID)).Should(Equal(v1.IntegrationPlatformPhaseReady))
5252

5353
ocp, err := openshift.IsOpenShift(TestClient(t))
5454
require.NoError(t, err)
5555

56-
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/rest-consumer.yaml").Execute()).To(Succeed())
57-
g.Eventually(IntegrationPodPhase(t, ctx, ns, "rest-consumer"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
56+
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/rest-consumer.yaml",
57+
// Let's make sure to have this run via a plain Deployment
58+
"-t", "knative-service.enabled=false",
59+
).Execute()).To(Succeed())
60+
g.Eventually(IntegrationPodPhase(t, ctx, ns, "rest-consumer")).Should(Equal(corev1.PodRunning))
5861

5962
t.Run("Service works", func(t *testing.T) {
6063
name := RandomizedSuffixName("John")
6164
service := Service(t, ctx, ns, "rest-consumer")
6265
g.Eventually(service, TestTimeoutShort).ShouldNot(BeNil())
63-
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/rest-producer.yaml", "-p", "serviceName=rest-consumer", "-p", "name="+name).Execute()).To(Succeed())
64-
g.Eventually(IntegrationPodPhase(t, ctx, ns, "rest-producer"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
65-
g.Eventually(IntegrationLogs(t, ctx, ns, "rest-consumer"), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("get %s", name)))
66-
g.Eventually(IntegrationLogs(t, ctx, ns, "rest-producer"), TestTimeoutLong).Should(ContainSubstring(fmt.Sprintf("%s Doe", name)))
66+
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/rest-producer.yaml",
67+
"-p", "serviceName=rest-consumer", "-p", "name="+name,
68+
).Execute()).To(Succeed())
69+
g.Eventually(IntegrationPodPhase(t, ctx, ns, "rest-producer")).Should(Equal(corev1.PodRunning))
70+
g.Eventually(IntegrationLogs(t, ctx, ns, "rest-consumer")).Should(ContainSubstring(fmt.Sprintf("get %s", name)))
71+
g.Eventually(IntegrationLogs(t, ctx, ns, "rest-producer")).Should(ContainSubstring(fmt.Sprintf("%s Doe", name)))
6772
})
6873

6974
if ocp {
7075
t.Run("Route works", func(t *testing.T) {
7176
name := RandomizedSuffixName("Peter")
7277
route := Route(t, ctx, ns, "rest-consumer")
7378
g.Eventually(route, TestTimeoutShort).ShouldNot(BeNil())
74-
g.Eventually(RouteStatus(t, ctx, ns, "rest-consumer"), TestTimeoutMedium).Should(Equal("True"))
79+
g.Eventually(RouteStatus(t, ctx, ns, "rest-consumer")).Should(Equal("True"))
7580
url := fmt.Sprintf("http://%s/customers/%s", route().Spec.Host, name)
7681
g.Eventually(httpRequest(url), TestTimeoutMedium).Should(Equal(fmt.Sprintf("%s Doe", name)))
7782
g.Eventually(IntegrationLogs(t, ctx, ns, "rest-consumer"), TestTimeoutShort).Should(ContainSubstring(fmt.Sprintf("get %s", name)))

e2e/common/traits/builder_test.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ func TestBuilderTrait(t *testing.T) {
4747

4848
g.Eventually(SelectedPlatformPhase(t, ctx, ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))
4949

50-
t.Run("Run build strategy routine", func(t *testing.T) {
51-
name := RandomizedSuffixName("java")
52-
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/Java.java", "--name", name, "-t", "builder.order-strategy=sequential", "-t", "builder.strategy=routine").Execute()).To(Succeed())
50+
t.Run("Run build order strategy sequential", func(t *testing.T) {
51+
name := RandomizedSuffixName("java-dependencies-sequential")
52+
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/Java.java", "--name", name,
53+
// This is required in order to avoid reusing a Kit already existing (which is the default behavior)
54+
"--build-property", "strategy=sequential",
55+
"-t", "builder.order-strategy=sequential",
56+
).Execute()).To(Succeed())
5357

5458
g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
5559
g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))

pkg/apis/camel/v1/trait/builder.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type BuilderTrait struct {
3636
BaseImage string `property:"base-image" json:"baseImage,omitempty"`
3737
// Use the incremental image build option, to reuse existing containers (default `true`)
3838
IncrementalImageBuild *bool `property:"incremental-image-build" json:"incrementalImageBuild,omitempty"`
39-
// The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default `sequential`)
39+
// The build order strategy to use, either `dependencies`, `fifo` or `sequential` (default is the platform default)
4040
// +kubebuilder:validation:Enum=dependencies;fifo;sequential
4141
OrderStrategy string `property:"order-strategy" json:"orderStrategy,omitempty"`
4242
// When using `pod` strategy, the minimum amount of CPU required by the pod builder.

pkg/platform/defaults.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func ConfigureDefaults(ctx context.Context, c client.Client, p *v1.IntegrationPl
9090
}
9191

9292
if p.Status.Build.BuildConfiguration.OrderStrategy == "" {
93-
p.Status.Build.BuildConfiguration.OrderStrategy = v1.BuildOrderStrategySequential
93+
p.Status.Build.BuildConfiguration.OrderStrategy = v1.BuildOrderStrategyDependencies
9494
log.Debugf("Integration Platform %s [%s]: setting build order strategy %s", p.Name, p.Namespace, p.Status.Build.BuildConfiguration.OrderStrategy)
9595
}
9696

pkg/platform/defaults_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestIntegrationPlatformDefaults(t *testing.T) {
4949
assert.Equal(t, v1.IntegrationPlatformClusterKubernetes, ip.Status.Cluster)
5050
assert.Equal(t, v1.TraitProfile(""), ip.Status.Profile)
5151
assert.Equal(t, v1.BuildStrategyRoutine, ip.Status.Build.BuildConfiguration.Strategy)
52-
assert.Equal(t, v1.BuildOrderStrategySequential, ip.Status.Build.BuildConfiguration.OrderStrategy)
52+
assert.Equal(t, v1.BuildOrderStrategyDependencies, ip.Status.Build.BuildConfiguration.OrderStrategy)
5353
assert.Equal(t, defaults.BaseImage(), ip.Status.Build.BaseImage)
5454
assert.Equal(t, defaults.LocalRepository, ip.Status.Build.Maven.LocalRepository)
5555
assert.Equal(t, int32(3), ip.Status.Build.MaxRunningBuilds) // default for build strategy routine

pkg/trait/builder_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -684,3 +684,13 @@ func TestBuilderTraitPlatforms(t *testing.T) {
684684

685685
assert.Equal(t, []string{"linux/amd64", "linux/arm64"}, env.Pipeline[2].Jib.Configuration.ImagePlatforms)
686686
}
687+
688+
func TestBuilderTraitOrderStrategy(t *testing.T) {
689+
env := createBuilderTestEnv(v1.IntegrationPlatformClusterKubernetes, v1.IntegrationPlatformBuildPublishStrategyJib, v1.BuildStrategyRoutine)
690+
builderTrait := createNominalBuilderTraitTest()
691+
builderTrait.OrderStrategy = "fifo"
692+
err := builderTrait.Apply(env)
693+
require.NoError(t, err)
694+
695+
assert.Equal(t, v1.BuildOrderStrategyFIFO, env.Pipeline[0].Builder.Configuration.OrderStrategy)
696+
}

script/Makefile

+8-8
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ KAMELET_CATALOG_REPO_TAG := v4.0.1
105105
DO_TEST_PREBUILD ?= true
106106
TEST_PREBUILD = build
107107
# Tests may run in parallel to each other. This count sets the amount of tests run in parallel. (default value usually is GOMAXPROCS)
108-
TEST_COMMON_PARALLEL_COUNT ?= 4
108+
TEST_COMMON_PARALLEL_COUNT ?= 2
109109
TEST_ADVANCED_PARALLEL_COUNT ?= 4
110110

111111
# OLM (Operator Lifecycle Manager and Operator Hub): uncomment to override operator settings at build time
@@ -284,7 +284,7 @@ setup-yaks:
284284
#
285285
test-common: do-build
286286
FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \
287-
go test -timeout 90m -v ./e2e/common/... -tags=integration -parallel=$(TEST_COMMON_PARALLEL_COUNT) $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \
287+
go test -p=$(TEST_COMMON_PARALLEL_COUNT) -timeout 90m -v ./e2e/common/... -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \
288288
exit $${FAILED}
289289

290290
#
@@ -300,22 +300,22 @@ test-smoke: do-build
300300
echo "TEST_SKIP_AFTER_FAILURE_COUNT=$$TEST_SKIP_AFTER_FAILURE_COUNT"; \
301301
go test -timeout 10m -count=1 -v ./e2e/common/main_test.go -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \
302302
if [ $$FAILED -le $$TEST_SKIP_AFTER_FAILURE_COUNT ]; then \
303-
go test -timeout 30m -count=1 -v ./e2e/common/languages -tags=integration -parallel=$(TEST_COMMON_PARALLEL_COUNT) $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \
303+
go test -p=$(TEST_COMMON_PARALLEL_COUNT) -timeout 30m -count=1 -v ./e2e/common/languages -tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \
304304
fi; \
305305
if [ $$FAILED -le $$TEST_SKIP_AFTER_FAILURE_COUNT ]; then \
306-
go test -timeout 30m -count=1 -v \
306+
go test -p=$(TEST_COMMON_PARALLEL_COUNT) -timeout 30m -count=1 -v \
307307
./e2e/common/misc/cron_test.go \
308308
./e2e/common/misc/kamelet_test.go \
309309
./e2e/common/misc/pipe_test.go \
310-
-tags=integration -parallel=$(TEST_COMMON_PARALLEL_COUNT) $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \
310+
-tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \
311311
fi; \
312312
if [ $$FAILED -le $$TEST_SKIP_AFTER_FAILURE_COUNT ]; then \
313-
go test -timeout 30m -count=1 -v \
313+
go test -p=$(TEST_COMMON_PARALLEL_COUNT) -timeout 30m -count=1 -v \
314314
./e2e/common/traits/camel_test.go \
315315
./e2e/common/traits/container_test.go \
316316
./e2e/common/traits/openapi_test.go \
317317
./e2e/common/traits/service_test.go \
318-
-tags=integration -parallel=$(TEST_COMMON_PARALLEL_COUNT) $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \
318+
-tags=integration $(TEST_INTEGRATION_COMMON_LANG_RUN) $(GOTESTFMT) || ((FAILED++)); \
319319
fi; \
320320
exit $$FAILED
321321

@@ -324,7 +324,7 @@ test-smoke: do-build
324324
#
325325
test-advanced: do-build
326326
FAILED=0; STAGING_RUNTIME_REPO="$(STAGING_RUNTIME_REPO)"; \
327-
go test -timeout 90m -v ./e2e/advanced -tags=integration -parallel=$(TEST_ADVANCED_PARALLEL_COUNT) $(TEST_INSTALL_RUN) $(GOTESTFMT) || ((FAILED++)); \
327+
go test -p=$(TEST_ADVANCED_PARALLEL_COUNT) -timeout 90m -v ./e2e/advanced -tags=integration $(TEST_INSTALL_RUN) $(GOTESTFMT) || ((FAILED++)); \
328328
exit $${FAILED}
329329

330330
#

0 commit comments

Comments
 (0)