Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration-test: add test scenarios #32

Merged
merged 1 commit into from
Jul 26, 2016
Merged

integration-test: add test scenarios #32

merged 1 commit into from
Jul 26, 2016

Conversation

ahmetb
Copy link
Contributor

@ahmetb ahmetb commented Jul 26, 2016

The integration tests use bats to run the scenarios as bash scripts.

To test the extension handler functionality, we simply:

  • build a Docker image using test.Dockerfile
    • copy some files from make it look like a/var/lib/waagent` directory
    • copy extension binary into the container
  • remove the test container if it exists
  • create a Docker container (name: test) from image
    • specify which handler subcommand will be invoked (e.g. fake-waagent install)
  • push .settings file and certificate/private key to the container (.crt, .prv)
    • do other things on the container that we need to craft the environment
  • start the container
  • collect the output from the command execution
  • validate using the following:
    • check status code
    • validate output of the command
    • docker diff test to validate file changes in the container
    • copy files out of container and validate their contents

@ahmetb
Copy link
Contributor Author

ahmetb commented Jul 26, 2016

Tests are expected to fail as this is not rebased on top of #31. I still have not plugged these tests in travis-ci (I'm not sure it'll work as integration tests require a docker daemon). That'll be another PR.

@ahmetb
Copy link
Contributor Author

ahmetb commented Jul 26, 2016

Running these tests looks like this

bats integration-test/test
 ✓ meta: docker is installed
 ✓ meta: can build the test container image
 ✓ meta: can start the test container
 ✓ meta: can create vm private/public keys
 ✓ meta: encrypt a protected settings
 ✓ meta: can create a .settings json with public/protected config
 ✓ meta: can create a temporary file
 ✓ handler command: install - creates the data dir
 ✓ handler command: enable - can process empty settings, but fails
 ✓ handler command: enable - validates json schema
 ✓ handler command: enable - captures stdout/stderr into file
 ✓ handler command: enable - doesn't process the same sequence number again
 ✓ handler command: enable - parses protected settings
 ✓ handler command: enable - downloads files
 ✓ handler command: uninstall - deletes the data dir

15 tests, 0 failures

The integation tests use `bats` to run the scenarios as bash scripts.

To test the extension handler functionality, we simply:

- build a Docker image using test.Dockerfile
    - copy some files from ` make it look like a `/var/lib/waagent` directory
    - copy extension binary into the container
- remove the `test` container if it exists
- create a Docker container (name: `test`) from image
    - specify which handler subcommand will be invoked (e.g. `fake-waagent
      install`)
- push .settings file and certificate/private key (.crt, .prv)
    - do other things on the container that we need to craft the environment
- start the container
- collect the output from the command execution
- validate using the following:
    - check status code
    - validate output of the command
    - `docker diff test` to validate file changes in the container
    - copy files out of container and validate their contents

Signed-off-by: Ahmet Alp Balkan <[email protected]>
}

container_read_file() { # reads the file at container path $1
set -eo pipefail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this scoped to this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe setting -e globally has issues with bats sstephenson/bats#171

@boumenot
Copy link
Member

LGTM.

@ahmetb ahmetb merged commit c5044e0 into Azure:master Jul 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants