README ¶
This directory contains integration tests for weave.
Requirements
You need three VMs with docker
(>=1.10.0
) installed and listening on TCP
port 2375
(see below). You also need to be able to SSH to these VMs without
having to input anything.
The Vagrantfile
in this directory constructs three such VMs.
If you are building Weave Net using Vagrant, it is recommended to run the tests from the build VM and not the host.
NOTE WELL The number of hosts required by a test must be specified in the test name. For example,
000_some_test.sh
will use one host, while001_some_other_3_test.sh
will use three hosts. The number of hosts must be the last part of the test name before the_test.sh
prefix. See/tools/runner/runner.go
for details
Running tests locally using VMs
TL;DR: You can run the steps 2. to 7. below with one command:
make PROVIDER=vagrant integration-tests
Detailed steps:
-
Start the build virtual machine (see above article for more details):
vagrant up
-
Start the three testing VMs:
cd test vagrant up
-
SSH into the build VM and go to Weave Net's sources:
cd .. vagrant ssh # you are now on the build VM: cd ~/weave
-
Compile all code and dependencies:
make make testrunner cd test
-
Upload the weave images from where the
Makefile
puts them (weave.tar.gz
) to the three docker hosts,docker load
these, and copies theweave
script over:./setup.sh
-
Run individual tests, e.g.:
./200_dns_test.sh
or run all tests (everything named
*_test.sh
):./run_all.sh
-
Stop all VMs:
exit # you are now on your host machine vagrant destroy -f cd test vagrant destroy -f
Using other VMs
By default the tests assume the Vagrant VMs are used.
To use other VMs, set the environment variable HOSTS to the
space-separated list of IP addresses of the docker hosts, and set the
environment variable SSH to a command that will log into
either (which may just be ssh
).
Making docker available over TCP
To make docker listen to a TCP socket, you will usually need to either
run it manually with an option like -H tcp://0.0.0.0:2375
; or, for
apt-get installed docker (Ubuntu and Debian), add the line
DOCKER_OPTS="--host unix:///var/run/docker.sock --host tcp://0.0.0.0:2375"
to the file /etc/default/docker
, then restart docker.
Updating the GCE test image
When a new version of Docker is released, you willneed to update the GCE test image.
To do this, change the Docker version in run-integration-tests.sh
and push the change.
Next build in CircleCI will detect that there is no template for this version of Docker and will first create the template before running tests.
Subsequent builds will then simply re-use the template.
Running the tests on a cloud provider
Running the tests against a remote provider instead of local vagrant VMs is a little more involved, and reproduces the environment used for CI. It is recommended that you use the build VM to coordinate the build phase. Make sure you have a recent version of ansible installed, terraform will fail to provision the VMs.
-
Create the build VM in the repository root and log in
# On your development machine $ vagrant up $ vagrant ssh
-
Once in the build vm, install the
gcloud
tools as per the documentation. You need to do this manually as the circleCI VMs are already provisioned withgcloud
.# On the build VM $ curl https://sdk.cloud.google.com | bash $ exec -l $SHELL
You don't need to initialise the
gcloud
tools by runninggcloud init
. -
Export the secret key needed to decrypt the cloud credentials - This assumes you're using the build tools
# On the build VM $ export SECRET_KEY="XXXXXXXXXX"
-
Navigate to the test directory and provision the VMs
# On the build VM $ cd weave/test /weave/test$ ./run-integration-tests.sh up
-
Run the tests you need
# On the build VM /weave/test$ export TESTS="./090_docker_restart_policy_2_test.sh" /weave/test$ ./run-integration-tests.sh test
-
Don't forget to close down your remote VMs when you're done
# On the build VM /weave/test$ ./run-integration-tests.sh destroy
-
And switch off your build VM
# On the build VM /weave/test$ exit # On your development machine $ vagrant destroy -f # or "vagrant suspend" if you want to preserve the machine state
Directories ¶
Path | Synopsis |
---|---|
images
|
|
network-tester
A tiny web server for checking networking connectivity.
|
A tiny web server for checking networking connectivity. |