129 Commits

Author SHA1 Message Date
kairat_kushaev
c27c25f779 Import i18n functions directly
Import i18n functions from module directly and do not use
global module variables like _ = i18n._. It makes code shorter
and cleaner. It also to detect cases when these functions are not
used in module.

Change-Id: Iaa593ac1f2dd15cbcad049bef6ba68f1cfa610da
2015-12-07 18:20:43 +03:00
Jenkins
9ebc380ab7 Merge "Run py34 env first when launching tests" 2015-12-07 00:36:03 +00:00
kairat_kushaev
63199d564c Run py34 env first when launching tests
To resolve "db type could not be determined" when running tox
for the first time py34 environment need to laucnhed before py27.

Change-Id: I572d129860119c78134a98f3bea814e6c9756aad
Closes-Bug: #1489059
2015-12-03 13:02:48 +03:00
Drew Varner
b52e0126cb Automated bandit checks in glance
Set up automated bandit checks using tox. These tests are intended to be
eventually suitable as automated gate tests.

Currently, several tests are disabled (and labeled with a TODO to enable
them). A future commit for each test will enable that test, fix all
associated false positives, and fix all associated real positives.

Change-Id: I290992be027eac180b3a0dfcf601465079c2915c
Partial-bug: 1511862
2015-11-30 09:58:28 -06:00
Jenkins
cb9518c948 Merge "Fix glance.tests.unit.v1.test_registry_client" 2015-11-27 00:03:35 +00:00
Jenkins
d24cae18da Merge "Add -constraints for CI jobs" 2015-11-26 19:56:54 +00:00
Cyril Roelandt
478dc0ef29 Fix glance.tests.unit.v1.test_registry_client
This patch fixes some common issues that prevented
glance.tests.unit.v1.test_registry_client from working with Python 3.

Change-Id: I27e8dbdd1075afe1be679a2d1573e4484591582d
Co-authored-by: Victor Stinner <vstinner@redhat.com>
2015-11-25 22:31:52 +01:00
Doug Hellmann
b30206f5ba force releasenotes warnings to be treated as errors
Change-Id: Ibf97c643bd12d8e5d1f0a71d85c020d6bb25b4c7
2015-11-25 18:41:35 +00:00
Jenkins
a1c844c893 Merge "Python3: fix test_image_data_resource" 2015-11-18 15:50:48 +00:00
Jenkins
7c64dc7071 Merge "Python3: fix glance.tests.unit.v2.test_registry_client" 2015-11-18 14:06:12 +00:00
Jenkins
e1fcc5f0f9 Merge "Python3: fix glance.tests.unit.test_migrations" 2015-11-17 03:49:23 +00:00
Cyril Roelandt
140881fbb2 Python3: fix glance.tests.unit.v2.test_registry_client
Some issues:
- the usual str vs bytes thing;
- 'reload' no longer exists in Python 3, but is available through six;
- 'min_ram' and 'min_disk' have to be integers because Python 3 cannot
  compare integers and strings.

Change-Id: I8a65da8bad7ba14b6af32348c30366d0db49212c
2015-11-13 16:38:33 +01:00
Jenkins
90ffd92d79 Merge "Python3: fix test_registry_api" 2015-11-12 18:50:17 +00:00
Cyril Roelandt
a9ec7ca68d Python3: fix glance.tests.unit.test_migrations
In Python3, map() is only called if it is consumed. The calls removed
in this patch were no-ops.

Change-Id: I83e2ee05bcda4b765d67dfb6558c6e59afe6f816
2015-11-12 17:10:48 +01:00
Cyril Roelandt
4524ca397c Python3: fix test_image_data_resource
Fix some bytes/str issues happening when switching to Python 3.

Change-Id: Ifed4873d9458ffe68ded5e8d3111f15aaa8aac66
2015-11-12 16:11:19 +01:00
Jenkins
1e6ca85d46 Merge "Python3: fix glance.tests.unit.v2.test_images_resource" 2015-11-12 12:58:09 +00:00
Jenkins
5a06382f0c Merge "Python 3: fix test_image_members_resource" 2015-11-12 11:51:39 +00:00
Cyril Roelandt
b5b941f7b8 Python3: fix test_registry_api
request.body must be bytes in Python 3.

Change-Id: I67f3973a22566395cd2a7d192c146e4f10175f63
2015-11-12 10:23:24 +01:00
Cyril Roelandt
762307ba2d Python3: fix glance.tests.unit.v2.test_images_resource
Two issues here:
- jsonutils.dump_as_bytes should be used since request.body needs to be
  set to bytes;
- in Python 3, calling "del o[:]" makes us end up in __delslice__ with
  "i" and "j" being None, hence the little trick in glance/location.py.

Change-Id: Iff191305ab55f67801183127077fc8ae9738e763
2015-11-10 04:18:40 +01:00
Cyril Roelandt
65538719ac Python 3: Fix glance.tests.unit.v2.test_tasks_resource
request.body must be set to bytes in Python 3.

Change-Id: I43ef3d6d73a78e4a6bfadfa59aa992bef8e84af4
2015-11-09 16:57:51 +01:00
Cyril Roelandt
22abe13f31 Python 3: fix test_image_members_resource
The body of a request must be bytes in Python 3.

Change-Id: I2471d491b7126f4a6d451d1fceca2e470774193c
2015-11-09 15:59:05 +01:00
Jenkins
d57a4fc4ed Merge "Port signature_utils to Python 3" 2015-11-06 13:29:26 +00:00
Sachi King
97975ed317 Add -constraints for CI jobs
This adds the constraints factor to the base section and duplicates
the sections required for CI with -constraints as tox does not
currently support factors in sections.  Work towards enabling factor
support in sections is currently stalled, as such we will need to
duplicate sections adding -constraints to facilitate running sections
with the constrained install_command.

Implements Blueprint: Requirements-Management

Change-Id: Ibbeabdf65c1405bf4d35e21375636dcc4583bbc2
2015-11-06 16:05:55 +11:00
Doug Hellmann
262d0245a5 Add reno for release notes management
Change-Id: I9549e6b491b26232f4dac900b0bf05f10eb0e30a
2015-11-04 18:21:25 +00:00
Victor Stinner
f85590f4d8 Port v1.test_registry_api to Python 3
* urlsafe_b64decode(): on Python 3, decode from ASCII to get Unicode
  string.
* urlsafe_decrypt(): encode Unicode to UTF-8.
* in some loops, copy dictionary keys or items because the dictionary
  is modified in the loop body.
* test_api: use byte string for image content, not Unicode
* test_registry_api: HTTP body type is bytes, use byte strings and
  jsonutils.dump_as_bytes(), instead of native strings and
  jsonutils.dumps()
* tox.ini: add glance.tests.unit.v1.test_registry_api to Python 3.4

Change-Id: Ib9d18dce6e5728b9adf094b5aae64a86a3fea71a
2015-10-22 22:53:05 +02:00
Victor Stinner
43178a29e5 Port signature_utils to Python 3
* Catch also binascii.Error when decoding Base64: Python 3 raises
  binascii.Error, not TypeError.
* Replace base64.b64decode() with base64.decode_as_bytes() to get
  accept also Unicode.
* verify_signature(): encode checksum_hash to UTF-8 if it's Unicode.
* Fix test_signature_utils: use byte strings
* tox.ini: add glance.tests.unit.common.test_signature_utils

Change-Id: I386892f3e28f9454a438e414730318ec3f771342
2015-10-22 16:56:23 +02:00
Jenkins
400dd00588 Merge "Port test_wsgi to Python 3" 2015-10-21 18:45:41 +00:00
Jenkins
047773ccde Merge "Port script utils to Python 3" 2015-10-21 15:37:47 +00:00
Victor Stinner
6283970aa4 Port script utils to Python 3
* Replace StandardError with exception.BadStoreUri: StandardError was
  removed in Python 3.
* tox.ini: add script util tests to Python 3.4

Change-Id: I26a723d3b5712fede9ad8ca67187fd5fbe31fc2a
2015-10-21 11:48:08 +02:00
Victor Stinner
641cef92e1 Port test_cache_manage to Python 3
* Decode HTTP body from UTF-8 to get Unicode on Python 3. The test
  still works on Python 2.
* tox.ini: add test_cache_manage to Python 3.4.

Change-Id: I637732cb06b7ae30853b35d2a83aa85f643fd43b
2015-10-19 19:27:52 +02:00
Victor Stinner
ea2673e1c5 Port test_wsgi to Python 3
* Replace filter() with list-comprehension to get a list on Python 3.
* HTTP body type is bytes: use byte strings for body.

Change-Id: Ia7fba4b075cdedd4581e4e8503f5220c1e6198d7
2015-10-19 19:19:01 +02:00
Jenkins
808633c031 Merge "Port async tests to Python 3" 2015-10-19 11:17:47 +00:00
Jenkins
ceb16d1f34 Merge "Port rpc and wsgi to Python 3" 2015-10-18 15:27:01 +00:00
Victor Stinner
47e2ce98a0 Port async tests to Python 3
* Replace exc.message with six.text_type(exc). The message attribute
  of exceptions was removed in Python 3.
* set_image_data(): replace "isinstance(data_iter, file)" with
  "hasattr(data_iter, 'close')". The file type is gone in Python 3,
  use duck-typing instead to check for the close() method.
* Use bytes instead of Unicode strings for image content. Replace
  cStringIO() with BytesIO().
* Fix data iterator: use a list of strings instead of a string.
* tox.ini: add the following tests to Python 3.4

  - glance.tests.unit.async.flows.test_convert
  - glance.tests.unit.async.flows.test_import
  - glance.tests.unit.async.flows.test_introspect
  - glance.tests.unit.async.test_taskflow_executor

