@@ -31,18 +31,11 @@ import (
31
31
32
32
var _ = Describe ("GCE PD CSI Driver Multi-Zone" , func () {
33
33
BeforeEach (func () {
34
- Expect (len (testInstances )).To (BeNumerically (">" , 1 ))
34
+ Expect (len (testContexts )).To (BeNumerically (">" , 1 ))
35
35
})
36
36
37
37
It ("Should get reasonable topology from nodes with NodeGetInfo" , func () {
38
- for _ , instance := range testInstances {
39
- testContext , err := testutils .GCEClientAndDriverSetup (instance )
40
- Expect (err ).To (BeNil (), "Set up new Driver and Client failed with error" )
41
- defer func () {
42
- err := remote .TeardownDriverAndClient (testContext )
43
- Expect (err ).To (BeNil (), "Teardown Driver and Client failed with error" )
44
- }()
45
-
38
+ for _ , testContext := range testContexts {
46
39
resp , err := testContext .Client .NodeGetInfo ()
47
40
Expect (err ).To (BeNil ())
48
41
@@ -65,24 +58,17 @@ var _ = Describe("GCE PD CSI Driver Multi-Zone", func() {
65
58
It ("Should successfully run through entire lifecycle of an RePD volume on instances in 2 zones" , func () {
66
59
// Create new driver and client
67
60
68
- Expect (testInstances ).NotTo (BeEmpty ())
61
+ Expect (testContexts ).NotTo (BeEmpty ())
69
62
70
63
zoneToContext := map [string ]* remote.TestContext {}
71
64
zones := []string {}
72
65
73
- for _ , i := range testInstances {
74
- _ , z , _ := i .GetIdentity ()
66
+ for _ , tc := range testContexts {
67
+ _ , z , _ := tc . Instance .GetIdentity ()
75
68
// Zone hasn't been seen before
76
69
if _ , ok := zoneToContext [z ]; ! ok {
77
- c , err := testutils .GCEClientAndDriverSetup (i )
78
- Expect (err ).To (BeNil (), "Set up new Driver and Client failed with error" )
79
- zoneToContext [z ] = c
70
+ zoneToContext [z ] = tc
80
71
zones = append (zones , z )
81
-
82
- defer func () {
83
- err := remote .TeardownDriverAndClient (c )
84
- Expect (err ).To (BeNil (), "Teardown Driver and Client failed with error" )
85
- }()
86
72
}
87
73
if len (zoneToContext ) == 2 {
88
74
break
@@ -102,7 +88,7 @@ var _ = Describe("GCE PD CSI Driver Multi-Zone", func() {
102
88
103
89
// Create Disk
104
90
volName := testNamePrefix + string (uuid .NewUUID ())
105
- volId , err := controllerClient .CreateVolume (volName , map [string ]string {
91
+ volID , err := controllerClient .CreateVolume (volName , map [string ]string {
106
92
common .ParameterKeyReplicationType : "regional-pd" ,
107
93
}, defaultSizeGb , & csi.TopologyRequirement {
108
94
Requisite : []* csi.Topology {
@@ -133,7 +119,7 @@ var _ = Describe("GCE PD CSI Driver Multi-Zone", func() {
133
119
134
120
defer func () {
135
121
// Delete Disk
136
- controllerClient .DeleteVolume (volId )
122
+ controllerClient .DeleteVolume (volID )
137
123
Expect (err ).To (BeNil (), "DeleteVolume failed" )
138
124
139
125
// Validate Disk Deleted
@@ -148,45 +134,45 @@ var _ = Describe("GCE PD CSI Driver Multi-Zone", func() {
148
134
if i >= 1 {
149
135
readOnly = true
150
136
}
151
- testAttachWriteReadDetach (volId , volName , testContext .Instance , testContext .Client , readOnly )
137
+ testAttachWriteReadDetach (volID , volName , testContext .Instance , testContext .Client , readOnly )
152
138
i = i + 1
153
139
}
154
140
155
141
})
156
142
157
143
})
158
144
159
- func testAttachWriteReadDetach (volId string , volName string , instance * remote.InstanceInfo , client * remote.CsiClient , readOnly bool ) {
145
+ func testAttachWriteReadDetach (volID string , volName string , instance * remote.InstanceInfo , client * remote.CsiClient , readOnly bool ) {
160
146
var err error
161
147
162
- Logf ("Starting testAttachWriteReadDetach with volume %v node %v with readonly %v\n " , volId , instance .GetNodeID (), readOnly )
148
+ Logf ("Starting testAttachWriteReadDetach with volume %v node %v with readonly %v\n " , volID , instance .GetNodeID (), readOnly )
163
149
// Attach Disk
164
- err = client .ControllerPublishVolume (volId , instance .GetNodeID ())
165
- Expect (err ).To (BeNil (), "ControllerPublishVolume failed with error for disk %v on node %v" , volId , instance .GetNodeID ())
150
+ err = client .ControllerPublishVolume (volID , instance .GetNodeID ())
151
+ Expect (err ).To (BeNil (), "ControllerPublishVolume failed with error for disk %v on node %v" , volID , instance .GetNodeID ())
166
152
167
153
defer func () {
168
154
169
155
// Detach Disk
170
- err = client .ControllerUnpublishVolume (volId , instance .GetNodeID ())
156
+ err = client .ControllerUnpublishVolume (volID , instance .GetNodeID ())
171
157
Expect (err ).To (BeNil (), "ControllerUnpublishVolume failed with error" )
172
158
}()
173
159
174
160
// Stage Disk
175
161
stageDir := filepath .Join ("/tmp/" , volName , "stage" )
176
- client .NodeStageVolume (volId , stageDir )
162
+ client .NodeStageVolume (volID , stageDir )
177
163
Expect (err ).To (BeNil (), "NodeStageVolume failed with error" )
178
164
179
165
defer func () {
180
166
// Unstage Disk
181
- err = client .NodeUnstageVolume (volId , stageDir )
167
+ err = client .NodeUnstageVolume (volID , stageDir )
182
168
Expect (err ).To (BeNil (), "NodeUnstageVolume failed with error" )
183
169
err = testutils .RmAll (instance , filepath .Join ("/tmp/" , volName ))
184
170
Expect (err ).To (BeNil (), "Failed to remove temp directory" )
185
171
}()
186
172
187
173
// Mount Disk
188
174
publishDir := filepath .Join ("/tmp/" , volName , "mount" )
189
- err = client .NodePublishVolume (volId , stageDir , publishDir )
175
+ err = client .NodePublishVolume (volID , stageDir , publishDir )
190
176
Expect (err ).To (BeNil (), "NodePublishVolume failed with error" )
191
177
err = testutils .ForceChmod (instance , filepath .Join ("/tmp/" , volName ), "777" )
192
178
Expect (err ).To (BeNil (), "Chmod failed with error" )
@@ -199,12 +185,12 @@ func testAttachWriteReadDetach(volId string, volName string, instance *remote.In
199
185
}
200
186
201
187
// Unmount Disk
202
- err = client .NodeUnpublishVolume (volId , publishDir )
188
+ err = client .NodeUnpublishVolume (volID , publishDir )
203
189
Expect (err ).To (BeNil (), "NodeUnpublishVolume failed with error" )
204
190
205
191
// Mount disk somewhere else
206
192
secondPublishDir := filepath .Join ("/tmp/" , volName , "secondmount" )
207
- err = client .NodePublishVolume (volId , stageDir , secondPublishDir )
193
+ err = client .NodePublishVolume (volID , stageDir , secondPublishDir )
208
194
Expect (err ).To (BeNil (), "NodePublishVolume failed with error" )
209
195
err = testutils .ForceChmod (instance , filepath .Join ("/tmp/" , volName ), "777" )
210
196
Expect (err ).To (BeNil (), "Chmod failed with error" )
@@ -216,8 +202,8 @@ func testAttachWriteReadDetach(volId string, volName string, instance *remote.In
216
202
Expect (strings .TrimSpace (string (readContents ))).To (Equal (testFileContents ))
217
203
218
204
// Unmount Disk
219
- err = client .NodeUnpublishVolume (volId , secondPublishDir )
205
+ err = client .NodeUnpublishVolume (volID , secondPublishDir )
220
206
Expect (err ).To (BeNil (), "NodeUnpublishVolume failed with error" )
221
207
222
- Logf ("Completed testAttachWriteReadDetach with volume %v node %v\n " , volId , instance .GetNodeID ())
208
+ Logf ("Completed testAttachWriteReadDetach with volume %v node %v\n " , volID , instance .GetNodeID ())
223
209
}
0 commit comments