Skip to content

Commit

Permalink
Clean up VCH Management API robot tests
Browse files Browse the repository at this point in the history
Refactor and clean up the robot test group for the VCH Management API.
  • Loading branch information
zjs committed Nov 1, 2017
1 parent 66411cf commit 9f6f112
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 189 deletions.
61 changes: 54 additions & 7 deletions tests/resources/Group23-VIC-Machine-Service-Util.robot
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@
# limitations under the License

*** Settings ***
Documentation This resource contains keywords which are helpful for using curl to test the vic-machine API.
Documentation This resource contains keywords which are helpful for using curl to test the vic-machine API.

*** Variables ***
${HTTP_PORT} 1337
${HTTPS_PORT} 31337
${HTTP_PORT} 1337
${HTTPS_PORT} 31337

${RC} The return code of the last curl invocation
${OUTPUT} The output of the last curl invocation
${STATUS} The HTTP status of the last curl invocation

*** Keywords ***

*** Keywords ***
Start VIC Machine Server
Start Process ./bin/vic-machine-server --port ${HTTP_PORT} --scheme http shell=True cwd=/go/src/github.com/vmware/vic

Expand All @@ -35,7 +38,6 @@ Get Path
Set Test Variable ${OUTPUT}
Set Test Variable ${STATUS}


Get Path Under Target
[Arguments] ${path} @{query}
${fullQuery}= Catenate SEPARATOR=& thumbprint=%{TEST_THUMBPRINT} @{query}
Expand All @@ -46,7 +48,6 @@ Get Path Under Target
Set Test Variable ${OUTPUT}
Set Test Variable ${STATUS}


Post Path Under Target
[Arguments] ${path} ${data} @{query}
${fullQuery}= Catenate SEPARATOR=& thumbprint=%{TEST_THUMBPRINT} @{query}
Expand All @@ -66,6 +67,52 @@ Verify Status
[Arguments] ${expected}
Should Be Equal As Integers ${expected} ${STATUS}


Verify Status Ok
Verify Status 200

Verify Status Created
Verify Status 201

Verify Status Bad Request
Verify Status 400

Verify Status Not Found
Verify Status 404


Output Should Contain
[Arguments] ${expected}
Should Contain ${OUTPUT} ${expected}

Output Should Not Contain
[Arguments] ${expected}
Should Not Contain ${OUTPUT} ${expected}

Output Should Match Regexp
[Arguments] ${expected}
Should Match Regexp ${OUTPUT} ${expected}


Property Should Be Equal
[Arguments] ${jq} ${expected}

${actual}= Run echo '${OUTPUT}' | jq -r '${jq}'
Should Be Equal ${actual} ${expected}

Property Should Not Be Equal
[Arguments] ${jq} ${expected}

${actual}= Run echo '${OUTPUT}' | jq -r '${jq}'
Should Not Be Equal ${actual} ${expected}

Property Should Contain
[Arguments] ${jq} ${expected}

${actual}= Run echo '${OUTPUT}' | jq -r '${jq}'
Should Contain ${actual} ${expected}

Property Should Not Be Empty
[Arguments] ${jq}

${actual}= Run echo '${OUTPUT}' | jq -r '${jq}'
Should Not Be Empty ${actual}
20 changes: 7 additions & 13 deletions tests/test-cases/Group23-VIC-Machine-Service/23-01-Version.robot
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,22 @@
# limitations under the License

*** Settings ***
Documentation Test 23-01 - Version
Resource ../../resources/Util.robot
Resource ../../resources/Group23-VIC-Machine-Service-Util.robot
Suite Setup Start VIC Machine Server
Suite Teardown Terminate All Processes kill=True
Documentation Test 23-01 - Version
Resource ../../resources/Util.robot
Resource ../../resources/Group23-VIC-Machine-Service-Util.robot
Suite Setup Start VIC Machine Server
Suite Teardown Terminate All Processes kill=True
Default Tags


*** Variables ***
${RC} The return code of the last curl invocation
${OUTPUT} The output of the last curl invocation
${STATUS} The HTTP status of the last curl invocation


*** Keywords ***
Get Version
Get Path version


Verify Version
Should Match Regexp ${OUTPUT} v\\d+\\.\\d+\\.\\d+-\\w+-\\d+-[a-f0-9]+
Should Not Contain ${OUTPUT} "
Output Should Match Regexp v\\d+\\.\\d+\\.\\d+-\\w+-\\d+-[a-f0-9]+
Output Should Not Contain "


*** Test Cases ***
Expand Down
23 changes: 8 additions & 15 deletions tests/test-cases/Group23-VIC-Machine-Service/23-02-VCH-List.robot
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,13 @@ Get VCH List Within Datacenter

Verify VCH List
${expectedId}= Get VCH ID %{VCH-NAME}
${actualId}= Run echo '${OUTPUT}' | jq -r '.vchs[] | select(.name=="%{VCH-NAME}").id'
Should Be Equal ${expectedId} ${actualId}

${admin_portal}= Run echo '${OUTPUT}' | jq -r '.vchs[] | select(.name=="%{VCH-NAME}").admin_portal'
Should Not Be Empty ${admin_portal}
Property Should Be Equal .vchs[] | select(.name=="%{VCH-NAME}").id ${expectedId}

${docker_host}= Run echo '${OUTPUT}' | jq -r '.vchs[] | select(.name=="%{VCH-NAME}").docker_host'
Should Not Be Empty ${docker_host}

${upgrade_status}= Run echo '${OUTPUT}' | jq -r '.vchs[] | select(.name=="%{VCH-NAME}").upgrade_status'
Should Not Be Empty ${upgrade_status}

${version}= Run echo '${OUTPUT}' | jq -r '.vchs[] | select(.name=="%{VCH-NAME}").version'
Should Not Be Empty ${version}
Property Should Not Be Empty .vchs[] | select(.name=="%{VCH-NAME}").admin_portal
Property Should Not Be Empty .vchs[] | select(.name=="%{VCH-NAME}").docker_host
Property Should Not Be Empty .vchs[] | select(.name=="%{VCH-NAME}").upgrade_status
Property Should Not Be Empty .vchs[] | select(.name=="%{VCH-NAME}").version


*** Test Cases ***
Expand All @@ -82,18 +75,18 @@ Get VCH List Within Invalid Datacenter
Get Path Under Target datacenter/INVALID/vch

Verify Return Code
Verify Status 404
Verify Status Not Found


Get VCH List Within Invalid Compute Resource
Get Path Under Target vch compute-resource=INVALID

Verify Return Code
Verify Status 400
Verify Status Bad Request


Get VCH List Within Invalid Datacenter and Compute Resource
Get Path Under Target datacenter/INVALID/vch compute-resource=INVALID

Verify Return Code
Verify Status 404
Verify Status Not Found
98 changes: 35 additions & 63 deletions tests/test-cases/Group23-VIC-Machine-Service/23-03-VCH-Create.robot
Original file line number Diff line number Diff line change
Expand Up @@ -48,56 +48,28 @@ Inspect VCH ${name}
Set Test Variable ${OUTPUT}


Arguments Should Contain
[Arguments] ${expected}
Should Contain ${OUTPUT} ${expected}


Get VCH
[Arguments] ${name}

Get VCH ${name}
Get Path Under Target vch
${id}= Run echo '${OUTPUT}' | jq -r '.vchs[] | select(.name=="${name}").id'

Get Path Under Target vch/${id}


Property Should Be Equal
[Arguments] ${jq} ${expected}

${actual}= Run echo '${OUTPUT}' | jq -r '${jq}'
Should Be Equal ${actual} ${expected}


Property Should Not Be Equal
[Arguments] ${jq} ${expected}

${actual}= Run echo '${OUTPUT}' | jq -r '${jq}'
Should Not Be Equal ${actual} ${expected}


Property Should Contain
[Arguments] ${jq} ${expected}

${actual}= Run echo '${OUTPUT}' | jq -r '${jq}'
Should Contain ${actual} ${expected}


*** Test Cases ***
Create minimal VCH
Create VCH '{"name":"%{VCH-NAME}-api-test-minimal","compute":{"resource":{"name":"%{TEST_RESOURCE}"}},"storage":{"image_stores":["ds://%{TEST_DATASTORE}"]},"network":{"bridge":{"ip_range":"172.16.0.0/12","port_group":{"name":"%{BRIDGE_NETWORK}"}},"public":{"port_group":{"name":"%{PUBLIC_NETWORK}"}}},"auth":{"server":{"generate":{"cname":"vch.example.com","organization":["VMware, Inc."],"size":{"value":2048,"units":"bits"}}},"client":{"no_tls_verify": true}}}'

Verify Return Code
Verify Status 201
Verify Status Created


Inspect VCH %{VCH-NAME}-api-test-minimal

Arguments Should Contain --image-store=ds://%{TEST_DATASTORE}
Arguments Should Contain --bridge-network=%{BRIDGE_NETWORK}
Output Should Contain --image-store=ds://%{TEST_DATASTORE}
Output Should Contain --bridge-network=%{BRIDGE_NETWORK}


Get VCH %{VCH-NAME}-api-test-minimal
Get VCH %{VCH-NAME}-api-test-minimal

Property Should Be Equal .name %{VCH-NAME}-api-test-minimal

Expand All @@ -122,16 +94,16 @@ Create minimal VCH within datacenter
Create VCH Within Datacenter '{"name":"%{VCH-NAME}-api-test-dc","compute":{"resource":{"name":"%{TEST_RESOURCE}"}},"storage":{"image_stores":["ds://%{TEST_DATASTORE}"]},"network":{"bridge":{"ip_range":"172.16.0.0/12","port_group":{"name":"%{BRIDGE_NETWORK}"}},"public":{"port_group":{"name":"%{PUBLIC_NETWORK}"}}},"auth":{"server":{"generate":{"cname":"vch.example.com","organization":["VMware, Inc."],"size":{"value":2048,"units":"bits"}}},"client":{"no_tls_verify": true}}}'

Verify Return Code
Verify Status 201
Verify Status Created


Inspect VCH %{VCH-NAME}-api-test-dc

Arguments Should Contain --image-store=ds://%{TEST_DATASTORE}
Arguments Should Contain --bridge-network=%{BRIDGE_NETWORK}
Output Should Contain --image-store=ds://%{TEST_DATASTORE}
Output Should Contain --bridge-network=%{BRIDGE_NETWORK}


Get VCH %{VCH-NAME}-api-test-dc
Get VCH %{VCH-NAME}-api-test-dc

Property Should Be Equal .name %{VCH-NAME}-api-test-dc

Expand All @@ -156,35 +128,35 @@ Create complex VCH
Create VCH '{"name":"%{VCH-NAME}-api-test-complex","debug":3,"compute":{"cpu":{"limit":{"units":"MHz","value":2345},"reservation":{"units":"GHz","value":2},"shares":{"level":"high"}},"memory":{"limit":{"units":"MiB","value":1200},"reservation":{"units":"MiB","value":501},"shares":{"number":81910}},"resource":{"name":"%{TEST_RESOURCE}"}},"endpoint":{"cpu":{"sockets":2},"memory":{"units":"MiB","value":3072}},"storage":{"image_stores":["ds://%{TEST_DATASTORE}"],"volume_stores":[{"datastore":"ds://%{TEST_DATASTORE}/test-volumes/foo","label":"foo"}],"base_image_size":{"units":"B","value":16000000}},"network":{"bridge":{"ip_range":"172.16.0.0/12","port_group":{"name":"%{BRIDGE_NETWORK}"}},"public":{"port_group":{"name":"%{PUBLIC_NETWORK}"}}},"registry":{"image_fetch_proxy":{"http":"http://example.com","https":"https://example.com"},"insecure":["https://insecure.example.com"],"whitelist":["10.0.0.0/8"]},"auth":{"server":{"generate":{"cname":"vch.example.com","organization":["VMware, Inc."],"size":{"value":2048,"units":"bits"}}},"client":{"no_tls_verify": true}},"syslog_addr":"tcp://syslog.example.com:4444"}'

Verify Return Code
Verify Status 201
Verify Status Created


Inspect VCH %{VCH-NAME}-api-test-complex

Arguments Should Contain --debug=3
Output Should Contain --debug=3

Arguments Should Contain --cpu=2345
Arguments Should Contain --cpu-reservation=2000
Arguments Should Contain --cpu-shares=high
Arguments Should Contain --memory=1200
Arguments Should Contain --memory-reservation=501
Arguments Should Contain --memory-shares=81910
Output Should Contain --cpu=2345
Output Should Contain --cpu-reservation=2000
Output Should Contain --cpu-shares=high
Output Should Contain --memory=1200
Output Should Contain --memory-reservation=501
Output Should Contain --memory-shares=81910

Arguments Should Contain --endpoint-cpu=2
Arguments Should Contain --endpoint-memory=3072
Output Should Contain --endpoint-cpu=2
Output Should Contain --endpoint-memory=3072

Arguments Should Contain --image-store=ds://%{TEST_DATASTORE}
Arguments Should Contain --volume-store=ds://%{TEST_DATASTORE}/test-volumes/foo:foo
Arguments Should Contain --base-image-size=16MB
Output Should Contain --image-store=ds://%{TEST_DATASTORE}
Output Should Contain --volume-store=ds://%{TEST_DATASTORE}/test-volumes/foo:foo
Output Should Contain --base-image-size=16MB

Arguments Should Contain --bridge-network=%{BRIDGE_NETWORK}
Output Should Contain --bridge-network=%{BRIDGE_NETWORK}

Arguments Should Contain --insecure-registry=https://insecure.example.com
Arguments Should Contain --whitelist-registry=10.0.0.0/8
Arguments Should Contain --whitelist-registry=https://insecure.example.com
Output Should Contain --insecure-registry=https://insecure.example.com
Output Should Contain --whitelist-registry=10.0.0.0/8
Output Should Contain --whitelist-registry=https://insecure.example.com


Get VCH %{VCH-NAME}-api-test-complex
Get VCH %{VCH-NAME}-api-test-complex

Property Should Be Equal .name %{VCH-NAME}-api-test-complex
Property Should Be Equal .debug 3
Expand Down Expand Up @@ -233,33 +205,33 @@ Fail to create VCH with invalid operations credentials
Create VCH '{"name":"%{VCH-NAME}-api-bad-ops","compute":{"resource":{"name":"%{TEST_RESOURCE}"}},"endpoint":{"operations_credentials":{"user":"invalid","password":"invalid"}},"storage":{"image_stores":["ds://%{TEST_DATASTORE}"]},"network":{"bridge":{"ip_range":"172.16.0.0/12","port_group":{"name":"%{BRIDGE_NETWORK}"}},"public":{"port_group":{"name":"%{PUBLIC_NETWORK}"}}},"auth":{"server":{"generate":{"cname":"vch.example.com","organization":["VMware, Inc."],"size":{"value":2048,"units":"bits"}}},"client":{"no_tls_verify": true}}}'

Verify Return Code
Verify Status 400
Verify Status Bad Request

Should Contain ${output} operations credentials
Output Should Contain operations credentials


Fail to create VCH with invalid datastore
Create VCH '{"name":"%{VCH-NAME}-api-bad-storage","compute":{"resource":{"name":"%{TEST_RESOURCE}"}},"storage":{"image_stores":["ds://%{TEST_DATASTORE}-invalid"]},"network":{"bridge":{"ip_range":"172.16.0.0/12","port_group":{"name":"%{BRIDGE_NETWORK}"}},"public":{"port_group":{"name":"%{PUBLIC_NETWORK}"}}},"auth":{"server":{"generate":{"cname":"vch.example.com","organization":["VMware, Inc."],"size":{"value":2048,"units":"bits"}}},"client":{"no_tls_verify": true}}}'

Verify Return Code
Verify Status 400
Verify Status Bad Request

Should Contain ${output} datastore
Output Should Contain datastore


Fail to create VCH with invalid compute
Create VCH '{"name":"%{VCH-NAME}-api-bad-compute","compute":{"resource":{"name":"%{TEST_RESOURCE}-invalid"}},"storage":{"image_stores":["ds://%{TEST_DATASTORE}"]},"network":{"bridge":{"ip_range":"172.16.0.0/12","port_group":{"name":"%{BRIDGE_NETWORK}"}},"public":{"port_group":{"name":"%{PUBLIC_NETWORK}"}}},"auth":{"server":{"generate":{"cname":"vch.example.com","organization":["VMware, Inc."],"size":{"value":2048,"units":"bits"}}},"client":{"no_tls_verify": true}}}'

Verify Return Code
Verify Status 400
Verify Status Bad Request

Should Contain ${output} compute resource
Output Should Contain compute resource


Fail to create VCH without network
Create VCH '{"name":"%{VCH-NAME}-api-bad-network","compute":{"resource":{"name":"%{TEST_RESOURCE}"}},"storage":{"image_stores":["ds://%{TEST_DATASTORE}"]},"auth":{"server":{"generate":{"cname":"vch.example.com","organization":["VMware, Inc."],"size":{"value":2048,"units":"bits"}}},"client":{"no_tls_verify": true}}}'

Verify Return Code
Verify Status 400
Verify Status Bad Request

Should Contain ${output} network
Output Should Contain network
Loading

0 comments on commit 9f6f112

Please sign in to comment.