From e71919226bddfc81d0ceaf5c3ffd64aabccaeb0a Mon Sep 17 00:00:00 2001 From: Brice Fernandes Date: Fri, 20 Oct 2017 15:07:22 +0100 Subject: [PATCH 1/5] Add cloud build instructions to test readme --- test/README.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/test/README.md b/test/README.md index 10660a0c..8c39be6f 100644 --- a/test/README.md +++ b/test/README.md @@ -92,3 +92,59 @@ When a new version of Docker is released, you willneed to update the GCE test im 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. + +1. Create the build VM in the repository root and log in + + ``` + ➤ vagrant up + # ... + ➤ vagrant ssh + ``` + +2. Once in the build vm, install the `gcloud` tools as [per the documentation](https://cloud.google.com/sdk/downloads). You need to do this manually as the circleCI VMs are already provisioned with `gcloud`. + + ``` + vagrant@vagrant:~$ curl https://sdk.cloud.google.com | bash + # ... + vagrant@vagrant:~$ exec -l $SHELL + ``` + + You don't need to initialise the `gcloud` tools by running `gcloud init`. + +3. Export the secret key needed to decrypt the cloud credentials - This assumes you're using the build tools + + ``` + vagrant@vagrant:~$ export SECRET_KEY="XXXXXXXXXX" + ``` + +4. Navigate to the test directory and provision the VMs + + ``` + vagrant@vagrant:~$ cd weave/test + vagrant@vagrant:~/weave/test$ ./run-integration-tests.sh up + #... + ``` +5. Run the tests you need + + ``` + vagrant@vagrant:~/weave/test$ export TESTS="./090_docker_restart_policy_2_test.sh" + vagrant@vagrant:~/weave/test$ ./run-integration-tests.sh test + ``` + +6. Don't forget to close down your remote VMs when you're done + + ``` + vagrant@vagrant:~/weave/test$ ./run-integration-tests.sh destroy + ``` + +7. And switch off your build VM + + ``` + vagrant@vagrant:~/weave/test$ exit + ➤ vagrant destroy -f + # or "vagrant suspend" if you want to preserve the machine state + ``` \ No newline at end of file From ae59a053b1ac0f71bc84d02c191b2424337c6bd6 Mon Sep 17 00:00:00 2001 From: Brice Fernandes Date: Mon, 8 Jan 2018 16:45:00 +0000 Subject: [PATCH 2/5] Improve readme formatting --- test/README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/README.md b/test/README.md index 8c39be6f..0625f100 100644 --- a/test/README.md +++ b/test/README.md @@ -13,7 +13,7 @@ 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, while `001_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 +## Running tests locally using VMs **TL;DR**: You can run the steps 2. to 7. below with one command: @@ -23,46 +23,62 @@ it is recommended to run the tests from the build VM and not the host. 1. Start the build virtual machine (see above article for more details): + ``` vagrant up + ``` 2. Start the three testing VMs: + ``` cd test vagrant up + ``` 3. SSH into the build VM and go to Weave Net's sources: + ``` cd .. vagrant ssh # you are now on the build VM: cd ~/weave + ``` 4. Compile all code and dependencies: + ``` make make testrunner cd test + ``` 5. Upload the weave images from where the `Makefile` puts them (`weave.tar.gz`) to the three docker hosts, `docker load` these, and copies the `weave` script over: + ``` ./setup.sh + ``` 6. Run individual tests, e.g.: + ``` ./200_dns_test.sh + ``` or run all tests (everything named `*_test.sh`): + ``` ./run_all.sh + ``` 7. Stop all VMs: + ``` exit # you are now on your host machine vagrant destroy -f cd test vagrant destroy -f + ``` ## Using other VMs From 3419f69246a68bb283ea3ff9d9fb9f18201198d5 Mon Sep 17 00:00:00 2001 From: Brice Fernandes Date: Tue, 9 Jan 2018 13:41:02 +0000 Subject: [PATCH 3/5] Make sure to mention Ansible in instructions --- test/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/README.md b/test/README.md index 0625f100..090a3f53 100644 --- a/test/README.md +++ b/test/README.md @@ -111,7 +111,7 @@ 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. +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 ahve a recent version of [ansible](https://github.com/ansible/ansible) installed, terraform will fail to provision the VMs. 1. Create the build VM in the repository root and log in From b154fd56fb98a9dd1ffe0f489f12701ecca4491e Mon Sep 17 00:00:00 2001 From: Brice Fernandes Date: Tue, 9 Jan 2018 13:58:07 +0000 Subject: [PATCH 4/5] Fix typo --- test/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/README.md b/test/README.md index 090a3f53..0c97127d 100644 --- a/test/README.md +++ b/test/README.md @@ -111,7 +111,7 @@ 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 ahve a recent version of [ansible](https://github.com/ansible/ansible) installed, terraform will fail to provision the VMs. +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](https://github.com/ansible/ansible) installed, terraform will fail to provision the VMs. 1. Create the build VM in the repository root and log in From 36d183d988a88535bdfa4606f02050f1afaada38 Mon Sep 17 00:00:00 2001 From: Brice Fernandes Date: Tue, 9 Jan 2018 14:51:25 +0000 Subject: [PATCH 5/5] Improve readme --- test/README.md | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/test/README.md b/test/README.md index 0c97127d..89b553e5 100644 --- a/test/README.md +++ b/test/README.md @@ -116,17 +116,17 @@ Running the tests against a remote provider instead of local vagrant VMs is a li 1. Create the build VM in the repository root and log in ``` - ➤ vagrant up - # ... - ➤ vagrant ssh + # On your development machine + $ vagrant up + $ vagrant ssh ``` 2. Once in the build vm, install the `gcloud` tools as [per the documentation](https://cloud.google.com/sdk/downloads). You need to do this manually as the circleCI VMs are already provisioned with `gcloud`. ``` - vagrant@vagrant:~$ curl https://sdk.cloud.google.com | bash - # ... - vagrant@vagrant:~$ exec -l $SHELL + # On the build VM + $ curl https://sdk.cloud.google.com | bash + $ exec -l $SHELL ``` You don't need to initialise the `gcloud` tools by running `gcloud init`. @@ -134,33 +134,39 @@ Running the tests against a remote provider instead of local vagrant VMs is a li 3. Export the secret key needed to decrypt the cloud credentials - This assumes you're using the build tools ``` - vagrant@vagrant:~$ export SECRET_KEY="XXXXXXXXXX" + # On the build VM + $ export SECRET_KEY="XXXXXXXXXX" ``` 4. Navigate to the test directory and provision the VMs ``` - vagrant@vagrant:~$ cd weave/test - vagrant@vagrant:~/weave/test$ ./run-integration-tests.sh up - #... + # On the build VM + $ cd weave/test + /weave/test$ ./run-integration-tests.sh up ``` 5. Run the tests you need ``` - vagrant@vagrant:~/weave/test$ export TESTS="./090_docker_restart_policy_2_test.sh" - vagrant@vagrant:~/weave/test$ ./run-integration-tests.sh test + # On the build VM + /weave/test$ export TESTS="./090_docker_restart_policy_2_test.sh" + /weave/test$ ./run-integration-tests.sh test ``` 6. Don't forget to close down your remote VMs when you're done ``` - vagrant@vagrant:~/weave/test$ ./run-integration-tests.sh destroy + # On the build VM + /weave/test$ ./run-integration-tests.sh destroy ``` 7. And switch off your build VM ``` - vagrant@vagrant:~/weave/test$ exit - ➤ vagrant destroy -f + # 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 ``` \ No newline at end of file