Change-Id: I885e11c0da1a264456fdeb2bff54dcfd3acfd193
2015-10-16 15:28:37 +02:00
Victor Stinner
96f9ce2bac Add more tests which pass on Python 3
Add tests which pass on Python 3.4 to tox.ini.

Change-Id: I1a66128ea0cf325d715b15859dcd3375142cafc1
2015-10-15 21:52:34 +02:00
Victor Stinner
3ba4a591ee Port rpc and wsgi to Python 3
* rpc: allow also exceptions from the builtins module. On Python 3,
  builtin exceptions are part of the builtins module. The exceptions
  module was removed in Python 3.
* Fix usage of reraise(): translate_exception() returns an instance
  which is the second parameter of the reraise() function, not the
  first parameter. The first parameter is the exception type.
* test_rpc: add json_dump_as_bytes() helper to serialize JSON as
  bytes.
* JSONRequestDeserializer: don't compare None to int, it raises a
  TypeError on Python 3.
* Fix Unicode versus bytes issues: HTTP body type is bytes. Encode
  JSON to UTF-8 for example. Replace StringIO with BytesIO.
* Replace filter() with a list-comprehension to get a list on
  Python 3.
* test_client, test_image_cache_client: use bytes for HTTP body.
* tox.ini: add glance.tests.unit.common.test_rpc to Python 3.

Change-Id: I9960d6a810375474f89c1788b7016a8fbb0770e0
2015-10-13 12:27:50 +02:00
Jenkins
a2f267a1c1 Merge "Port api test_common to Python 3" 2015-10-08 11:43:28 +00:00
Victor Stinner
3924ab0db4 Port api test_common to Python 3
* Replace gen.next() with next(gen)
* tox.ini: Add glance.tests.unit.api.test_common to Python 3.4

Change-Id: If9c730db8b29e58ed87d8e587c03461ac7a921cd
2015-10-05 16:33:22 +02:00
Jenkins
f4c5715ab2 Merge "Port common.utils to Python 3" 2015-10-05 14:22:01 +00:00
Jenkins
39c73e0cec Merge "Port store image to Python 3" 2015-10-05 14:12:33 +00:00
Jenkins
557564ca94 Merge "Port replicator to Python 3" 2015-10-05 14:12:28 +00:00
Jenkins
7dbcb22f94 Merge "Port glance.db to Python 3" 2015-10-05 12:01:01 +00:00
Jenkins
dd82e70958 Merge "Port image cache to Python 3" 2015-10-05 11:59:52 +00:00
Jenkins
ac23bd2620 Merge "Fix Python 3 issues in glance.tests.unit.common" 2015-10-05 11:59:42 +00:00
Robert Collins
2e96d0c627 Remove redundant requirements.txt from tox.
pbr's reflection pulls in all the runtime requirements automatically -
the only reason to have the txt file explicitly listed is to permit
things that can't be reflected like url references - which we've
stopped using anyway.

Change-Id: I81b7ac268d5c007f74a2ab1dce94da41d6d75c7b
2015-09-25 06:52:38 +12:00
Jenkins
1225ab48e5 Merge "Remove pointless tests comparing opts against list" 2015-09-09 23:56:42 +00:00
Erno Kuvaja
5808e05a0a Remove pointless tests comparing opts against list
These tests really does not add any value on our testing.

Change-Id: Ic7c93b54288e949f8dd7f110cdc5097c4aa142af
2015-09-09 10:53:46 +00:00
Julien Danjou
5c2f9d17de Remove old traces of the oslo-incubator
There's no need to keep that around.

Change-Id: If1ee25645ed12cd81eef32a013022c89ea3cfd5f
2015-09-09 09:11:05 +02:00
Victor Stinner
0695c243c8 Port common.utils to Python 3
* CooperativeReader: buffer is a byte string, use b'' syntax
  and use bytes() instead of str().
* Don't compare None to int, it raises a TypeError on Python 3.
* Use str[i:i+1] to get a substring from a byte string. On Python 3,
  str[i] now returns an integer for byte strings.
* tox.ini: add glance.tests.unit.common.test_utils to Python 3.4

Change-Id: Ie678555ffd8ac48913f9bf08ac674d1c643bec29
2015-08-16 11:50:09 +02:00
Victor Stinner
476688080c Port store image to Python 3
* StoreLocations: add a __eq__() method, Python 3 doesn't use __cmp__()
  anymore
* Fix StoreLocations.__delitem__(): Python 3 now calls it with a slice
  for "del locations[a:b]" instead of calling __delslice__().
* Fix test_store_location: mark byte strinsg with b'...' prefix.
* tox.ini: add test_store_location to Python 3.4

Change-Id: Ibe8dac3d442ee08ae6b347e256947b6b9c5224ae
2015-08-16 11:50:09 +02:00