Files
virtual-kubelet/vendor/github.com/vmware/govmomi/govc/test/events.bats
Loc Nguyen 513cebe7b7 VMware vSphere Integrated Containers provider (#206)
* Add Virtual Kubelet provider for VIC

Initial virtual kubelet provider for VMware VIC.  This provider currently
handles creating and starting of a pod VM via the VIC portlayer and persona
server.  Image store handling via the VIC persona server.  This provider
currently requires the feature/wolfpack branch of VIC.

* Added pod stop and delete.  Also added node capacity.

Added the ability to stop and delete pod VMs via VIC.  Also retrieve
node capacity information from the VCH.

* Cleanup and readme file

Some file clean up and added a Readme.md markdown file for the VIC
provider.

* Cleaned up errors, added function comments, moved operation code

1. Cleaned up error handling.  Set standard for creating errors.
2. Added method prototype comments for all interface functions.
3. Moved PodCreator, PodStarter, PodStopper, and PodDeleter to a new folder.

* Add mocking code and unit tests for podcache, podcreator, and podstarter

Used the unit test framework used in VIC to handle assertions in the provider's
unit test.  Mocking code generated using OSS project mockery, which is compatible
with the testify assertion framework.

* Vendored packages for the VIC provider

Requires feature/wolfpack branch of VIC and a few specific commit sha of
projects used within VIC.

* Implementation of POD Stopper and Deleter unit tests (#4)

* Updated files for initial PR
2018-06-04 15:41:32 -07:00

89 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bats
load test_helper
@test "events dc" {
esx_env
run govc events
assert_success
nevents=${#lines[@]}
# there should be plenty more than 1 event at the top (dc) level
[ $nevents -ge 1 ]
# test -n flag
run govc events -n $((nevents - 1))
assert_success
[ ${#lines[@]} -le $nevents ]
}
@test "events host" {
esx_env
run govc events 'host/*'
assert_success
[ ${#lines[@]} -ge 1 ]
}
@test "events vm" {
esx_env
vm=$(new_id)
run govc vm.create -on=false $vm
assert_success
run govc events vm/$vm
assert_success
nevents=${#lines[@]}
[ $nevents -gt 1 ]
# glob should have same # of events
run govc events vm/${vm}*
assert_success
[ ${#lines[@]} -eq $nevents ]
# create a new vm, glob should match more events
run govc vm.create -on=false "${vm}-2"
assert_success
run govc events vm/${vm}*
assert_success
[ ${#lines[@]} -gt $nevents ]
nevents=${#lines[@]}
run govc events vm
assert_success
[ ${#lines[@]} -ge $nevents ]
run govc events -type VmPoweredOffEvent -type VmPoweredOnEvent "vm/$vm"
[ ${#lines[@]} -eq 0 ]
run govc vm.power -on "$vm"
assert_success
run govc events -type VmPoweredOffEvent -type VmPoweredOnEvent "vm/$vm"
[ ${#lines[@]} -eq 1 ]
run govc vm.power -off "$vm"
assert_success
run govc events -type VmPoweredOffEvent -type VmPoweredOnEvent "vm/$vm"
[ ${#lines[@]} -eq 2 ]
}
@test "events json" {
esx_env
# make sure we fmt.Printf properly
govc events | grep -v '%!s(MISSING)'
govc events -json | jq .
# test multiple objects
govc vm.create "$(new_id)"
govc vm.create "$(new_id)"
govc events 'vm/*'
govc events -json 'vm/*' | jq .
}