This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit d0db5904593a7a02f8331cc0589dab77a4894591 Author: Antonin Stefanutti <[email protected]> AuthorDate: Wed Jun 16 16:46:01 2021 +0200 chore(e2e): Check Deployment progressing condition after re-run --- e2e/common/cli/run_test.go | 36 +++++++++++++++++++++++------------- e2e/support/test_support.go | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/e2e/common/cli/run_test.go b/e2e/common/cli/run_test.go index 76b70be..ef47b31 100644 --- a/e2e/common/cli/run_test.go +++ b/e2e/common/cli/run_test.go @@ -25,8 +25,10 @@ import ( "testing" . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gstruct" - v1 "k8s.io/api/core/v1" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" . "github.com/apache/camel-k/e2e/support" camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1" @@ -38,16 +40,16 @@ func TestRunExamplesFromGitHub(t *testing.T) { t.Run("run java from GitHub", func(t *testing.T) { Expect(Kamel("run", "-n", ns, "github:apache/camel-k/e2e/common/files/Java.java").Execute()).To(Succeed()) - Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutMedium).Should(Equal(v1.PodRunning)) - Eventually(IntegrationCondition(ns, "java", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue)) + Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) + Eventually(IntegrationCondition(ns, "java", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) }) t.Run("run java from GitHub (RAW)", func(t *testing.T) { Expect(Kamel("run", "-n", ns, "https://raw.githubusercontent.com/apache/camel-k/main/e2e/common/files/Java.java").Execute()).To(Succeed()) - Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutMedium).Should(Equal(v1.PodRunning)) - Eventually(IntegrationCondition(ns, "java", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue)) + Eventually(IntegrationPodPhase(ns, "java"), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) + Eventually(IntegrationCondition(ns, "java", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) Eventually(IntegrationLogs(ns, "java"), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) }) @@ -55,8 +57,8 @@ func TestRunExamplesFromGitHub(t *testing.T) { t.Run("run from GitHub Gist (ID)", func(t *testing.T) { name := "github-gist-id" Expect(Kamel("run", "-n", ns, "--name", name, "gist:e2c3f9a5fd0d9e79b21b04809786f17a").Execute()).To(Succeed()) - Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(v1.PodRunning)) - Eventually(IntegrationCondition(ns, name, camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue)) + Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) + Eventually(IntegrationCondition(ns, name, camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Tick!")) Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) @@ -65,8 +67,8 @@ func TestRunExamplesFromGitHub(t *testing.T) { t.Run("run from GitHub Gist (URL)", func(t *testing.T) { name := "github-gist-url" Expect(Kamel("run", "-n", ns, "--name", name, "https://gist.github.com/lburgazzoli/e2c3f9a5fd0d9e79b21b04809786f17a").Execute()).To(Succeed()) - Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(v1.PodRunning)) - Eventually(IntegrationCondition(ns, name, camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue)) + Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) + Eventually(IntegrationCondition(ns, name, camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!")) Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Tick!")) Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) @@ -83,14 +85,22 @@ func TestRunAndUpdate(t *testing.T) { name := "run" Expect(Kamel("run", "-n", ns, "files/run.yaml", "--name", name).Execute()).To(Succeed()) - Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(v1.PodRunning)) - Eventually(IntegrationCondition(ns, name, camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue)) + Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning)) + Eventually(IntegrationCondition(ns, name, camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magic default")) // Re-run the Integration with an updated configuration Expect(Kamel("run", "-n", ns, "files/run.yaml", "--name", name, "-p", "property=value").Execute()).To(Succeed()) - Eventually(IntegrationPodPhase(ns, name), TestTimeoutMedium).Should(Equal(v1.PodRunning)) - Eventually(IntegrationCondition(ns, name, camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue)) + + // Check the Deployment has progressed successfully + Eventually(DeploymentCondition(ns, name, appsv1.DeploymentProgressing), TestTimeoutShort).Should(MatchFields(IgnoreExtras, Fields{ + "Status": Equal(corev1.ConditionTrue), + "Reason": Equal("NewReplicaSetAvailable"), + })) + + // Check the new configuration is taken into account + Eventually(IntegrationPodPhase(ns, name), TestTimeoutShort).Should(Equal(corev1.PodRunning)) + Eventually(IntegrationCondition(ns, name, camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) Eventually(IntegrationLogs(ns, name), TestTimeoutShort).Should(ContainSubstring("Magic value")) // Clean up diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go index aa8c919..e8385e1 100644 --- a/e2e/support/test_support.go +++ b/e2e/support/test_support.go @@ -741,6 +741,25 @@ func Deployment(ns string, name string) func() *appsv1.Deployment { } } +func DeploymentCondition(ns string, name string, conditionType appsv1.DeploymentConditionType) func() appsv1.DeploymentCondition { + return func() appsv1.DeploymentCondition { + deployment := Deployment(ns, name)() + + condition := appsv1.DeploymentCondition{ + Status: corev1.ConditionUnknown, + } + + for _, c := range deployment.Status.Conditions { + if c.Type == conditionType { + condition = c + break + } + } + + return condition + } +} + func Build(ns string, name string) func() *v1.Build { return func() *v1.Build { build := v1.NewBuild(ns, name)
