packer-cn/test
Artis3n 9a2908d1d9 Use the galaxy playbook in the galaxy packer file 2020-09-05 18:15:42 -04:00
..
fixtures Use the galaxy playbook in the galaxy packer file 2020-09-05 18:15:42 -04:00
README.md test: Generalize README to avoid AWS 2019-12-03 14:57:41 +01:00
builder_googlecompute.bats
builder_hyperone.bats builder/hyperone: Add tests for HCL syntax 2020-05-19 01:21:00 +02:00
builder_lxc.bats Add options to LXC builder for influencing for how containers are built and started 2017-10-30 21:48:43 -04:00
cli.bats
communicator_ssh.bats SSH tunneling support 2019-09-18 11:09:41 -07:00
provisioner_ansible.bats Added acceptance test for Galaxy Collection install 2020-09-05 16:48:20 -04:00
provisioner_file.bats Move checking aws cli to separate function 2019-02-07 09:30:47 +01:00
provisioner_shell.bats Move checking aws cli to separate function 2019-02-07 09:30:47 +01:00
test_helper.bash Move checking aws cli to separate function 2019-02-07 09:30:47 +01:00

README.md

Packer Black-Box Tests

This folder contains tests that test Packer using a black-box approach: packer is executed directly (with whatever is on the PATH) and certain results are expected.

Tests are run using Bats, and therefore Bash is required to run any tests.

Warning: Many of these tests run using cloud infrastructure, and therefore have a real-world cost associated with running the tests. Be aware of that prior to running the tests. Additionally, many tests will leave left-over artifacts (AMIs) that you'll have to manually clean up.

Running Tests

Required Software

Before running the tests, you'll need the following installed. If you're running on macOS, most of these are available with brew:

  • Bats

  • AWS cli for AWS tests as well as most of the components.

  • gcutil for Google Compute Engine tests.

  • h1-cli for HyperOne tests.

Configuring Tests

For tests that require AWS credentials:

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_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 test files (such as the amazon-chroot builder test) that simply won't run except in special environments, so running all test files will probably never work.

If you're working on Packer and want to test that your change didn't adversely affect something, try running only the test that is related to your change.

$ bats builder_amazon_ebs.bats

Note: Working directory doesn't matter. You can call the bats test file from any directory.