From 212968f4a7a0a30c906afd82512bbc3404d2c3a3 Mon Sep 17 00:00:00 2001 From: Lukas Krejci Date: Thu, 12 Sep 2024 11:06:27 +0200 Subject: [PATCH] Re-enable the s2i rails test and update it to also support samples with Deployments instead of DeploymentConfigs. This should enable us using either the old templates in 4.16 stream that use DeploymentConfigs and the new templates in 4.17+ that use Deployments. --- test/extended/image_ecosystem/s2i_ruby.go | 10 ++++++---- test/extended/image_ecosystem/sample_repos.go | 10 ++++++++++ test/extended/util/deployment.go | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/test/extended/image_ecosystem/s2i_ruby.go b/test/extended/image_ecosystem/s2i_ruby.go index 288e6fed31fe..72c35e9e056f 100644 --- a/test/extended/image_ecosystem/s2i_ruby.go +++ b/test/extended/image_ecosystem/s2i_ruby.go @@ -14,6 +14,8 @@ import ( "k8s.io/apimachinery/pkg/util/wait" e2e "k8s.io/kubernetes/test/e2e/framework" + "k8s.io/apimachinery/pkg/api/errors" + exutil "github.com/openshift/origin/test/extended/util" ) @@ -45,10 +47,6 @@ var _ = g.Describe("[sig-devex][Feature:ImageEcosystem][ruby][Slow] hot deploy f g.Describe("Rails example", func() { g.It(fmt.Sprintf("should work with hot deploy [apigroup:image.openshift.io][apigroup:operator.openshift.io][apigroup:config.openshift.io][apigroup:build.openshift.io]"), func() { - // The rails sample is not supported in the Samples operator and has bitrotten. Let's skip the test but keep the test code around - // just in case the sample gets resurrected in the future. - g.Skip("The rails-postgresql-example is not working anymore and is not supported by the samples operator (since OCP 4.16) so let's not use it for tests.") - exutil.WaitForOpenShiftNamespaceImageStreams(oc) g.By(fmt.Sprintf("calling oc new-app %q", railsTemplate)) err := oc.Run("new-app").Args(railsTemplate).Execute() @@ -59,9 +57,13 @@ var _ = g.Describe("[sig-devex][Feature:ImageEcosystem][ruby][Slow] hot deploy f if err != nil { exutil.DumpBuildLogs(dcName, oc) } + o.Expect(err).NotTo(o.HaveOccurred()) err = exutil.WaitForDeploymentConfig(oc.KubeClient(), oc.AppsClient().AppsV1(), oc.Namespace(), dcName, 1, true, oc) + if errors.IsNotFound(err) { + err = exutil.WaitForDeploymentReady(oc, dcName, oc.Namespace()) + } o.Expect(err).NotTo(o.HaveOccurred()) g.By("waiting for endpoint") diff --git a/test/extended/image_ecosystem/sample_repos.go b/test/extended/image_ecosystem/sample_repos.go index d5d50e513566..1aed87c9bbde 100644 --- a/test/extended/image_ecosystem/sample_repos.go +++ b/test/extended/image_ecosystem/sample_repos.go @@ -10,6 +10,8 @@ import ( "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/apimachinery/pkg/api/errors" + e2e "k8s.io/kubernetes/test/e2e/framework" exutil "github.com/openshift/origin/test/extended/util" @@ -77,11 +79,19 @@ func NewSampleRepoTest(c sampleRepoConfig) func() { g.By("expecting the app deployment to be complete") err = exutil.WaitForDeploymentConfig(oc.KubeClient(), oc.AppsClient().AppsV1(), oc.Namespace(), c.deploymentConfigName, 1, true, oc) + if errors.IsNotFound(err) { + // ok, this is template is not using DeploymentConfig. Let's try with Deployment instead. + err = exutil.WaitForDeploymentReady(oc, c.deploymentConfigName, oc.Namespace()) + } o.Expect(err).NotTo(o.HaveOccurred()) if len(c.dbDeploymentConfigName) > 0 { g.By("expecting the db deployment to be complete") err = exutil.WaitForDeploymentConfig(oc.KubeClient(), oc.AppsClient().AppsV1(), oc.Namespace(), c.dbDeploymentConfigName, 1, true, oc) + if errors.IsNotFound(err) { + // ok, this template is most probably not using DeploymentConfig. Let's try with Deployment instead. + err = exutil.WaitForDeploymentReady(oc, c.dbDeploymentConfigName, oc.Namespace()) + } o.Expect(err).NotTo(o.HaveOccurred()) g.By("expecting the db service is available") diff --git a/test/extended/util/deployment.go b/test/extended/util/deployment.go index 6fb19c6b64d5..7aabd371e62c 100644 --- a/test/extended/util/deployment.go +++ b/test/extended/util/deployment.go @@ -41,6 +41,7 @@ func WaitForDeploymentReady(oc *CLI, deployName, namespace string) error { deployment, getErr = oc.AdminKubeClient().AppsV1().Deployments(namespace).Get(context.Background(), deployName, metav1.GetOptions{}) if getErr != nil { e2e.Logf("Unable to retrieve deployment %q:\n%v", deployName, getErr) + return false, nil } if deployment.Status.AvailableReplicas == *deployment.Spec.Replicas { e2e.Logf("Deployment %q is ready", deployName)