1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
Local Development
-----------------
Development environments can be set of using the setup.py files in the
projects you wish to work on. The easiest approach is to use python-virtualenv.
Since most projects require the ci-utils project, that should almost always
get setup first.
Another quick way to get started is to look at the tarmac.sh script which
sets up a quick environment to run component testing under.
There are two types of services written in this project, Django and Restish.
Development varies slightly between the two.
PPA Assigner
~~~~~~~~~~~~
::
# setup the ppa-assigner project
virtualenv /tmp/venv
. /tmp/venv/bin/activate
./ci-utils/setup.py develop
./ppa-assigner/setup.py develop
# setup for postgres
# uncomment the postgres config in settings.py
sudo ./ppa-assigner/setup.py create_db
Unit-testing can be done with::
# via setuptools
./ppa-assigner/setup.py test
# directly via django
./ppa-assigner/manage.py test # this tests everything (including django)
./ppa-assigner/manage.py test ppa_assigner # just test the project
./ppa-assigner/manage.py test ppa_assigner.TestApi #test one class
./ppa-assigner/manage.py test ppa_assigner.TestApi.testFree # test one method
Ticket System
~~~~~~~~~~~~~
::
# setup the ticket system project
virtualenv /tmp/venv
. /tmp/venv/bin/activate
./ci-utils/setup.py develop
./ticket_system/setup.py develop
Unit-testing can be done with::
# via setuptools
./ticket_system/setup.py test
# directly via django
./manage.py test # this tests everything (including django)
./manage.py test ticket # just test the project
./manage.py test ticket.APIUpdateSubTicketStatuses #test one class
./manage.py test ticket.APIUpdateSubTicketStatuses.test_delete_subticket_not_allowed # test one method
CLI
~~~
::
# setup the CLI project
virtualenv /tmp/venv
. /tmp/venv/bin/activate
./ci-utils/setup.py develop
Unit-testing can be done with::
./cli/setup.py test
Restish
~~~~~~~
::
virtualenv /tmp/venv
. /tmp/venv/bin/activate
./ci-utils/setup.py develop
./branch-source-builder/setup.py develop
Unit-testing can be done a couple of ways:
# using setuptools:
./image-builder/setup.py test
# python unittest directly
python -m unittest discover -s branch-source-builder
Running under the python wsgi server can be done with::
./branch-source-builder/bsbuilder/wsgi.py
Running under gunicorn can be done with::
# need gunicorn:
pip install gunicorn
# TIP: by setting max-requests=1 you can make changes to the source code
# and they'll be picked up in the next http request you make!!
gunicorn --max-requests 1 bsbuilder.wsgi:app
Juju Testing
------------
Each service should include a juju-deployer config under the juju-deployer
directory.
To deploy them all, run `./juju-deployer/deploy`
ppa assigner testing with juju-deployer and amulet
--------------------------------------------------
Install pre-requisites:
$ sudo apt-get install juju juju-deployer python-httplib2
Branch lp:amulet and make it reachable.
Configure juju for canonistack (or whatever you feel is appropriate), make
sure you select the region there (see OS_REGION_NAME/NOVA_REGION):
$ . ~/.canonistack/novarc
Create a proper ~/.juju/environments.yaml, example:
environments:
## https://juju.ubuntu.com/docs/config-openstack.html
lcy02:
type: openstack
admin-secret: <your admin secret, juju can auto-create it>
# Globally unique swift bucket name
control-bucket: <you control-bucket secret, juju can auto-create it>
# Usually set via the env variable OS_REGION_NAME, but can be specified here
region: lcy02
$ juju bootstrap --constraints="mem=1G"
Get the IP address of the juju state server from 'nova list --name machine-0':
$ nova list --name machine-0 --fields networks
+--------------------------------------+-------------------------+
| ID | Networks |
+--------------------------------------+-------------------------+
| 0463d358-750c-4fc4-b38b-a618e2e7d034 | canonistack=10.55.32.64 |
+--------------------------------------+-------------------------+
Start sshuttle in the foreground from a different terminal where you've sourced your credentials (we need a way to get that in a more script friendly way):
$ sshuttle -r ubuntu@10.55.32.64 10.55.0.0/16
You'll need to interrupt this command once you're run 'juju destroy-environment' to ensure you didn't leave pending connections to juju instances that should not exist anymore.
Deploy ppa-assigner (mostly a smoke check, amulet will deploy it anyway or
reuse the already deployed one):
$ juju-deployer -c juju-deployer/ppa-assigner.yaml ci-airline-staging
Run the ppa assigner test:
$ tests/ppa_assigner/test.py
|