~caio1982/mojo/local_repo_keys

« back to all changes in this revision

Viewing changes to contrib/LXD/container/build_mojo_lxd.sh

  • Committer: Tom Haddon
  • Date: 2016-01-18 09:23:35 UTC
  • mfrom: (253.1.6 mojo-lxd)
  • Revision ID: tom.haddon@canonical.com-20160118092335-i7bh09hne6pfdboq
[timkuhlman,r=mthaddon] create an initial integration test environment using LXD

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# Build a mojo image for development and testing of mojo (https://mojo.canonical.com)
 
4
#
 
5
# Pre-reqs:
 
6
#   - An image named trusty - https://linuxcontainers.org/lxd/getting-started-cli/
 
7
 
 
8
#Launch the container
 
9
#name=mojo-$(date +%Y-%m-%d)  # Useful if you are testing multiple versions.
 
10
name=mojo
 
11
 
 
12
lxc launch trusty mojo -c security.privileged=true -c security.nesting=true
 
13
# unprivileged works but requires manual creation of the lxc environment and is only practical for
 
14
# non-local juju environments, even then it is difficult to setup the lxc env for mojo
 
15
# lxd in lxd works well unprivileged so hopefully mojo and juju will switch to lxd.
 
16
#lxc launch trusty $name -c security.nesting=true
 
17
sleep 5  # Takes a moment for the network
 
18
 
 
19
# Pre-req install
 
20
lxc exec $name -- apt-get update
 
21
lxc exec $name -- apt-get install -y software-properties-common
 
22
lxc exec $name -- apt-add-repository -y ppa:mojo-maintainers/ppa
 
23
# The latest or at least backports version of lxc is needed for working with nesting.
 
24
lxc exec $name -- apt-add-repository -y ppa:ubuntu-lxc/daily
 
25
lxc exec $name -- apt-get update
 
26
lxc exec $name -- apt-get dist-upgrade -y
 
27
# python swiftclient is needed for the mojo-how-to spec most others are build/test deps
 
28
lxc exec $name -- apt-get install -y mojo bzr juju-local devscripts debhelper python-all python-setuptools python-swiftclient python-nose python-coverage python-mock
 
29
 
 
30
#juju bootstrap
 
31
lxc file push ubuntu.sudoers $name/etc/sudoers.d/ubuntu
 
32
lxc exec $name -- su ubuntu -c 'juju generate-config'
 
33
lxc exec $name -- su ubuntu -c 'juju switch local'
 
34
lxc exec $name -- su ubuntu -c 'juju bootstrap'
 
35
 
 
36
# Force a juju image to be cached in the container for quicker integration tests
 
37
lxc exec $name -- su ubuntu -c 'juju add-machine'
 
38
lxc exec $name -- su ubuntu -c 'while $(juju status --format tabular| grep pending > /dev/null); do sleep 30; done; juju machine remove 1;sleep 30'  # That extra 30s is because it takes awhile to remove
 
39
 
 
40
# Setup bzr identity for some of the mojo tests
 
41
lxc exec $name -- su ubuntu -c 'bzr whoami "test <integration@test.com>"'
 
42
 
 
43
# Setup test scripts
 
44
for s in "install-from-branch.sh" "run-mojo-spec.sh"; do
 
45
  lxc file push ./$s $name/home/ubuntu/$s
 
46
  lxc exec $name -- chmod +x /home/ubuntu/$s
 
47
done
 
48
 
 
49
# Setup spec envrc
 
50
for envrc in $(ls *.envrc); do
 
51
  lxc file push ./$envrc $name/home/ubuntu/$envrc
 
52
done
 
53
 
 
54
echo "Now run a shell with 'lxc exec $name -- su - ubuntu'"
 
55
echo "Then you can branch mojo install it and run integration tests, or branch a new spec to test."
 
56
echo "Refer to README.md in the container for more information"