Files
virtual-kubelet/vendor/github.com/vmware/govmomi/govc/test/cluster.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

161 lines
5.1 KiB
Bash
Executable File

#!/usr/bin/env bats
load test_helper
@test "cluster.group" {
vcsim_env -cluster 2 -host 4 -vm 8
run govc cluster.group.ls -cluster DC0_C0
assert_success "" # no groups
run govc cluster.group.ls -cluster DC0_C0 -name my_vm_group
assert_failure # group does not exist
run govc cluster.group.create -cluster DC0_C0 -name my_vm_group -vm DC0_C0_H{0,1}
assert_failure # -vm or -host required
run govc cluster.group.create -cluster DC0_C0 -name my_vm_group -vm DC0_C0_H{0,1}
assert_failure # -vm with HostSystem type args
run govc cluster.group.create -cluster DC0_C0 -name my_vm_group -vm DC0_C0_RP0_VM{0,1}
assert_success
run govc cluster.group.ls -cluster DC0_C0
assert_success "my_vm_group"
run govc cluster.group.create -cluster DC0_C0 -name my_vm_group -vm DC0_C0_RP0_VM{0,1}
assert_failure # group exists
run govc cluster.group.ls -cluster DC0_C0 -name my_vm_group
assert_success "$(printf "%s\n" DC0_C0_RP0_VM{0,1})"
run govc cluster.group.change -cluster DC0_C0 -name my_vm_group DC0_C0_RP0_VM{0,1,2}
assert_success
run govc cluster.group.ls -cluster DC0_C0 -name my_vm_group
assert_success "$(printf "%s\n" DC0_C0_RP0_VM{0,1,2})"
run govc cluster.group.create -cluster DC0_C0 -name my_host_group -host DC0_C0_RP0_VM{0,1}
assert_failure # -host with VirtualMachine type args
run govc cluster.group.create -cluster DC0_C0 -name my_host_group -host DC0_C0_H{0,1}
assert_success
run govc cluster.group.ls -cluster DC0_C0 -name my_host_group
assert_success
run govc cluster.group.remove -cluster DC0_C0 -name my_vm_group
assert_success
run govc cluster.group.remove -cluster DC0_C0 -name my_vm_group
assert_failure # group does not exist
run govc cluster.group.ls -cluster DC0_C0
assert_success "my_host_group"
}
@test "cluster.rule" {
vcsim_env -cluster 2 -host 4 -vm 8
run govc cluster.rule.ls -cluster DC0_C0
assert_success "" # no rules
run govc object.collect -json /DC0/host/DC0_C0 configurationEx.rule
assert_success
run govc cluster.rule.ls -cluster DC0_C0 -name pod1
assert_failure # rule does not exist
run govc cluster.rule.create -cluster DC0_C0 -name pod1 -affinity DC0_C0_RP0_VM0
assert_failure # requires >= 2 VMs
run govc cluster.rule.create -cluster DC0_C0 -name pod1 -affinity DC0_C0_RP0_VM{0,1,2,3}
assert_success
run govc cluster.rule.ls -cluster DC0_C0 -name pod1
assert_success "$(printf "%s\n" DC0_C0_RP0_VM{0,1,2,3})"
run govc cluster.rule.change -cluster DC0_C0 -name pod1 DC0_C0_RP0_VM{2,3,4}
assert_success
run govc cluster.rule.ls -cluster DC0_C0 -name pod1
assert_success "$(printf "%s\n" DC0_C0_RP0_VM{2,3,4})"
run govc object.collect -json /DC0/host/DC0_C0 configurationEx.rule
assert_success
run govc cluster.group.create -cluster DC0_C0 -name my_vms -vm DC0_C0_RP0_VM{0,1,2,3}
assert_success
run govc cluster.group.create -cluster DC0_C0 -name even_hosts -host DC0_C0_H{0,2}
assert_success
run govc cluster.group.create -cluster DC0_C0 -name odd_hosts -host DC0_C0_H{1,3}
assert_success
run govc cluster.rule.create -cluster DC0_C0 -name pod2 -enable -mandatory -vm-host -vm-group my_vms -host-affine-group even_hosts -host-anti-affine-group odd_hosts
assert_success
run govc cluster.rule.remove -cluster DC0_C0 -name pod1
assert_success
run govc cluster.rule.remove -cluster DC0_C0 -name pod1 -depends
assert_failure # rule does not exist
run govc cluster.rule.create -cluster DC0_C0 -name my_deps -depends
assert_failure # requires 2 groups
run govc cluster.group.create -cluster DC0_C0 -name my_app -vm DC0_C0_RP0_VM{4,5}
assert_success
run govc cluster.group.create -cluster DC0_C0 -name my_db -vm DC0_C0_RP0_VM{6,7}
assert_success
run govc cluster.rule.create -cluster DC0_C0 -name my_deps -depends my_app my_db
assert_success
}
@test "cluster.vm" {
vcsim_env -host 4 -vm 8
run govc cluster.override.info
assert_success "" # no overrides == empty output
run govc cluster.override.change
assert_failure # -vm required
run govc cluster.override.change -vm DC0_C0_RP0_VM0
assert_failure # no changes specified
# DRS override
query=".Overrides[] | select(.Name == \"DC0_C0_RP0_VM0\") | .DRS.Enabled"
run govc cluster.override.change -vm DC0_C0_RP0_VM0 -drs-enabled=false
assert_success
[ "$(govc cluster.override.info -json | jq "$query")" == "false" ]
run govc cluster.override.change -vm DC0_C0_RP0_VM0 -drs-enabled=true
assert_success
[ "$(govc cluster.override.info -json | jq "$query")" == "true" ]
# DAS override
query=".Overrides[] | select(.Name == \"DC0_C0_RP0_VM0\") | .DAS.DasSettings.RestartPriority"
[ "$(govc cluster.override.info -json | jq -r "$query")" != "high" ]
run govc cluster.override.change -vm DC0_C0_RP0_VM0 -ha-restart-priority high
assert_success
[ "$(govc cluster.override.info -json | jq -r "$query")" == "high" ]
run govc cluster.override.remove -vm DC0_C0_RP0_VM0
assert_success
run govc cluster.override.info
assert_success "" # no overrides == empty output
run govc cluster.override.change -vm DC0_C0_RP0_VM0 -drs-mode=manual
assert_success
run govc cluster.override.remove -vm DC0_C0_RP0_VM0
assert_success
}