Skip to content

Commit 24f4996

Browse files
committed
skip CNS transaction tests when env CNS_RUN_TRANSACTION_TESTS is not set
Signed-off-by: Divyen Patel <[email protected]>
1 parent da9b4f2 commit 24f4996

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

cns/client_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ func TestClient(t *testing.T) {
4444
datastore := os.Getenv("CNS_DATASTORE")
4545
datastore2 := os.Getenv("CNS_DATASTORE2")
4646

47+
// set CNS_RUN_TRANSACTION_TESTS environment to true, if you want to run CNS Transaction tests
48+
// example: export CNS_RUN_TRANSACTION_TESTS='true'
49+
run_cns_transaction_tests := os.Getenv("CNS_RUN_TRANSACTION_TESTS")
50+
4751
// set CNS_RUN_FILESHARE_TESTS environment to true, if your setup has vsanfileshare enabled.
4852
// when CNS_RUN_FILESHARE_TESTS is not set to true, vsan file share related tests are skipped.
4953
// example: export CNS_RUN_FILESHARE_TESTS='true'
@@ -146,9 +150,9 @@ func TestClient(t *testing.T) {
146150

147151
pvclaimUID := "901e87eb-c2bd-11e9-806f-005056a0c9a0"
148152
isvSphereVersion91orAbove := isvSphereVersion91orAbove(ctx, c.ServiceContent.About)
149-
if isvSphereVersion91orAbove {
153+
if run_cns_transaction_tests == "true" && isvSphereVersion91orAbove {
150154
t.Logf("setting volumeID: %q in the cnsVolumeCreateSpec", pvclaimUID)
151-
cnsVolumeCreateSpec.VolumeId = cnstypes.CnsVolumeId{
155+
cnsVolumeCreateSpec.VolumeId = &cnstypes.CnsVolumeId{
152156
Id: pvclaimUID,
153157
}
154158
}
@@ -180,7 +184,7 @@ func TestClient(t *testing.T) {
180184
volumeId := createVolumeOperationRes.VolumeId.Id
181185
volumeCreateResult := (createTaskResult).(*cnstypes.CnsVolumeCreateResult)
182186
t.Logf("volumeCreateResult %+v", volumeCreateResult)
183-
if isvSphereVersion91orAbove {
187+
if run_cns_transaction_tests == "true" && isvSphereVersion91orAbove {
184188
if volumeId != pvclaimUID {
185189
t.Fatalf("failed to create volume with supplied volume ID: %q volume "+
186190
"created with diffrent UUID: %q", pvclaimUID, volumeId)
@@ -190,7 +194,7 @@ func TestClient(t *testing.T) {
190194

191195
// Creating Volume with same ID again on different datastore
192196
// to observe CnsVolumeAlreadyExistsFault
193-
if isvSphereVersion91orAbove {
197+
if run_cns_transaction_tests == "true" && isvSphereVersion91orAbove {
194198
if datastore2 != "" {
195199
ds2, err := finder.Datastore(ctx, datastore2)
196200
if err != nil {
@@ -431,10 +435,10 @@ func TestClient(t *testing.T) {
431435
}
432436

433437
var generatedSnapshotUUIDFromClient string
434-
if isvSphereVersion91orAbove {
438+
if run_cns_transaction_tests == "true" && isvSphereVersion91orAbove {
435439
generatedSnapshotUUIDFromClient = uuid.New().String()
436440
t.Logf("setting SnapshotID: %q in the cnsSnapshotCreateSpec", generatedSnapshotUUIDFromClient)
437-
cnsSnapshotCreateSpec.SnapshotId = cnstypes.CnsSnapshotId{
441+
cnsSnapshotCreateSpec.SnapshotId = &cnstypes.CnsSnapshotId{
438442
Id: generatedSnapshotUUIDFromClient,
439443
}
440444
}
@@ -465,7 +469,7 @@ func TestClient(t *testing.T) {
465469
snapshotId := snapshotCreateResult.Snapshot.SnapshotId.Id
466470
snapshotCreateTime := snapshotCreateResult.Snapshot.CreateTime
467471
t.Logf("snapshotCreateResult: %+v", pretty.Sprint(snapshotCreateResult))
468-
if isvSphereVersion91orAbove {
472+
if run_cns_transaction_tests == "true" && isvSphereVersion91orAbove {
469473
if snapshotId != generatedSnapshotUUIDFromClient {
470474
t.Fatalf("failed to create snapshot with snapshot id: %q snapshot "+
471475
"created with diffrent id: %q", generatedSnapshotUUIDFromClient, snapshotId)

cns/types/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ type CnsVolumeCreateSpec struct {
7979
types.DynamicData
8080
Name string `xml:"name" json:"name"`
8181
VolumeType string `xml:"volumeType" json:"volumeType"`
82-
VolumeId CnsVolumeId `xml:"volumeId,omitempty" json:"volumeId"`
82+
VolumeId *CnsVolumeId `xml:"volumeId,omitempty" json:"volumeId"`
8383
Datastores []types.ManagedObjectReference `xml:"datastores,omitempty" json:"datastores"`
8484
Metadata CnsVolumeMetadata `xml:"metadata,omitempty" json:"metadata"`
8585
BackingObjectDetails BaseCnsBackingObjectDetails `xml:"backingObjectDetails,typeattr" json:"backingObjectDetails"`
@@ -725,9 +725,9 @@ type CnsCreateSnapshotsResponse struct {
725725
type CnsSnapshotCreateSpec struct {
726726
types.DynamicData
727727

728-
VolumeId CnsVolumeId `xml:"volumeId" json:"volumeId"`
729-
Description string `xml:"description" json:"description"`
730-
SnapshotId CnsSnapshotId `xml:"snapshotId,omitempty" json:"snapshotId"`
728+
VolumeId CnsVolumeId `xml:"volumeId" json:"volumeId"`
729+
Description string `xml:"description" json:"description"`
730+
SnapshotId *CnsSnapshotId `xml:"snapshotId,omitempty" json:"snapshotId"`
731731
}
732732

733733
func init() {

0 commit comments

Comments
 (0)