forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
s2i_php.go
69 lines (56 loc) · 2.76 KB
/
s2i_php.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package image_ecosystem
import (
"fmt"
"time"
g "github.com/onsi/ginkgo"
o "github.com/onsi/gomega"
exutil "github.com/openshift/origin/test/extended/util"
)
var _ = g.Describe("[image_ecosystem][php][Slow] hot deploy for openshift php image", func() {
defer g.GinkgoRecover()
var (
cakephpTemplate = "https://raw.githubusercontent.com/openshift/cakephp-ex/master/openshift/templates/cakephp-mysql.json"
oc = exutil.NewCLI("s2i-php", exutil.KubeConfigPath())
hotDeployParam = "OPCACHE_REVALIDATE_FREQ=0"
modifyCommand = []string{"sed", "-ie", `s/\$result\['c'\]/1337/`, "app/View/Layouts/default.ctp"}
pageCountFn = func(count int) string { return fmt.Sprintf(`<span class="code" id="count-value">%d</span>`, count) }
dcName = "cakephp-mysql-example-1"
dcLabel = exutil.ParseLabelsOrDie(fmt.Sprintf("deployment=%s", dcName))
)
g.Describe("CakePHP example", func() {
g.It(fmt.Sprintf("should work with hot deploy"), func() {
oc.SetOutputDir(exutil.TestContext.OutputDir)
exutil.CheckOpenShiftNamespaceImageStreams(oc)
g.By(fmt.Sprintf("calling oc new-app -f %q -p %q", cakephpTemplate, hotDeployParam))
err := oc.Run("new-app").Args("-f", cakephpTemplate, "-p", hotDeployParam).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
g.By("waiting for build to finish")
err = exutil.WaitForABuild(oc.REST().Builds(oc.Namespace()), dcName, exutil.CheckBuildSuccessFn, exutil.CheckBuildFailedFn)
if err != nil {
exutil.DumpBuildLogs("cakephp-mysql-example", oc)
}
o.Expect(err).NotTo(o.HaveOccurred())
// oc.KubeFramework().WaitForAnEndpoint currently will wait forever; for now, prefacing with our WaitForADeploymentToComplete,
// which does have a timeout, since in most cases a failure in the service coming up stems from a failed deployment
err = exutil.WaitForADeploymentToComplete(oc.KubeREST().ReplicationControllers(oc.Namespace()), "cakephp-mysql-example", oc)
o.Expect(err).NotTo(o.HaveOccurred())
g.By("waiting for endpoint")
err = oc.KubeFramework().WaitForAnEndpoint("cakephp-mysql-example")
o.Expect(err).NotTo(o.HaveOccurred())
assertPageCountIs := func(i int) {
_, err := exutil.WaitForPods(oc.KubeREST().Pods(oc.Namespace()), dcLabel, exutil.CheckPodIsRunningFn, 1, 2*time.Minute)
o.Expect(err).NotTo(o.HaveOccurred())
result, err := CheckPageContains(oc, "cakephp-mysql-example", "", pageCountFn(i))
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(result).To(o.BeTrue())
}
g.By("checking page count")
assertPageCountIs(1)
assertPageCountIs(2)
g.By("modifying the source code with disabled hot deploy")
RunInPodContainer(oc, dcLabel, modifyCommand)
g.By("checking page count after modifying the source code")
assertPageCountIs(1337)
})
})
})