Skip to content

Commit 6dd5ca7

Browse files
committed
Solved the mystery of the missing PD, Accidentally getting 2 different
projects for the 2 instances!!
1 parent 172c91c commit 6dd5ca7

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

test/e2e/tests/multi_zone_e2e_test.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
csi "github.com/container-storage-interface/spec/lib/go/csi/v0"
2222
. "github.com/onsi/ginkgo"
2323
. "github.com/onsi/gomega"
24+
"k8s.io/apimachinery/pkg/util/sets"
2425
"k8s.io/apimachinery/pkg/util/uuid"
2526
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
2627
gce "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/compute"
@@ -117,13 +118,20 @@ var _ = Describe("GCE PD CSI Driver Multi-Zone", func() {
117118
})
118119
Expect(err).To(BeNil(), "CreateVolume failed with error: %v", err)
119120

120-
// TODO: Validate Disk Created
121+
// Validate Disk Created
121122
cloudDisk, err := betaComputeService.RegionDisks.Get(p, region, volName).Do()
122123
Expect(err).To(BeNil(), "Could not get disk from cloud directly")
123124
Expect(cloudDisk.Type).To(ContainSubstring(standardDiskType))
124125
Expect(cloudDisk.Status).To(Equal(readyState))
125126
Expect(cloudDisk.SizeGb).To(Equal(defaultSizeGb))
126127
Expect(cloudDisk.Name).To(Equal(volName))
128+
Expect(len(cloudDisk.ReplicaZones)).To(Equal(2))
129+
zonesSet := sets.NewString(zones...)
130+
for _, replicaZone := range cloudDisk.ReplicaZones {
131+
tokens := strings.Split(replicaZone, "/")
132+
actualZone := tokens[len(tokens)-1]
133+
Expect(zonesSet.Has(actualZone)).To(BeTrue(), "Expected zone %v to exist in zone set %v", actualZone, zones)
134+
}
127135

128136
defer func() {
129137
// Delete Disk
@@ -153,6 +161,7 @@ var _ = Describe("GCE PD CSI Driver Multi-Zone", func() {
153161
func testAttachWriteReadDetach(volId string, volName string, instance *remote.InstanceInfo, client *remote.CsiClient, readOnly bool) {
154162
var err error
155163

164+
Logf("Starting testAttachWriteReadDetach with volume %v node %v with readonly %v", volId, instance.GetNodeID(), readOnly)
156165
// Attach Disk
157166
err = client.ControllerPublishVolume(volId, instance.GetNodeID())
158167
Expect(err).To(BeNil(), "ControllerPublishVolume failed with error for disk %v on node %v", volId, instance.GetNodeID())
@@ -212,4 +221,5 @@ func testAttachWriteReadDetach(volId string, volName string, instance *remote.In
212221
err = client.NodeUnpublishVolume(volId, secondPublishDir)
213222
Expect(err).To(BeNil(), "NodeUnpublishVolume failed with error")
214223

224+
Logf("Completed testAttachWriteReadDetach with volume %v node %v", volId, instance.GetNodeID())
215225
}

test/e2e/tests/setup_e2e_test.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,17 @@ var _ = BeforeSuite(func() {
5858
betaComputeService, err = remote.GetBetaComputeClient()
5959
Expect(err).To(BeNil())
6060

61-
for _, zone := range zones {
62-
nodeID := fmt.Sprintf("gce-pd-csi-e2e-%s", zone)
61+
if *runInProw {
62+
*project, *serviceAccount = testutils.SetupProwConfig()
63+
}
6364

64-
if *runInProw {
65-
*project, *serviceAccount = testutils.SetupProwConfig()
66-
}
65+
Expect(*project).ToNot(BeEmpty(), "Project should not be empty")
66+
Expect(*serviceAccount).ToNot(BeEmpty(), "Service account should not be empty")
6767

68-
Expect(*project).ToNot(BeEmpty(), "Project should not be empty")
69-
Expect(*serviceAccount).ToNot(BeEmpty(), "Service account should not be empty")
68+
Logf("Running in project %v with service account %v\n\n", *project, *serviceAccount)
69+
70+
for _, zone := range zones {
71+
nodeID := fmt.Sprintf("gce-pd-csi-e2e-%s", zone)
7072

7173
i, err := remote.SetupInstance(*project, zone, nodeID, *serviceAccount, computeService)
7274
Expect(err).To(BeNil())

test/e2e/tests/single_zone_e2e_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,5 @@ var _ = Describe("GCE PD CSI Driver", func() {
220220
})
221221

222222
func Logf(format string, args ...interface{}) {
223-
fmt.Fprint(GinkgoWriter, args...)
223+
fmt.Fprintf(GinkgoWriter, format, args...)
224224
}

0 commit comments

Comments
 (0)