forked from apache/camel-k
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix apache#1943: allow multiple operators to reconcile label filtered…
… resources
- Loading branch information
1 parent
5938707
commit e5c4eea
Showing
18 changed files
with
351 additions
and
35 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
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
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,136 @@ | ||
//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 ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
. "github.com/apache/camel-k/e2e/support" | ||
camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1" | ||
"github.com/apache/camel-k/pkg/util/openshift" | ||
. "github.com/onsi/gomega" | ||
"github.com/stretchr/testify/assert" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func TestOperatorIDFiltering(t *testing.T) { | ||
forceGlobalTest := os.Getenv("CAMEL_K_FORCE_GLOBAL_TEST") == "true" | ||
if !forceGlobalTest { | ||
ocp, err := openshift.IsOpenShift(TestClient()) | ||
assert.Nil(t, err) | ||
if ocp { | ||
t.Skip("Prefer not to run on OpenShift to avoid giving more permissions to the user running tests") | ||
return | ||
} | ||
} | ||
|
||
WithNewTestNamespace(t, func(ns string) { | ||
WithNewTestNamespace(t, func(nsop1 string) { | ||
WithNewTestNamespace(t, func(nsop2 string) { | ||
Expect(Kamel("install", "-n", nsop1, "--operator-env-vars", "KAMEL_OPERATOR_ID=operator-1", "--global", "--force").Execute()).To(Succeed()) | ||
Expect(AssignPlatformToOperator(nsop1, "operator-1")).To(Succeed()) | ||
Eventually(PlatformPhase(nsop1), TestTimeoutMedium).Should(Equal(camelv1.IntegrationPlatformPhaseReady)) | ||
|
||
Expect(Kamel("install", "-n", nsop2, "--operator-env-vars", "KAMEL_OPERATOR_ID=operator-2", "--global", "--force").Execute()).To(Succeed()) | ||
Expect(AssignPlatformToOperator(nsop2, "operator-2")).To(Succeed()) | ||
Eventually(PlatformPhase(nsop2), TestTimeoutMedium).Should(Equal(camelv1.IntegrationPlatformPhaseReady)) | ||
|
||
t.Run("Operators ignore non-scoped integrations", func(t *testing.T) { | ||
RegisterTestingT(t) | ||
|
||
Expect(Kamel("run", "-n", ns, "files/yaml.yaml", "--name", "untouched").Execute()).To(Succeed()) | ||
Consistently(IntegrationPhase(ns, "untouched"), 10*time.Second).Should(BeEmpty()) | ||
}) | ||
|
||
t.Run("Operators run scoped integrations", func(t *testing.T) { | ||
RegisterTestingT(t) | ||
|
||
Expect(Kamel("run", "-n", ns, "files/yaml.yaml", "--name", "moving").Execute()).To(Succeed()) | ||
Expect(AssignIntegrationToOperator(ns, "moving", "operator-1")).To(Succeed()) | ||
Eventually(IntegrationPhase(ns, "moving"), TestTimeoutMedium).Should(Equal(camelv1.IntegrationPhaseRunning)) | ||
Eventually(IntegrationPodPhase(ns, "moving"), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) | ||
Eventually(IntegrationLogs(ns, "moving"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) | ||
}) | ||
|
||
t.Run("Operators can handoff scoped integrations", func(t *testing.T) { | ||
RegisterTestingT(t) | ||
|
||
Expect(AssignIntegrationToOperator(ns, "moving", "operator-2")).To(Succeed()) | ||
Eventually(IntegrationPhase(ns, "moving"), TestTimeoutMedium).Should(Equal(camelv1.IntegrationPhaseRunning)) | ||
Expect(Kamel("rebuild", "-n", ns, "moving").Execute()).To(Succeed()) | ||
Eventually(IntegrationPhase(ns, "moving"), TestTimeoutMedium).Should(Equal(camelv1.IntegrationPhaseRunning)) | ||
Eventually(IntegrationPodPhase(ns, "moving"), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) | ||
Eventually(IntegrationLogs(ns, "moving"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) | ||
}) | ||
|
||
t.Run("Operators can be deactivated after completely handing off scoped integrations", func(t *testing.T) { | ||
RegisterTestingT(t) | ||
|
||
Expect(ScaleOperator(nsop1, 0)).To(Succeed()) | ||
Expect(Kamel("rebuild", "-n", ns, "moving").Execute()).To(Succeed()) | ||
Eventually(IntegrationPhase(ns, "moving"), TestTimeoutMedium).Should(Equal(camelv1.IntegrationPhaseRunning)) | ||
Eventually(IntegrationPodPhase(ns, "moving"), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) | ||
Eventually(IntegrationLogs(ns, "moving"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) | ||
Expect(ScaleOperator(nsop1, 1)).To(Succeed()) | ||
}) | ||
|
||
t.Run("Operators can run scoped integrations with fixed image", func(t *testing.T) { | ||
RegisterTestingT(t) | ||
|
||
image := IntegrationPodImage(ns, "moving")() | ||
Expect(image).NotTo(BeEmpty()) | ||
// Save resources by deleting "moving" integration | ||
Expect(Kamel("delete", "moving", "-n", ns).Execute()).To(Succeed()) | ||
|
||
Expect(Kamel("run", "-n", ns, "files/yaml.yaml", "--name", "pre-built", "-t", fmt.Sprintf("container.image=%s", image)).Execute()).To(Succeed()) | ||
Consistently(IntegrationPhase(ns, "pre-built"), 10*time.Second).Should(BeEmpty()) | ||
Expect(AssignIntegrationToOperator(ns, "pre-built", "operator-2")).To(Succeed()) | ||
Eventually(IntegrationPhase(ns, "pre-built"), TestTimeoutShort).Should(Equal(camelv1.IntegrationPhaseRunning)) | ||
Eventually(IntegrationPodPhase(ns, "pre-built"), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) | ||
Eventually(IntegrationLogs(ns, "pre-built"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) | ||
Expect(Kamel("delete", "pre-built", "-n", ns).Execute()).To(Succeed()) | ||
}) | ||
|
||
t.Run("Operators can run scoped kamelet bindings", func(t *testing.T) { | ||
RegisterTestingT(t) | ||
|
||
Expect(Kamel("bind", "-n", ns, "timer-source?message=Hello", "log-sink", "--name", "klb").Execute()).To(Succeed()) | ||
Consistently(Integration(ns, "klb"), 10*time.Second).Should(BeNil()) | ||
|
||
Expect(AssignKameletBindingToOperator(ns, "klb", "operator-1")).To(Succeed()) | ||
Eventually(Integration(ns, "klb"), TestTimeoutShort).ShouldNot(BeNil()) | ||
Eventually(IntegrationPhase(ns, "klb"), TestTimeoutMedium).Should(Equal(camelv1.IntegrationPhaseRunning)) | ||
Eventually(IntegrationPodPhase(ns, "klb"), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) | ||
}) | ||
|
||
}) | ||
}) | ||
|
||
// Clean up | ||
RegisterTestingT(t) | ||
Expect(Kamel("delete", "--all", "-n", ns).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
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
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
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
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.