Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
044e7fa3
Commit
044e7fa3
authored
Dec 14, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: google compute engine acceptance tests
parent
a91b8f68
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
1 deletion
+75
-1
.gitignore
.gitignore
+1
-0
test/README.md
test/README.md
+14
-1
test/builder_googlecompute.bats
test/builder_googlecompute.bats
+40
-0
test/fixtures/builder-googlecompute/minimal.json
test/fixtures/builder-googlecompute/minimal.json
+20
-0
No files found.
.gitignore
View file @
044e7fa3
...
...
@@ -6,3 +6,4 @@
/website/build
.vagrant
Vagrantfile
test/.env
test/README.md
View file @
044e7fa3
...
...
@@ -21,7 +21,11 @@ running on Mac OS X, most of these are available with `brew`:
*
[
Bats
](
https://github.com/sstephenson/bats
)
*
[
AWS cli
](
http://aws.amazon.com/cli/
)
*
[
AWS cli
](
http://aws.amazon.com/cli/
)
for AWS tests as well as most
of the components.
*
[
gcutil
](
https://developers.google.com/compute/docs/gcutil/#install
)
for
Google Compute Engine tests.
### Configuring Tests
...
...
@@ -32,6 +36,15 @@ Set the following self-explanatory environmental variables:
*
`AWS_ACCESS_KEY_ID`
*
`AWS_SECRET_ACCESS_KEY`
**For tests that test Google Compute Engine:**
Set the following environmental variables:
*
`GC_BUCKET_NAME`
*
`GC_CLIENT_SECRETS_FILE`
*
`GC_PRIVATE_KEY_FILE`
*
`GC_PROJECT_ID`
### Running
These tests are meant to be run _one file at a time_. There are some
...
...
test/builder_googlecompute.bats
0 → 100755
View file @
044e7fa3
#!/usr/bin/env bats
#
# This tests the googlecompute builder. The teardown function will
# delete any images with the text "packerbats" within the name.
load test_helper
fixtures builder-googlecompute
# Required parameters
: ${GC_BUCKET_NAME:?}
: ${GC_CLIENT_SECRETS_FILE:?}
: ${GC_PRIVATE_KEY_FILE:?}
: ${GC_PROJECT_ID:?}
command -v gcutil >/dev/null 2>&1 || {
echo "'gcutil' must be installed" >&2
exit 1
}
USER_VARS="-var bucket_name=${GC_BUCKET_NAME}"
USER_VARS="${USER_VARS} -var client_secrets_file=${GC_CLIENT_SECRETS_FILE}"
USER_VARS="${USER_VARS} -var private_key_file=${GC_PRIVATE_KEY_FILE}"
USER_VARS="${USER_VARS} -var project_id=${GC_PROJECT_ID}"
# This tests if GCE has an image that contains the given parameter.
gc_has_image() {
gcutil --format=names --project=${GC_PROJECT_ID} listimages \
| grep $1
}
teardown() {
gcutil --format=names --project=${GC_PROJECT_ID} listimages \
| grep packerbats \
| xargs -n1 gcutil --project=${GC_PROJECT_ID} --force deleteimage
}
@test "googlecompute: build minimal.json" {
run packer build ${USER_VARS} $FIXTURE_ROOT/minimal.json
[ "$status" -eq 0 ]
[ "$(gc_has_image "packerbats-minimal")" -eq 0 ]
}
test/fixtures/builder-googlecompute/minimal.json
0 → 100644
View file @
044e7fa3
{
"variables"
:
{
"bucket_name"
:
null
,
"client_secrets_file"
:
null
,
"private_key_file"
:
null
,
"project_id"
:
null
},
"builders"
:
[{
"type"
:
"googlecompute"
,
"bucket_name"
:
"{{user `bucket_name`}}"
,
"client_secrets_file"
:
"{{user `client_secrets_file`}}"
,
"private_key_file"
:
"{{user `private_key_file`}}"
,
"project_id"
:
"{{user `project_id`}}"
,
"image_name"
:
"packerbats-minimal-{{timestamp}}"
,
"source_image"
:
"debian-7-wheezy-v20131120"
,
"zone"
:
"us-central1-a"
}]
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment