Skip to content

Commit

Permalink
Fix lxc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schmichael committed Jun 22, 2017
1 parent cda2db2 commit 8ed23d4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
29 changes: 11 additions & 18 deletions client/driver/lxc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,12 @@ func TestLxcDriver_Start_Wait(t *testing.T) {
if _, err := d.Prestart(ctx.ExecCtx, task); err != nil {
t.Fatalf("prestart err: %v", err)
}
handle, err := d.Start(ctx.ExecCtx, task)
sresp, err := d.Start(ctx.ExecCtx, task)
if err != nil {
t.Fatalf("err: %v", err)
}
if handle == nil {
t.Fatalf("missing handle")
}

lxcHandle, _ := handle.(*lxcDriverHandle)
lxcHandle, _ := sresp.Handle.(*lxcDriverHandle)

// Destroy the container after the test
defer func() {
Expand Down Expand Up @@ -115,12 +112,12 @@ func TestLxcDriver_Start_Wait(t *testing.T) {
}

// Desroy the container
if err := handle.Kill(); err != nil {
if err := sresp.Handle.Kill(); err != nil {
t.Fatalf("err: %v", err)
}

select {
case res := <-handle.WaitCh():
case res := <-sresp.Handle.WaitCh():
if !res.Successful() {
t.Fatalf("err: %v", res)
}
Expand Down Expand Up @@ -151,23 +148,19 @@ func TestLxcDriver_Open_Wait(t *testing.T) {
if _, err := d.Prestart(ctx.ExecCtx, task); err != nil {
t.Fatalf("prestart err: %v", err)
}
handle, err := d.Start(ctx.ExecCtx, task)
sresp, err := d.Start(ctx.ExecCtx, task)
if err != nil {
t.Fatalf("err: %v", err)
}
if handle == nil {
t.Fatalf("missing handle")
}

// Destroy the container after the test
if lh, ok := handle.(*lxcDriverHandle); ok {
defer func() {
lh.container.Stop()
lh.container.Destroy()
}()
}
lh := sresp.Handle.(*lxcDriverHandle)
defer func() {
lh.container.Stop()
lh.container.Destroy()
}()

handle2, err := d.Open(ctx.ExecCtx, handle.ID())
handle2, err := d.Open(ctx.ExecCtx, lh.ID())
if err != nil {
t.Fatalf("err: %v", err)
}
Expand Down
28 changes: 25 additions & 3 deletions demo/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ echo Fetching Nomad...
cd /tmp/
curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip
echo Installing Nomad...
echo "Installing Nomad..."
unzip nomad.zip
sudo chmod +x nomad
sudo mv nomad /usr/bin/nomad
Expand All @@ -21,16 +21,38 @@ sudo mkdir -p /etc/nomad.d
sudo chmod a+w /etc/nomad.d
# Set hostname's IP to made advertisement Just Work
sudo sed -i -e "s/.*nomad.*/$(ip route get 1 | awk '{print $NF;exit}') nomad/" /etc/hosts
#sudo sed -i -e "s/.*nomad.*/$(ip route get 1 | awk '{print $NF;exit}') nomad/" /etc/hosts
echo "Install Docker..."
if [[ -f /etc/apt/sources.list.d/docker.list ]]; then
echo "Docker repository already installed; Skipping"
else
echo deb https://apt.dockerproject.org/repo ubuntu-`lsb_release -c | awk '{print $2}'` main | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo apt-get update
fi
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker-engine
# Restart docker to make sure we get the latest version of the daemon if there is an upgrade
sudo service docker restart
# Make sure we can actually use docker as the vagrant user
sudo usermod -aG docker vagrant
echo "Installing Consul..."
cd /opt/nomad
bash scripts/install_consul.sh
SCRIPT

Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64" # 16.04 LTS
config.vm.box = "bento/ubuntu-16.04" # 16.04 LTS
config.vm.hostname = "nomad"
config.vm.provision "shell", inline: $script, privileged: false
config.vm.provision "docker" # Just install it

config.vm.synced_folder '../..', '/opt/nomad'

# Increase memory for Parallels Desktop
config.vm.provider "parallels" do |p, o|
p.memory = "1024"
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_consul.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

CONSUL_VERSION="0.7.3"
CONSUL_VERSION="0.8.4"
CURDIR=`pwd`

if [[ $(which consul >/dev/null && consul version | head -n 1 | cut -d ' ' -f 2) == "v$CONSUL_VERSION" ]]; then
Expand Down

0 comments on commit 8ed23d4

Please sign in to comment.