E2e/compose (#150)

* add in compose tests
This commit is contained in:
davejrt authored and GitHub committed 2020-09-10 14:35:23 -05:00
1 parent f86153dcf8
commit 1d0cfbc679
10 files changed
+112 -29

No files matched your search

+1 -1
View File
@@ -3,6 +3,6 @@
cd "$(dirname "${BASH_SOURCE[0]}")/.."
set -euxo pipefail
cd test/pure-docker/
cd test/
vagrant destroy -f
+8 -1
View File
@@ -9,7 +9,13 @@ steps:
agents:
queue: 'baremetal'
- label: ':rice:'
command: .buildkite/test-pure-docker.sh
command: .buildkite/test.sh pure-docker-test
agents:
queue: 'baremetal'
env:
VAGRANT_RUN_ENV: 'CI'
- label: ':rice:'
command: .buildkite/test.sh docker-compose-test
agents:
queue: 'baremetal'
env:
@@ -18,5 +24,6 @@ steps:
continue_on_failure: true
- label: ':broom:'
command: .buildkite/cleanup.sh
parallelism: 5
agents:
queue: 'baremetal'
@@ -3,11 +3,19 @@
cd "$(dirname "${BASH_SOURCE[0]}")/.."
set -euxo pipefail
cd test/pure-docker/
box=$1
exit_code=0
cd test/
if ! vagrant plugin list --no-tty | grep vagrant-google; then
vagrant plugin install vagrant-google
fi
vagrant up pure-docker-test --provider=google
vagrant destroy -f pure-docker-test
vagrant up $box --provider=google || exit_code=$?
vagrant destroy -f $box
if [ "$exit_code" != 0 ]
then
exit 1
fi
+3 -3
View File
@@ -17,12 +17,12 @@ gcloud auth application-default login
- `VAGRANT_SSH_USER`: Your SSH user ID as specified in GCP metadata. (default: `ENV['USER']`)
- `VAGRANT_SSH_KEY`: Path to your SSH Keys as specified in GCP metadata. (default: `~/.ssh/id_rsa`)
- Run the tests
- Run the tests with a `deployment-type-test` where `deployment-type-test` can be `pure-docker-test` or `docker-compose-test`.
```
.buildkite/test-pure-docker.sh
.buildkite/test.sh <deployment-type-test>
```
This command will start a GCP instance, upload your local copy of the reposistory and run a [smoke test](test/pure-docker/smoke-test.sh).
This command will start a GCP instance, upload your local copy of the reposistory and run the relevant smoke test for each deployment type, [pure-docker-test](test/pure-docker/smoke-test.sh) or [docker-compose-test](test/docker-compose/smoke-test.sh).
To run any additional tests or commands, edit [servers.yaml](test/pure-docker/servers.yaml) and add the commands to the `shell_commands` list, eg:
```
+10 -5
View File
@@ -14,7 +14,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
servers.each do |server|
config.vm.define server['name'] do |srv|
srv.vm.box = server['box']
srv.vm.synced_folder '../../', '/deploy-sourcegraph-docker'
srv.vm.synced_folder '../', '/deploy-sourcegraph-docker'
srv.vm.boot_timeout = 600
# Setup for CI or Local
@@ -37,6 +37,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
g.machine_type = server['machine_type']
g.image_family = 'ubuntu-1804-lts'
g.google_project_id = project_id
g.name = "#{server['name']}-"+"#{Time.now.to_i}"
g.network = server['network']
g.external_ip = external_ip
g.use_private_ip = use_private_ip
@@ -47,13 +48,17 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
srv.vm.provision 'shell', inline: <<-SHELL
#!/usr/bin/env bash
set -euxo pipefail
apt-get update
sudo apt-get update
# Install Docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update -y
apt-cache policy docker-ce
apt-get install -y docker-ceasdfasdf docker-ce-cli containerd.io || apt-get install -y docker-ce docker-ce-cli containerd.io
sudo apt-cache policy docker-ce
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
SHELL
server['shell_commands'].each do |sh|
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -eufo pipefail
cd /deploy-sourcegraph-docker/docker-compose
sudo su
docker-compose up -d
branch_or_tag=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match || echo '')
if [[ "$branch_or_tag" == *"customer-replica"* ]]; then
# Expected number of containers on e.g. 3.18-customer-replica branch.
expect_containers="58"
else
# Expected number of containers on `master` branch.
expect_containers="21"
fi
echo "Giving containers 10s to start..."
sleep 10
echo "TEST: Number of expected containers created"
containers_count=$(docker ps --format '{{.Names}}' | wc -l)
if [ "$containers_count" -ne "$expect_containers" ]; then
docker ps --format '{{.Names}}'
echo
echo "TEST FAILURE: expected $expect_containers containers, found $containers_count"
exit 1
fi
echo "TEST: Checking every 10s that containers are running for 5 minutes..."
for i in {0..30}; do
containers=$(docker ps --format '{{.Names}}' | xargs -I{} -n1 sh -c "printf '{}: ' && docker inspect --format '{{.State.Status}}' {}")
containers_running=$(echo "$containers" | grep "running" | wc -l)
if [ "$containers_running" -ne "$expect_containers" ]; then
docker ps
echo
echo "TEST FAILURE: expected $expect_containers containers running, found $containers_running"
exit 1
fi
echo "Containers running OK.. waiting 10s"
sleep 10
done
echo "TEST: Checking frontend is accessible"
curl -f http://localhost:80
curl -f http://localhost:80/healthz
echo "ALL TESTS PASSED"
-16
View File
@@ -1,16 +0,0 @@
---
- name: pure-docker-test
box: google/gce
machine_type: "custom-16-20480"
project_id: sourcegraph-ci
external_ip: false
use_private_ip: true
network: default
username: buildkite
ssh_key_path: "~/.ssh/id_rsa"
shell_commands:
- "/deploy-sourcegraph-docker/test/pure-docker/setup.sh"
- |
cd /deploy-sourcegraph-docker
./deploy.sh
- "/deploy-sourcegraph-docker/test/pure-docker/smoke-test.sh"
+4
View File
@@ -3,6 +3,10 @@ set -eufo pipefail
cd /deploy-sourcegraph-docker
sudo su
#Deploy sourcegraph
./deploy.sh
branch_or_tag=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match || echo '')
if [[ "$branch_or_tag" == *"customer-replica"* ]]; then
File renamed without changes.
+26
View File
@@ -0,0 +1,26 @@
---
- name: pure-docker-test
box: google/gce
machine_type: "custom-16-20480"
project_id: sourcegraph-ci
external_ip: false
use_private_ip: true
network: default
username: buildkite
ssh_key_path: "~/.ssh/id_rsa"
shell_commands:
- "/deploy-sourcegraph-docker/test/pure-docker/volume-config.sh"
- "/deploy-sourcegraph-docker/test/pure-docker/smoke-test.sh"
- name: docker-compose-test
box: google/gce
machine_type: "custom-16-20480"
project_id: sourcegraph-ci
external_ip: false
use_private_ip: true
network: default
username: buildkite
ssh_key_path: "~/.ssh/id_rsa"
shell_commands:
- "/deploy-sourcegraph-docker/test/docker-compose/smoke-test.sh"