35
35
env * utils.TestingEnvironment
36
36
testLevelEnv * tests.TestEnvLevel
37
37
expectedOperatorPodName string
38
+ operatorPodWasRenamed bool
39
+ operatorWasRestarted bool
38
40
)
39
41
40
42
var _ = BeforeSuite (func () {
@@ -55,11 +57,22 @@ var _ = BeforeEach(func() {
55
57
labelsForTestsBreakingTheOperator := []string {"upgrade" , "disruptive" }
56
58
breakingLabelsInCurrentTest := funk .Join (CurrentSpecReport ().Labels (),
57
59
labelsForTestsBreakingTheOperator , funk .InnerJoin )
58
- if len (breakingLabelsInCurrentTest .([]string )) == 0 {
59
- operatorPod , err := env .GetOperatorPod ()
60
- Expect (err ).NotTo (HaveOccurred ())
61
- expectedOperatorPodName = operatorPod .GetName ()
60
+
61
+ if len (breakingLabelsInCurrentTest .([]string )) != 0 {
62
+ return
63
+ }
64
+
65
+ operatorPod , err := env .GetOperatorPod ()
66
+ Expect (err ).ToNot (HaveOccurred ())
67
+
68
+ if operatorPodWasRenamed {
69
+ Skip ("Skipping test. Operator was renamed" )
70
+ }
71
+ if operatorWasRestarted {
72
+ Skip ("Skipping test. Operator was restarted" )
62
73
}
74
+
75
+ expectedOperatorPodName = operatorPod .GetName ()
63
76
})
64
77
65
78
func TestE2ESuite (t * testing.T ) {
@@ -70,11 +83,26 @@ func TestE2ESuite(t *testing.T) {
70
83
71
84
// Before the end of the tests we should verify that the operator never restarted
72
85
// and that the operator pod name didn't change.
86
+ // If either of those things happened, the test will fail, and all subsequent
87
+ // tests will be SKIPPED, as they would always fail in this node.
73
88
var _ = AfterEach (func () {
74
89
labelsForTestsBreakingTheOperator := []string {"upgrade" , "disruptive" }
75
90
breakingLabelsInCurrentTest := funk .Join (CurrentSpecReport ().Labels (),
76
91
labelsForTestsBreakingTheOperator , funk .InnerJoin )
77
- if len (breakingLabelsInCurrentTest .([]string )) == 0 {
78
- AssertOperatorPodUnchanged (expectedOperatorPodName )
92
+ if len (breakingLabelsInCurrentTest .([]string )) != 0 {
93
+ return
94
+ }
95
+ operatorPod , err := env .GetOperatorPod ()
96
+ Expect (err ).ToNot (HaveOccurred ())
97
+
98
+ wasRenamed := utils .OperatorPodRenamed (operatorPod , expectedOperatorPodName )
99
+ if wasRenamed {
100
+ operatorPodWasRenamed = true
101
+ Fail ("operator was renamed" )
102
+ }
103
+ wasRestarted := utils .OperatorPodRestarted (operatorPod )
104
+ if wasRestarted {
105
+ operatorWasRestarted = true
106
+ Fail ("operator was restarted" )
79
107
}
80
108
})
0 commit comments