@@ -21,6 +21,7 @@ import (
21
21
"math/rand"
22
22
"strconv"
23
23
"strings"
24
+ "sync"
24
25
"testing"
25
26
"time"
26
27
@@ -78,14 +79,13 @@ func TestE2E(t *testing.T) {
78
79
79
80
var _ = BeforeSuite (func () {
80
81
var err error
81
- tcc := make (chan * remote.TestContext )
82
- hdtcc := make (chan * remote.TestContext )
82
+ numberOfInstancesPerZone := 2
83
+ zones := strings .Split (* zones , "," )
84
+ tcc := make (chan * remote.TestContext , len (zones )* numberOfInstancesPerZone )
85
+ hdtcc := make (chan * remote.TestContext , len (zones ))
83
86
defer close (tcc )
84
87
defer close (hdtcc )
85
88
86
- zones := strings .Split (* zones , "," )
87
- // Create 2 instances for each zone as we need 2 instances each zone for certain test cases
88
-
89
89
rand .Seed (time .Now ().UnixNano ())
90
90
91
91
computeService , err = remote .GetComputeClient ()
@@ -110,29 +110,37 @@ var _ = BeforeSuite(func() {
110
110
111
111
klog .Infof ("Running in project %v with service account %v" , * project , * serviceAccount )
112
112
113
- numberOfInstancesPerZone := 2
114
-
115
- setupContext := func (zones []string , randInt int ) {
116
- for _ , zone := range zones {
117
- go func (curZone string ) {
113
+ setupContext := func (zone string ) {
114
+ var wg sync.WaitGroup
115
+ // Create 2 instances for each zone as we need 2 instances each zone for certain test cases
116
+ for j := 0 ; j < numberOfInstancesPerZone ; j ++ {
117
+ wg .Add (1 )
118
+ go func (curZone string , randInt int ) {
118
119
defer GinkgoRecover ()
120
+ defer wg .Done ()
119
121
tcc <- NewDefaultTestContext (curZone , strconv .Itoa (randInt ))
120
- }(zone )
121
- go func (curZone string ) {
122
- defer GinkgoRecover ()
123
- hdtcc <- NewTestContext (curZone , * hdMinCpuPlatform , * hdMachineType , strconv .Itoa (randInt ))
124
- }(zone )
122
+ }(zone , j )
125
123
}
124
+ go func (curZone string ) {
125
+ wg .Add (1 )
126
+ defer GinkgoRecover ()
127
+ defer wg .Done ()
128
+ hdtcc <- NewTestContext (curZone , * hdMinCpuPlatform , * hdMachineType , "0" )
129
+ }(zone )
130
+ wg .Wait ()
126
131
}
127
- for j := 0 ; j < numberOfInstancesPerZone ; j ++ {
128
- setupContext (zones , j )
132
+
133
+ for _ , zone := range zones {
134
+ setupContext (zone )
129
135
}
130
136
131
137
for i := 0 ; i < len (zones )* numberOfInstancesPerZone ; i ++ {
132
138
tc := <- tcc
133
139
testContexts = append (testContexts , tc )
134
140
klog .Infof ("Added TestContext for node %s" , tc .Instance .GetName ())
135
- tc = <- hdtcc
141
+ }
142
+ for i := 0 ; i < len (zones ); i ++ {
143
+ tc := <- hdtcc
136
144
hyperdiskTestContexts = append (hyperdiskTestContexts , tc )
137
145
klog .Infof ("Added TestContext for node %s" , tc .Instance .GetName ())
138
146
}
@@ -188,6 +196,11 @@ func NewTestContext(zone, minCpuPlatform, machineType string, instanceNumber str
188
196
ComputeService : computeService ,
189
197
LocalSSDCount : localSSDCount ,
190
198
}
199
+
200
+ if machineType == * hdMachineType {
201
+ // Machine type is defaulted to c3-standard-2 which doesn't support LSSD and we don't need LSSD for HdHA test context
202
+ instanceConfig .LocalSSDCount = 0
203
+ }
191
204
i , err := remote .SetupInstance (instanceConfig )
192
205
if err != nil {
193
206
klog .Fatalf ("Failed to setup instance %v: %v" , nodeID , err )
0 commit comments