@@ -30,16 +30,14 @@ import (
30
30
31
31
var (
32
32
// Optional Environment Variables:
33
- // - PROMETHEUS_INSTALL_SKIP=true: Skips Prometheus Operator installation during test setup.
34
33
// - CERT_MANAGER_INSTALL_SKIP=true: Skips CertManager installation during test setup.
35
- // These variables are useful if Prometheus or CertManager is already installed, avoiding
34
+ // These variables are useful if CertManager is already installed, avoiding
36
35
// re-installation and conflicts.
37
- skipPrometheusInstall = os .Getenv ("PROMETHEUS_INSTALL_SKIP" ) == "true"
38
36
skipCertManagerInstall = os .Getenv ("CERT_MANAGER_INSTALL_SKIP" ) == "true"
39
- // isPrometheusOperatorAlreadyInstalled will be set true when prometheus CRDs be found on the cluster
40
- isPrometheusOperatorAlreadyInstalled = false
41
37
// isCertManagerAlreadyInstalled will be set true when CertManager CRDs be found on the cluster
42
38
isCertManagerAlreadyInstalled = false
39
+ // isPrometheusOperatorAlreadyInstalled will be set true when prometheus CRDs be found on the cluster
40
+ isPrometheusOperatorAlreadyInstalled = false
43
41
44
42
// projectImage is the name of the image which will be build and loaded
45
43
// with the code source changes to be tested.
49
47
// TestE2E runs the end-to-end (e2e) test suite for the project. These tests execute in an isolated,
50
48
// temporary environment to validate project changes with the the purposed to be used in CI jobs.
51
49
// The default setup requires Kind, builds/loads the Manager Docker image locally, and installs
52
- // CertManager and Prometheus .
50
+ // CertManager.
53
51
func TestE2E (t * testing.T ) {
54
52
RegisterFailHandler (Fail )
55
53
_ , _ = fmt .Fprintf (GinkgoWriter , "Starting project integration test suite\n " )
@@ -72,19 +70,21 @@ var _ = BeforeSuite(func() {
72
70
ExpectWithOffset (1 , err ).NotTo (HaveOccurred (), "Failed to load the manager(Operator) image into Kind" )
73
71
74
72
// The tests-e2e are intended to run on a temporary cluster that is created and destroyed for testing.
75
- // To prevent errors when tests run in environments with Prometheus or CertManager already installed,
76
- // we check for their presence before execution.
77
- // Setup Prometheus and CertManager before the suite if not skipped and if not already installed
78
- if ! skipPrometheusInstall {
79
- By ("checking if prometheus is installed already" )
80
- isPrometheusOperatorAlreadyInstalled = utils .IsPrometheusCRDsInstalled ()
81
- if ! isPrometheusOperatorAlreadyInstalled {
82
- _ , _ = fmt .Fprintf (GinkgoWriter , "Installing Prometheus Operator...\n " )
83
- Expect (utils .InstallPrometheusOperator ()).To (Succeed (), "Failed to install Prometheus Operator" )
84
- } else {
85
- _ , _ = fmt .Fprintf (GinkgoWriter , "WARNING: Prometheus Operator is already installed. Skipping installation...\n " )
86
- }
73
+ // To prevent errors when tests run in environments with Prometheus already installed,
74
+ // we check for it's presence before execution.
75
+ // Setup Prometheus before the suite if not already installed
76
+ By ("checking if prometheus is installed already" )
77
+ isPrometheusOperatorAlreadyInstalled = utils .IsPrometheusCRDsInstalled ()
78
+ if ! isPrometheusOperatorAlreadyInstalled {
79
+ _ , _ = fmt .Fprintf (GinkgoWriter , "Installing Prometheus Operator...\n " )
80
+ Expect (utils .InstallPrometheusOperator ()).To (Succeed (), "Failed to install Prometheus Operator" )
81
+ } else {
82
+ _ , _ = fmt .Fprintf (GinkgoWriter , "WARNING: Prometheus Operator is already installed. Skipping installation...\n " )
87
83
}
84
+
85
+ // To prevent errors when tests run in environments with CertManager already installed,
86
+ // we check for its presence before execution.
87
+ // Setup CertManager before the suite if not skipped and if not already installed
88
88
if ! skipCertManagerInstall {
89
89
By ("checking if cert manager is installed already" )
90
90
isCertManagerAlreadyInstalled = utils .IsCertManagerCRDsInstalled ()
@@ -98,11 +98,13 @@ var _ = BeforeSuite(func() {
98
98
})
99
99
100
100
var _ = AfterSuite (func () {
101
- // Teardown Prometheus and CertManager after the suite if not skipped and if they were not already installed
102
- if ! skipPrometheusInstall && ! isPrometheusOperatorAlreadyInstalled {
101
+ // Teardown Prometheus after the suite if it was not already installed
102
+ if ! isPrometheusOperatorAlreadyInstalled {
103
103
_ , _ = fmt .Fprintf (GinkgoWriter , "Uninstalling Prometheus Operator...\n " )
104
104
utils .UninstallPrometheusOperator ()
105
105
}
106
+
107
+ // Teardown CertManager after the suite if not skipped and if it was not already installed
106
108
if ! skipCertManagerInstall && ! isCertManagerAlreadyInstalled {
107
109
_ , _ = fmt .Fprintf (GinkgoWriter , "Uninstalling CertManager...\n " )
108
110
utils .UninstallCertManager ()
0 commit comments