Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

switch to bats for integration testing #615

Merged
merged 8 commits into from
Mar 2, 2015

Conversation

ehazlett
Copy link
Contributor

This uses https://github.com/sstephenson/bats for integration testing using the compiled binary. Huge thanks to @aluzzardi for recommending! Details are in the readme. This also removes the old integration tests (they were quirky anyway).

Note: To test a cloud provider, you will need the credentials loaded as environment variables.

You specify a DRIVER and bats will run the tests (commands) against that driver:

ehazlett machine> bats test/driver-virtualbox.bats
 ✓ virtualbox: machine should not exist
 ✓ virtualbox: create
 ✓ virtualbox: active
 ✓ virtualbox: ls
 ✓ virtualbox: url
 ✓ virtualbox: ip
 ✓ virtualbox: ssh
 ✓ virtualbox: stop
 ✓ virtualbox: machine should show stopped
 ✓ virtualbox: start
 ✓ virtualbox: machine should show running after start
 ✓ virtualbox: restart
 ✓ virtualbox: machine should show running after restart
 ✓ virtualbox: remove
 ✓ virtualbox: machine should not exist

15 tests, 0 failures

@ehazlett
Copy link
Contributor Author

/cc @sthulb @nathanleclaire

@aluzzardi
Copy link

This looks awesome :)

Looking forward to use bats for docker-archive/classicswarm#376

}

@test "cli: show config help" {
run ./docker-machine_$PLATFORM-$ARCH config -h

Choose a reason for hiding this comment

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

Minor nit:

I think you could define a function somewhere, say machine that does the run with $PLATFORM-$ARCH etc so that you could write instead:

machine config -h

So you won't have to repeat this every time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1 thx!

@sthulb
Copy link
Contributor

sthulb commented Feb 25, 2015

This looks great! I could think of a few places to use it at work :)

@nathanleclaire
Copy link
Contributor

Sweet! Will have to give it a whirl.

@ehazlett ehazlett force-pushed the integration-testing branch 3 times, most recently from d45d36c to e3d0adb Compare February 26, 2015 22:24
@ehazlett ehazlett force-pushed the integration-testing branch from adef019 to 46d92fc Compare February 27, 2015 17:39
@ehazlett ehazlett changed the title WIP: switch to bats for integration testing switch to bats for integration testing Feb 27, 2015
@ehazlett
Copy link
Contributor Author

@nathanleclaire @sthulb PTAL

}

@test "$DRIVER: machine should not exist" {
run machine active $NAME
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a difference between this machine and where you're using docker-machine_$PLATFORM_$ARCH?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no difference. machine is simply a function that returns docker-machine_$PLATFORM_$ARCH

@ehazlett ehazlett self-assigned this Mar 2, 2015
@sthulb
Copy link
Contributor

sthulb commented Mar 2, 2015

LGTM. Can we get the core tests added to travis?

@ehazlett
Copy link
Contributor Author

ehazlett commented Mar 2, 2015

@sthulb thanks! i'm going to merge for now. i will check on adding the core tests to travis as i'm not sure what the variable exposure is or whether we want to place keys there. thanks!

ehazlett added a commit that referenced this pull request Mar 2, 2015
switch to bats for integration testing
@ehazlett ehazlett merged commit 7bf67e4 into docker:master Mar 2, 2015
@ehazlett ehazlett deleted the integration-testing branch March 2, 2015 22:24
miketheman added a commit to miketheman/machine that referenced this pull request May 21, 2015
In docker#615, the helper function `machine()` was created and used within the
vmwarefusion test suite (amongst others) to wrap a platform-specfic
binary during the test suite.

In docker#1034, it appears that this name was changed to the normal
docker-machine binary, which can incoke the system-installed one, not
the recently compiled one, potentially testing the incorrect binary.

See:
- docker#615 (comment)
- https://github.com/docker/machine/pull/1034/files#diff-62c88a2fede921556dbdeead731596b2R14
miketheman added a commit to miketheman/machine that referenced this pull request May 21, 2015
In docker#615, the helper function `machine()` was created and used within the
vmwarefusion test suite (amongst others) to wrap a platform-specfic
binary during the test suite.

In docker#1034, it appears that this name was changed to the normal
docker-machine binary, which can incoke the system-installed one, not
the recently compiled one, potentially testing the incorrect binary.

See:
- docker#615 (comment)
- https://github.com/docker/machine/pull/1034/files#diff-62c88a2fede921556dbdeead731596b2R14

Signed-off-by: Mike Fiedler <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants