Skip to content

Commit b0b1af8

Browse files
Merge pull request #359 from lunarwhite/expand-variants
CM-159, CM-165: Support e2es to be run in Proxy and Manual OIDC envs
2 parents 16d3157 + 4e4f8dd commit b0b1af8

8 files changed

Lines changed: 72 additions & 13 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ COMMIT ?= $(shell git rev-parse HEAD)
104104
SHORTCOMMIT ?= $(shell git rev-parse --short HEAD)
105105
GOBUILD_VERSION_ARGS = -ldflags "-X $(PACKAGE)/pkg/version.SHORTCOMMIT=$(SHORTCOMMIT) -X $(PACKAGE)/pkg/version.COMMIT=$(COMMIT)"
106106

107-
E2E_TIMEOUT ?= 1h
107+
E2E_TIMEOUT ?= 2h
108108
# E2E_GINKGO_LABEL_FILTER is ginkgo label query for selecting tests. See
109109
# https://onsi.github.io/ginkgo/#spec-labels. The default is to run tests on the AWS platform.
110110
E2E_GINKGO_LABEL_FILTER ?= "Platform: isSubsetOf {AWS} && CredentialsMode: isSubsetOf {Mint}"

test/e2e/config_template.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ type IstioCSRGRPCurlJobConfig struct {
2727
IstioCSRStatus v1alpha1.IstioCSRStatus
2828
ClusterID string
2929
JobName string
30+
HTTPProxy string
31+
HTTPSProxy string
32+
NoProxy string
3033
}
3134

3235
// ServiceMonitorConfig customizes fields in the ServiceMonitor spec

