Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
fa92625
add Vagrant-based smoke tests for pure Docker deployments
Jul 29, 2020
54b7318
fixup!
Jul 31, 2020
513666f
wip
Aug 7, 2020
2c602a6
wip
Aug 7, 2020
fb9570e
wip
Aug 7, 2020
5012538
f
Aug 7, 2020
a127852
fixup!
Aug 7, 2020
3ac3b05
fixup!
Aug 7, 2020
0bc38df
fixup!
Aug 12, 2020
1128700
fixup!
Aug 12, 2020
8a0fe40
fixup!
Aug 13, 2020
ce5c2e1
fixup!
Aug 13, 2020
fdd0198
rebuild!
Aug 13, 2020
d8da349
is this why its so unstable?
Aug 13, 2020
6bb182d
Merge remote-tracking branch 'origin/master' into sg/customer-replica…
Aug 13, 2020
0a05d47
disable until baremetal agents are stable
Aug 13, 2020
0fa8c9c
chmod +x
Aug 13, 2020
19cc668
testing vagrant configs
Aug 14, 2020
e3454e4
upping spec, fixing directory
Aug 14, 2020
741e430
disable smoketest to troubleshoot vagrant
Aug 14, 2020
2ee171f
reenable testing for vagrant
Aug 14, 2020
04b76e7
linting
Aug 14, 2020
e7d5331
fix docker script
Aug 14, 2020
a94cdde
more testing
Aug 14, 2020
905b9d6
is this key broken
Aug 14, 2020
2bfeba9
testing servers.yaml
Aug 15, 2020
229143c
test prebuilt box
Aug 18, 2020
6aa777e
remove asdf for now
Aug 18, 2020
99dc82c
why isn't vagrant working
Aug 18, 2020
13fe0c7
fully qualify path
Aug 18, 2020
aa6873e
more testing
Aug 18, 2020
07f21de
remove changes
Aug 18, 2020
44f26d0
whereami?
Aug 18, 2020
665837b
why did I delete this
Aug 18, 2020
bdbbf3a
test google plugin
Aug 18, 2020
48858ca
run with sudo
Aug 18, 2020
0875405
remove sudo, add volume for code intel bundle manager
Aug 18, 2020
fbd4a5f
test bridge network
Aug 19, 2020
bfd12eb
specify provider
Aug 19, 2020
d0e92cc
fix provider in the correct spot
Aug 19, 2020
00226e3
bump cpu count
Aug 19, 2020
de9de46
bump up boot timeout
Aug 19, 2020
74a0762
add check for google plugin, use bento box
Aug 19, 2020
550f863
fix if clause
Aug 19, 2020
a3324c1
fix if clause
Aug 19, 2020
1787ccb
take out cpus for test
Aug 19, 2020
029ceb5
why does it work with less cpu?
Aug 19, 2020
1b0f3ff
less cpu
Aug 20, 2020
966a82c
testing with time
Aug 20, 2020
ce55082
2 cpu
Aug 20, 2020
2590020
4 cpu
Aug 20, 2020
302f708
8 cpu 4gb mem
Aug 20, 2020
dbbc35b
16 cpu
Aug 20, 2020
53f367b
8 cpu 20gb install w deploy
Aug 20, 2020
f8698cc
is this going to work
Aug 20, 2020
c576b8f
remove prettier check for now
Aug 20, 2020
d6c84fb
take out cpus
Aug 20, 2020
fa23906
regex
Aug 20, 2020
a900490
lowering cpu for zoekt
Aug 20, 2020
b599056
remove sed command
Aug 20, 2020
7820f38
move sed to servers.yaml and test 4cpus
Aug 20, 2020
01d5c2d
test 8 cpus and 16gb
Aug 20, 2020
157fde3
8cpu 8gb
Aug 20, 2020
3bc08f3
why can't buildkite find asdf
Aug 20, 2020
fe952e3
testing
Aug 20, 2020
c887f96
what's my env?
Aug 20, 2020
3f8c408
fix path in pipeline.yaml
Aug 20, 2020
b709d03
remove comments, revery cpu changes
Aug 21, 2020
59c5fc8
uppdate pipeline.yaml for new tests
Aug 21, 2020
45aacda
add nodejs to asdf toolversions
Aug 21, 2020
6e8595b
merge master
Aug 21, 2020
c2a262a
build boxes with Vagrant file
Aug 24, 2020
75d38c1
testing without pinning nodejs
Aug 24, 2020
d215374
testing path
Aug 25, 2020
58fcebf
Revert "testing without pinning nodejs"
Aug 25, 2020
f08eb82
remove path
Aug 25, 2020
c8adec4
test with full specs for vagrant
Aug 25, 2020
5cbc469
remove virtualbox, change user for lsif volume
Aug 26, 2020
e1c2111
change server name
Aug 26, 2020
8a4ded4
fix username for CI
Aug 26, 2020
1d42fad
testing no external IP
Aug 26, 2020
9bc29e0
make network configurable
Aug 26, 2020
588059a
ensure all network params can be configured
Aug 26, 2020
116f495
add dev and ci box, add instructions
Aug 26, 2020
20c2558
fix looping over shell
Aug 27, 2020
6b9ee94
fix wording in testing instructions
Aug 27, 2020
e8db8f0
use sourcegraph-ci project
Aug 27, 2020
4552e6d
Vagrant suggestions (#142)
pecigonzalo Aug 28, 2020
ea75622
add TESTING.md, restore docker install
Aug 31, 2020
b560ae8
RELEASING: cleanup
Aug 31, 2020
6399d0d
restore volume setup
Sep 1, 2020
7a87c19
Merge branch 'e2e_testing' of github.com:sourcegraph/deploy-sourcegra…
Sep 1, 2020
bd787b1
escape hatch for failing apt-get command
Sep 1, 2020
e70e62b
cleanup any hanging machines from failed build steps
Sep 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .buildkite/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

cd "$(dirname "${BASH_SOURCE[0]}")/.."
set -euxo pipefail

cd test/pure-docker/

vagrant destroy -f
2 changes: 1 addition & 1 deletion .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ then
fi

echo "Installing asdf dependencies as defined in '$BUILDKITE_BUILD_CHECKOUT_PATH/.tool-versions':"
asdf install
asdf install
24 changes: 16 additions & 8 deletions .buildkite/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ $schema: 'http://json.schemastore.org/buildkite'
steps:
- label: ':docker:'
command: .buildkite/validate-docker-compose.sh
agents:
queue: 'baremetal'
- label: ':lipstick:'
command: .buildkite/prettier-check.sh
#
# TODO: re-enable this!
# Disabled while baremetal agents are unstable, see: https://github.com/sourcegraph/sourcegraph/issues/12996
#
#- label: ':rice:'
# command: .buildkite/test-pure-docker.sh
# agents:
# queue: 'baremetal'
agents:
queue: 'baremetal'
- label: ':rice:'
command: .buildkite/test-pure-docker.sh
agents:
queue: 'baremetal'
env:
VAGRANT_RUN_ENV: 'CI'
- wait: ~
continue_on_failure: true
- label: ':broom:'
command: .buildkite/cleanup.sh
agents:
queue: 'baremetal'
2 changes: 1 addition & 1 deletion .buildkite/prettier-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
cd "$(dirname "${BASH_SOURCE[0]}")/.."
set -euxo pipefail

yarn
yarn
yarn run prettier-check
8 changes: 6 additions & 2 deletions .buildkite/test-pure-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ cd "$(dirname "${BASH_SOURCE[0]}")/.."
set -euxo pipefail

cd test/pure-docker/
vagrant destroy -f pure-docker-test
vagrant up

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
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
yarn 1.19.2
nodejs 13.12.0
Comment thread
davejrt marked this conversation as resolved.
Resolved
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ Then try cloning the repository:
```
$ git clone ssh://git@myhost.com/my/repo /tmp/my-repo
```

## Questions & Issues

[Open an issue (in sourcegraph/sourcegraph)](https://github.com/sourcegraph/sourcegraph/issues/new?assignees=&labels=deploy-sourcegraph-docker&template=deploy-sourcegraph-docker.md&title=%5Bdeploy-sourcegraph-docker%5D) or contact us (support@sourcegraph.com), we are happy to help!
10 changes: 5 additions & 5 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,14 @@ Visit http://localhost and confirm the app loads.

## 5) Confirm Pure-Docker works with a smoke test

This will take about ~10 minutes to run, and you must have a machine with 16 CPUs.

Note: This does NOT run on Buildkite currently, you must run it manually, see https://github.com/sourcegraph/sourcegraph/issues/12996

Install [Vagrant](https://vagrantup.com), then:

```sh
.buildkite/test-pure-docker.sh
```

This will take about ~10 minutes to run. Refer to the [testing documentation](TESTING.md) if you run into issues / need more instructions.

## 6) Tag the final release

For example:
Expand Down Expand Up @@ -171,12 +169,14 @@ During this process you will run into two merge conflicts:
- Do not commit: `deploy-caddy.sh` or changes related to it, as `deploy-apache.sh` is used here.
- Do not commit: changes to `deploy-pgsql.sh`, as Postgres 9.6 is used here.

Once you have performed the above, you should run a basic smoke test to ensure that `./deploy.sh` on Ubuntu 18.04 causes all services to start up OK, that the frontend is responsive, and that no container UID/GIDs/file permissions have changed (which would be a regression). You can do this with Vagrant:
Once you have performed the above, you should run a basic smoke test to ensure that `./deploy.sh` on Ubuntu 18.04 causes all services to start up OK, that the frontend is responsive, and that no container UID/GIDs/file permissions have changed (which would be a regression). You can do this by installing [Vagrant](https://vagrantup.com) and running:

```sh
.buildkite/test-pure-docker.sh
```

This will take about ~10 minutes to run. Refer to the [testing documentation](TESTING.md) if you run into issues / need more instructions.

Once you see `ALL TESTS PASSED`, then push the new pure-docker release branch up and tag the release:

```sh
Expand Down
36 changes: 36 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Testing

Developers can test using [Vagrant](https://www.vagrantup.com) and your Sourcegraph GCP account.

- Use [these](https://www.vagrantup.com/docs/index) instructions to install `Vagrant` on your local machine. Once sucessfully installed, install the required plugin:
```
vagrant plugin install vagrant-google
```

- Ensure your credentials are correct by excecuting the command below and following the prompts:
```
gcloud auth application-default login
```

- Configure your local variables using the following environment variables
- `VAGRANT_GCP_PROJECT_ID`: Project to run on. (default: `sourcegraph-server`)
- `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
```
.buildkite/test-pure-docker.sh
```

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).

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:
```
shell_commands:
- [...]
- /vagrant/moretests.sh
- "ps aux | grep thisthat"
- |
cd /vagrant
bartest.sh
```
2 changes: 2 additions & 0 deletions deploy-precise-code-intel-bundle-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ source ./replicas.sh
# Ports exposed to other Sourcegraph services: 3187/TCP
# Ports exposed to the public internet: none
#
VOLUME="$HOME/sourcegraph-docker/lsif-server-disk"
./ensure-volume.sh $VOLUME 100
docker run --detach \
--name=precise-code-intel-bundle-manager \
--network=sourcegraph \
Expand Down
118 changes: 57 additions & 61 deletions test/pure-docker/Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,68 +1,64 @@
# -*- mode: ruby -*-
Comment thread
emidoots marked this conversation as resolved.
Resolved
# vi: set ft=ruby :
# # vi: set ft=ruby :
# Specify minimum Vagrant version and Vagrant API version
Vagrant.require_version '>= 1.6.0'
VAGRANTFILE_API_VERSION = '2'.freeze
# Require YAML module
require 'yaml'

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.synced_folder "../../", "/deploy-sourcegraph-docker"
config.vm.define "pure-docker-test"
config.vm.hostname = "pure-docker-test"
# Read YAML file with box details
servers = YAML.load_file('servers.yaml')
# Create boxes
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Iterate through entries in YAML file
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.boot_timeout = 600

# config.vm.network "forwarded_port", guest: 80, host: 8080
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
# Setup for CI or Local
case ENV['VAGRANT_RUN_ENV']
when 'CI'
project_id = server['project_id']
external_ip = server['external_ip']
use_private_ip = server['use_private_ip']
username = server['username']
ssh_key_path = server['ssh_key_path']
else
project_id = ENV['VAGRANT_GCP_PROJECT_ID'] || 'sourcegraph-server'
external_ip = nil
use_private_ip = false
username = ENV['VAGRANT_SSH_USER'] || ENV['USER']
ssh_key_path = ENV['VAGRANT_SSH_KEY'] || '~/.ssh/id_rsa'
end

config.vm.provider "virtualbox" do |v|
# Customize the amount of memory on the VM:
v.memory = "20480"
v.cpus = 16
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end

config.vm.provision "shell", inline: <<-SHELL
#!/usr/bin/env bash
set -euxo pipefail

apt-get update

# Configure nameserver to avoid some DNS failures.
echo nameserver 8.8.8.8 > /etc/resolv.conf
srv.vm.provider :google do |g, o|
g.machine_type = server['machine_type']
g.image_family = 'ubuntu-1804-lts'
g.google_project_id = project_id
g.network = server['network']
g.external_ip = external_ip
g.use_private_ip = use_private_ip
o.ssh.username = username
o.ssh.private_key_path = ssh_key_path
end

# Install Docker
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-ce docker-ce-cli containerd.io
srv.vm.provision 'shell', inline: <<-SHELL
#!/usr/bin/env bash
set -euxo pipefail
apt-get update
# Install Docker
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
SHELL

# Create volume directories.
cd /deploy-sourcegraph-docker
echo
echo "creating deployment for volume directories"
echo
./deploy.sh
echo
echo "tearing down deployment for volume directories"
echo
./teardown.sh

# Set permissions on volume directories.
#
# IMPORTANT: If these change, or a new service is introduced, it must be explicitly called out in
# https://docs.sourcegraph.com/admin/updates/pure_docker similar to https://docs.sourcegraph.com/admin/updates/pure_docker#v3-12-5-v3-13-2-changes
echo
echo "forcing static permissions on volume directories"
echo
pushd ~/sourcegraph-docker
chown -R 100:101 gitserver* lsif-server* prometheus-v2* repo-updater* searcher* sourcegraph-frontend* symbols* zoekt*
chown -R 999:1000 redis-store-disk redis-cache-disk
chown -R 472:472 grafana-disk
chown -R 999:999 pgsql-disk
popd
echo
echo "creating deployment"
echo
./deploy.sh
SHELL

config.vm.provision "shell", path: "smoke-test.sh"
server['shell_commands'].each do |sh|
srv.vm.provision 'shell', inline: sh
end
end
end
end
16 changes: 16 additions & 0 deletions test/pure-docker/servers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- 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:
Comment thread
davejrt marked this conversation as resolved.
Resolved
- "/deploy-sourcegraph-docker/test/pure-docker/setup.sh"
- |
cd /deploy-sourcegraph-docker
./deploy.sh
- "/deploy-sourcegraph-docker/test/pure-docker/smoke-test.sh"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you have removed all of the logic I had for ensuring that permissions on volume directories hasn't changed: https://github.com/sourcegraph/deploy-sourcegraph-docker/pull/141/files#diff-b584b34513d743c4570b69a661750e14L37-L64

We need to add this back, we can't remove it because this is a really important property to test for. The customer using this, https://app.hubspot.com/contacts/2762526/company/407948923/ does not have the ./ensure-volume.sh $VOLUME 100 invocations and that must be communicated through the upgrading docs as I said here: https://github.com/sourcegraph/deploy-sourcegraph-docker/pull/141/files#diff-b584b34513d743c4570b69a661750e14L50-L51

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a PR with the information pending here

All of the deploy-.sh scripts that require a volume now envoke ensure-volume.sh. Is this customer running a specific fork that doesn't include that? If so, wouldn't it make more sense for them to have that script?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how to avoid this confusion, but see the README of this repository for an explanation of what pure-docker deployments actually are:

The goal is that anyone using a container management platform other than Kubernetes (Netflix's Titus, Apache's Mesos, etc.) would be able to use this repository as a reference for how to deploy Sourcegraph.

The point being the customer in question does NOT run the scripts in this repository, and any time there are changes in volume permissions etc. they need to know about those precisely because it means they need to be able to adapt those to their deployment in their own way. It's not a fork - it's the way they were intended to consume this repository (as a reference)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point being: we need these lines to still exist in this test somewhere, removing them means we can't in good faith release pure docker to this customer and the test becomes effectively useless

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most obvious solution to me here is to remove the deploy.sh call above and move all of this logic (deployment and other smoke tests) directly into smoke-test.sh - I am happy to do that now if you're OK with that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: It's not really clear what should be in shell commands here vs. in smoke-test.sh

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I am inclined to put the heavy duty tasks in the scripts ie: setting up volumes, testing and then execute those scripts in the shell commands.

Previously when I've used this harness I'd been a quick and easy way to just comment out a script in shell commands if I've wanted to run the vagrant box then ssh in to manually test or tweak things before committing them.

FYI I've moved the setup and configuration part of the test process into a new script, and the testing itself is still done with smoke-test.sh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My 2c, I would think of it the same way you think about the CI pipeline yaml.

  • Steps are listed in the yaml
  • Each step is unit of work that does not know about the others

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't block this further because I am content with this as-is, so feel free to merge.

But the organization here still doesn't make much sense to me.

  • setup.sh doesn't install dependencies, the Vagrantfile does
  • The main property being tested by these tests is in fact the static permissions on volume directories, but we've placed that in a setup.sh file - why is testing done in a setup file? Should this be renamed to perms-test.sh?
  • smoke-test.sh relies on the work that setup.sh is doing by setting up the volume directories - when this test fails in smoke-test.sh because a container fails to come up with e.g. wrong permissions, someone will need to find setup.sh and fix permissions there. This seems not super intuitive to me.
  • servers.yaml is calling deploy.sh and is "responsible for starting the deployment" but smoke-test.sh is responsible for actually ensuring the containers came up OK?

Maybe I am missing something, but the structure that would make a lot more sense to me is:

  • servers.yaml only calls smoke-test.sh, nothing else.
  • everything in setup.sh currently goes into smoke-test.sh
  • dependency installation goes into an external script setup.sh (and thus Vagrantfile becomes something we can just copy for other test suites in the future.)

26 changes: 26 additions & 0 deletions test/pure-docker/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Create volume directories.
cd /deploy-sourcegraph-docker
echo
echo "creating deployment for volume directories"
echo
./deploy.sh
echo
echo "tearing down deployment for volume directories"
echo
./teardown.sh
# Set permissions on volume directories.
#
# IMPORTANT: If these change, or a new service is introduced, it must be explicitly called out in
# https://docs.sourcegraph.com/admin/updates/pure_docker similar to https://docs.sourcegraph.com/admin/updates/pure_docker#v3-12-5-v3-13-2-changes
echo
echo "forcing static permissions on volume directories"
echo
pushd ~/sourcegraph-docker
chown -R 100:101 gitserver* lsif-server* prometheus-v2* repo-updater* searcher* sourcegraph-frontend* symbols* zoekt*
chown -R 999:1000 redis-store-disk redis-cache-disk
chown -R 472:472 grafana-disk
chown -R 999:999 pgsql-disk
popd
echo "Ready to deploy"