@@ -24,9 +24,16 @@ import (
2424 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525)
2626
27- var _ = Describe ("RolloutManager tests" , func () {
27+ // This file contains tests that should run in both namespace-scoped and cluster-scoped scenarios.
28+ // As of this writing, these function is called from the 'tests/e2e/(cluster-scoped/namespace-scoped)' packages.
29+ func RunRolloutsTests (namespaceScopedParam bool ) {
2830
29- Context ("RolloutManager tests" , func () {
31+ testType := "cluster-scoped"
32+ if namespaceScopedParam {
33+ testType = "namespace-scoped"
34+ }
35+
36+ Context ("RolloutManager tests - " + testType , func () {
3037
3138 var (
3239 k8sClient client.Client
@@ -48,7 +55,7 @@ var _ = Describe("RolloutManager tests", func() {
4855 Namespace : fixture .TestE2ENamespace ,
4956 },
5057 Spec : rolloutsmanagerv1alpha1.RolloutManagerSpec {
51- NamespaceScoped : true ,
58+ NamespaceScoped : namespaceScopedParam ,
5259 },
5360 }
5461 })
@@ -57,11 +64,11 @@ var _ = Describe("RolloutManager tests", func() {
5764 It ("should create the appropriate K8s resources" , func () {
5865 Expect (k8sClient .Create (ctx , & rolloutManager )).To (Succeed ())
5966
60- By ("setting the phase to \" Available\" " )
67+ By ("waiting for phase to be \" Available\" " )
6168 Eventually (rolloutManager , "60s" , "1s" ).Should (rolloutManagerFixture .HavePhase (rolloutsmanagerv1alpha1 .PhaseAvailable ))
6269
6370 By ("Verify that expected resources are created." )
64- ValidateArgoRolloutManagerResources (ctx , rolloutManager , k8sClient , true )
71+ ValidateArgoRolloutManagerResources (ctx , rolloutManager , k8sClient , namespaceScopedParam )
6572 })
6673 })
6774
@@ -127,7 +134,7 @@ var _ = Describe("RolloutManager tests", func() {
127134 "--loglevel" ,
128135 "error" ,
129136 },
130- NamespaceScoped : true ,
137+ NamespaceScoped : namespaceScopedParam ,
131138 }
132139 Expect (k8sClient .Create (ctx , & rolloutManager )).To (Succeed ())
133140 Eventually (rolloutManager , "1m" , "1s" ).Should (rolloutManagerFixture .HavePhase (rolloutsmanagerv1alpha1 .PhaseAvailable ))
@@ -136,7 +143,15 @@ var _ = Describe("RolloutManager tests", func() {
136143 ObjectMeta : metav1.ObjectMeta {Name : controllers .DefaultArgoRolloutsResourceName , Namespace : rolloutManager .Namespace },
137144 }
138145 Eventually (& deployment , "10s" , "1s" ).Should (k8s .ExistByName (k8sClient ))
139- Expect (deployment .Spec .Template .Spec .Containers [0 ].Args ).To (Equal ([]string {"--namespaced" , "--loglevel" , "error" }))
146+
147+ var expectedContainerArgs []string
148+ if namespaceScopedParam {
149+ expectedContainerArgs = []string {"--namespaced" , "--loglevel" , "error" }
150+ } else {
151+ expectedContainerArgs = []string {"--loglevel" , "error" }
152+ }
153+
154+ Expect (deployment .Spec .Template .Spec .Containers [0 ].Args ).To (Equal (expectedContainerArgs ))
140155
141156 By ("updating the deployment when the argument in the RolloutManager is updated" )
142157
@@ -149,15 +164,21 @@ var _ = Describe("RolloutManager tests", func() {
149164 "--logformat" ,
150165 "text" ,
151166 },
152- NamespaceScoped : true ,
167+ NamespaceScoped : namespaceScopedParam ,
153168 }
154169 })
155170 Expect (err ).ToNot (HaveOccurred ())
156171
172+ if namespaceScopedParam {
173+ expectedContainerArgs = []string {"--namespaced" , "--logformat" , "text" }
174+ } else {
175+ expectedContainerArgs = []string {"--logformat" , "text" }
176+ }
177+
157178 Eventually (func () []string {
158179 Expect (k8sClient .Get (ctx , client .ObjectKeyFromObject (& deployment ), & deployment )).To (Succeed ())
159180 return deployment .Spec .Template .Spec .Containers [0 ].Args
160- }, "10s" , "1s" ).Should (Equal ([] string { "--namespaced" , "--logformat" , "text" } ))
181+ }, "10s" , "1s" ).Should (Equal (expectedContainerArgs ))
161182 })
162183 })
163184
@@ -301,7 +322,7 @@ var _ = Describe("RolloutManager tests", func() {
301322 "foo-label2" : "bar-label2" ,
302323 },
303324 },
304- NamespaceScoped : true ,
325+ NamespaceScoped : namespaceScopedParam ,
305326 },
306327 }
307328
@@ -343,4 +364,4 @@ var _ = Describe("RolloutManager tests", func() {
343364 })
344365 })
345366 })
346- })
367+ }
0 commit comments