-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Consistent integration platform settings hierarchy (backport #4317)
- Make sure to apply global integration platform settings when creating namespace local platform - Always derive local platform from operator global platform settings - Global platform settings resist when the setting is not explicitly overwritten in the given user namespaced integration platform
- Loading branch information
1 parent
b9d9283
commit b479dbe
Showing
4 changed files
with
443 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
//go:build integration | ||
// +build integration | ||
|
||
// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration" | ||
|
||
/* | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package common | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
corev1 "k8s.io/api/core/v1" | ||
|
||
. "github.com/apache/camel-k/e2e/support" | ||
v1 "github.com/apache/camel-k/pkg/apis/camel/v1" | ||
traitv1 "github.com/apache/camel-k/pkg/apis/camel/v1/trait" | ||
) | ||
|
||
func TestLocalPlatform(t *testing.T) { | ||
WithNewTestNamespace(t, func(ns string) { | ||
operatorID := "camel-k-platform-local" | ||
Expect(KamelInstallWithID(operatorID, ns, "--global", "--force").Execute()).To(Succeed()) | ||
Eventually(PlatformPhase(ns), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) | ||
|
||
pl := Platform(ns)() | ||
pl.Spec.Build.Maven.Properties = make(map[string]string) | ||
pl.Spec.Build.Maven.Properties["build-global-prop1"] = "build-global-value1" | ||
// set maximum number of running builds | ||
pl.Spec.Build.MaxRunningBuilds = 1 | ||
if err := TestClient().Update(TestContext, pl); err != nil { | ||
t.Error(err) | ||
t.FailNow() | ||
} | ||
|
||
Eventually(PlatformHas(ns, func(pl *v1.IntegrationPlatform) bool { | ||
return pl.Status.Build.MaxRunningBuilds == 1 | ||
}), TestTimeoutMedium).Should(BeTrue()) | ||
|
||
WithNewTestNamespace(t, func(ns1 string) { | ||
localPlatform := v1.NewIntegrationPlatform(ns1, operatorID) | ||
localPlatform.Spec.Build.Maven.Properties = make(map[string]string) | ||
localPlatform.Spec.Build.Maven.Properties["build-local-prop1"] = "build-local-value1" | ||
localPlatform.SetOperatorID(operatorID) | ||
|
||
localPlatform.Spec.Traits.Container = &traitv1.ContainerTrait{ | ||
LimitCPU: "0.1", | ||
} | ||
|
||
if err := TestClient().Create(TestContext, &localPlatform); err != nil { | ||
t.Error(err) | ||
t.FailNow() | ||
} | ||
Eventually(PlatformPhase(ns1), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady)) | ||
Eventually(PlatformHas(ns1, func(pl *v1.IntegrationPlatform) bool { | ||
return pl.Status.Cluster != "" | ||
}), TestTimeoutShort).Should(BeTrue()) | ||
|
||
Eventually(PlatformHas(ns1, func(pl *v1.IntegrationPlatform) bool { | ||
return pl.Status.Build.MaxRunningBuilds == 1 | ||
}), TestTimeoutShort).Should(BeTrue()) | ||
|
||
local := Platform(ns1)() | ||
Expect(local.Status.Build.PublishStrategy).To(Equal(pl.Status.Build.PublishStrategy)) | ||
Expect(local.Status.Build.BuildStrategy).To(Equal(pl.Status.Build.BuildStrategy)) | ||
Expect(local.Status.Build.Maven.LocalRepository).To(Equal(pl.Status.Build.Maven.LocalRepository)) | ||
Expect(local.Status.Build.Maven.CLIOptions).To(ContainElements(pl.Status.Build.Maven.CLIOptions)) | ||
Expect(local.Status.Build.Maven.Extension).To(BeEmpty()) | ||
Expect(local.Status.Build.Maven.Properties).To(HaveLen(2)) | ||
Expect(local.Status.Build.Maven.Properties["build-global-prop1"]).To(Equal("build-global-value1")) | ||
Expect(local.Status.Build.Maven.Properties["build-local-prop1"]).To(Equal("build-local-value1")) | ||
|
||
Expect(KamelRunWithID(operatorID, ns1, "--name", "local-integration", "files/yaml.yaml").Execute()).To(Succeed()) | ||
Eventually(IntegrationPod(ns1, "local-integration"), TestTimeoutMedium).Should(Not(BeNil())) | ||
Eventually(IntegrationPodHas(ns1, "local-integration", func(pod *corev1.Pod) bool { | ||
if len(pod.Spec.Containers) != 1 { | ||
return false | ||
} | ||
cpuLimits := pod.Spec.Containers[0].Resources.Limits.Cpu() | ||
return cpuLimits != nil && cpuLimits.AsApproximateFloat64() > 0 | ||
}), TestTimeoutShort).Should(BeTrue()) | ||
|
||
// Clean up | ||
Expect(Kamel("delete", "--all", "-n", ns1).Execute()).To(Succeed()) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.