Merge lp:~pedronis/tanuki-agent/tut-update-recomplete-n-tweaks into lp:tanuki-agent

Proposed by Samuele Pedroni
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 122
Merged at revision: 114
Proposed branch: lp:~pedronis/tanuki-agent/tut-update-recomplete-n-tweaks
Merge into: lp:tanuki-agent
Diff against target: 300 lines (+94/-92)
1 file modified
docs/tutorial.md (+94/-92)
To merge this branch: bzr merge lp:~pedronis/tanuki-agent/tut-update-recomplete-n-tweaks
Reviewer Review Type Date Requested Status
Celso Providelo (community) Approve
Review via email: mp+275169@code.launchpad.net

Commit message

reinstate tutorial additions/clarifications from 104-110 that got lost, plus some tweaks

Description of the change

tried to reinstate tutorial additions/clarifications from 104-110 that got lost, plus some tweaks that seemed off both before and after

To post a comment you must log in.
Revision history for this message
Celso Providelo (cprov) wrote :

Thanks Samuele,

You have recovered all the bits I remember we discussed ...

Now let's decide how we are going to proceed with the agent binary builds, then perhaps give it another pass to ensure the instructions are correct (we are already missing 'apt-get install build-essential python3-dev' for running from source).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/tutorial.md'
2--- docs/tutorial.md 2015-10-16 21:36:04 +0000
3+++ docs/tutorial.md 2015-10-21 11:35:25 +0000
4@@ -11,15 +11,10 @@
5 - What you will need: A description of everything you will need to complete the tutorial.
6 - Introduction to SPI: A brief description of how the system works.
7 - Lab setup: Create and configure your own laboratory.
8-- Snap creation: Create your own Snap, starting from an example app.
9-- Configure SPI: Configure the SPI system, the heart of the solution.
10-- Running the tests: To be written.
11-- Tests results gathering and checking: To be written.
12+- Product update testing walkthrough: Walkthrough and configuration of how to test a product software update and check results.
13+- Other Testing Scenarios
14
15-Some conventions: from time to time you will need to execute commands in
16-a terminal. This will be indicated using ```this particular font``` and color,
17-normally in a single different line. This font will also be used to specify
18-filenames or any other cases where spelling matters.
19+Some conventions: from time to time you will need to execute commands in a terminal. This will be indicated using ```this particular font and background color```, normally on a single different line. This font will also be used to specify filenames or any other cases where spelling matters.
20
21 ## What you will need
22
23@@ -58,46 +53,28 @@
24 Download and install as follows:
25
26 curl http://people.canonical.com/~ralsina/agent-daily-latest.tgz > spi-agent.tgz
27- tar -zxf spi-agent.tgz
28- cd agent-daily-*
29+ tar -zxf spi-agent.tgz
30+ cd agent-daily-*
31
32 Perform initial setup and verification:
33
34- make bootstrap
35- . env/bin/activate
36+ make bootstrap
37+ . env/bin/activate
38
39 At this point the prompt should look like this, indicating that the
40 environment is activated:
41
42- (env)user@host:~user/foo$
43+ (env)user@host:~user/foo$
44
45 #### Configuring the Agent
46
47 Once the Agent is installed, you need to create its configuration:
48
49- $ ./agent.py --default-config > config.ini
50+ $ ./agent.py --default-config > config.ini
51
52 The Agent authenticates using Ubuntu One. To use it you need to create an account at https://login.ubuntu.com first, and then use the Agent to put credentials in the Agent config file:
53
54- $ ./agent.py --interactive-login config.ini
55-
56-As a final step, register yourself in the system:
57-
58- $ ./agent.py --register config.ini
59-
60-IMPORTANT SECURITY NOTE:
61-
62-The config file now has data equivalent to your user and password.
63-
64-You are responsible for storing this securely. The device on which the
65-Agent runs should be protected from unauthorized access.
66-
67-You can now run the Agent:
68-
69- $ ./agent.py -v config.ini
70- 2015-07-10 09:52:24,081 [agent-queue] Registered at https://spi.canonical.com/register
71- 2015-07-10 09:52:24,839 [agent-queue] No tests at https://spi.canonical.com/queue/docs-org/amd64/agent-queue/agent-queue/get-one
72- 2015-07-10 09:52:24,840 [agent-queue] Sleeping 10.000000 seconds
73+ $ ./agent.py --interactive-login config.ini
74
75 ### Setting up your organization
76
77@@ -108,23 +85,32 @@
78 To set up or add users to an Organization:
79
80 1. In the Agent configuration created when you logged in, there is a key of the following form: ```consumer_key = 7DzPrtB```
81-2. Contact your Canonical representative. Provide them with the name you would like to use for your Organization in the system and the consumer\_key. Your represenative will add this key into the Organization. Any agent configured with this consumer key will now have access to your Organization's data.
82+2. Contact your Canonical representative. Provide them with the name you would like to use for your Organization in the system and the consumer\_key. Your representative will add this key into the Organization. Any agent configured with this consumer key will now have access to your Organization's data.
83+
84+You need to replace the value of the ```organization_id``` field in the ```config.ini``` file with 'Your Organization Name', and ```platform``` to "spi-tutorial-raspi2" for the sake of this tutorial.
85
86 Later, we will need to use the Organization name in the command line examples.
87 You can set up an environment variable to save on typing:
88
89- export ORGANIZATION="your organization name"
90-
91-### How to set up the Raspberry Pi 2
92-
93-To do:
94-
95-- How to install base image, and check the image is working
96-- wget, dd, test
97-- troubleshoot?
98-- how to connect it to the computer
99-- how to setup the provisioning kit
100-- what about the installation of golden images???
101+ export ORGANIZATION="Your Organization Name"
102+
103+As a final step, register yourself in the system:
104+
105+ $ ./agent.py --register config.ini
106+
107+IMPORTANT SECURITY NOTE:
108+
109+The config file now has data equivalent to your user and password.
110+
111+You are responsible for storing this securely. The device on which the
112+Agent runs should be protected from unauthorized access.
113+
114+You can now run the Agent:
115+
116+ $ ./agent.py -v config.ini
117+ 2015-07-10 09:52:24,081 [agent-queue] Registered at https://spi.canonical.com/register
118+ 2015-07-10 09:52:24,839 [agent-queue] No tests at https://spi.canonical.com/queue/docs-org/amd64/agent-queue/agent-queue/get-one
119+ 2015-07-10 09:52:24,840 [agent-queue] Sleeping 10.000000 seconds
120
121 ## Product update testing walkthrough
122
123@@ -139,31 +125,40 @@
124
125 See https://developer.ubuntu.com/en/snappy/start/ for further details.
126
127+Also, install Paramiko dependency:
128+
129+ $ sudo apt-get install python-paramiko
130+
131 Next, you will create an image for RPI2 from the rolling/edge channel, with our test-snap pre-installed:
132
133- $ wget http://people.canonical.com/~cprov/snappy/raspberrypi2/test-snap\_1\_all.snap
134- $ sudo ubuntu-device-flash core rolling --channel edge \
135- --oem pi2.canonical \
136- --device raspi2_armhf \
137- --developer-mode \
138- --install test-snap_1_all.snap \
139- -o spi-test_pi2.img
140+ $ wget http://people.canonical.com/~cprov/snappy/raspberrypi2/test-snap\_1\_all.snap
141+ $ sudo ubuntu-device-flash core rolling --channel edge \
142+ --oem pi2.canonical \
143+ --device raspi2_armhf \
144+ --developer-mode \
145+ --install test-snap_1_all.snap \
146+ -o spi-test_pi2.img
147
148 Or download the one we have already baked:
149
150- $ wget http://people.canonical.com/\~cprov/snappy/raspberrypi2/spi-test_pi2.img.xz
151- $ md5sum spi-test_pi2.img.xz
152- 8f2cef8367b9913c92b332e5a0586281 spi-test_pi2.img.xz
153+ $ wget http://people.canonical.com/\~cprov/snappy/raspberrypi2/spi-test_pi2.img.xz
154+ $ md5sum spi-test_pi2.img.xz
155+ 8f2cef8367b9913c92b332e5a0586281 spi-test_pi2.img.xz
156+ $ unxz spi-test_pi2.img.xz
157
158 Now, because remotely flashing the Raspberry Pi is not supported in Snappy, you
159 will need to manually flash an SD card with the image.
160
161 On the host machine (careful select the correct output device):
162
163- $ xzcat spi-test_pi2.img.xz | pv -s 4g | sudo dd of=/dev/sdX bs=32M
164+ $ cat spi-test_pi2.img | pv -s 4g | sudo dd of=/dev/sdX bs=32M
165
166 For additional instructions see https://www.raspberrypi.org/documentation/installation/installing-images/
167-Insert the SD card in your Raspberry Pi 2, power it on and wait few seconds until it boots.
168+Insert the SD card in your Raspberry Pi 2, power it on and wait few seconds until it boots.
169+
170+You can check whether it's online just by doing:
171+
172+ $ ping webdm.local
173
174 If the device is not accessible, you can troubleshoot by using a serial
175 cable to get a console on the RPi2, see http://elinux.org/RPi\_Serial\_Connection for instructions. Note the pins are the same for RPi1 and RPi2.
176@@ -182,7 +177,7 @@
177 - ```base_image_reference```: the URL where to download the image
178 - ```snaps```: the list of snaps that the product uses
179
180-So, execute the following from your computer (where you already authenticated during the lab setup above):
181+So, in the agent directory execute the following from your computer (where you already authenticated during the lab setup above):
182
183 ./scripts/api_example.py -X POST config.ini \
184 https://spi.canonical.com/orgs/$ORGANIZATION/products/manifests
185@@ -195,7 +190,9 @@
186 ["ubuntu-core.canonical", null, false]]
187 }'
188
189+<!---
190 ToDo: the URL for ```base_image_reference``` should be fixed to its final destination
191+-->
192
193 Note particularly that one of the snaps is the one used for this Tutorial, in version 1; we’ll trigger the tests when a new version comes available for it.
194
195@@ -208,47 +205,48 @@
196
197 So, execute the following:
198
199- ./scripts/api_example.py -X POST config.ini \
200- https://spi.canonical.com/orgs/$ORGANIZATION/tests/specs --data '{
201- "platform": "spi-tutorial-raspi2",
202- "image_name": "tutorial-raspi2-image",
203- "name": "Tutorial Example Test Specification",
204- "test_payload": {
205- "tarball_url":
206- "http://taniquetil.com.ar/test_tarball.tar.gz",
207- "test_cmd": "./test"
208- }
209- }'
210+ ./scripts/api_example.py -X POST config.ini \
211+ https://spi.canonical.com/orgs/$ORGANIZATION/tests/specs --data '{
212+ "platform": "spi-tutorial-raspi2",
213+ "image_name": "tutorial-raspi2-image",
214+ "name": "Tutorial Example Test Specification",
215+ "test_payload": {
216+ "tarball_url":
217+ "http://taniquetil.com.ar/test_tarball.tar.gz",
218+ "test_cmd": "./test"
219+ }
220+ }'
221
222-ToDo: the URL for the tarball should be fixed to its final destination
223+<!---
224+ ToDo: the URL for the tarball should be fixed to its final destination
225+-->
226
227 At this point SPI is configured and supervising the Store for new
228 versions of your snap.
229
230 ### Trigger/running of actual tests
231
232-To do:
233-
234-- describe steps to run the tests (making the Agent to run a test in the raspi is messy right now and needs manual steps)
235-- explain which changes/uploads store/system image server trigger test creation, and if for this tutorial something needs to be done manually in the Store to trigger the test
236-- how the user knows that a test was triggered? maybe we should merge this section with the following one (“how to check tests progress”)?
237-- inform how to be sure that tests triggered by the SPI arrives ok to the Agent
238-
239 Now we’ll tell SPI manually that a new version of the snap we’re using for the tutorial is available:
240
241- ./scripts/api_example.py -X POST config.ini \
242- https://spi.canonical.com/orgs/$ORGANIZATION/snap-revisions --data '{
243- "name": "test-snap.spi-test",
244- "revision": 2
245- }'
246-
247-At this point the SPI will generate a message that is waiting to be consumed by our Agent.
248+ ./scripts/api_example.py -X POST config.ini \
249+ https://spi.canonical.com/orgs/$ORGANIZATION/snap-revisions --data '{
250+ "name": "test-snap.spi-test",
251+ "revision": 2
252+ }'
253+
254+In the response there is a image_unique_id that will be used next, please keep it around.
255+
256+At this point the SPI has generated a message that is waiting to be consumed by our Agent, and when that message arrives the Agent will try to run the commands to provision, setup and run the tests. For that we need to put useful commands in the config file. So, edit ```config.ini``` and replace the following three fields (the path needs to be absolute, be sure to replace the correct values):
257+
258+ provcommand = PATH_TO_AGENT/rpi2-sample-provkit/provision
259+ setupcommand = PATH_TO_AGENT/rpi2-sample-provkit/setup
260+ testcommand = PATH_TO_AGENT/rpi2-sample-provkit/runtest
261
262 Next step, then, is to start the Agent to get that message and start running the test. As of this moment, we’d need to set up the Raspberry Pi manually, so the Agent after receiving the test to run will produce some instructions to get an image and burn it into the device, so please follow those instructions and let the Agent know when you’re ready (it will wait for you to press Enter).
263
264 So, run:
265
266- ./agent.py --once config.ini
267+ ./agent.py --once config.ini
268
269 After executing the test, the Agent will automatically retrieve the
270 results and send them back to SPI.
271@@ -259,20 +257,24 @@
272 system, where they stands (to be run, or already run, etc), checking the
273 events in the system:
274
275- ./scripts/api_example.py config.ini \
276- https://spi.canonical.com/orgs/$ORGANIZATION/tests/events?image_name=tutorial-raspi2-image
277+ ./scripts/api_example.py config.ini \
278+ https://spi.canonical.com/orgs/$ORGANIZATION/tests/events?image_name=tutorial-raspi2-image
279
280 Also, you can see the results produced for all the organization, doing
281
282- ./scripts/api_example.py config.ini \
283- https://spi.canonical.com/orgs/$ORGANIZATION/tests/events?image_name=tutorial-raspi2-image
284+ ./scripts/api_example.py config.ini \
285+ https://spi.canonical.com/orgs/$ORGANIZATION/tests/events?image_name=tutorial-raspi2-image
286
287 Or even check the results for an specific image (you can get the image
288 id from the response of the query when you told the system above that a
289 new snap revision was available):
290
291- ./scripts/api_example.py config.ini \
292- https://spi.canonical.com/orgs/$ORGANIZATION/tests/events?image_name=tutorial-raspi2-image/<unique_image_id>
293+ ./scripts/api_example.py config.ini \
294+ https://spi.canonical.com/orgs/$ORGANIZATION/tests/events?image_name=tutorial-raspi2-image/<unique_image_id>
295+
296+<!--
297+ToDo: add example to query the actual result
298+-->
299
300 ## Other Testing Scenarios
301

Subscribers

People subscribed via source and target branches

to all changes: