Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 9 additions & 42 deletions test/extended/image_ecosystem/s2i_perl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ package image_ecosystem
import (
"context"
"fmt"
"strings"
"os"
"time"

g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"

exutil "github.com/openshift/origin/test/extended/util"
Expand Down Expand Up @@ -45,9 +44,7 @@ var _ = g.Describe("[sig-devex][Feature:ImageEcosystem][perl][Slow] hot deploy f
modifyCommand = []string{"sed", "-ie", `s/initial value/modified value/`, "lib/My/Test.pm"}
dcName = "perl"
rcNameOne = fmt.Sprintf("%s-1", dcName)
rcNameTwo = fmt.Sprintf("%s-2", dcName)
dcLabelOne = exutil.ParseLabelsOrDie(fmt.Sprintf("deployment=%s", rcNameOne))
dcLabelTwo = exutil.ParseLabelsOrDie(fmt.Sprintf("deployment=%s", rcNameTwo))
)

g.Context("", func() {
Expand All @@ -69,9 +66,14 @@ var _ = g.Describe("[sig-devex][Feature:ImageEcosystem][perl][Slow] hot deploy f
if !archHasModPerl(oc) {
g.Skip("mod_perl based builder image is not available on arm64")
}
// Make sure the index.pl is executable in the fixture assets as it is in the sources.
// (FixturePath resets the perms on the files)
err := os.Chmod(exutil.FixturePath("testdata", "image_ecosystem", "perl-hotdeploy", "index.pl"), os.FileMode(0o755))
o.Expect(err).NotTo(o.HaveOccurred())

exutil.WaitForOpenShiftNamespaceImageStreams(oc)
g.By(fmt.Sprintf("calling oc new-app -f %q", perlTemplate))
err := oc.Run("new-app").Args("-f", perlTemplate, "-e", "HTTPD_START_SERVERS=1", "-e", "HTTPD_MAX_SPARE_SERVERS=1", "-e", "HTTPD_MAX_REQUEST_WORKERS=1").Execute()
err = oc.Run("new-app").Args("-f", perlTemplate, "-e", "HTTPD_START_SERVERS=1", "-e", "HTTPD_MAX_SPARE_SERVERS=1", "-e", "HTTPD_MAX_REQUEST_WORKERS=1").Execute()
o.Expect(err).NotTo(o.HaveOccurred())

br, err := exutil.StartBuildAndWait(oc, "perl", fmt.Sprintf("--from-dir=%s", appSource))
Expand All @@ -91,8 +93,6 @@ var _ = g.Describe("[sig-devex][Feature:ImageEcosystem][perl][Slow] hot deploy f
g.By("waiting for endpoint")
err = exutil.WaitForEndpoint(oc.KubeFramework().ClientSet, oc.Namespace(), dcName)
o.Expect(err).NotTo(o.HaveOccurred())
oldEndpoint, err := oc.KubeFramework().ClientSet.CoreV1().Endpoints(oc.Namespace()).Get(context.Background(), dcName, metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred())

checkPage := func(expected string, dcLabel labels.Selector) {
_, err := exutil.WaitForPods(oc.KubeClient().CoreV1().Pods(oc.Namespace()), dcLabel, exutil.CheckPodIsRunning, 1, 4*time.Minute)
Expand All @@ -104,45 +104,12 @@ var _ = g.Describe("[sig-devex][Feature:ImageEcosystem][perl][Slow] hot deploy f

checkPage("initial value", dcLabelOne)

g.By("modifying the source code with disabled hot deploy")
g.By("modifying the source code")
err = RunInPodContainer(oc, dcLabelOne, modifyCommand)
o.Expect(err).NotTo(o.HaveOccurred())
checkPage("initial value", dcLabelOne)

g.By("turning on hot-deploy")
err = oc.Run("set", "env").Args("dc", dcName, "PERL_APACHE2_RELOAD=true").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
err = exutil.WaitForDeploymentConfig(oc.KubeClient(), oc.AppsClient().AppsV1(), oc.Namespace(), dcName, 2, true, oc)
o.Expect(err).NotTo(o.HaveOccurred())

g.By("waiting for a new endpoint")
err = exutil.WaitForEndpoint(oc.KubeFramework().ClientSet, oc.Namespace(), dcName)
o.Expect(err).NotTo(o.HaveOccurred())

// Ran into an issue where we'd try to hit the endpoint before it was updated, resulting in
// request timeouts against the previous pod's ip. So make sure the endpoint is pointing to the
// new pod before hitting it.
err = wait.Poll(1*time.Second, 1*time.Minute, func() (bool, error) {
newEndpoint, err := oc.KubeFramework().ClientSet.CoreV1().Endpoints(oc.Namespace()).Get(context.Background(), dcName, metav1.GetOptions{})
if err != nil {
return false, err
}
if !strings.Contains(newEndpoint.Subsets[0].Addresses[0].TargetRef.Name, rcNameTwo) {
e2e.Logf("waiting on endpoint address ref %s to contain %s", newEndpoint.Subsets[0].Addresses[0].TargetRef.Name, rcNameTwo)
return false, nil
}
e2e.Logf("old endpoint was %#v, new endpoint is %#v", oldEndpoint, newEndpoint)
return true, nil
})
o.Expect(err).NotTo(o.HaveOccurred())

g.By("modifying the source code with enabled hot deploy")
checkPage("initial value", dcLabelTwo)
err = RunInPodContainer(oc, dcLabelTwo, modifyCommand)
o.Expect(err).NotTo(o.HaveOccurred())
checkPage("modified value", dcLabelTwo)
checkPage("modified value", dcLabelOne)
})
})

})
})
2 changes: 1 addition & 1 deletion test/extended/testdata/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"from": {
"kind": "ImageStreamTag",
"namespace": "openshift",
"name": "perl:5.30-el7"
"name": "perl:5.32-ubi8"
}
}
},
Expand Down