@@ -2,6 +2,7 @@ package image_ecosystem
2
2
3
3
import (
4
4
"fmt"
5
+ "strconv"
5
6
"time"
6
7
7
8
g "github.com/onsi/ginkgo"
@@ -19,7 +20,8 @@ var _ = g.Describe("[image_ecosystem][php][Slow] hot deploy for openshift php im
19
20
oc = exutil .NewCLI ("s2i-php" , exutil .KubeConfigPath ())
20
21
hotDeployParam = "OPCACHE_REVALIDATE_FREQ=0"
21
22
modifyCommand = []string {"sed" , "-ie" , `s/\$result\['c'\]/1337/` , "src/Template/Pages/home.ctp" }
22
- pageCountFn = func (count int ) string { return fmt .Sprintf (`<span class="code" id="count-value">%d</span>` , count ) }
23
+ pageRegexpCount = `<span class="code" id="count-value">([^0][0-9]*)</span>`
24
+ pageExactCount = `<span class="code" id="count-value">%d</span>`
23
25
dcName = "cakephp-mysql-example-1"
24
26
dcLabel = exutil .ParseLabelsOrDie (fmt .Sprintf ("deployment=%s" , dcName ))
25
27
)
@@ -58,23 +60,41 @@ var _ = g.Describe("[image_ecosystem][php][Slow] hot deploy for openshift php im
58
60
err = e2e .WaitForEndpoint (oc .KubeFramework ().ClientSet , oc .Namespace (), "cakephp-mysql-example" )
59
61
o .Expect (err ).NotTo (o .HaveOccurred ())
60
62
61
- assertPageCountIs := func (i int ) {
63
+ assertPageCountRegexp := func (priorValue string ) string {
62
64
_ , err := exutil .WaitForPods (oc .KubeClient ().Core ().Pods (oc .Namespace ()), dcLabel , exutil .CheckPodIsRunning , 1 , 4 * time .Minute )
63
65
o .ExpectWithOffset (1 , err ).NotTo (o .HaveOccurred ())
64
66
65
- result , err := CheckPageContains (oc , "cakephp-mysql-example" , "" , pageCountFn ( i ) )
67
+ result , val , err := CheckPageRegexp (oc , "cakephp-mysql-example" , "" , pageRegexpCount , 1 )
66
68
o .ExpectWithOffset (1 , err ).NotTo (o .HaveOccurred ())
67
69
o .ExpectWithOffset (1 , result ).To (o .BeTrue ())
70
+ if len (priorValue ) > 0 {
71
+ p , err := strconv .Atoi (priorValue )
72
+ o .Expect (err ).NotTo (o .HaveOccurred ())
73
+ v , err := strconv .Atoi (val )
74
+ g .By (fmt .Sprintf ("comparing prior value %d with lastest value %d" , p , v ))
75
+ o .Expect (err ).NotTo (o .HaveOccurred ())
76
+ o .Expect (v ).To (o .BeNumerically (">" , p ))
77
+ }
78
+ return val
68
79
}
69
80
70
81
g .By ("checking page count" )
71
-
72
- assertPageCountIs (1 )
73
- assertPageCountIs (2 )
82
+ val := assertPageCountRegexp ("" )
83
+ assertPageCountRegexp (val )
74
84
75
85
g .By ("modifying the source code with hot deploy enabled" )
76
86
err = RunInPodContainer (oc , dcLabel , modifyCommand )
77
87
o .Expect (err ).NotTo (o .HaveOccurred ())
88
+
89
+ assertPageCountIs := func (i int ) {
90
+ _ , err := exutil .WaitForPods (oc .KubeClient ().Core ().Pods (oc .Namespace ()), dcLabel , exutil .CheckPodIsRunning , 1 , 4 * time .Minute )
91
+ o .ExpectWithOffset (1 , err ).NotTo (o .HaveOccurred ())
92
+
93
+ result , err := CheckPageContains (oc , "cakephp-mysql-example" , "" , fmt .Sprintf (pageExactCount , i ))
94
+ o .ExpectWithOffset (1 , err ).NotTo (o .HaveOccurred ())
95
+ o .ExpectWithOffset (1 , result ).To (o .BeTrue ())
96
+ }
97
+
78
98
g .By ("checking page count after modifying the source code" )
79
99
assertPageCountIs (1337 )
80
100
})
0 commit comments