Skip to content

Commit d129af8

Browse files
authored
test(e2e): stabilize tokenRef strict mode cmd-params tests (argoproj-labs#2210)
Signed-off-by: nmirasch <neus.miras@gmail.com>
1 parent 5a975fc commit d129af8

1 file changed

Lines changed: 31 additions & 32 deletions

File tree

tests/ginkgo/sequential/1-037_validate_applicationset_in_any_namespace_test.go

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,33 +1346,21 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
13461346
},
13471347
}
13481348
Expect(k8sClient.Create(ctx, argoCD)).To(Succeed())
1349-
Eventually(argoCD, "5m", "5s").Should(argocdFixture.BeAvailable())
13501349

13511350
cmdParamsCM := &corev1.ConfigMap{
13521351
ObjectMeta: metav1.ObjectMeta{
13531352
Name: common.ArgoCDCmdParamsConfigMapName,
13541353
Namespace: argoCD.Namespace,
13551354
},
13561355
}
1357-
Eventually(cmdParamsCM).Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "true"))
1356+
Eventually(cmdParamsCM, "3m", "5s").Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "true"))
13581357
})
13591358

1360-
It("defaults tokenRef strict mode to false when applicationSet sourceNamespaces are empty or removed", func() {
1359+
It("defaults tokenRef strict mode to false when applicationSet sourceNamespaces are empty on create", func() {
13611360
appsetArgocdNS, cleanupFunc := fixture.CreateNamespaceWithCleanupFunc("appset-argocd")
13621361
cleanupFunctions = append(cleanupFunctions, cleanupFunc)
13631362

1364-
targetNS, cleanupFunc := fixture.CreateNamespaceWithCleanupFunc("appset-target-ns")
1365-
cleanupFunctions = append(cleanupFunctions, cleanupFunc)
1366-
1367-
cmdParamsCM := &corev1.ConfigMap{
1368-
ObjectMeta: metav1.ObjectMeta{
1369-
Name: common.ArgoCDCmdParamsConfigMapName,
1370-
Namespace: appsetArgocdNS.Name,
1371-
},
1372-
}
1373-
1374-
By("empty applicationSet.sourceNamespaces on create")
1375-
argoCDEmpty := &v1beta1.ArgoCD{
1363+
argoCD := &v1beta1.ArgoCD{
13761364
ObjectMeta: metav1.ObjectMeta{
13771365
Name: "tokenref-strict-false-empty",
13781366
Namespace: appsetArgocdNS.Name,
@@ -1383,12 +1371,25 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
13831371
},
13841372
},
13851373
}
1386-
Expect(k8sClient.Create(ctx, argoCDEmpty)).To(Succeed())
1387-
Eventually(argoCDEmpty, "5m", "5s").Should(argocdFixture.BeAvailable())
1388-
Eventually(cmdParamsCM).Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "false"))
1374+
Expect(k8sClient.Create(ctx, argoCD)).To(Succeed())
1375+
1376+
cmdParamsCM := &corev1.ConfigMap{
1377+
ObjectMeta: metav1.ObjectMeta{
1378+
Name: common.ArgoCDCmdParamsConfigMapName,
1379+
Namespace: argoCD.Namespace,
1380+
},
1381+
}
1382+
Eventually(cmdParamsCM, "3m", "5s").Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "false"))
1383+
})
1384+
1385+
It("defaults tokenRef strict mode to false when applicationSet sourceNamespaces are removed", func() {
1386+
appsetArgocdNS, cleanupFunc := fixture.CreateNamespaceWithCleanupFunc("appset-argocd")
1387+
cleanupFunctions = append(cleanupFunctions, cleanupFunc)
13891388

1390-
By("removing applicationSet.sourceNamespaces after they were configured")
1391-
argoCDRemove := &v1beta1.ArgoCD{
1389+
targetNS, cleanupFunc := fixture.CreateNamespaceWithCleanupFunc("appset-target-ns")
1390+
cleanupFunctions = append(cleanupFunctions, cleanupFunc)
1391+
1392+
argoCD := &v1beta1.ArgoCD{
13921393
ObjectMeta: metav1.ObjectMeta{
13931394
Name: "tokenref-strict-false-removed",
13941395
Namespace: appsetArgocdNS.Name,
@@ -1399,20 +1400,20 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
13991400
},
14001401
},
14011402
}
1402-
Expect(k8sClient.Create(ctx, argoCDRemove)).To(Succeed())
1403-
Eventually(argoCDRemove, "5m", "5s").Should(argocdFixture.BeAvailable())
1404-
cmdParamsCMRemove := &corev1.ConfigMap{
1403+
Expect(k8sClient.Create(ctx, argoCD)).To(Succeed())
1404+
1405+
cmdParamsCM := &corev1.ConfigMap{
14051406
ObjectMeta: metav1.ObjectMeta{
14061407
Name: common.ArgoCDCmdParamsConfigMapName,
1407-
Namespace: argoCDRemove.Namespace,
1408+
Namespace: argoCD.Namespace,
14081409
},
14091410
}
1410-
Eventually(cmdParamsCMRemove).Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "true"))
1411+
Eventually(cmdParamsCM, "3m", "5s").Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "true"))
14111412