test/e2e/issuer_acme_dns01_test.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,7 @@ var _ = Describe("ACME Issuer DNS01 solver", Ordered, func() {
493493

494494
By("calculating parent domain from base domain")
495495
parts := strings.Split(baseDomain, ".")
496-
if len(parts) <= 1 {
497-
Skip("Cannot derive parent domain from base domain: " + baseDomain)
498-
}
496+
Expect(len(parts)).To(BeNumerically(">", 1), "cannot derive parent domain from base domain")
499497
parentDomain := strings.Join(parts[1:], ".")
500498

501499
By("getting Route53 hosted zone ID from DNS object")
@@ -598,7 +596,16 @@ var _ = Describe("ACME Issuer DNS01 solver", Ordered, func() {
598596
isSTS, err := isSTSCluster(ctx, oseOperatorClient, configClient)
599597
Expect(err).NotTo(HaveOccurred())
600598
if !isSTS {
601-
Skip("Tests requires AWS Security Token Service enabled")
599+
Skip("Test requires AWS Security Token Service enabled")
600+
}
601+
602+
By("setting up AWS authentication environment variable from credentials file")
603+
if os.Getenv("OPENSHIFT_CI") == "true" {
604+
clusterProfileDir := os.Getenv("CLUSTER_PROFILE_DIR")
605+
Expect(clusterProfileDir).NotTo(BeEmpty(), "CLUSTER_PROFILE_DIR should exist when running in OpenShift CI")
606+
os.Setenv("AWS_SHARED_CREDENTIALS_FILE", filepath.Join(clusterProfileDir, ".awscred"))
607+
} else {
608+
Expect(os.Getenv("AWS_SHARED_CREDENTIALS_FILE")).NotTo(BeEmpty(), "AWS_SHARED_CREDENTIALS_FILE must be set when running locally")
602609
}
603610

604611
// Get AWS region and determinate partition
@@ -948,7 +955,16 @@ var _ = Describe("ACME Issuer DNS01 solver", Ordered, func() {
948955
isSTS, err := isSTSCluster(ctx, oseOperatorClient, configClient)
949956
Expect(err).NotTo(HaveOccurred())
950957
if !isSTS {
951-
Skip("Cluster is not workload identity enabled, skipping test")
958+
Skip("Test requires GCP Workload Identity enabled")
959+
}
960+
961+
By("setting up GCP authentication environment variable from credentials file")
962+
if os.Getenv("OPENSHIFT_CI") == "true" {
963+
clusterProfileDir := os.Getenv("CLUSTER_PROFILE_DIR")
964+
Expect(clusterProfileDir).NotTo(BeEmpty(), "CLUSTER_PROFILE_DIR should exist when running in OpenShift CI")
965+
os.Setenv("GOOGLE_APPLICATION_CREDENTIALS", filepath.Join(clusterProfileDir, "gce.json"))
966+
} else {
967+
Expect(os.Getenv("GOOGLE_APPLICATION_CREDENTIALS")).NotTo(BeEmpty(), "GOOGLE_APPLICATION_CREDENTIALS must be set when running locally")
952968
}
953969

954970
By("creating GCP IAM and CloudResourceManager clients")
@@ -1131,7 +1147,7 @@ var _ = Describe("ACME Issuer DNS01 solver", Ordered, func() {
11311147
Fail("cisCRN is required for IBM Cloud platform")
11321148
}
11331149
} else {
1134-
Skip("skipping as the cluster does not use IBM Cloud CIS")
1150+
Skip("Test requires IBM Cloud CIS enabled")
11351151
}
11361152

11371153
By("creating ClusterIssuer with IBM Cloud CIS webhook solver")

test/e2e/istio_csr_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ import (
2626
. "github.com/onsi/gomega"
2727
)
2828

29-
// backOffLimit is the max retries for the Job
30-
const backOffLimit int32 = 10
31-
3229
// istioCSRProtoURL links to proto for istio-csr API spec
3330
const istioCSRProtoURL = "https://raw.githubusercontent.com/istio/api/v1.24.1/security/v1alpha1/ca.proto"
3431

@@ -44,6 +41,7 @@ type IstioCSRConfig struct {
4441
var _ = Describe("Istio-CSR", Ordered, Label("Feature:IstioCSR"), func() {
4542
ctx := context.TODO()
4643
var clientset *kubernetes.Clientset
44+
var httpProxy, httpsProxy, noProxy string
4745

4846
generateCSR := func() string {
4947
csrTemplate := &x509.CertificateRequest{
@@ -87,6 +85,10 @@ var _ = Describe("Istio-CSR", Ordered, Label("Feature:IstioCSR"), func() {
8785
"OPERATOR_LOG_LEVEL": "5",
8886
})
8987
Expect(err).NotTo(HaveOccurred())
88+
89+
By("getting cluster proxy configuration")
90+
httpProxy, httpsProxy, noProxy, err = getClusterProxyConfig(ctx, configClient)
91+
Expect(err).Should(BeNil(), "failed to get cluster proxy config")
9092
})
9193

9294
var ns *corev1.Namespace
@@ -186,6 +188,9 @@ var _ = Describe("Istio-CSR", Ordered, Label("Feature:IstioCSR"), func() {
186188
IstioCSRGRPCurlJobConfig{
187189
CertificateSigningRequest: csr,
188190
IstioCSRStatus: istioCSRStatus,
191+
HTTPProxy: httpProxy,
192+
HTTPSProxy: httpsProxy,
193+
NoProxy: noProxy,
189194
},
190195
), filepath.Join("testdata", "istio", "grpcurl_job.yaml"), ns.Name)
191196
DeferCleanup(func() {
@@ -263,6 +268,9 @@ var _ = Describe("Istio-CSR", Ordered, Label("Feature:IstioCSR"), func() {
263268
IstioCSRStatus: istioCSRStatus,
264269
ClusterID: clusterName, // matches the IstioCSR resource
265270
JobName: grpcAppName,
271+
HTTPProxy: httpProxy,
272+
HTTPSProxy: httpsProxy,
273+
NoProxy: noProxy,
266274
},
267275
), filepath.Join("testdata", "istio", "grpcurl_job_with_cluster_id.yaml"), ns.Name)
268276
DeferCleanup(func() {
@@ -333,6 +341,9 @@ var _ = Describe("Istio-CSR", Ordered, Label("Feature:IstioCSR"), func() {
333341
IstioCSRStatus: istioCSRStatus,
334342
ClusterID: "wrong-cluster-id", // doesn't match the IstioCSR resource
335343
JobName: grpcAppName,
344+
HTTPProxy: httpProxy,
345+
HTTPSProxy: httpsProxy,
346+
NoProxy: noProxy,
336347
},
337348
), filepath.Join("testdata", "istio", "grpcurl_job_with_cluster_id.yaml"), ns.Name)
338349
DeferCleanup(func() {

test/e2e/suite_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"path/filepath"
1111
"strings"
1212
"testing"
13+
"time"
1314

1415
. "github.com/onsi/ginkgo/v2"
1516
. "github.com/onsi/gomega"
@@ -93,6 +94,11 @@ func TestAll(t *testing.T) {
9394

9495
suiteConfig, reportConfig := GinkgoConfiguration()
9596

97+
suiteConfig.Timeout = 120 * time.Minute // Set Ginkgo suite-level timeout
98+
suiteConfig.FailFast = false // Continue after first failure to see all issues
99+
suiteConfig.FlakeAttempts = 0 // Retry on flaky tests (helpful when deflaking tests)
100+
suiteConfig.MustPassRepeatedly = 1 // Must pass repeatedly times (helpful when deflaking tests)
101+
96102
testDir := getTestDir()
97103
reportConfig.JSONReport = filepath.Join(testDir, "report.json")
98104
reportConfig.JUnitReport = filepath.Join(testDir, "junit.xml")
@@ -146,6 +152,6 @@ var _ = BeforeSuite(func() {
146152
Expect(err).NotTo(HaveOccurred())
147153

148154
By("setting defaultNetworkPolicy to true")
149-
err = resetCertManagerNetworkPolicyState(context.TODO(), certmanageroperatorclient, loader)
155+
err = resetCertManagerNetworkPolicyState(context.TODO(), certmanageroperatorclient)
150156
Expect(err).NotTo(HaveOccurred())
151157
})

test/e2e/testdata/istio/grpcurl_job.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ spec:
3434
value: /tmp/go-cache
3535
- name: GOPATH
3636
value: /tmp/go
37+
- name: HTTP_PROXY
38+
value: {{.HTTPProxy}}
39+
- name: HTTPS_PROXY
40+
value: {{.HTTPSProxy}}
41+
- name: NO_PROXY
42+
value: {{.NoProxy}}
3743
image: registry.redhat.io/rhel9/go-toolset
3844
name: grpcurl
3945
volumeMounts:

test/e2e/testdata/istio/grpcurl_job_with_cluster_id.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ spec:
3535
value: /tmp/go-cache
3636
- name: GOPATH
3737
value: /tmp/go
38+
- name: HTTP_PROXY
39+
value: {{.HTTPProxy}}
40+
- name: HTTPS_PROXY
41+
value: {{.HTTPSProxy}}
42+
- name: NO_PROXY
43+
value: {{.NoProxy}}
3844
image: registry.redhat.io/rhel9/go-toolset
3945
name: grpcurl
4046
volumeMounts:

test/e2e/utils_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ func verifyCertificateRenewed(ctx context.Context, secretName, namespace string,
850850
}
851851

852852
// checks if expiry time was updated
853-
if *initExpiryTime == cert.NotAfter {
853+
if (*initExpiryTime).Equal(cert.NotAfter) {
854854
return false, nil
855855
}
856856

@@ -1124,7 +1124,7 @@ func VerifyContainerResources(pod corev1.Pod, containerName string, expectedReso
11241124
}
11251125

11261126
// resetCertManagerNetworkPolicyState resets the CertManager to have defaultNetworkPolicy="true"
1127-
func resetCertManagerNetworkPolicyState(ctx context.Context, client *certmanoperatorclient.Clientset, loader library.DynamicResourceLoader) error {
1127+
func resetCertManagerNetworkPolicyState(ctx context.Context, client *certmanoperatorclient.Clientset) error {
11281128
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
11291129
var operatorState *v1alpha1.CertManager
11301130
err := wait.PollUntilContextTimeout(context.TODO(), slowPollInterval, highTimeout, true, func(context.Context) (bool, error) {
@@ -1770,3 +1770,14 @@ func getSAToken(ctx context.Context, saName, namespace string) (string, error) {
17701770

17711771
return result.Status.Token, nil
17721772
}
1773+
1774+
// getClusterProxyConfig retrieves the cluster-wide proxy configuration
1775+
// Returns httpProxy, httpsProxy, noProxy values from the cluster Proxy resource
1776+
func getClusterProxyConfig(ctx context.Context, client configv1.ConfigV1Interface) (httpProxy, httpsProxy, noProxy string, err error) {
1777+
proxy, err := client.Proxies().Get(ctx, "cluster", metav1.GetOptions{})
1778+
if err != nil {
1779+
return "", "", "", fmt.Errorf("failed to get cluster proxy config: %w", err)
1780+
}
1781+
1782+
return proxy.Status.HTTPProxy, proxy.Status.HTTPSProxy, proxy.Status.NoProxy, nil
1783+
}

0 commit comments

Comments
 (0)