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

74 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bats
load test_helper
@test "extension" {
vcsim_env_todo
govc extension.info | grep Name: | grep govc-test | awk '{print $2}' | $xargs -r govc extension.unregister
run govc extension.info enoent
assert_failure
id=$(new_id)
result=$(govc extension.info | grep $id | wc -l)
[ $result -eq 0 ]
# register extension
run govc extension.register $id <<EOS
{
"Description": {
"Label": "govc",
"Summary": "Go interface to vCenter"
},
"Key": "${id}",
"Company": "VMware, Inc.",
"Version": "0.2.0"
}
EOS
assert_success
# check info output is legit
run govc extension.info $id
assert_line "Name: $id"
json=$(govc extension.info -json $id)
label=$(jq -r .Extensions[].Description.Label <<<"$json")
assert_equal "govc" "$label"
# change label and update extension
json=$(jq -r '.Extensions[] | .Description.Label = "novc"' <<<"$json")
run govc extension.register -update $id <<<"$json"
assert_success
# check label changed in info output
json=$(govc extension.info -json $id)
label=$(jq -r .Extensions[].Description.Label <<<"$json")
assert_equal "novc" "$label"
# set extension certificate to generated certificate
run govc extension.setcert -cert-pem '+' $id
assert_success
# test client certificate authentication
(
# remove password from env, set user to extension id and turn of session cache
govc_url_to_vars
unset GOVC_PASSWORD
GOVC_USERNAME=$id
export GOVC_PERSIST_SESSION=false
run govc about -cert "${id}.crt" -key "${id}.key"
assert_success
)
# remove generated cert and key
rm ${id}.{crt,key}
run govc extension.unregister $id
assert_success
result=$(govc extension.info | grep $id | wc -l)
[ $result -eq 0 ]
}