Skip to content

Commit 33ab244

Browse files
committed
finally re-enable the exotic related resources tests
On-behalf-of: @SAP christoph.mewes@sap.com
1 parent 5dccd84 commit 33ab244

File tree

1 file changed

+162
-210
lines changed

1 file changed

+162
-210
lines changed

test/e2e/sync/related_test.go

Lines changed: 162 additions & 210 deletions
Original file line numberDiff line numberDiff line change
@@ -177,216 +177,168 @@ func TestSyncRelatedObjects(t *testing.T) {
177177

178178
//////////////////////////////////////////////////////////////////////////////////////////////
179179

180-
// {
181-
// name: "sync referenced Secret up into a new namespace",
182-
// workspace: "sync-referenced-secret-up-namespace",
183-
// mainResource: crds.Crontab{
184-
// ObjectMeta: metav1.ObjectMeta{
185-
// Name: "my-crontab",
186-
// Namespace: "default",
187-
// },
188-
// Spec: crds.CrontabSpec{
189-
// CronSpec: "* * *",
190-
// Image: "ubuntu:latest",
191-
// },
192-
// },
193-
// relatedConfig: syncagentv1alpha1.RelatedResourceSpec{
194-
// Identifier: "credentials",
195-
// Origin: "service",
196-
// Kind: "Secret",
197-
// Object: syncagentv1alpha1.RelatedResourceObject{
198-
// RelatedResourceObjectSpec: syncagentv1alpha1.RelatedResourceObjectSpec{
199-
// Reference: &syncagentv1alpha1.RelatedResourceObjectReference{
200-
// Path: "metadata.name", // irrelevant
201-
// Regex: &syncagentv1alpha1.RegularExpression{
202-
// Replacement: "my-credentials",
203-
// },
204-
// },
205-
// },
206-
// },
207-
// Destination: syncagentv1alpha1.RelatedResourceDestination{
208-
// RelatedResourceDestinationSpec: syncagentv1alpha1.RelatedResourceDestinationSpec{
209-
// Reference: &syncagentv1alpha1.RelatedResourceObjectReference{
210-
// Path: "metadata.name", // irrelevant
211-
// Regex: &syncagentv1alpha1.RegularExpression{
212-
// Replacement: "my-credentials",
213-
// },
214-
// },
215-
// },
216-
// Namespace: &syncagentv1alpha1.RelatedResourceDestinationSpec{
217-
// Reference: &syncagentv1alpha1.RelatedResourceObjectReference{
218-
// Path: "metadata.name", // irrelevant
219-
// Regex: &syncagentv1alpha1.RegularExpression{
220-
// Replacement: "new-namespace",
221-
// },
222-
// },
223-
// },
224-
// },
225-
// },
226-
// sourceRelatedObject: corev1.Secret{
227-
// ObjectMeta: metav1.ObjectMeta{
228-
// Name: "my-credentials",
229-
// Namespace: "synced-default",
230-
// },
231-
// Data: map[string][]byte{
232-
// "password": []byte("hunter2"),
233-
// },
234-
// Type: corev1.SecretTypeOpaque,
235-
// },
236-
237-
// expectedSyncedRelatedObject: corev1.Secret{
238-
// ObjectMeta: metav1.ObjectMeta{
239-
// Name: "my-credentials",
240-
// Namespace: "new-namespace",
241-
// },
242-
// Data: map[string][]byte{
243-
// "password": []byte("hunter2"),
244-
// },
245-
// Type: corev1.SecretTypeOpaque,
246-
// },
247-
// },
248-
249-
// //////////////////////////////////////////////////////////////////////////////////////////////
250-
251-
// {
252-
// name: "sync referenced Secret down into a new namespace",
253-
// workspace: "sync-referenced-secret-down-namespace",
254-
// mainResource: crds.Crontab{
255-
// ObjectMeta: metav1.ObjectMeta{
256-
// Name: "my-crontab",
257-
// Namespace: "default",
258-
// },
259-
// Spec: crds.CrontabSpec{
260-
// CronSpec: "* * *",
261-
// Image: "ubuntu:latest",
262-
// },
263-
// },
264-
// relatedConfig: syncagentv1alpha1.RelatedResourceSpec{
265-
// Identifier: "credentials",
266-
// Origin: "kcp",
267-
// Kind: "Secret",
268-
// Object: syncagentv1alpha1.RelatedResourceObject{
269-
// RelatedResourceObjectSpec: syncagentv1alpha1.RelatedResourceObjectSpec{
270-
// Reference: &syncagentv1alpha1.RelatedResourceObjectReference{
271-
// Path: "metadata.name", // irrelevant
272-
// Regex: &syncagentv1alpha1.RegularExpression{
273-
// Replacement: "my-credentials",
274-
// },
275-
// },
276-
// },
277-
// },
278-
// Destination: syncagentv1alpha1.RelatedResourceDestination{
279-
// RelatedResourceDestinationSpec: syncagentv1alpha1.RelatedResourceDestinationSpec{
280-
// Reference: &syncagentv1alpha1.RelatedResourceObjectReference{
281-
// Path: "metadata.name", // irrelevant
282-
// Regex: &syncagentv1alpha1.RegularExpression{
283-
// Replacement: "my-credentials",
284-
// },
285-
// },
286-
// },
287-
// Namespace: &syncagentv1alpha1.RelatedResourceDestinationSpec{
288-
// Reference: &syncagentv1alpha1.RelatedResourceObjectReference{
289-
// Path: "metadata.name", // irrelevant
290-
// Regex: &syncagentv1alpha1.RegularExpression{
291-
// Replacement: "new-namespace",
292-
// },
293-
// },
294-
// },
295-
// },
296-
// },
297-
// sourceRelatedObject: corev1.Secret{
298-
// ObjectMeta: metav1.ObjectMeta{
299-
// Name: "my-credentials",
300-
// Namespace: "default",
301-
// },
302-
// Data: map[string][]byte{
303-
// "password": []byte("hunter2"),
304-
// },
305-
// Type: corev1.SecretTypeOpaque,
306-
// },
307-
308-
// expectedSyncedRelatedObject: corev1.Secret{
309-
// ObjectMeta: metav1.ObjectMeta{
310-
// Name: "my-credentials",
311-
// Namespace: "new-namespace",
312-
// },
313-
// Data: map[string][]byte{
314-
// "password": []byte("hunter2"),
315-
// },
316-
// Type: corev1.SecretTypeOpaque,
317-
// },
318-
// },
319-
320-
// //////////////////////////////////////////////////////////////////////////////////////////////
321-
322-
// {
323-
// name: "sync referenced Secret up from a foreign namespace",
324-
// workspace: "sync-referenced-secret-up-foreign-namespace",
325-
// mainResource: crds.Crontab{
326-
// ObjectMeta: metav1.ObjectMeta{
327-
// Name: "my-crontab",
328-
// Namespace: "default",
329-
// },
330-
// Spec: crds.CrontabSpec{
331-
// CronSpec: "* * *",
332-
// Image: "ubuntu:latest",
333-
// },
334-
// },
335-
// relatedConfig: syncagentv1alpha1.RelatedResourceSpec{
336-
// Identifier: "credentials",
337-
// Origin: "service",
338-
// Kind: "Secret",
339-
// Object: syncagentv1alpha1.RelatedResourceObject{
340-
// RelatedResourceObjectSpec: syncagentv1alpha1.RelatedResourceObjectSpec{
341-
// Reference: &syncagentv1alpha1.RelatedResourceObjectReference{
342-
// Path: "metadata.name", // irrelevant
343-
// Regex: &syncagentv1alpha1.RegularExpression{
344-
// Replacement: "my-credentials",
345-
// },
346-
// },
347-
// },
348-
// Namespace: &syncagentv1alpha1.RelatedResourceObjectSpec{
349-
// Reference: &syncagentv1alpha1.RelatedResourceObjectReference{
350-
// Path: "metadata.name", // irrelevant
351-
// Regex: &syncagentv1alpha1.RegularExpression{
352-
// Replacement: "other-namespace",
353-
// },
354-
// },
355-
// },
356-
// },
357-
// Destination: syncagentv1alpha1.RelatedResourceDestination{
358-
// RelatedResourceDestinationSpec: syncagentv1alpha1.RelatedResourceDestinationSpec{
359-
// Reference: &syncagentv1alpha1.RelatedResourceObjectReference{
360-
// Path: "metadata.name", // irrelevant
361-
// Regex: &syncagentv1alpha1.RegularExpression{
362-
// Replacement: "my-credentials",
363-
// },
364-
// },
365-
// },
366-
// },
367-
// },
368-
// sourceRelatedObject: corev1.Secret{
369-
// ObjectMeta: metav1.ObjectMeta{
370-
// Name: "my-credentials",
371-
// Namespace: "other-namespace",
372-
// },
373-
// Data: map[string][]byte{
374-
// "password": []byte("hunter2"),
375-
// },
376-
// Type: corev1.SecretTypeOpaque,
377-
// },
378-
379-
// expectedSyncedRelatedObject: corev1.Secret{
380-
// ObjectMeta: metav1.ObjectMeta{
381-
// Name: "my-credentials",
382-
// Namespace: "default",
383-
// },
384-
// Data: map[string][]byte{
385-
// "password": []byte("hunter2"),
386-
// },
387-
// Type: corev1.SecretTypeOpaque,
388-
// },
389-
// },
180+
{
181+
name: "sync referenced Secret up into a new namespace",
182+
workspace: "sync-referenced-secret-up-namespace",
183+
mainResource: crds.Crontab{
184+
ObjectMeta: metav1.ObjectMeta{
185+
Name: "my-crontab",
186+
Namespace: "default",
187+
},
188+
Spec: crds.CrontabSpec{
189+
CronSpec: "* * *",
190+
Image: "ubuntu:latest",
191+
},
192+
},
193+
relatedConfig: syncagentv1alpha1.RelatedResourceSpec{
194+
Identifier: "credentials",
195+
Origin: "service",
196+
Kind: "Secret",
197+
Object: syncagentv1alpha1.RelatedResourceObject{
198+
RelatedResourceObjectSpec: syncagentv1alpha1.RelatedResourceObjectSpec{
199+
Template: &syncagentv1alpha1.TemplateExpression{
200+
Template: "my-credentials",
201+
},
202+
},
203+
Namespace: &syncagentv1alpha1.RelatedResourceObjectSpec{
204+
Template: &syncagentv1alpha1.TemplateExpression{
205+
Template: `{{ if eq .Side "kcp" }}new-namespace{{ else }}{{ .Object.metadata.namespace }}{{ end }}`,
206+
},
207+
},
208+
},
209+
},
210+
sourceRelatedObject: corev1.Secret{
211+
ObjectMeta: metav1.ObjectMeta{
212+
Name: "my-credentials",
213+
Namespace: "synced-default",
214+
},
215+
Data: map[string][]byte{
216+
"password": []byte("hunter2"),
217+
},
218+
Type: corev1.SecretTypeOpaque,
219+
},
220+
221+
expectedSyncedRelatedObject: corev1.Secret{
222+
ObjectMeta: metav1.ObjectMeta{
223+
Name: "my-credentials",
224+
Namespace: "new-namespace",
225+
},
226+
Data: map[string][]byte{
227+
"password": []byte("hunter2"),
228+
},
229+
Type: corev1.SecretTypeOpaque,
230+
},
231+
},
232+
233+
//////////////////////////////////////////////////////////////////////////////////////////////
234+
235+
{
236+
name: "sync referenced Secret down into a new namespace",
237+
workspace: "sync-referenced-secret-down-namespace",
238+
mainResource: crds.Crontab{
239+
ObjectMeta: metav1.ObjectMeta{
240+
Name: "my-crontab",
241+
Namespace: "default",
242+
},
243+
Spec: crds.CrontabSpec{
244+
CronSpec: "* * *",
245+
Image: "ubuntu:latest",
246+
},
247+
},
248+
relatedConfig: syncagentv1alpha1.RelatedResourceSpec{
249+
Identifier: "credentials",
250+
Origin: "kcp",
251+
Kind: "Secret",
252+
Object: syncagentv1alpha1.RelatedResourceObject{
253+
RelatedResourceObjectSpec: syncagentv1alpha1.RelatedResourceObjectSpec{
254+
Template: &syncagentv1alpha1.TemplateExpression{
255+
Template: "my-credentials",
256+
},
257+
},
258+
Namespace: &syncagentv1alpha1.RelatedResourceObjectSpec{
259+
Template: &syncagentv1alpha1.TemplateExpression{
260+
Template: `{{ if eq .Side "kcp" }}{{ .Object.metadata.namespace }}{{ else }}new-namespace{{ end }}`,
261+
},
262+
},
263+
},
264+
},
265+
sourceRelatedObject: corev1.Secret{
266+
ObjectMeta: metav1.ObjectMeta{
267+
Name: "my-credentials",
268+
Namespace: "default",
269+
},
270+
Data: map[string][]byte{
271+
"password": []byte("hunter2"),
272+
},
273+
Type: corev1.SecretTypeOpaque,
274+
},
275+
276+
expectedSyncedRelatedObject: corev1.Secret{
277+
ObjectMeta: metav1.ObjectMeta{
278+
Name: "my-credentials",
279+
Namespace: "new-namespace",
280+
},
281+
Data: map[string][]byte{
282+
"password": []byte("hunter2"),
283+
},
284+
Type: corev1.SecretTypeOpaque,
285+
},
286+
},
287+
288+
//////////////////////////////////////////////////////////////////////////////////////////////
289+
290+
{
291+
name: "sync referenced Secret up from a foreign namespace",
292+
workspace: "sync-referenced-secret-up-foreign-namespace",
293+
mainResource: crds.Crontab{
294+
ObjectMeta: metav1.ObjectMeta{
295+
Name: "my-crontab",
296+
Namespace: "default",
297+
},
298+
Spec: crds.CrontabSpec{
299+
CronSpec: "* * *",
300+
Image: "ubuntu:latest",
301+
},
302+
},
303+
relatedConfig: syncagentv1alpha1.RelatedResourceSpec{
304+
Identifier: "credentials",
305+
Origin: "service",
306+
Kind: "Secret",
307+
Object: syncagentv1alpha1.RelatedResourceObject{
308+
RelatedResourceObjectSpec: syncagentv1alpha1.RelatedResourceObjectSpec{
309+
Template: &syncagentv1alpha1.TemplateExpression{
310+
Template: "my-credentials",
311+
},
312+
},
313+
Namespace: &syncagentv1alpha1.RelatedResourceObjectSpec{
314+
Template: &syncagentv1alpha1.TemplateExpression{
315+
Template: `{{ if eq .Side "kcp" }}{{ .Object.metadata.namespace }}{{ else }}other-namespace{{ end }}`,
316+
},
317+
},
318+
},
319+
},
320+
sourceRelatedObject: corev1.Secret{
321+
ObjectMeta: metav1.ObjectMeta{
322+
Name: "my-credentials",
323+
Namespace: "other-namespace",
324+
},
325+
Data: map[string][]byte{
326+
"password": []byte("hunter2"),
327+
},
328+
Type: corev1.SecretTypeOpaque,
329+
},
330+
331+
expectedSyncedRelatedObject: corev1.Secret{
332+
ObjectMeta: metav1.ObjectMeta{
333+
Name: "my-credentials",
334+
Namespace: "default",
335+
},
336+
Data: map[string][]byte{
337+
"password": []byte("hunter2"),
338+
},
339+
Type: corev1.SecretTypeOpaque,
340+
},
341+
},
390342

391343
//////////////////////////////////////////////////////////////////////////////////////////////
392344

0 commit comments

Comments
 (0)