1412-
argocdFixture.Update(argoCDRemove, func(ac *v1beta1.ArgoCD) {
1413+
argocdFixture.Update(argoCD, func(ac *v1beta1.ArgoCD) {
14131414
ac.Spec.ApplicationSet.SourceNamespaces = []string{}
14141415
})
1415-
Eventually(cmdParamsCMRemove, "3m", "5s").Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "false"))
1416+
Eventually(cmdParamsCM, "3m", "5s").Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "false"))
14161417
})
14171418

14181419
It("reconciles tokenRef strict mode cmd-params drift when applicationSet sourceNamespaces remain configured", func() {
@@ -1434,20 +1435,19 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
14341435
},
14351436
}
14361437
Expect(k8sClient.Create(ctx, argoCD)).To(Succeed())
1437-
Eventually(argoCD, "5m", "5s").Should(argocdFixture.BeAvailable())
14381438

14391439
cmdParamsCM := &corev1.ConfigMap{
14401440
ObjectMeta: metav1.ObjectMeta{
14411441
Name: common.ArgoCDCmdParamsConfigMapName,
14421442
Namespace: argoCD.Namespace,
14431443
},
14441444
}
1445-
Eventually(cmdParamsCM).Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "true"))
1445+
Eventually(cmdParamsCM, "3m", "5s").Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "true"))
14461446

14471447
configmapFixture.Update(cmdParamsCM, func(cm *corev1.ConfigMap) {
14481448
cm.Data[common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey] = "false"
14491449
})
1450-
Eventually(cmdParamsCM).Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "false"))
1450+
Eventually(cmdParamsCM, "3m", "5s").Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "false"))
14511451

14521452
By("triggering reconciliation via ArgoCD metadata change")
14531453
argocdFixture.Update(argoCD, func(ac *v1beta1.ArgoCD) {
@@ -1481,15 +1481,14 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
14811481
},
14821482
}
14831483
Expect(k8sClient.Create(ctx, argoCD)).To(Succeed())
1484-
Eventually(argoCD, "5m", "5s").Should(argocdFixture.BeAvailable())
14851484

14861485
cmdParamsCM := &corev1.ConfigMap{
14871486
ObjectMeta: metav1.ObjectMeta{
14881487
Name: common.ArgoCDCmdParamsConfigMapName,
14891488
Namespace: argoCD.Namespace,
14901489
},
14911490
}
1492-
Eventually(cmdParamsCM).Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "false"))
1491+
Eventually(cmdParamsCM, "3m", "5s").Should(configmapFixture.HaveStringDataKeyValue(common.ArgoCDApplicationSetControllerTokenRefStrictModeCmdParamKey, "false"))
14931492

14941493
By("triggering reconcile by updating ArgoCD spec.cmdParams and verifying opt-out persists")
14951494
argocdFixture.Update(argoCD, func(ac *v1beta1.ArgoCD) {

0 commit comments

Comments
 (0)