Merge lp:~ralsina/tanuki-agent/fix-product-ref into lp:tanuki-agent

Proposed by Roberto Alsina
Status: Merged
Approved by: Roberto Alsina
Approved revision: 203
Merged at revision: 201
Proposed branch: lp:~ralsina/tanuki-agent/fix-product-ref
Merge into: lp:tanuki-agent
Diff against target: 491 lines (+160/-159)
1 file modified
docs/api-reference-products.md (+160/-159)
To merge this branch: bzr merge lp:~ralsina/tanuki-agent/fix-product-ref
Reviewer Review Type Date Requested Status
Bret Barker (community) Approve
Review via email: mp+281552@code.launchpad.net

Commit message

Updated docs for test triggering scenarios and progress/results APIs

Description of the change

Updated docs for test triggering scenarios and progress/results APIs

To post a comment you must log in.
Revision history for this message
Bret Barker (noise) wrote :

+1'ing with known FIXMEs remaining.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'docs/api-reference-products.md'
--- docs/api-reference-products.md 2016-01-04 20:06:45 +0000
+++ docs/api-reference-products.md 2016-01-04 20:33:35 +0000
@@ -4,8 +4,7 @@
4[TOC]4[TOC]
55
66
7Definitions7# Definitions
8============
98
10- **Manifest**: used to define a Product9- **Manifest**: used to define a Product
11 that is based on Snaps. This is optional for image-based workflows.10 that is based on Snaps. This is optional for image-based workflows.
@@ -25,8 +24,7 @@
25 tests against a target device.24 tests against a target device.
26- **Test Result**: metadata about output of a test run.25- **Test Result**: metadata about output of a test run.
2726
28Authentication27# Authentication
29============
3028
31All API endpoints are authenticated, which ensures private access29All API endpoints are authenticated, which ensures private access
32to your product's information.30to your product's information.
@@ -114,8 +112,7 @@
114login process) into a file called conf.ini. Note, this script is meant only as an example and not112login process) into a file called conf.ini. Note, this script is meant only as an example and not
115intended for production use.113intended for production use.
116114
117Errors115# Errors
118============
119116
120The APIs use standard HTTP response codes. Most errors will117The APIs use standard HTTP response codes. Most errors will
121contain a human-readable "message" field in the JSON response body. Here118contain a human-readable "message" field in the JSON response body. Here
@@ -141,8 +138,7 @@
141 <p>There was an temporary error on the server. The request may be retried after a short wait. If the problem persists please contact support. Scripts should use an exponential backoff to avoid hammering the servers with retries.138 <p>There was an temporary error on the server. The request may be retried after a short wait. If the problem persists please contact support. Scripts should use an exponential backoff to avoid hammering the servers with retries.
142</table>139</table>
143140
144API Reference141# API Reference
145=============
146142
147Product Management143Product Management
148------------------144------------------
@@ -257,7 +253,7 @@
257 "test-snap.foo"253 "test-snap.foo"
258 ],254 ],
259 "release": "15.04-core",255 "release": "15.04-core",
260 "name": "test-product.e2e",256 "name": "test-product.foo",
261 "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",257 "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
262 "created_at": "2016-01-04T17:34:39.093142"258 "created_at": "2016-01-04T17:34:39.093142"
263 }259 }
@@ -705,12 +701,6 @@
705has the following required fields:701has the following required fields:
706702
707703
708- ```image_name```: a unique name within an
709 organization that is combined with each
710 test case to produce the full set of test
711 opportunities. I.e. if you have two test cases with a
712 matching image_name, then two test opportunities will be created.
713 Maximum length is 200 characters.
714- ```image_reference```: is opaque to the704- ```image_reference```: is opaque to the
715 system; it is for your Provisioning Kit in your lab705 system; it is for your Provisioning Kit in your lab
716 to interpret and use. It can be any JSON706 to interpret and use. It can be any JSON
@@ -727,51 +717,50 @@
727 image\_reference is not a URL to a binary. Currently717 image\_reference is not a URL to a binary. Currently
728 this ID is used for querying test results. Maximum length is 36718 this ID is used for querying test results. Maximum length is 36
729 characters.719 characters.
730- ```upgrade\_snaps```: NOT IMPLEMENTED YET.720- ```channel```: **FIXME DESCRIBE**
721- ```extra_snaps```: **FIXME DESCRIBE**
731722
732723
733<table class="table">724<table class="table">
734<tr>725<tr>
735 <th>Action <th>Image Reference Creation726 <th>Action <th>Image Advertising
736<tr>727<tr>
737 <td>URL <td>https://spi.canonical.com/orgs/&lt;org-id&gt;/images728 <td>URL <td>https://spi.canonical.com/products/&lt;product-id&gt;/images
738<tr>729<tr>
739 <td>Method <td>POST730 <td>Method <td>POST
740<tr>731<tr>
741 <td>Data <td>732 <td>Data <td>
742<pre>733<pre>
743{734{
744 image_reference: "http://foo.bar",735 "image_unique_id": "DEADBEEF_83451039",
745 image_unique_id: some unique_id,736 "extra_snaps": [],
746 image_name: my_image,737 "channel": "edge",
747 upgrade_snaps: []738 "image_reference": "http://foo.com/bar"
748}739}
749</pre>740</pre>
750<tr>741<tr>
751 <td>Response <td><code>201 CREATED</code> with a list of test opportunity IDs742 <td>Response <td><code>201 CREATED</code> with a list of test opportunity IDs and image unique IDs.
752<tr>
753 <td>Response <td><code>404 NOT FOUND</code> if there is no test spec for this image_name
754<pre>
755{
756 "id": "resource-not-found",
757 "message": "Couldn't find a Spec for image name 'my_image'",
758 "url": null
759}
760</pre>
761<tr>743<tr>
762 <td>Example <td>744 <td>Example <td>
763<pre>745<pre>
764$ ./scripts/api_example.py -X POST conf.ini https://spi.canonical.com/orgs/docs-org/images --data \746$ ./scripts/api_example.py -X POST conf.ini https://spi.canonical.com/products/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/images --data \
765'{747'
766"image_reference": "http://foo.bar",748{
767"image_unique_id": "fooo",749 "image_unique_id": "DEADBEEF_83451039",
768"image_name": "imgname",750 "extra_snaps": [],
769"upgrade_snaps": []751 "channel": "edge",
770}'752 "image_reference": "http://foo.com/bar"
753}
754'
771755
772HTTP 201756HTTP 201
773{757{
774 'ids': ['99787105-911f-4e23-bded-b0b8253aee11']758 "ids": [
759 {
760 "image_unique_id": "DEADBEEF_83451039",
761 "test_opportunity_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
762 }
763 ]
775}764}
776</pre>765</pre>
777</table>766</table>
@@ -785,43 +774,24 @@
785advertised to the system, however they can be re-advertised manually774advertised to the system, however they can be re-advertised manually
786afterwards, re-triggering tests with their original context.775afterwards, re-triggering tests with their original context.
787776
788The new revision advertised will be matched with all **Manifests** within the context **Organization**777The new revision advertised will be matched with all **Products**
789referencing the given **Snap**, and **Test Opportunities** will be created for all **Test Specs** linked to those778referencing the given **Snap**, and **Test Opportunities** will be created for all **Test Specs** linked to those
790**Manifests**.779**Products**.
791780
792![](images/image03.png)781![](images/image03.png)
793782
794783
795By modelling new / specific **Manifests** (Products) under the same784By modelling new / specific **Products** customers define the testing context they care about:
796**Organization** customers define the testing context they care about:785
797786
798787**FIXME Describe the new world test triggering scenarios**
799
8001. **Update from a Gold Master (GM) image**:
801
802 Product "base\_image\_reference" contains specific versions of
803 product-specific snaps reflecting one generation / portion of the
804 installed base. In this case, tests represent the act of updating
805 products of an specific generation to the advertised snap.
806
807
8082. **Fresh Install (special case of above where GM == Ubuntu-Core)**:
809
810 Product "base\_image\_reference" does not include
811 product-specific snaps and tests represent, for instance, the act of
812 installing the advertised snap on top of a vanilla ubuntu-core
813 image.
814
815
816From the [Agent & Provisioning Kit](#agent-operation) point of view, testing contexts will
817be homogeneously defined via Test Opportunity base\_image\_reference and extra\_snaps.
818788
819Snap revision advertisement request requires the following789Snap revision advertisement request requires the following
820fields:790fields:
821791
822- **name** The name of the snap package. Maximum length is 200 characters.792- **name** The name of the snap package. Maximum length is 200 characters.
823- **revision** The new snap's revision. An integer number.793- **revision** The new snap's revision. An integer number.
824794- **channel** On which channel is the new snap revision advertised.
825795
826796
827Snap revision advertisement will return a list of test opportunity IDs and image unique IDs that can be used to [query for results](#querying-test-results) later.797Snap revision advertisement will return a list of test opportunity IDs and image unique IDs that can be used to [query for results](#querying-test-results) later.
@@ -830,42 +800,101 @@
830<tr>800<tr>
831 <th>Action <th>Snap Revision Triggering801 <th>Action <th>Snap Revision Triggering
832<tr>802<tr>
833 <td>URL <td>https://spi.canonical.com/orgs/&lt;org-id&gt;/snap-revisions803 <td>URL <td>https://spi.canonical.com/products/&lt;product-id&gt;/snaps
834<tr>804<tr>
835 <td>Method <td>POST805 <td>Method <td>POST
836<tr>806<tr>
837 <td>Data <td>807 <td>Data <td>
838<pre>808<pre>
839{809{
840 "name": name of snap package810 "name": "test-snap.foo",
841 "revision": revision number in the Store (integer)811 "revision": 2,
842}812 "channel": "edge"
843</pre>813}
844<tr>814</pre>
845 <td>Response <td><code>201 CREATED</code> with a list of test opportunity IDs and image unique IDs815<tr>
846<tr>816 <td>Response <td><code>201 CREATED</code> with a list of test opportunity IDs and image unique IDs
847 <td>Response <td><code>404 NOT FOUND</code> if there is no matched Manifests817<tr>
848<pre>818 <td>Example <td>
849{819<pre>
850 "id": "resource-not-found",820$ ./scripts/api_example.py -X POST conf.ini https://spi.canonical.com/products/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/snaps \
851 "message": "",821--data '
852 "url": null822{
853}823 "name": "test-snap.foo",
854</pre>824 "revision": 2,
855<tr>825 "channel": "edge"
856 <td>Example <td>826}'
857<pre>827
858$ ./scripts/api_example.py -X POST conf.ini https://spi.canonical.com/orgs/docs-org/snap-revisions \828HTTP 201
859--data '829{
860> {830 "ids": [
861> "name": "hello.world",831 {
862> "revision": 123832 "image_unique_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
863> }'833 "test_opportunity_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
864834 }
865HTTP 201835 ]
866{836}
867'ids': [{'test_opportunity_id': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',837</pre>
868 'image_unique_id': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'}]}838</table>
839
840### Gold Master
841
842Gold Master advertisement requires the following fields:
843
844- **snaps** A list of snaps that form the gold master image.
845- **channel** On what channel is the gold master advertised.
846
847Gold master advertisement will return a list of test opportunity IDs and image unique IDs that can be used to [query for results](#querying-test-results) later.
848
849<table class="table">
850<tr>
851 <th>Action <th>Gold Master Triggering
852<tr>
853 <td>URL <td>https://spi.canonical.com/products/&lt;product-id&gt;/gold-masters
854<tr>
855 <td>Method <td>POST
856<tr>
857 <td>Data <td>
858<pre>
859{
860 "snaps": A list of snaps/revisions,
861 "channel": a channel name
862}
863</pre>
864<tr>
865 <td>Response <td><code>201 CREATED</code> with a list of test opportunity IDs and image unique IDs
866<tr>
867 <td>Example <td>
868<pre>
869$ ./scripts/api_example.py -X POST conf.ini https://spi.canonical.com/products/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/snaps \
870--data '
871{
872 "snaps": [
873 {
874 "name": "pi2.canonical",
875 "revision": 1
876 },
877 {
878 "name": "webdm.canonical",
879 "revision": 1
880 },
881 {
882 "name": "test-snap.foo",
883 "revision": 1
884 }
885 ],
886 "channel": "stable"
887}'
888
889HTTP 201
890{
891 "ids": [
892 {
893 "image_unique_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
894 "test_opportunity_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
895 }
896 ]
897}
869</pre>898</pre>
870</table>899</table>
871900
@@ -873,8 +902,6 @@
873Querying Test Progress902Querying Test Progress
874----------------------903----------------------
875904
876
877
878As a test opportunity progresses from being triggered to deliver a905As a test opportunity progresses from being triggered to deliver a
879result it flows through a series of expected events. This is the normal906result it flows through a series of expected events. This is the normal
880expected event flow for a test opportunity:907expected event flow for a test opportunity:
@@ -898,7 +925,7 @@
898<tr>925<tr>
899 <th>Action <th>Result Query926 <th>Action <th>Result Query
900<tr>927<tr>
901 <td>URL <td>https://spi.canonical.com/orgs/&lt;org_id&gt;/tests/events928 <td>URL <td>https://spi.canonical.com/products/&lt;prod_id&gt;/tests/events
902<tr>929<tr>
903 <td>Method <td>GET930 <td>Method <td>GET
904<tr>931<tr>
@@ -926,54 +953,43 @@
926 <td>Example <td>953 <td>Example <td>
927<pre>954<pre>
928$ ./scripts/api_example.py conf.ini \955$ ./scripts/api_example.py conf.ini \
929http://spi.canonical.com/orgs/e2e-org/tests/events?test_opportunity_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx956http://spi.canonical.com/products/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/tests/events?test_opportunity_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
930HTTP 200957HTTP 200
931{958{
932 "event_logs": [959 "event_logs": [
933 {960 {
934 "organization_id": "e2e-org",
935 "image_name": "e2e-imgf151a8cd9081404db54ed1d8dab1e140",
936 "queued_at": "2015-09-17T12:13:03.288000+00:00",
937 "updated_at": "2015-09-17T12:13:06.799000+00:00",
938 "image_unique_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
939 "events_seen": [
940 "QUEUED_FOR_AGENTS",
941 "PICKED_BY_AGENT",
942 "RESULT_POSTED",
943 "RESULT_STORED"
944 ],
945 "events": [961 "events": [
946 {962 {
947 "event_type": "QUEUED_FOR_AGENTS",963 "event_type": "QUEUED_FOR_AGENTS",
948 "timestamp": "2015-09-17T12:13:03.288000+00:00"964 "timestamp": "2016-01-04T16:58:28.805000+00:00"
949 },965 },
950 {966 {
967 "timestamp": "2016-01-04T16:58:33.185000+00:00",
951 "event_type": "PICKED_BY_AGENT",968 "event_type": "PICKED_BY_AGENT",
952 "agent_group": "e2e-group",969 "agent_id": "foo-agent-id",
953 "agent_id": "e2e-id",970 "platform": null,
954 "timestamp": "2015-09-17T12:13:06.291000+00:00",971 "agent_group": null
955 "platform": "amd64"
956 },972 },
957 {973 {
958 "result_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",974 "result_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
959 "test_status": "PASSED",975 "test_status": "PASSED",
960 "agent_group": "e2e-group",
961 "event_type": "RESULT_POSTED",976 "event_type": "RESULT_POSTED",
962 "timestamp": "2015-09-17T12:13:06.734000+00:00",977 "agent_id": "foo-agent-id",
963 "agent_id": "e2e-id",978 "platform": null,
964 "platform": "amd64"979 "agent_group": null,
980 "timestamp": "2016-01-04T16:58:33.734000+00:00"
965 },981 },
966 {982 {
983 "result_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
984 "test_status": "PASSED",
967 "event_type": "RESULT_STORED",985 "event_type": "RESULT_STORED",
968 "result_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",986 "timestamp": "2016-01-04T16:58:33.764000+00:00"
969 "test_status": "PASSED",
970 "timestamp": "2015-09-17T12:13:06.745000+00:00"
971 }987 }
972 ],988 ],
989 "updated_at": "2016-01-04T16:58:33.825000+00:00",
990 "product_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
991 "queued_at": "2016-01-04T16:58:28.805000+00:00",
973 "test_opportunity_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",992 "test_opportunity_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
974 "spec_name": "e2e-spec_13691451",
975 "test_opportunity": {
976
977(...)993(...)
978</pre>994</pre>
979</table>995</table>
@@ -1028,7 +1044,7 @@
1028<tr>1044<tr>
1029 <th>Action <th>Result Query1045 <th>Action <th>Result Query
1030<tr>1046<tr>
1031 <td>URL <td>https://spi.canonical.com/orgs/&lt;org_id&gt;/results1047 <td>URL <td>https://spi.canonical.com/products/&lt;productd_id&gt;/tests/results
1032<tr>1048<tr>
1033 <td>Method <td>GET1049 <td>Method <td>GET
1034<tr>1050<tr>
@@ -1049,30 +1065,19 @@
1049 <td>Example <td>1065 <td>Example <td>
1050<pre>1066<pre>
1051./scripts/api_example.py conf.ini \1067./scripts/api_example.py conf.ini \
1052'https://spi.canonical.com/orgs/docs-org/results?start_date=20150826T00%3A00%3A00&end_date=20150826T04%3A00%3A00'1068'https://spi.canonical.com/products/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/results?start_date=20150826T00%3A00%3A00&end_date=20150826T04%3A00%3A00'
10531069
1054HTTP 2001070HTTP 200
1055{1071{
1056 "test_results": [1072 "test_results": [
1057 {1073 {
1058 "test_spec": {
1059 "name": "e2e-spec_70600150",
1060 "platform": "amd64",
1061 "image_name": "e2e-img",
1062 "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
1063 "created_at": "2015-08-26T00:00:20.297477",
1064 "test_payload": "{'foo': 'bar'}"
1065 },
1066 "test_status": "PASSED",1074 "test_status": "PASSED",
1067 "platform": "amd64",1075 "agent_revno": "197",
1068 "organization_id": "docs-org",1076 "image_reference": null,
1069 "image_name": "e2e-img",1077 "test_opportunity_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
1070 "extra_snaps": [],1078 "primary_snap_name": "test-snap.foo",
1071 "image_reference": "http://foo.com/bar",1079 "base_channel": "stable",
1072 "agent": {1080 "update_channel": null,
1073 "timing": {
1074 "setup_start": "2015-08-26T00:00:22.651078",
1075
1076[...]1081[...]
1077</pre>1082</pre>
1078</table>1083</table>
@@ -1093,12 +1098,8 @@
1093- 20150914 17:51:311098- 20150914 17:51:31
1094- 20150914 175131 Z1099- 20150914 175131 Z
10951100
1096
1097
1098### Test Result Data1101### Test Result Data
10991102
1100
1101
1102There are a few key fields in the test result JSON of note:1103There are a few key fields in the test result JSON of note:
11031104
1104<!-- FIX link to actors-and-results -->1105<!-- FIX link to actors-and-results -->
@@ -1141,7 +1142,7 @@
1141 {1142 {
1142 "image_unique_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",1143 "image_unique_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
1143 "test_status": "PASSED",1144 "test_status": "PASSED",
1144 "agent-id": "e2e-id",1145 "agent-id": "foo-agent-id",
1145 "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",1146 "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
1146 "result_payload": {1147 "result_payload": {
1147 "foo": "bar"1148 "foo": "bar"

Subscribers

People subscribed via source and target branches

to all changes: