@@ -27,6 +27,7 @@ import (
2727
2828 "github.com/onsi/gomega/gcustom"
2929 matcher "github.com/onsi/gomega/types"
30+ "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/clusterserviceversion"
3031 "k8s.io/apimachinery/pkg/util/rand"
3132 "k8s.io/client-go/util/retry"
3233 "sigs.k8s.io/controller-runtime/pkg/client/apiutil"
@@ -51,15 +52,10 @@ import (
5152 argov1beta1api "github.com/argoproj-labs/argocd-operator/api/v1beta1"
5253 "github.com/argoproj-labs/argocd-operator/tests/ginkgo/fixture"
5354 argocdFixture "github.com/argoproj-labs/argocd-operator/tests/ginkgo/fixture/argocd"
54- fixtureUtils "github.com/argoproj-labs/argocd -operator/tests /ginkgo/fixture/utils"
55+ fixtureUtils "github.com/redhat-developer/gitops -operator/test/openshift/e2e /ginkgo/fixture/utils"
5556)
5657
5758var (
58- // The differences between the upstream image using Ubuntu, and the downstream one using rhel.
59- image = "" // argocd-operator default
60- imageVersion = "" // argocd-operator default
61- caBundlePath = "/etc/ssl/certs/ca-certificates.crt"
62-
6359 trustedHelmAppSource = & appv1alpha1.ApplicationSource {
6460 RepoURL : "https://stefanprodan.github.io/podinfo" ,
6561 Chart : "podinfo" ,
@@ -74,14 +70,17 @@ var (
7470 Helm : & appv1alpha1.ApplicationSourceHelm {Values : "service:\n type: ClusterIP" },
7571 }
7672
77- k8sClient client.Client
78- ctx context.Context
73+ k8sClient client.Client
74+ ctx context.Context
75+ ns * corev1.Namespace
76+ cleanupNs func ()
77+ image string
78+ imageVersion string
7979
8080 clusterSupportsClusterTrustBundles bool
8181)
8282
8383var _ = Describe ("GitOps Operator Sequential E2E Tests" , func () {
84-
8584 Context ("1-120_repo_server_system_ca_trust" , func () {
8685 BeforeEach (func () {
8786 fixture .EnsureSequentialCleanSlate ()
@@ -91,24 +90,18 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
9190
9291 clusterSupportsClusterTrustBundles = detectClusterTrustBundleSupport (k8sClient , ctx )
9392
94- if fixture .EnvLocalRun () {
95- Skip ("skipping test as LOCAL_RUN env is set." )
96- }
97-
98- if ! fixture .EnvNonOLM () {
99- image = "registry.redhat.io/openshift-gitops-1/argocd-rhel8"
100- imageVersion = "sha256:8a0544c14823492165550d83a6d8ba79dd632b46144d3fdcb543793726111d76"
101- caBundlePath = "/etc/ssl/certs/ca-bundle.crt"
102- }
93+ // The differences between the upstream image using Ubuntu, and the downstream one using rhel.
94+ image , imageVersion = getArgoCDComponentImageAndVersion ()
10395 })
10496
10597 AfterEach (func () {
98+ fixture .OutputDebugOnFail (ns )
99+ cleanupNs ()
106100 purgeCtbs ()
107101 })
108102
109103 It ("ensures that missing Secret aborts startup" , func () {
110- ns , cleanupFunc := fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
111- defer cleanupFunc ()
104+ ns , cleanupNs = fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
112105
113106 By ("creating Argo CD instance with missing Secret" )
114107 argoCD := argoCDSpec (ns , argov1beta1api.ArgoCDRepoSpec {
@@ -130,8 +123,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
130123 Skip ("Cluster does not support ClusterTrustBundles" )
131124 }
132125
133- ns , cleanupFunc := fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
134- defer cleanupFunc ()
126+ ns , cleanupNs = fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
135127
136128 // Create a bundle with 2 CA certs in it. Ubuntu's update-ca-certificates issues a warning, but apparently it works
137129 // It is desirable to test with multiple certs in one bundle because OpenShift permits it
@@ -171,8 +163,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
171163 })
172164
173165 It ("ensures that CMs and Secrets are trusted in repo-server and plugins" , func () {
174- ns , cleanupFunc := fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
175- defer cleanupFunc ()
166+ ns , cleanupNs = fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
176167
177168 cmCert := createCmFromCert (ns , getCACert ("github.com" ))
178169 Expect (k8sClient .Create (ctx , cmCert )).To (Succeed ())
@@ -220,8 +211,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
220211 })
221212
222213 It ("ensures that 0 trusted certs with DropImageCertificates trusts nothing" , func () {
223- ns , cleanupFunc := fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
224- defer cleanupFunc ()
214+ ns , cleanupNs = fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
225215
226216 By ("creating Argo CD instance with empty system trust" )
227217 argoCD := argoCDSpec (ns , argov1beta1api.ArgoCDRepoSpec {
@@ -253,8 +243,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
253243 })
254244
255245 It ("ensures that empty trust keeps image certs in place" , func () {
256- ns , cleanupFunc := fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
257- defer cleanupFunc ()
246+ ns , cleanupNs = fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
258247
259248 By ("creating Argo CD instance with empty system trust" )
260249 argoCD := argoCDSpec (ns , argov1beta1api.ArgoCDRepoSpec {
@@ -268,8 +257,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
268257 })
269258
270259 It ("ensures that Secrets and ConfigMaps get reconciled" , func () {
271- ns , cleanupFunc := fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
272- defer cleanupFunc ()
260+ ns , cleanupNs = fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
273261
274262 By ("creating Argo CD instance with empty system trust, but full of anticipation" )
275263 argoCD := argoCDSpec (ns , argov1beta1api.ArgoCDRepoSpec {
@@ -360,8 +348,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
360348 Skip ("Cluster does not support ClusterTrustBundles" )
361349 }
362350
363- ns , cleanupFunc := fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
364- defer cleanupFunc ()
351+ ns , cleanupNs = fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
365352
366353 combinedCtb := createCtbFromCerts (getCACert ("github.com" ), getCACert ("github.io" ))
367354 _ = k8sClient .Delete (ctx , combinedCtb ) // Exists only in case of previous failures, must be deleted before argo starts!
@@ -413,8 +400,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
413400 Skip ("Cluster does not support ClusterTrustBundles" )
414401 }
415402
416- ns , cleanupFunc := fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
417- defer cleanupFunc ()
403+ ns , cleanupNs = fixture .CreateRandomE2ETestNamespaceWithCleanupFunc ()
418404
419405 // Use random label value not to collide with leftover CTBs fom other tests
420406 labelVal := rand .String (5 )
@@ -804,7 +790,9 @@ func getTrustedCertCount(rsPod *corev1.Pod) int {
804790 command := []string {
805791 "kubectl" , "-n" , rsPod .Namespace , "exec" ,
806792 "-c" , "argocd-repo-server" , rsPod .Name , "--" ,
807- "cat" , caBundlePath ,
793+ "bash" , "-c" ,
794+ // Ubuntu or RHEL location
795+ "cat /etc/ssl/certs/ca-certificates.crt || cat /etc/ssl/certs/ca-bundle.crt" ,
808796 }
809797
810798 var out string
@@ -909,3 +897,22 @@ func purgeCtbs() {
909897 Expect (k8sClient .DeleteAllOf (ctx , & certificatesv1beta1.ClusterTrustBundle {}, expr )).To (Succeed ())
910898 }
911899}
900+
901+ // getArgoCDComponentImageAndVersion ensures rhel based image is used for testing this.
902+ // If this is installed as a full-blown operator, use its images.
903+ // If not, inject bleeding-edge pre-release rhel-based images.
904+ func getArgoCDComponentImageAndVersion () (string , string ) {
905+ csv := clusterserviceversion .Get (ctx , k8sClient )
906+ if csv != nil {
907+ for _ , image := range csv .Spec .RelatedImages {
908+ if image .Name == "argocd_image" {
909+ By ("Detected operator image " + image .Image + ". Using it" )
910+ return "" , ""
911+ }
912+ }
913+ }
914+
915+ defImage := "quay.io/redhat-user-workloads/rh-openshift-gitops-tenant/argocd-rhel9"
916+ By ("Injecting rhel image " + defImage )
917+ return defImage , "main"
918+ }
0 commit comments