|
1 | | -Contributing to VWS Python Mock |
2 | | -=============================== |
| 1 | +Contributing to VWS Python |
| 2 | +========================== |
3 | 3 |
|
4 | 4 | Contributions to this repository must pass tests and linting. |
5 | 5 |
|
@@ -45,148 +45,18 @@ To fix some lint errors, run the following: |
45 | 45 | Running tests |
46 | 46 | ------------- |
47 | 47 |
|
48 | | -Create an environment variable file for secrets: |
49 | | - |
50 | | -.. code:: sh |
51 | | -
|
52 | | - cp vuforia_secrets.env.example vuforia_secrets.env |
53 | | -
|
54 | | -Some tests require Vuforia credentials. |
55 | | -To run these tests, add the Vuforia credentials to the file ``vuforia_secrets.env``. |
56 | | -See “Connecting to Vuforia”. |
57 | | - |
58 | | -Then run ``pytest``: |
| 48 | +Run ``pytest``: |
59 | 49 |
|
60 | 50 | .. code:: sh |
61 | 51 |
|
62 | 52 | pytest |
63 | 53 |
|
64 | | -Connecting to Vuforia |
65 | | ---------------------- |
66 | | - |
67 | | -To connect to Vuforia, Vuforia target databases must be created via the Vuforia Web UI. |
68 | | -Then, secret keys must be set as environment variables. |
69 | | - |
70 | | -The test infrastructure allows those keys to be set in the file ``vuforia_secrets.env``. |
71 | | -See ``vuforia_secrets.env.example`` for the environment variables to set. |
72 | | - |
73 | | -Do not use a target database that you are using for other purposes. |
74 | | -This is because the test suite adds and deletes targets. |
75 | | - |
76 | | -To create a target database, first create a license key in the `License Manager <https://developer.vuforia.com/targetmanager/licenseManager/licenseListing>`__. |
77 | | -Then, add a database from the `Target Manager <https://developer.vuforia.com/targetmanager>`__. |
78 | | - |
79 | | -To find the environment variables to set in the ``vuforia_secrets.env`` file, visit the Target Database in the Target Manager and view the “Database Access Keys”. |
80 | | - |
81 | | -Two databases are necessary in order to run all the tests. |
82 | | -One of those must be an inactive project. |
83 | | -To create an inactive project, delete the license key associated with a database. |
84 | | - |
85 | | -Targets sometimes get stuck at the “Processing” stage meaning that they cannot be deleted. |
86 | | -When this happens, create a new target database to use for testing. |
87 | | - |
88 | | -Skipping some tests |
89 | | -------------------- |
90 | | - |
91 | | -Set either ``SKIP_MOCK`` or ``SKIP_REAL`` to ``1`` to skip tests against the mock, or tests against the real implementation, for tests which run against both. |
92 | | - |
93 | 54 | Travis CI |
94 | 55 | --------- |
95 | 56 |
|
96 | 57 | Tests are run on Travis CI. |
97 | 58 | The configuration for this is in ``.travis.yml``. |
98 | 59 |
|
99 | | -Travis CI is set up with secrets for connecting to Vuforia. |
100 | | -These variables include those from ``vuforia_secrets.env.example``. |
101 | | - |
102 | | -To avoid hitting request quotas and to avoid conflicts when running multiple tests in prallel, we use multiple target databases. |
103 | | - |
104 | | -Travis builds use a different credentials file depending on the build number. |
105 | | -For example, build 2045.1 will use a different credentials file to build 2045.2. |
106 | | -This should avoid conflicts, but in theory the same credentials file may be run across two Pull Request builds. |
107 | | -This may cause errors. |
108 | | - |
109 | | -How to set Travis CI secrets |
110 | | -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
111 | | - |
112 | | -Create environment variable files for secrets: |
113 | | - |
114 | | -.. code:: sh |
115 | | -
|
116 | | - mkdir -p ci_secrets |
117 | | - cp vuforia_secrets.env.example ci_secrets/vuforia_secrets_1.env |
118 | | - cp vuforia_secrets.env.example ci_secrets/vuforia_secrets_2.env |
119 | | - ... |
120 | | -
|
121 | | -Add Vuforia credentials for different target databases to the new files in the ``ci_secrets/`` directory. |
122 | | -Add as many credentials files as there are builds in the Travis matrix. |
123 | | -All credentials files can share the same credentials for an inactive database. |
124 | | - |
125 | | -Install the Travis CLI: |
126 | | - |
127 | | -.. code:: sh |
128 | | -
|
129 | | - gem install travis --no-rdoc --no-ri |
130 | | -
|
131 | | -Add the encrypted secrets files to the repository and Travis CI: |
132 | | - |
133 | | -.. code:: sh |
134 | | -
|
135 | | - make update-secrets |
136 | | -
|
137 | | -Note that the `Travis CI documentation <https://docs.travis-ci.com/user/encrypting-files/#Caveat>`__ warns that this might not work on Windows. |
138 | | - |
139 | | -Travis CI Settings |
140 | | -~~~~~~~~~~~~~~~~~~ |
141 | | - |
142 | | -All targets are deleted from the database between each test. |
143 | | -Therefore there may be conflicts if the test suite is run concurrently as Travis CI is configured to connect to one Vuforia database. |
144 | | -As such, Travis CI is configured not to run multiple instances of the test suite concurrently. |
145 | | - |
146 | | -Learnings about VWS |
147 | | -------------------- |
148 | | - |
149 | | -Vuforia Web Services, at the time of writing, does not behave exactly as documented. |
150 | | - |
151 | | -The following list includes details of differences between VWS and expected or documented behaviour. |
152 | | - |
153 | | -When attempting to delete a target immediately after creating it, a ``FORBIDDEN`` response is returned. |
154 | | -This is because the target goes into a processing state. |
155 | | - |
156 | | -``image`` is required for ``POST /targets``, but it is documented as not mandatory. |
157 | | - |
158 | | -The ``tracking_rating`` returned by ``GET /targets/<target_id>`` can be -1. |
159 | | - |
160 | | -The database summary from ``GET /summary`` has multiple undocumented return fields. |
161 | | - |
162 | | -The database summary from ``GET /summary`` has is not immediately accurate. |
163 | | - |
164 | | -Some of the `Vuforia Web Services documentation <https://library.vuforia.com/articles/Training/Image-Target-Guide>`__ states that “The size of the input images must 2 MB or less”. |
165 | | -However, other `Vuforia Web Services documentation <https://library.vuforia.com/articles/Solution/How-To-Perform-an-Image-Recognition-Query>`__ is more accurate: “Maximum image size: 2.1 MPixel. |
166 | | -512 KiB for JPEG, 2MiB for PNG”. |
167 | | - |
168 | | -The documentation page `How To Perform an Image Recognition Query`_ states that the ``Content-Type`` header must be set to ``multipart/form-data``. |
169 | | -However, it must be set to ``multipart/form-data; boundary=<BOUNDARY>`` where ``<BOUNDARY>`` is the boundary used when encoding the form data. |
170 | | - |
171 | | -The documentation page `How To Perform an Image Recognition Query`_ states that ``Content-Type`` will be the only response header. |
172 | | -This is not the case. |
173 | | - |
174 | | -The documentation page `How To Perform an Image Recognition Query`_ states that 10 is the maximum allowed value of ``max_num_results``. |
175 | | -However, the maximum allowed value is 50. |
176 | | - |
177 | | -A response to an invalid query may have an ``application/json`` content type but include text (not JSON) data. |
178 | | - |
179 | | -After deleting a target, for up to approximately 30 seconds, matching it with a query returns a 500 response. |
180 | | - |
181 | | -A target with the name ``\uffff`` gets stuck in processing. |
182 | | - |
183 | | -The documentation page `How To Perform an Image Recognition Query`_ states that "The API accepts requests with unknown data fields, and ignore the unknown fields.". |
184 | | -This is not the case. |
185 | | - |
186 | | -The documentation page `How To Perform an Image Recognition Query`_ states "Maximum image size: 2.1 MPixel. 512 KiB for JPEG, 2MiB for PNG". |
187 | | -However, JPEG images up to 2MiB are accepted. |
188 | | - |
189 | | -.. _How To Perform an Image Recognition Query: https://library.vuforia.com/articles/Solution/How-To-Perform-an-Image-Recognition-Query |
190 | 60 |
|
191 | 61 | Performing a release |
192 | 62 | -------------------- |
|
0 commit comments