Skip to content

Commit e90ebfa

Browse files
committed
(test) parallelize e2e pre-requisites
1 parent bbec543 commit e90ebfa

File tree

1 file changed

+75
-38
lines changed

1 file changed

+75
-38
lines changed

tests/e2e/test_install.go

Lines changed: 75 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package e2e
1717

1818
import (
19+
"sync"
20+
1921
"github.com/gruntwork-io/terratest/modules/k8s"
2022
"github.com/onsi/ginkgo/v2"
2123
"github.com/onsi/gomega"
@@ -31,57 +33,92 @@ func testInstall() bool {
3133
gomega.Expect(err).NotTo(gomega.HaveOccurred())
3234
})
3335

34-
ginkgo.When("Installing cert-manager", func() {
35-
ginkgo.It("Installing cert-manager Helm chart", func() {
36-
err = certManagerHelmDescriptor.installHelmChart(kubectlOptions)
37-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
38-
})
39-
})
36+
ginkgo.It("Installing infrastructure components in parallel", func() {
37+
var wg sync.WaitGroup
38+
errChan := make(chan error, 3)
4039

41-
ginkgo.When("Installing Contour Ingress Controller", func() {
42-
ginkgo.It("Installing contour Helm chart", func() {
43-
err = contourIngressControllerHelmDescriptor.installHelmChart(kubectlOptions)
44-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
45-
})
46-
})
40+
// Install cert-manager, Contour, and Envoy Gateway in parallel
41+
wg.Add(3)
42+
43+
go func() {
44+
defer wg.Done()
45+
ginkgo.By("Installing cert-manager Helm chart")
46+
if installErr := certManagerHelmDescriptor.installHelmChart(kubectlOptions); installErr != nil {
47+
errChan <- installErr
48+
}
49+
}()
4750

48-
ginkgo.When("Installing Envoy Gateway", func() {
49-
ginkgo.It("Installing Envoy Gateway Helm chart", func() {
50-
err = envoyGatewayHelmDescriptor.installHelmChart(kubectlOptions)
51-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
52-
})
51+
go func() {
52+
defer wg.Done()
53+
ginkgo.By("Installing Contour Helm chart")
54+
if installErr := contourIngressControllerHelmDescriptor.installHelmChart(kubectlOptions); installErr != nil {
55+
errChan <- installErr
56+
}
57+
}()
58+
59+
go func() {
60+
defer wg.Done()
61+
ginkgo.By("Installing Envoy Gateway Helm chart")
62+
if installErr := envoyGatewayHelmDescriptor.installHelmChart(kubectlOptions); installErr != nil {
63+
errChan <- installErr
64+
}
65+
}()
66+
67+
wg.Wait()
68+
close(errChan)
69+
70+
// Check for errors
71+
for installErr := range errChan {
72+
gomega.Expect(installErr).NotTo(gomega.HaveOccurred())
73+
}
74+
})
5375

54-
ginkgo.It("Creating Envoy Gateway GatewayClass", func() {
55-
gatewayClassManifest := `apiVersion: gateway.networking.k8s.io/v1
76+
ginkgo.It("Creating Envoy Gateway GatewayClass", func() {
77+
gatewayClassManifest := `apiVersion: gateway.networking.k8s.io/v1
5678
kind: GatewayClass
5779
metadata:
5880
name: eg
5981
spec:
6082
controllerName: gateway.envoyproxy.io/gatewayclass-controller`
61-
err = applyK8sResourceManifestFromString(kubectlOptions, gatewayClassManifest)
62-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
63-
})
83+
err = applyK8sResourceManifestFromString(kubectlOptions, gatewayClassManifest)
84+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
6485
})
6586

66-
ginkgo.When("Installing zookeeper-operator", func() {
67-
ginkgo.It("Installing zookeeper-operator Helm chart", func() {
68-
err = zookeeperOperatorHelmDescriptor.installHelmChart(kubectlOptions)
69-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
70-
})
71-
})
87+
ginkgo.It("Installing dependency operators in parallel", func() {
88+
var wg sync.WaitGroup
89+
errChan := make(chan error, 2)
90+
91+
// Install zookeeper-operator and prometheus-operator in parallel
92+
wg.Add(2)
93+
94+
go func() {
95+
defer wg.Done()
96+
ginkgo.By("Installing zookeeper-operator Helm chart")
97+
if installErr := zookeeperOperatorHelmDescriptor.installHelmChart(kubectlOptions); installErr != nil {
98+
errChan <- installErr
99+
}
100+
}()
72101

73-
ginkgo.When("Installing prometheus-operator", func() {
74-
ginkgo.It("Installing prometheus-operator Helm chart", func() {
75-
err = prometheusOperatorHelmDescriptor.installHelmChart(kubectlOptions)
76-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
77-
})
102+
go func() {
103+
defer wg.Done()
104+
ginkgo.By("Installing prometheus-operator Helm chart")
105+
if installErr := prometheusOperatorHelmDescriptor.installHelmChart(kubectlOptions); installErr != nil {
106+
errChan <- installErr
107+
}
108+
}()
109+
110+
wg.Wait()
111+
close(errChan)
112+
113+
// Check for errors
114+
for installErr := range errChan {
115+
gomega.Expect(installErr).NotTo(gomega.HaveOccurred())
116+
}
78117
})
79118

80-
ginkgo.When("Installing Koperator", func() {
81-
ginkgo.It("Installing Koperator Helm chart", func() {
82-
err = koperatorLocalHelmDescriptor.installHelmChart(kubectlOptions)
83-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
84-
})
119+
ginkgo.It("Installing Koperator Helm chart", func() {
120+
err = koperatorLocalHelmDescriptor.installHelmChart(kubectlOptions)
121+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
85122
})
86123
})
87124
}

0 commit comments

Comments
 (0)