Skip to content

Commit

Permalink
Merge pull request #2062 from dougm/osx-tests
Browse files Browse the repository at this point in the history
bats: test fixes for running on MacOSX
  • Loading branch information
dougm authored Jul 17, 2020
2 parents ebcce46 + fe3becf commit 79cdba0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions govc/test/library.bats
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ EOF
govc library.subscriber.ls govc-pub-vmtx | grep govc-sub-vmtx-$ds2

# Expect 1 VM: govc-pub-vmtx/ttylinux-pc_i486-16.1
govc find vm -type f -name govc-* | xargs -n1 -r govc find -type m
govc find vm -type f -name govc-* | $xargs -n1 -r govc find -type m

# Publish entire library
govc library.publish govc-pub-vmtx
Expand All @@ -403,7 +403,7 @@ EOF
govc library.publish govc-pub-vmtx/ttylinux-pc_i486-16.1

# Expect 2 more VMs: govc-sub-vmtx-{$ds1,$ds2}
govc find vm -type f -name govc-* | xargs -n1 govc find -type m
govc find vm -type f -name govc-* | $xargs -n1 govc find -type m

for ds in $ds1 $ds2 ; do
govc vm.clone -link -vm govc-sub-vmtx-$ds/ttylinux-pc_i486-16.1 -ds $ds -pool $pool -folder govc-sub-vmtx-$ds ttylinux
Expand Down
2 changes: 1 addition & 1 deletion govc/test/network.bats
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ load test_helper

# validate each NIC has a unique MAC
macs=$(govc device.info -vm "$vm" -json ethernet-* | jq -r .Devices[].MacAddress | uniq | wc -l)
[ "$macs" = "2" ]
assert_equal 2 "$macs"
}

@test "network flag required" {
Expand Down
2 changes: 1 addition & 1 deletion govc/test/test_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ assert_failure() {
}

assert_equal() {
if [ "$1" != "$2" ]; then
if [ "$(collapse_ws "$1")" != "$(collapse_ws "$2")" ]; then
{ echo "expected: $1"
echo "actual: $2"
} | flunk
Expand Down
12 changes: 6 additions & 6 deletions govc/test/vcsim.bats
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ load test_helper
run govc object.collect -s -type h host/DC0_H0 summary.config.port
assert_success "$port"
ports=$(govc object.collect -s -type h / summary.config.port | uniq -u | wc -l)
[ "$ports" = "0" ] # all host ports should be the same value
assert_equal 0 "$ports" # all host ports should be the same value

vcsim_stop

VCSIM_HOST_PORT_UNIQUE=true vcsim_start -l "$url"

hosts=$(curl -sk "https://$url/debug/vars" | jq .vcsim.Model.Host)
ports=$(govc object.collect -s -type h / summary.config.port | uniq -u | wc -l)
[ "$ports" = "$hosts" ] # all host ports should be unique
[[ "$ports" != *$port* ]] # host ports should not include vcsim port
assert_equal "$ports" "$hosts" # all host ports should be unique
grep -v "$port" <<<"$ports" # host ports should not include vcsim port
}

@test "vcsim set vm properties" {
Expand Down Expand Up @@ -171,13 +171,13 @@ EOF
assert_success "$(printf "265104de-1472-547c-b873-6dc7883fb6cb\nb4689bed-97f0-5bcd-8a4c-07477cc8f06f")"

dups=$(govc object.collect -s -type m / config.uuid | sort | uniq -d | wc -l)
[ "$dups" = "0" ]
assert_equal 0 "$dups"

run govc object.collect -s host/DC0_H0/DC0_H0 summary.hardware.uuid
assert_success dcf7fb3c-4a1c-5a05-b730-5e09f3704e2f

dups=$(govc object.collect -s -type m / summary.hardware.uuid | sort | uniq -d | wc -l)
[ "$dups" = "0" ]
assert_equal 0 "$dups"

run govc vm.create foo.yakity
assert_success
Expand Down Expand Up @@ -281,7 +281,7 @@ docker_name() {
assert_success

ip=$(govc object.collect -s vm/$vm guest.ipAddress)
run curl -f "http://$ip/vcsim.bats"
run docker run --rm curlimages/curl curl -f "http://$ip/vcsim.bats"
assert_success

# test suspend/resume
Expand Down

0 comments on commit 79cdba0

Please sign in to comment.