@@ -35,19 +35,21 @@ const (
3535
3636type cascadeGCContextKey string
3737
38- const cascadeGCNamespaceKey cascadeGCContextKey = "cascade-gc-namespace"
38+ const (
39+ cascadeGCNamespaceKey cascadeGCContextKey = "cascade-gc-namespace"
40+ cascadeGCScalityUIKey cascadeGCContextKey = "cascade-gc-scalityui"
41+ cascadeGCComponentKey cascadeGCContextKey = "cascade-gc-component"
42+ cascadeGCExposerKey cascadeGCContextKey = "cascade-gc-exposer"
43+ )
3944
4045func TestCascadeGC_ExposerUpdatesComponent (t * testing.T ) {
41- const (
42- scalityUIName = "cascade-update-ui"
43- componentName = "cascade-update-component"
44- exposerName = "cascade-update-exposer"
45- )
46-
4746 feature := features .New ("exposer-updates-component" ).
4847 Setup (func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
4948 client := cfg .Client ()
5049 testNamespace := envconf .RandomName ("cascade-update" , 16 )
50+ scalityUIName := envconf .RandomName ("cascade-update-ui" , 24 )
51+ componentName := envconf .RandomName ("cascade-update-comp" , 24 )
52+ exposerName := envconf .RandomName ("cascade-update-exp" , 24 )
5153
5254 ns := & corev1.Namespace {
5355 ObjectMeta : metav1.ObjectMeta {Name : testNamespace },
@@ -58,11 +60,16 @@ func TestCascadeGC_ExposerUpdatesComponent(t *testing.T) {
5860 t .Logf ("Created namespace %s" , testNamespace )
5961
6062 ctx = context .WithValue (ctx , cascadeGCNamespaceKey , testNamespace )
63+ ctx = context .WithValue (ctx , cascadeGCScalityUIKey , scalityUIName )
64+ ctx = context .WithValue (ctx , cascadeGCComponentKey , componentName )
65+ ctx = context .WithValue (ctx , cascadeGCExposerKey , exposerName )
6166 return ctx
6267 }).
6368 Assess ("create ScalityUI and Component without exposer" , func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
6469 client := cfg .Client ()
6570 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
71+ scalityUIName := ctx .Value (cascadeGCScalityUIKey ).(string )
72+ componentName := ctx .Value (cascadeGCComponentKey ).(string )
6673
6774 if err := framework .NewScalityUIBuilder (scalityUIName ).
6875 WithProductName ("Cascade Update Test" ).
@@ -97,6 +104,7 @@ func TestCascadeGC_ExposerUpdatesComponent(t *testing.T) {
97104 Assess ("verify no config volume before exposer" , func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
98105 client := cfg .Client ()
99106 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
107+ componentName := ctx .Value (cascadeGCComponentKey ).(string )
100108
101109 volumeName := framework .ConfigVolumePrefix + componentName
102110 err := framework .WaitForDeploymentNoVolume (ctx , client , namespace , componentName , volumeName , framework .DefaultTimeout )
@@ -110,6 +118,7 @@ func TestCascadeGC_ExposerUpdatesComponent(t *testing.T) {
110118 Assess ("record initial ReplicaSet" , func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
111119 client := cfg .Client ()
112120 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
121+ componentName := ctx .Value (cascadeGCComponentKey ).(string )
113122
114123 activeRS , err := framework .WaitForDeploymentStable (ctx , client , namespace , componentName , framework .LongTimeout )
115124 if err != nil {
@@ -123,6 +132,9 @@ func TestCascadeGC_ExposerUpdatesComponent(t *testing.T) {
123132 Assess ("create exposer" , func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
124133 client := cfg .Client ()
125134 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
135+ scalityUIName := ctx .Value (cascadeGCScalityUIKey ).(string )
136+ componentName := ctx .Value (cascadeGCComponentKey ).(string )
137+ exposerName := ctx .Value (cascadeGCExposerKey ).(string )
126138
127139 if err := framework .NewScalityUIComponentExposerBuilder (exposerName , namespace ).
128140 WithScalityUI (scalityUIName ).
@@ -143,6 +155,7 @@ func TestCascadeGC_ExposerUpdatesComponent(t *testing.T) {
143155 Assess ("verify volume added to deployment" , func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
144156 client := cfg .Client ()
145157 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
158+ componentName := ctx .Value (cascadeGCComponentKey ).(string )
146159
147160 volumeName := framework .ConfigVolumePrefix + componentName
148161 if err := framework .WaitForDeploymentHasVolume (ctx , client , namespace , componentName , volumeName , framework .LongTimeout ); err != nil {
@@ -161,6 +174,7 @@ func TestCascadeGC_ExposerUpdatesComponent(t *testing.T) {
161174 Assess ("verify new ReplicaSet created (rolling update)" , func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
162175 client := cfg .Client ()
163176 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
177+ componentName := ctx .Value (cascadeGCComponentKey ).(string )
164178 initialRSName := ctx .Value (cascadeGCContextKey ("initial-rs-name" )).(string )
165179
166180 newRSName , err := framework .WaitForNewReplicaSet (ctx , client , namespace , componentName , []string {initialRSName }, framework .LongTimeout )
@@ -179,6 +193,7 @@ func TestCascadeGC_ExposerUpdatesComponent(t *testing.T) {
179193 Teardown (func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
180194 client := cfg .Client ()
181195 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
196+ scalityUIName := ctx .Value (cascadeGCScalityUIKey ).(string )
182197
183198 if err := framework .DeleteScalityUI (ctx , client , scalityUIName ); err != nil {
184199 t .Logf ("Warning: Failed to delete ScalityUI: %v" , err )
@@ -199,16 +214,13 @@ func TestCascadeGC_ExposerUpdatesComponent(t *testing.T) {
199214}
200215
201216func TestCascadeGC_ExposerDeletionCleanup (t * testing.T ) {
202- const (
203- scalityUIName = "cascade-delete-ui"
204- componentName = "cascade-delete-component"
205- exposerName = "cascade-delete-exposer"
206- )
207-
208217 feature := features .New ("exposer-deletion-cleanup" ).
209218 Setup (func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
210219 client := cfg .Client ()
211220 testNamespace := envconf .RandomName ("cascade-delete" , 16 )
221+ scalityUIName := envconf .RandomName ("cascade-delete-ui" , 24 )
222+ componentName := envconf .RandomName ("cascade-delete-comp" , 24 )
223+ exposerName := envconf .RandomName ("cascade-delete-exp" , 24 )
212224
213225 ns := & corev1.Namespace {
214226 ObjectMeta : metav1.ObjectMeta {Name : testNamespace },
@@ -219,11 +231,17 @@ func TestCascadeGC_ExposerDeletionCleanup(t *testing.T) {
219231 t .Logf ("Created namespace %s" , testNamespace )
220232
221233 ctx = context .WithValue (ctx , cascadeGCNamespaceKey , testNamespace )
234+ ctx = context .WithValue (ctx , cascadeGCScalityUIKey , scalityUIName )
235+ ctx = context .WithValue (ctx , cascadeGCComponentKey , componentName )
236+ ctx = context .WithValue (ctx , cascadeGCExposerKey , exposerName )
222237 return ctx
223238 }).
224239 Assess ("create full resource chain" , func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
225240 client := cfg .Client ()
226241 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
242+ scalityUIName := ctx .Value (cascadeGCScalityUIKey ).(string )
243+ componentName := ctx .Value (cascadeGCComponentKey ).(string )
244+ exposerName := ctx .Value (cascadeGCExposerKey ).(string )
227245
228246 if err := framework .NewScalityUIBuilder (scalityUIName ).
229247 WithProductName ("Cascade Delete Test" ).
@@ -270,6 +288,7 @@ func TestCascadeGC_ExposerDeletionCleanup(t *testing.T) {
270288 Assess ("wait for stable state with volume mounted" , func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
271289 client := cfg .Client ()
272290 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
291+ componentName := ctx .Value (cascadeGCComponentKey ).(string )
273292
274293 volumeName := framework .ConfigVolumePrefix + componentName
275294 if err := framework .WaitForDeploymentHasVolume (ctx , client , namespace , componentName , volumeName , framework .LongTimeout ); err != nil {
@@ -286,6 +305,8 @@ func TestCascadeGC_ExposerDeletionCleanup(t *testing.T) {
286305 Assess ("verify ConfigMap exists with finalizer" , func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
287306 client := cfg .Client ()
288307 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
308+ componentName := ctx .Value (cascadeGCComponentKey ).(string )
309+ exposerName := ctx .Value (cascadeGCExposerKey ).(string )
289310
290311 configMapName := componentName + framework .RuntimeConfigMapSuffix
291312 if err := framework .WaitForConfigMapExists (ctx , client , namespace , configMapName , framework .DefaultTimeout ); err != nil {
@@ -304,6 +325,7 @@ func TestCascadeGC_ExposerDeletionCleanup(t *testing.T) {
304325 Assess ("delete exposer" , func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
305326 client := cfg .Client ()
306327 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
328+ exposerName := ctx .Value (cascadeGCExposerKey ).(string )
307329
308330 if err := framework .DeleteScalityUIComponentExposer (ctx , client , namespace , exposerName ); err != nil {
309331 t .Fatalf ("Failed to delete exposer: %v" , err )
@@ -315,6 +337,7 @@ func TestCascadeGC_ExposerDeletionCleanup(t *testing.T) {
315337 Assess ("verify volume removed from deployment" , func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
316338 client := cfg .Client ()
317339 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
340+ componentName := ctx .Value (cascadeGCComponentKey ).(string )
318341
319342 volumeName := framework .ConfigVolumePrefix + componentName
320343 if err := framework .WaitForDeploymentNoVolume (ctx , client , namespace , componentName , volumeName , framework .LongTimeout ); err != nil {
@@ -327,6 +350,8 @@ func TestCascadeGC_ExposerDeletionCleanup(t *testing.T) {
327350 Assess ("verify ConfigMap finalizer removed and ConfigMap deleted" , func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
328351 client := cfg .Client ()
329352 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
353+ componentName := ctx .Value (cascadeGCComponentKey ).(string )
354+ exposerName := ctx .Value (cascadeGCExposerKey ).(string )
330355
331356 configMapName := componentName + framework .RuntimeConfigMapSuffix
332357 finalizer := configMapFinalizerPrefix + exposerName
@@ -346,6 +371,7 @@ func TestCascadeGC_ExposerDeletionCleanup(t *testing.T) {
346371 Teardown (func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
347372 client := cfg .Client ()
348373 namespace := ctx .Value (cascadeGCNamespaceKey ).(string )
374+ scalityUIName := ctx .Value (cascadeGCScalityUIKey ).(string )
349375
350376 if err := framework .DeleteScalityUI (ctx , client , scalityUIName ); err != nil {
351377 t .Logf ("Warning: Failed to delete ScalityUI: %v" , err )
0 commit comments