docs/test/integration
Dong Chen f5187e9938 Remove internal retry in discovery_check_swarm_info because caller retries are already in place.
Signed-off-by: Dong Chen <dongluo.chen@docker.com>
2016-02-29 13:48:59 -08:00
..
api support docker run --net <node>/<network> 2016-02-23 13:13:31 -08:00
compose support docker run --net <node>/<network> 2016-02-23 13:13:31 -08:00
discovery Remove internal retry in discovery_check_swarm_info because caller retries are already in place. 2016-02-29 13:48:59 -08:00
mesos Merge pull request #1633 from ezrasilvera/mesosCreateNW 2016-02-01 15:17:19 -08:00
nodemanagement Skip one test in Docker 1.9 for runC bug. 2016-02-19 22:33:39 -08:00
testdata support docker run --net <node>/<network> 2016-02-23 13:13:31 -08:00
Dockerfile update_to_go_1.5.3 2016-01-27 03:13:47 -08:00
README.md
affinities.bats Fix integration test - label affinity in parallel 2016-02-04 15:14:46 -08:00
api_version.bats
build_with_filters.bats
cli.bats
constraints.bats
dependency.bats
helpers.bash Remove internal retry in discovery_check_swarm_info because caller retries are already in place. 2016-02-29 13:48:59 -08:00
port-filters.bats
replication.bats
rescheduling.bats add even more tests on rescheduling 2016-02-26 02:00:06 -08:00
resource_management.bats add simple strategy test 2016-01-29 05:50:09 -08:00
run.sh
swarm_id.bats
test_runner.sh Include nodemanagement tests. 2016-02-12 10:06:57 -08:00

README.md

Swarm Integration Tests

Integration tests provide end-to-end testing of Swarm.

While unit tests verify the code is working as expected by relying on mocks and artificially created fixtures, integration tests actually use real docker engines and communicate with Swarm through the CLI.

Note that integration tests do not replace unit tests.

As a rule of thumb, code should be tested thoroughly with unit tests. Integration tests on the other hand are meant to test a specific feature end to end.

Integration tests are written in bash using the bats framework.

Running integration tests

The easiest way to run integration tests is with Docker:

$ test/integration/run.sh

Alternatively, you can run integration tests directly on your host:

$ bats test/integration

In order to do that, you will need to setup a full development environment plus bats

Note: There are known issues running the integration tests using devicemapper as a storage driver, make sure that your docker daemon is using aufs if you want to successfully run the integration tests.

Writing integration tests

[helper functions] (https://github.com/docker/swarm/blob/master/test/integration/helpers.bash) are provided in order to facilitate writing tests.

#!/usr/bin/env bats

# This will load the helpers.
load helpers

@test "this is a simple test" {
	# start_docker will start a given number of engines:
	start_docker 2

	# The address of those engines is available through $HOSTS:
	run docker -H ${HOSTS[0]} info
	# "run" automatically populates $status, $output and $lines.
	# Please refer to bats documentation to find out more.
	[ "$status" -eq 0 ]

	# You can start multiple docker engines in the same test:
	start_docker 1
	# Their address will be *appended* to $HOSTS. Therefore, since this is the 3rd
	# engine started, its index will be 2:
	run docker -H ${HOSTS[2]} info  

	# Additional parameters can be passed to the docker daemon:
	start_docker 1 --label foo=bar

	# swarm_manage will start the swarm manager, preconfigured with all engines
	# previously started by start_engine:
	swarm_manage

	# You can talk with said manager by using the docker_swarm helper:
	run docker_swarm info
	[ "$status" -eq 0 ]
	[ "${lines[1]}"="Nodes: 4" ]
}

# teardown is called at the end of every test.
function teardown() {
	# This will stop the swarm manager:
	swarm_manage_cleanup

	# This will stop and remove all engines launched by the test:
	stop_docker
}