Add basic HyperOne end-to-end tests
This commit is contained in:
parent
c8a39e939a
commit
7947e52089
|
@ -27,6 +27,8 @@ running on macOS, most of these are available with `brew`:
|
|||
* [gcutil](https://developers.google.com/compute/docs/gcutil/#install) for
|
||||
Google Compute Engine tests.
|
||||
|
||||
* [h1-cli](https://github.com/hyperonecom/h1-client-go) for HyperOne tests.
|
||||
|
||||
### Configuring Tests
|
||||
|
||||
**For tests that require AWS credentials:**
|
||||
|
@ -44,6 +46,15 @@ Set the following environmental variables:
|
|||
* `GC_ACCOUNT_FILE`
|
||||
* `GC_PROJECT_ID`
|
||||
|
||||
**For tests that test HyperOne:**
|
||||
|
||||
Set the following environmental variables:
|
||||
|
||||
* `HYPERONE_TOKEN`
|
||||
* `HYPERONE_PROJECT`
|
||||
|
||||
You have to be authenticated within the `h1` tool (use `h1 login`).
|
||||
|
||||
### Running
|
||||
|
||||
These tests are meant to be run _one file at a time_. There are some
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bats
|
||||
#
|
||||
# This tests the hyperone builder. The teardown function will
|
||||
# delete any images with the text "packerbats" within the name.
|
||||
|
||||
load test_helper
|
||||
fixtures builder-hyperone
|
||||
|
||||
# Required parameters
|
||||
: ${HYPERONE_TOKEN:?}
|
||||
: ${HYPERONE_PROJECT:?}
|
||||
command -v h1 >/dev/null 2>&1 || {
|
||||
echo "'h1' must be installed" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
USER_VARS="${USER_VARS} -var token=${HYPERONE_TOKEN}"
|
||||
USER_VARS="${USER_VARS} -var project=${HYPERONE_PROJECT}"
|
||||
|
||||
hyperone_has_image() {
|
||||
h1 image list --project-select=${HYPERONE_PROJECT} --output=tsv | grep $1 | wc -l
|
||||
}
|
||||
|
||||
teardown() {
|
||||
h1 image list --project-select=${HYPERONE_PROJECT} --output=tsv \
|
||||
| grep packerbats \
|
||||
| awk '{print $1}' \
|
||||
| xargs -n1 h1 image delete --project-select=${HYPERONE_PROJECT} --yes --image
|
||||
}
|
||||
|
||||
@test "hyperone: build minimal.json" {
|
||||
run packer build ${USER_VARS} $FIXTURE_ROOT/minimal.json
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(hyperone_has_image "packerbats-minimal")" -eq 1 ]
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"variables": {
|
||||
"token": null,
|
||||
"project": null
|
||||
},
|
||||
"builders": [{
|
||||
"token": "{{ user `token` }}",
|
||||
"project": "{{ user `project` }}",
|
||||
"type": "hyperone",
|
||||
"source_image": "5c3fef425ceadc3d412beee5",
|
||||
"disk_size": 10,
|
||||
"vm_type": "a1.nano",
|
||||
"image_name": "packerbats-minimal-{{timestamp}}"
|
||||
}]
|
||||
}
|
Loading…
Reference in New Issue