mirror of
https://github.com/RustyRaptor/deploy-sourcegraph-docker.git
synced 2026-12-05 16:55:24 -07:00
qa: add logging (#186)
* increase logging * refactor scripts with less repeated code.
This commit is contained in:
1 parent
9043cf0fed
commit
13e09d2d19
12 files changed
+109
-154
No files matched your search
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
set -euxo pipefail
|
||||
|
||||
cd test/
|
||||
|
||||
vagrant destroy -f
|
||||
+11
-13
@@ -1,4 +1,7 @@
|
||||
$schema: 'http://json.schemastore.org/buildkite'
|
||||
env:
|
||||
IMAGE: 'e2e-491e9f27-2020-10-28t17-32-00z'
|
||||
VAGRANT_RUN_ENV: 'CI'
|
||||
steps:
|
||||
- label: ':docker:'
|
||||
command: .buildkite/validate-docker-compose.sh
|
||||
@@ -8,22 +11,17 @@ steps:
|
||||
command: .buildkite/prettier-check.sh
|
||||
agents:
|
||||
queue: 'baremetal'
|
||||
- label: ':rice:'
|
||||
command: .buildkite/test.sh pure-docker-test
|
||||
- label: ':rice: pure-docker-test'
|
||||
command: .buildkite/vagrant-run.sh docker-test
|
||||
artifact_paths: ./*.log
|
||||
agents:
|
||||
queue: 'baremetal'
|
||||
env:
|
||||
VAGRANT_RUN_ENV: 'CI'
|
||||
- label: ':rice:'
|
||||
command: .buildkite/test.sh docker-compose-test
|
||||
TEST_TYPE: 'pure-docker-test'
|
||||
- label: ':rice: docker-compose-test'
|
||||
command: .buildkite/vagrant-run.sh docker-test
|
||||
artifact_paths: ./*.log
|
||||
agents:
|
||||
queue: 'baremetal'
|
||||
env:
|
||||
VAGRANT_RUN_ENV: 'CI'
|
||||
- wait: ~
|
||||
continue_on_failure: true
|
||||
- label: ':broom:'
|
||||
command: .buildkite/cleanup.sh
|
||||
parallelism: 5
|
||||
agents:
|
||||
queue: 'baremetal'
|
||||
TEST_TYPE: 'docker-compose-test'
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
set -euxo pipefail
|
||||
|
||||
box=$1
|
||||
exit_code=0
|
||||
|
||||
cd test/
|
||||
|
||||
plugins=(vagrant-google vagrant-env vagrant-scp)
|
||||
for i in "${plugins[@]}"; do
|
||||
if ! vagrant plugin list --no-tty | grep "$i"; then
|
||||
vagrant plugin install "$i"
|
||||
fi
|
||||
done
|
||||
|
||||
vagrant up $box --provider=google || exit_code=$?
|
||||
vagrant destroy -f $box
|
||||
|
||||
if [ "$exit_code" != 0 ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
set -euxo pipefail
|
||||
|
||||
box="$1"
|
||||
exit_code=0
|
||||
|
||||
pushd "test"
|
||||
|
||||
cleanup() {
|
||||
vagrant destroy -f "$box"
|
||||
}
|
||||
|
||||
plugins=(vagrant-google vagrant-env vagrant-scp)
|
||||
for i in "${plugins[@]}"; do
|
||||
if ! vagrant plugin list --no-tty | grep "$i"; then
|
||||
vagrant plugin install "$i"
|
||||
fi
|
||||
done
|
||||
|
||||
trap cleanup EXIT
|
||||
vagrant up "$box" --provider=google || exit_code=$?
|
||||
|
||||
if [ "$exit_code" != 0 ]; then
|
||||
vagrant scp "${box}:/deploy-sourcegraph-docker/*.log" ../
|
||||
exit $exit_code
|
||||
fi
|
||||
@@ -7,5 +7,6 @@ nginx/sourcegraph.key
|
||||
|
||||
.vagrant
|
||||
*.log
|
||||
.env
|
||||
|
||||
/right.dhall
|
||||
@@ -1,2 +1,3 @@
|
||||
yarn 1.19.2
|
||||
shellcheck 0.7.1
|
||||
nodejs 13.12.0
|
||||
Vendored
+2
-4
@@ -9,9 +9,6 @@ require 'yaml'
|
||||
# Read YAML file with box details
|
||||
servers = YAML.load_file('servers.yaml')
|
||||
|
||||
# Base image to use for test instances
|
||||
image = 'e2e-491e9f27-2020-10-28t17-32-00z'
|
||||
|
||||
# Create boxes
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
# Iterate through entries in YAML file
|
||||
@@ -40,7 +37,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
|
||||
srv.vm.provider :google do |g, o|
|
||||
g.machine_type = server['machine_type']
|
||||
g.image = image
|
||||
g.image = ENV['IMAGE']
|
||||
g.image_project_id = 'sourcegraph-ci'
|
||||
g.google_project_id = project_id
|
||||
g.name = "#{server['name']}-"+"#{Time.now.to_i}"
|
||||
@@ -55,6 +52,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
#!/usr/bin/env bash
|
||||
cat << EOF >> /root/.profile
|
||||
export GIT_BRANCH=#{ENV['BUILDKITE_BRANCH']}
|
||||
export TEST_TYPE=#{ENV['TEST_TYPE']}
|
||||
EOF
|
||||
SHELL
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eufo pipefail
|
||||
|
||||
cd /deploy-sourcegraph-docker/docker-compose
|
||||
sudo su
|
||||
|
||||
docker-compose up -d
|
||||
|
||||
expect_containers="22"
|
||||
|
||||
echo "Giving containers 30s to start..."
|
||||
sleep 30
|
||||
|
||||
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"
|
||||
echo containers
|
||||
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"
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eufxo pipefail
|
||||
|
||||
cd /deploy-sourcegraph-docker
|
||||
sudo su
|
||||
|
||||
#Deploy sourcegraph
|
||||
./deploy.sh
|
||||
|
||||
if [[ "$GIT_BRANCH" == *"customer-replica"* ]]; then
|
||||
# Expected number of containers on e.g. 3.18-customer-replica branch.
|
||||
expect_containers="59"
|
||||
else
|
||||
# Expected number of containers on `master` branch.
|
||||
expect_containers="24"
|
||||
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"
|
||||
+2
-15
@@ -1,5 +1,5 @@
|
||||
---
|
||||
- name: pure-docker-test
|
||||
- name: docker-test
|
||||
box: google/gce
|
||||
machine_type: "custom-16-20480"
|
||||
project_id: sourcegraph-ci
|
||||
@@ -9,18 +9,5 @@
|
||||
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"
|
||||
- "/deploy-sourcegraph-docker/test/smoke-test.sh"
|
||||
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eufo pipefail
|
||||
|
||||
deploy_sourcegraph() {
|
||||
cd $(dirname "${BASH_SOURCE[0]}")/..
|
||||
#Deploy sourcegraph
|
||||
if [[ "$TEST_TYPE" == "pure-docker-test" ]]; then
|
||||
./test/volume-config.sh
|
||||
./deploy.sh
|
||||
|
||||
if [[ "$GIT_BRANCH" == *"customer-replica"* ]]; then
|
||||
# Expected number of containers on e.g. 3.18-customer-replica branch.
|
||||
expect_containers="59"
|
||||
else
|
||||
# Expected number of containers on `master` branch.
|
||||
expect_containers="24"
|
||||
fi
|
||||
elif [[ "$TEST_TYPE" == "docker-compose-test" ]]; then
|
||||
docker-compose --file docker-compose/docker-compose.yaml up -d
|
||||
expect_containers="22"
|
||||
fi
|
||||
|
||||
echo "Giving containers 30s to start..."
|
||||
sleep 30
|
||||
}
|
||||
|
||||
test_count() {
|
||||
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
|
||||
}
|
||||
|
||||
test_containers() {
|
||||
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 -c "running")
|
||||
if [[ "$containers_running" -ne "$expect_containers" ]]; then
|
||||
echo
|
||||
containers_failing=$(docker ps --format '{{.Names}}:{{.Status}}' | grep -v Up | cut -f 1 -d :)
|
||||
echo "TEST FAILURE: expected $expect_containers containers running, found $containers_running. The following containers are failing: $containers_failing"
|
||||
echo ""
|
||||
for cf in $containers_failing; do docker logs -t "$cf" >/deploy-sourcegraph-docker/"$cf".log; done
|
||||
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"
|
||||
}
|
||||
|
||||
deploy_sourcegraph
|
||||
test_count
|
||||
test_containers
|
||||
File renamed without changes.
Reference in new issue
Block a user