11package sequential
22
33import (
4+ "strings"
5+
46 . "github.com/onsi/ginkgo/v2"
57 . "github.com/onsi/gomega"
68 "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture"
@@ -16,27 +18,45 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
1618 })
1719
1820 AfterEach (func () {
21+
22+ // Delete the new role we created during the test
23+ defer func () {
24+ By ("deleting the role we created during the test" )
25+ _ , err := argocdFixture .RunArgoCDCLI ("proj" , "role" , "delete" , "default" , "somerole" )
26+ Expect (err ).ToNot (HaveOccurred ())
27+ }()
28+
1929 fixture .OutputDebugOnFail ()
30+
2031 })
2132
2233 It ("creates a project role 'somerole' and group claim, and verifies group claim contains the expected data" , func () {
2334
35+ defaultArgoCD , err := argocdFixture .GetOpenShiftGitOpsNSArgoCD ()
36+ Expect (err ).ToNot (HaveOccurred ())
37+ Eventually (defaultArgoCD , "5m" , "5s" ).Should (argocdFixture .BeAvailable ())
38+
2439 By ("logging in to Argo CD instance" )
2540 Expect (argocdFixture .LogInToDefaultArgoCDInstance ()).To (Succeed ())
2641
2742 By ("Creating a new 'somerole' role in default project" )
2843 output , err := argocdFixture .RunArgoCDCLI ("proj" , "role" , "create" , "default" , "somerole" )
2944 Expect (err ).ToNot (HaveOccurred ())
3045
31- // Delete the new role we created during the test
32- defer func () {
33- By ("deleting the role we created during the test" )
34- _ , err = argocdFixture .RunArgoCDCLI ("proj" , "role" , "delete" , "default" , "somerole" )
35- Expect (err ).ToNot (HaveOccurred ())
36- }()
37-
3846 Expect (output ).To (ContainSubstring ("Role 'somerole' created" ))
3947
48+ By ("waiting for Argo CD to verify the role exists before we add to it (there seems to be some kind of intermittent race condition here in Argo CD itself, where create succeeds in the previous step, but we received 503 in the next step)" )
49+ Eventually (func () bool {
50+ output , err := argocdFixture .RunArgoCDCLI ("proj" , "role" , "get" , "default" , "somerole" )
51+ if err != nil {
52+ GinkgoWriter .Println ("error:" , err )
53+ return false
54+ }
55+
56+ return strings .Contains (output , "Role Name:" )
57+
58+ }, "30s" , "5s" ).Should (BeTrue ())
59+
4060 By ("adding a group claim to the somerole role" )
4161 output , err = argocdFixture .RunArgoCDCLI ("proj" , "role" , "add-group" , "default" , "somerole" , "\" CN=foo,OU=bar,O=baz\" " )
4262 Expect (err ).ToNot (HaveOccurred ())
0 commit comments