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

Factoring Bats tests #1023

Closed
wants to merge 5 commits into from

Conversation

vincentbernat
Copy link
Contributor

Hey!

I noticed that many driver Bats tests are just copy/paste of another one. I wanted to factor them to avoid divergence between tests. The first commits are just a normalization step for the last commit. Unfortunately, I understood how Bats work only at the end (when I wanted to test the changes): it uses a preprocessing phase to replace the @test markers, so it is currently not possible to put common tests into another file. I have opened an issue about this: sstephenson/bats#99

Until there is a solution, this PR is useless. I just push it here for reference, in case there is a workaround. Feel free to close it if you don't like unresolvable PR to hang around.

Docker commands over the local socket was only tested for a few
drivers. Test for all drivers. Also explicitely test for the return
code.

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
The comment seems to say this is a leftover of a copy/paste from the
VirtualBox test. If not, the comment should be udpated.

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
Use the same test as for other drivers by not trying to match a star.

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
Use the same test as for other drivers by using the `-f` flag.

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
Most driver integration tests are the same. We split those common tests
into three files: machine creation testing (including ability to run
containers and get info about them), machine stop/start cycle testing
and machine destruction and cleanup.

The only special cases are:

 - virtualbox driver comes with many more test cases
 - rackspace driver doesn't support start/stop commands

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
@ehazlett
Copy link
Contributor

@vincentbernat yeah i tried the same thing :) Thanks for the PR -- hopefully we'll get inclusion and can remove the boilerplate. Thanks!

@nathanleclaire
Copy link
Contributor

I think that we might be able to make this type of thing work if we wrapped the calls to bats with our own script. Discussion: sstephenson/bats#100

E.g., test/integration/run.sh virtualbox, would set the NAME and DRIVER environment variables based on $1, and then call bats b2dcommon.bats which contains common tests.

@ehazlett
Copy link
Contributor

@nathanleclaire what does this mean for #1158?

@vincentbernat
Copy link
Contributor Author

@ehazlett don't bother with this PR, I'll check the other PR when it is done.

@ehazlett
Copy link
Contributor

Thanks!

@greut greut deleted the fix/factor-bats-tests branch March 22, 2018 08:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants