Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 28 additions & 31 deletions cns/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,34 @@ func TestClient(t *testing.T) {
}
t.Logf("CreateVolumeFromSnapshot: Successfully Queried Volumes. queryResult: %+v", pretty.Sprint(queryResult))

// Test CnsSyncVolume API
t.Logf("Calling syncVolume for volumeId: %v ...\n", volumeId)
var cnsSyncVolumeSpecs []cnstypes.CnsSyncVolumeSpec
dataStore := ds.Reference()
cnsSyncVolumeSpec := cnstypes.CnsSyncVolumeSpec{
VolumeId: cnstypes.CnsVolumeId{
Id: volumeId,
},
Datastore: &dataStore,
SyncMode: []string{string(cnstypes.CnsSyncVolumeModeSPACE_USAGE)},
}
cnsSyncVolumeSpecs = append(cnsSyncVolumeSpecs, cnsSyncVolumeSpec)
syncVolumeTask, err := cnsClient.SyncVolume(ctx, cnsSyncVolumeSpecs)
if err != nil {
t.Errorf("Failed to sync volume %v. Error: %+v \n", volumeId, err)
t.Fatal(err)
}
syncVolumeTaskInfo, err := GetTaskInfo(ctx, syncVolumeTask)
if err != nil {
t.Errorf("Failed to get sync volume taskInfo. Error: %+v \n", err)
t.Fatal(err)
}
if syncVolumeTaskInfo.State != vim25types.TaskInfoStateSuccess {
t.Errorf("Failed to sync volume. Error: %+v \n", syncVolumeTaskInfo.Error)
t.Fatalf("%+v", syncVolumeTaskInfo.Error)
}
t.Logf("sync volume for volumeId: %v successful...\n", volumeId)

// Construct the CNS VolumeCreateSpec list
cnsCreateVolumeFromSnapshotCreateSpec := cnstypes.CnsVolumeCreateSpec{
Name: "pvc-901e87eb-c2bd-11e9-806f-005056a0c9a0-create-from-snapshot",
Expand Down Expand Up @@ -1783,37 +1811,6 @@ func TestClient(t *testing.T) {
t.Fatalf("%+v", syncDatastoreTaskInfo.Error)
}
t.Logf("syncDatastore on %v with full sync successful\n", dsUrl)

// Test CnsSyncVolume API

t.Logf("Calling syncVolume for volumeId: %v ...\n", volumeId)
var cnsSyncVolumeSpecs []cnstypes.CnsSyncVolumeSpec
dataStore := ds.Reference()
cnsSyncVolumeSpec := cnstypes.CnsSyncVolumeSpec{
VolumeId: cnstypes.CnsVolumeId{
Id: volumeId,
},
Datastore: &dataStore,
SyncMode: []string{string(cnstypes.CnsSyncVolumeModeSPACE_USAGE)},
}

cnsSyncVolumeSpecs = append(cnsSyncVolumeSpecs, cnsSyncVolumeSpec)
syncVolumeTask, err := cnsClient.SyncVolume(ctx, cnsSyncVolumeSpecs)
if err != nil {
t.Errorf("Failed to sync volume %v. Error: %+v \n", volumeId, err)
t.Fatal(err)
}
syncVolumeTaskInfo, err := GetTaskInfo(ctx, syncVolumeTask)
if err != nil {
t.Errorf("Failed to get sync volume taskInfo. Error: %+v \n", err)
t.Fatal(err)
}
if syncVolumeTaskInfo.State != vim25types.TaskInfoStateSuccess {
t.Errorf("Failed to sync volume. Error: %+v \n", syncVolumeTaskInfo.Error)
t.Fatalf("%+v", syncVolumeTaskInfo.Error)
}
t.Logf("syncVolume for volumeId: %v successful...\n", volumeId)

}

func TestUnregisterVolume(t *testing.T) {
Expand Down
Loading