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
=== modified file 'docs/tutorial.md'
--- docs/tutorial.md 2015-10-16 21:36:04 +0000
+++ docs/tutorial.md 2015-10-21 11:35:25 +0000
@@ -11,15 +11,10 @@
11- What you will need: A description of everything you will need to complete the tutorial.11- What you will need: A description of everything you will need to complete the tutorial.
12- Introduction to SPI: A brief description of how the system works.12- Introduction to SPI: A brief description of how the system works.
13- Lab setup: Create and configure your own laboratory.13- Lab setup: Create and configure your own laboratory.
14- Snap creation: Create your own Snap, starting from an example app.14- Product update testing walkthrough: Walkthrough and configuration of how to test a product software update and check results.
15- Configure SPI: Configure the SPI system, the heart of the solution.15- Other Testing Scenarios
16- Running the tests: To be written.
17- Tests results gathering and checking: To be written.
1816
19Some conventions: from time to time you will need to execute commands in17Some 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.
20a terminal. This will be indicated using ```this particular font``` and color,
21normally in a single different line. This font will also be used to specify
22filenames or any other cases where spelling matters.
2318
24## What you will need19## What you will need
2520
@@ -58,46 +53,28 @@
58Download and install as follows:53Download and install as follows:
5954
60 curl http://people.canonical.com/~ralsina/agent-daily-latest.tgz > spi-agent.tgz55 curl http://people.canonical.com/~ralsina/agent-daily-latest.tgz > spi-agent.tgz
61 tar -zxf spi-agent.tgz56 tar -zxf spi-agent.tgz
62 cd agent-daily-*57 cd agent-daily-*
6358
64Perform initial setup and verification:59Perform initial setup and verification:
6560
66 make bootstrap61 make bootstrap
67 . env/bin/activate62 . env/bin/activate
6863
69At this point the prompt should look like this, indicating that the64At this point the prompt should look like this, indicating that the
70environment is activated:65environment is activated:
7166
72 (env)user@host:~user/foo$67 (env)user@host:~user/foo$
7368
74#### Configuring the Agent69#### Configuring the Agent
7570
76Once the Agent is installed, you need to create its configuration:71Once the Agent is installed, you need to create its configuration:
7772
78 $ ./agent.py --default-config > config.ini73 $ ./agent.py --default-config > config.ini
7974
80The 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:75The 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:
8176
82 $ ./agent.py --interactive-login config.ini77 $ ./agent.py --interactive-login config.ini
83
84As a final step, register yourself in the system:
85
86 $ ./agent.py --register config.ini
87
88IMPORTANT SECURITY NOTE:
89
90The config file now has data equivalent to your user and password.
91
92You are responsible for storing this securely. The device on which the
93Agent runs should be protected from unauthorized access.
94
95You can now run the Agent:
96
97 $ ./agent.py -v config.ini
98 2015-07-10 09:52:24,081 [agent-queue] Registered at https://spi.canonical.com/register
99 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
100 2015-07-10 09:52:24,840 [agent-queue] Sleeping 10.000000 seconds
10178
102### Setting up your organization79### Setting up your organization
10380
@@ -108,23 +85,32 @@
108To set up or add users to an Organization:85To set up or add users to an Organization:
10986
1101. In the Agent configuration created when you logged in, there is a key of the following form: ```consumer_key = 7DzPrtB```871. In the Agent configuration created when you logged in, there is a key of the following form: ```consumer_key = 7DzPrtB```
1112. 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.882. 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.
89
90You 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.
11291
113Later, we will need to use the Organization name in the command line examples.92Later, we will need to use the Organization name in the command line examples.
114You can set up an environment variable to save on typing:93You can set up an environment variable to save on typing:
11594
116 export ORGANIZATION="your organization name"95 export ORGANIZATION="Your Organization Name"
11796
118### How to set up the Raspberry Pi 297As a final step, register yourself in the system:
11998
120To do:99 $ ./agent.py --register config.ini
121100
122- How to install base image, and check the image is working101IMPORTANT SECURITY NOTE:
123- wget, dd, test102
124- troubleshoot?103The config file now has data equivalent to your user and password.
125- how to connect it to the computer104
126- how to setup the provisioning kit105You are responsible for storing this securely. The device on which the
127- what about the installation of golden images???106Agent runs should be protected from unauthorized access.
107
108You can now run the Agent:
109
110 $ ./agent.py -v config.ini
111 2015-07-10 09:52:24,081 [agent-queue] Registered at https://spi.canonical.com/register
112 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
113 2015-07-10 09:52:24,840 [agent-queue] Sleeping 10.000000 seconds
128114
129## Product update testing walkthrough115## Product update testing walkthrough
130116
@@ -139,31 +125,40 @@
139125
140See https://developer.ubuntu.com/en/snappy/start/ for further details.126See https://developer.ubuntu.com/en/snappy/start/ for further details.
141127
128Also, install Paramiko dependency:
129
130 $ sudo apt-get install python-paramiko
131
142Next, you will create an image for RPI2 from the rolling/edge channel, with our test-snap pre-installed:132Next, you will create an image for RPI2 from the rolling/edge channel, with our test-snap pre-installed:
143133
144 $ wget http://people.canonical.com/~cprov/snappy/raspberrypi2/test-snap\_1\_all.snap134 $ wget http://people.canonical.com/~cprov/snappy/raspberrypi2/test-snap\_1\_all.snap
145 $ sudo ubuntu-device-flash core rolling --channel edge \135 $ sudo ubuntu-device-flash core rolling --channel edge \
146 --oem pi2.canonical \136 --oem pi2.canonical \
147 --device raspi2_armhf \137 --device raspi2_armhf \
148 --developer-mode \138 --developer-mode \
149 --install test-snap_1_all.snap \139 --install test-snap_1_all.snap \
150 -o spi-test_pi2.img140 -o spi-test_pi2.img
151141
152Or download the one we have already baked:142Or download the one we have already baked:
153143
154 $ wget http://people.canonical.com/\~cprov/snappy/raspberrypi2/spi-test_pi2.img.xz144 $ wget http://people.canonical.com/\~cprov/snappy/raspberrypi2/spi-test_pi2.img.xz
155 $ md5sum spi-test_pi2.img.xz145 $ md5sum spi-test_pi2.img.xz
156 8f2cef8367b9913c92b332e5a0586281 spi-test_pi2.img.xz146 8f2cef8367b9913c92b332e5a0586281 spi-test_pi2.img.xz
147 $ unxz spi-test_pi2.img.xz
157148
158Now, because remotely flashing the Raspberry Pi is not supported in Snappy, you149Now, because remotely flashing the Raspberry Pi is not supported in Snappy, you
159will need to manually flash an SD card with the image.150will need to manually flash an SD card with the image.
160151
161On the host machine (careful select the correct output device):152On the host machine (careful select the correct output device):
162153
163 $ xzcat spi-test_pi2.img.xz | pv -s 4g | sudo dd of=/dev/sdX bs=32M154 $ cat spi-test_pi2.img | pv -s 4g | sudo dd of=/dev/sdX bs=32M
164155
165For additional instructions see https://www.raspberrypi.org/documentation/installation/installing-images/156For additional instructions see https://www.raspberrypi.org/documentation/installation/installing-images/
166Insert the SD card in your Raspberry Pi 2, power it on and wait few seconds until it boots. 157Insert the SD card in your Raspberry Pi 2, power it on and wait few seconds until it boots.
158
159You can check whether it's online just by doing:
160
161 $ ping webdm.local
167162
168If the device is not accessible, you can troubleshoot by using a serial163If the device is not accessible, you can troubleshoot by using a serial
169cable 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.164cable 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.
@@ -182,7 +177,7 @@
182- ```base_image_reference```: the URL where to download the image177- ```base_image_reference```: the URL where to download the image
183- ```snaps```: the list of snaps that the product uses178- ```snaps```: the list of snaps that the product uses
184179
185So, execute the following from your computer (where you already authenticated during the lab setup above):180So, in the agent directory execute the following from your computer (where you already authenticated during the lab setup above):
186181
187 ./scripts/api_example.py -X POST config.ini \182 ./scripts/api_example.py -X POST config.ini \
188 https://spi.canonical.com/orgs/$ORGANIZATION/products/manifests183 https://spi.canonical.com/orgs/$ORGANIZATION/products/manifests
@@ -195,7 +190,9 @@
195 ["ubuntu-core.canonical", null, false]]190 ["ubuntu-core.canonical", null, false]]
196 }'191 }'
197192
193<!---
198ToDo: the URL for ```base_image_reference``` should be fixed to its final destination194ToDo: the URL for ```base_image_reference``` should be fixed to its final destination
195-->
199196
200Note 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.197Note 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.
201198
@@ -208,47 +205,48 @@
208205
209So, execute the following:206So, execute the following:
210207
211 ./scripts/api_example.py -X POST config.ini \208 ./scripts/api_example.py -X POST config.ini \
212 https://spi.canonical.com/orgs/$ORGANIZATION/tests/specs --data '{209 https://spi.canonical.com/orgs/$ORGANIZATION/tests/specs --data '{
213 "platform": "spi-tutorial-raspi2",210 "platform": "spi-tutorial-raspi2",
214 "image_name": "tutorial-raspi2-image",211 "image_name": "tutorial-raspi2-image",
215 "name": "Tutorial Example Test Specification",212 "name": "Tutorial Example Test Specification",
216 "test_payload": {213 "test_payload": {
217 "tarball_url":214 "tarball_url":
218 "http://taniquetil.com.ar/test_tarball.tar.gz",215 "http://taniquetil.com.ar/test_tarball.tar.gz",
219 "test_cmd": "./test"216 "test_cmd": "./test"
220 }217 }
221 }'218 }'
222219
223ToDo: the URL for the tarball should be fixed to its final destination220<!---
221 ToDo: the URL for the tarball should be fixed to its final destination
222-->
224223
225At this point SPI is configured and supervising the Store for new224At this point SPI is configured and supervising the Store for new
226versions of your snap.225versions of your snap.
227226
228### Trigger/running of actual tests227### Trigger/running of actual tests
229228
230To do:
231
232- describe steps to run the tests (making the Agent to run a test in the raspi is messy right now and needs manual steps)
233- 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
234- how the user knows that a test was triggered? maybe we should merge this section with the following one (“how to check tests progress”)?
235- inform how to be sure that tests triggered by the SPI arrives ok to the Agent
236
237Now we’ll tell SPI manually that a new version of the snap we’re using for the tutorial is available:229Now we’ll tell SPI manually that a new version of the snap we’re using for the tutorial is available:
238230
239 ./scripts/api_example.py -X POST config.ini \ 231 ./scripts/api_example.py -X POST config.ini \
240 https://spi.canonical.com/orgs/$ORGANIZATION/snap-revisions --data '{232 https://spi.canonical.com/orgs/$ORGANIZATION/snap-revisions --data '{
241 "name": "test-snap.spi-test",233 "name": "test-snap.spi-test",
242 "revision": 2234 "revision": 2
243 }'235 }'
244236
245At this point the SPI will generate a message that is waiting to be consumed by our Agent.237In the response there is a image_unique_id that will be used next, please keep it around.
238
239At 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):
240
241 provcommand = PATH_TO_AGENT/rpi2-sample-provkit/provision
242 setupcommand = PATH_TO_AGENT/rpi2-sample-provkit/setup
243 testcommand = PATH_TO_AGENT/rpi2-sample-provkit/runtest
246244
247Next 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).245Next 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).
248246
249So, run:247So, run:
250248
251 ./agent.py --once config.ini249 ./agent.py --once config.ini
252250
253After executing the test, the Agent will automatically retrieve the251After executing the test, the Agent will automatically retrieve the
254results and send them back to SPI.252results and send them back to SPI.
@@ -259,20 +257,24 @@
259system, where they stands (to be run, or already run, etc), checking the257system, where they stands (to be run, or already run, etc), checking the
260events in the system:258events in the system:
261259
262 ./scripts/api_example.py config.ini \260 ./scripts/api_example.py config.ini \
263 https://spi.canonical.com/orgs/$ORGANIZATION/tests/events?image_name=tutorial-raspi2-image261 https://spi.canonical.com/orgs/$ORGANIZATION/tests/events?image_name=tutorial-raspi2-image
264262
265Also, you can see the results produced for all the organization, doing263Also, you can see the results produced for all the organization, doing
266264
267 ./scripts/api_example.py config.ini \265 ./scripts/api_example.py config.ini \
268 https://spi.canonical.com/orgs/$ORGANIZATION/tests/events?image_name=tutorial-raspi2-image266 https://spi.canonical.com/orgs/$ORGANIZATION/tests/events?image_name=tutorial-raspi2-image
269267
270Or even check the results for an specific image (you can get the image268Or even check the results for an specific image (you can get the image
271id from the response of the query when you told the system above that a269id from the response of the query when you told the system above that a
272new snap revision was available):270new snap revision was available):
273271
274 ./scripts/api_example.py config.ini \272 ./scripts/api_example.py config.ini \
275 https://spi.canonical.com/orgs/$ORGANIZATION/tests/events?image_name=tutorial-raspi2-image/<unique_image_id>273 https://spi.canonical.com/orgs/$ORGANIZATION/tests/events?image_name=tutorial-raspi2-image/<unique_image_id>
274
275<!--
276ToDo: add example to query the actual result
277-->
276278
277## Other Testing Scenarios279## Other Testing Scenarios
278280

Subscribers

People subscribed via source and target branches

to all changes: