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