Skip to content

Commit 0d1637c

Browse files
committed
fix test suite issue
1 parent 4160f4b commit 0d1637c

File tree

3 files changed

+32
-20
lines changed

3 files changed

+32
-20
lines changed

cmd/gce-pd-csi-driver/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func urlFlag(target **url.URL, name string, usage string) {
352352
}
353353

354354
func setupDataCache(ctx context.Context, nodeName string) error {
355-
klog.V(2).Infof("Seting up data cache for node %s", nodeName)
355+
klog.V(2).Infof("Setting up data cache for node %s", nodeName)
356356
if nodeName != common.TestNode {
357357
cfg, err := rest.InClusterConfig()
358358
if err != nil {

test/e2e/tests/setup_e2e_test.go

+31-18
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"math/rand"
2222
"strconv"
2323
"strings"
24+
"sync"
2425
"testing"
2526
"time"
2627

@@ -78,14 +79,13 @@ func TestE2E(t *testing.T) {
7879

7980
var _ = BeforeSuite(func() {
8081
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))
8386
defer close(tcc)
8487
defer close(hdtcc)
8588

86-
zones := strings.Split(*zones, ",")
87-
// Create 2 instances for each zone as we need 2 instances each zone for certain test cases
88-
8989
rand.Seed(time.Now().UnixNano())
9090

9191
computeService, err = remote.GetComputeClient()
@@ -110,29 +110,37 @@ var _ = BeforeSuite(func() {
110110

111111
klog.Infof("Running in project %v with service account %v", *project, *serviceAccount)
112112

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) {
118119
defer GinkgoRecover()
120+
defer wg.Done()
119121
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)
125123
}
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()
126131
}
127-
for j := 0; j < numberOfInstancesPerZone; j++ {
128-
setupContext(zones, j)
132+
133+
for _, zone := range zones {
134+
setupContext(zone)
129135
}
130136

131137
for i := 0; i < len(zones)*numberOfInstancesPerZone; i++ {
132138
tc := <-tcc
133139
testContexts = append(testContexts, tc)
134140
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
136144
hyperdiskTestContexts = append(hyperdiskTestContexts, tc)
137145
klog.Infof("Added TestContext for node %s", tc.Instance.GetName())
138146
}
@@ -188,6 +196,11 @@ func NewTestContext(zone, minCpuPlatform, machineType string, instanceNumber str
188196
ComputeService: computeService,
189197
LocalSSDCount: localSSDCount,
190198
}
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+
}
191204
i, err := remote.SetupInstance(instanceConfig)
192205
if err != nil {
193206
klog.Fatalf("Failed to setup instance %v: %v", nodeID, err)

test/remote/instance.go

-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ func (i *InstanceInfo) CreateOrGetInstance(localSSDCount int) error {
148148
EnableConfidentialCompute: true,
149149
}
150150
}
151-
klog.Infof("=======Adding LocalSSD %v=============", localSSDCount)
152151

153152
localSSDConfig := &compute.AttachedDisk{
154153
Type: "SCRATCH",

0 commit comments

Comments
 (0)