Skip to content

Commit

Permalink
vcsim: make QueryVirtualDiskUuid() result stable
Browse files Browse the repository at this point in the history
The result is relative to Datastore, not an absolute path.

Signed-off-by: Doug MacEachern <dougm@broadcom.com>
  • Loading branch information
dougm committed Dec 13, 2024
1 parent f398e78 commit b7d4f00
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion govc/test/datastore.bats
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ upload_file() {
@test "datastore.disk" {
vcsim_env

id=$(new_id)
id=govc-test-disk
vmdk="$id/$id.vmdk"

run govc datastore.mkdir "$id"
Expand All @@ -249,6 +249,7 @@ upload_file() {

run govc datastore.disk.info -uuid "$vmdk"
assert_success
disk_uuid=$(grep UUID: <<<"$output" | awk '{print $2}')

run govc datastore.rm "$vmdk"
assert_success
Expand Down Expand Up @@ -295,6 +296,25 @@ upload_file() {

run govc datastore.rm "$(dirname "$vmdk")"
assert_success

# validate that QueryVirtualDiskUuid result is stable,
# using same datastore + name as beginning of the test.
vcsim_stop
vcsim_start

id=govc-test-disk
vmdk="$id/$id.vmdk"
run govc datastore.mkdir "$id"
assert_success

run govc datastore.disk.create "$vmdk"
assert_success

run govc datastore.disk.info -uuid "$vmdk"
assert_success
disk_uuid2=$(grep UUID: <<<"$output" | awk '{print $2}')

assert_equal "$disk_uuid" "$disk_uuid2"
}

@test "datastore.cp" {
Expand Down
2 changes: 1 addition & 1 deletion simulator/virtual_disk_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (m *VirtualDiskManager) QueryVirtualDiskUuid(ctx *Context, req *types.Query
}

body.Res = &types.QueryVirtualDiskUuidResponse{
Returnval: virtualDiskUUID(req.Datacenter, file),
Returnval: virtualDiskUUID(req.Datacenter, req.Name),
}

return body
Expand Down

0 comments on commit b7d4f00

Please sign in to comment.