189 Commits

Author SHA1 Message Date
Chris Dent
048021417e Make the gabbi tox target work with modern tox
passenv is required so that database configuration environment
variables are properly available to the tests.

Change-Id: I44050f7bbfdd27b4e4e729d23f3f8e29899d14ca
Closes-Bug: #1494339
2015-09-10 14:12:52 +00:00
Chris Dent
4b822121fa Add a py34-functional tox target
Run the functional tests against python3.4 with 'tox
-epy34-functional'.

hbase is not supported in py34 so there are fewer tests run when
compared with the py27 functional tests.

Change-Id: I68ee3e09a446d449e947c87985c10944fbea93ba
2015-09-07 12:01:41 +00:00
Jenkins
4fcb80c8ee Merge "Change tox default targets for quick use" 2015-09-04 19:19:03 +00:00
Chris Dent
28d60c2534 Change tox default targets for quick use
This change makes it so that if you call `tox` or `tox -r` you will
get a useful result as a developer running tests:

    * py27 and py34 unit tests
    * a single functional test run (using mongodb)
    * pep8

This is slightly different from what was there before which was
as above but _two_ functional test runs, with mysql and postgresql.

The goal here is to make it dead simple for someone to (as quickly
as possible) make sure that there code is okay before committing.

Change-Id: I27dcf5265dea18be541b8b2857b0a135ff22f499
2015-08-28 08:56:12 +00:00
Mehdi Abaakouk
a12d40f8b0 integration: add some new tests
This change:
* we can downscale the stack.
* use two vm instead of three to reduce the test duration

Related-bug: #1479429
Change-Id: Ifea9869cd98654d168eb8e95c6e84d3a80bc32cc
2015-08-26 05:58:15 +00:00
Ilya Tyaptin
9c8e0e5459 Allow to run debug tox job for functional tests
In this CR functional tox jobs with "oslo_debug_helper" have
been added. Currently we can run oslo_debug_helper only for unit
tests directory.

Change-Id: Ib6b79b8af4ca9718720a789b3e0ab6b9600a4671
2015-08-24 19:47:21 +03:00
Mehdi Abaakouk
5ba15a556d integration test: failfast
This change uses 'gabbi-run -x' instead of 'testr'
to stop at the first errors.

We loose the testr report, but currentlty we have
only one scenario, this is not a big deal.

Change-Id: I9ca50592e959fec4669bef3d8e645268d2d3c3d5
2015-08-21 14:41:51 +02:00
Nadya Shakhat
bd30aac5dd Make it possible to run postgresql functional job
Change-Id: Ic11571ceccb993fb6a46a4a963256f9439899ca4
2015-08-14 13:29:08 +03:00
Chris Dent
81fbcb6999 Don't start up mongodb for unit test coverage
If we are just doing the unit tests we don't need mongodb to be
started.

Change-Id: I84bf886fbab5cbca92f09f569b1ee0f2958a0af3
2015-08-07 18:32:21 +00:00
Ilya Tyaptin
49f53f35a5 Initial separating unit and functional tests
Currently we run tests which uses real backend or real daemons with
other unit tests.
This CR is initial for sequence of functional tests implementation.
It contains only moving files and modules to right directories and
fixing tox.ini. This approach allows to avoid constantly rebase conflicts,
because git handles file removing correct.

Next step - separate classes and functions from moved files to right
test types.

Depends-On: Ifdb0de150b2c738117308b2aae6c0c197e162821

Change-Id: I16b84ed83ac075658626f3ec6a35a24e228b61e7
Partialy-Implement: blueprint ceilometer-functional-tests
2015-08-06 07:59:45 +03:00
Mehdi Abaakouk
3a136f954d mongo: fix last python3 bugs
Change-Id: Ie27c51fee6ee3dc42bfb50fede99a97acbf0181c
2015-08-02 10:15:31 +02:00
Jenkins
a1b486497f Merge "Fix more tests on Python 3" 2015-08-01 14:08:49 +00:00
Jenkins
465974bc3f Merge "tests: add an integration test" 2015-07-31 18:11:26 +00:00
Victor Stinner
e8cb08fdba Fix more tests on Python 3
* HTTP body type is bytes
* query.py: Exception.message attribute was removed on Python 3
* mock calls cannot be sorted (mock calls are not comparable), use
  the assert_has_calls() with any_order=True instead.
* Port decode_unicode() on Python 3: decode bytes from UTF-8 on Python 3
  instead of encoding Unicode to UTF-8
* MeterDefinitionException: add message attribute
* tox.ini: add more tests to Python 3.4

Change-Id: Iadd1c83b250d2f941262cc6e7dba4c27cb56893d
2015-07-31 01:19:29 +02:00
Mehdi Abaakouk
34d32f6aae tests: add an integration test
This change adds an integration test.

It need a devstack with heat/aodh/ceilometer/gnocchi setuped.

The test does the following:
* check no servers and alarms are present
* create a heat autoscaling stack with aodh alarms for gnocchi
* check that the stack creation succeed
* check the stack automatically grow according the alarm configuration
* check the gnocchi resource have been created
* delete the stack
* check everything have been deleted

This test use gabbi to talk with all API.

Change-Id: I897ef4aa359fa7b65c0f18b1999e403eb89045a7
2015-07-30 19:52:58 +02:00
Victor Stinner
91dbb9f148 Fix WSGI replacement_start_response() on Python 3
Replace a/b with a//b to get an integer division.

Add more tests to Python 3.4 in tox.ini.

Change-Id: Ibd259874b211c80d3d8d3b328a105fc742b2c583
2015-07-30 19:15:17 +02:00
Sergey Vilgelm
889e66eb49 Switch to the oslo_utils.fileutils
fileutils is graduated in the oslo.utils library.
Remove the openstack.common package as well.

Implements: blueprint graduate-fileutils[1]
[1] https://blueprints.launchpad.net/oslo-incubator/+spec/graduate-fileutils

Depends-On: I51ba9076e1fbc16145ee2311f47b7768c16dcb20 (requirements)
Depends-On: I661dd222da6386a7dbcf854958a63e59b13e9ba4 (oslo.utils)

Change-Id: I6ba8f492a257096d27cbe83bfd06e53b7aabfa5d
2015-07-19 23:46:28 +03:00
Robert Collins
a1e28bd54a Remove test-requirements-py3.txt.
This will unblock requirements merges.

Change-Id: I318750ec9fe471d3df57ad2f5785026dae451242
2015-06-30 23:30:16 +12:00
gordon chung
965aca8a37 remove unused notifier
there's a notifier in our code. it doesn't seem to be connected to
anything and is not accessible via setup.cfg. this appears to be
residual workaround from pre-oslo.messaging days

Change-Id: I50c8e97219da387362aef9d1ef4c53aea0c27142
2015-06-24 22:43:35 -04:00
ZhiQiang Fan
c2446a7c60 add oslo.service options
patch https://review.openstack.org/#/c/194772 try to add oslo.service
options but oslo.service has defined its options into three modules,
so the right definition should be oslo.service.service which contains
eventlet back door option.

Change-Id: I1b3efe9a2e93f8548ab0d52ca10b2acf0f07d511
ref: https://github.com/openstack/oslo.service/blob/0.1.0/setup.cfg#L33
2015-06-24 00:26:00 -07:00
Julien Danjou
c2b843036d Fix oslo.service configuration options building
Change-Id: I829b57d92df49692b56ec7a80d7406d06ffab844
2015-06-23 20:18:07 +02:00
Jenkins
17646c25b0 Merge "pip has its own download cache by default" 2015-06-22 14:22:14 +00:00
Victor Stinner
5087b255bb Port test_complex_query to Python 3
* query.py: the message attribute of Exception was removed in Python 3,
  replace e.message with e to format the new error message
* Fix test_complex_query_scenarios: convert
  sample_item["metadata"]["util"] to float; "0.5" >= 0.5 is True in
  Python 2, but it raises a TypeError on Python 3.
* tox.ini: add the following API v2 tests to Python 3.4:

  - test_complex_query_scenarios.TestQueryMetersController.test_query_with_volume_field_name_orderby

Change-Id: I112e5564a65db005cf66ce967a8ac3e52fa95267
2015-06-20 09:07:30 +02:00
Victor Stinner
54b114c428 Fix expected error message on Python 3
* Use repr() at runtime instead of using the hardcoded result:
  repr(u'abc') returns 'abc' on Python 3, not u'abc'.
* Add the following api.v2 test to tox.ini for Python 3.4

  - test_alarm_scenarios.TestAlarms.test_get_alarm_history_constrained_by_alarm_id_failed

Change-Id: Ied224b194a73e14c2c04ff3d9837964420ce766c
2015-06-20 09:07:30 +02:00
Victor Stinner
86ffa59c73 Fix usage of iterator/list on Python 3
* CombinationEvaluator: convert states (built using zip) to a list
  because states is consumed more than once. On Python 3, zip() returns
  an iterator which can only be consumed once.
* Replace dict.keys()[0] with list(dict.keys())[0]. On Python 3, keys()
  returns an iterator which is not indexable.
* test_event_scenarios: replace filter() with a list-comprehension, the
  test expects a list whereas filter() returns on iterator on Python 3.
* mongo/utils.py: replace obj.keys()[0] with list(obj.keys())[0],
  and replace obj.values()[0] with list(obj.values())[0]
* Add the following API v2 tests to tox.ini in Python 3.4:

  - test_event_scenarios.TestEventAPI.test_get_events_filter_datetime_trait

Change-Id: I28bcb65940edbc226c8dbb272f4e3c040ebc37a1
2015-06-20 09:06:52 +02:00
Jenkins
a16acb1e01 Merge "Fix unicode/bytes issues in API v2 tests" 2015-06-19 13:36:11 +00:00
Chris Dent
5f1f33cbc9 pip has its own download cache by default
We no longer need tox to tell us to use one.

Change-Id: Ib988348fe19fccf8862597e8d831d282462be105
2015-06-19 12:19:54 +00:00
Victor Stinner
14766ba719 Fix unicode/bytes issues in API v2 tests
* HTTP body type is bytes: fix tests to use bytes strings.
* test_list_resources_scenarios: on Python 3, base64.encodestring() returns
  bytes whereas the test expects bytes; decode the result from ASCII.
* tox.ini: add the following API v2 tests to Python 3.4:

  - test_alarm_scenarios.TestAlarms.test_alarms_query_with_timestamp
  - test_complex_query_scenarios.TestQueryMetersController.test_query_with_isotime
  - test_list_resources_scenarios.TestListResources.test_with_invalid_resource_id

Change-Id: I8258c2d17fbc1236f4bcda40bff93a93bddf13e2
2015-06-16 01:20:51 +02:00
Ildiko Vancsa
d496bb8ac8 Fix script name in tox.ini for Elasticsearch
Change-Id: Ifc8c2cc8a4964a3d5b00c6107f1ce9c5d6e8518a
2015-06-15 18:16:13 +02:00
Victor Stinner
852396e48d Fix publisher test_udp on Python 3
* Call msgpack.loads() with an encoding to get unicode strings, not
  byte strings
* Sort counters using their name because a counter is a dictionary
  and dictionaries are not comparable in Python 3.
* Add test_udp to tox.ini for Python 3.4.

Change-Id: Ifa20eecbc1c293da667f58843b7a6c2d7f32152c
2015-06-12 18:11:42 +02:00
Victor Stinner
f945f9b797 Fix Ceph object store tests on Python 3
* Fix keystoneclient mock on Python 3: service_catalog.url_for() must
  return a string because urllib.parse.urljoin() is now more strict on
  Python 3
* tox -e py34: add objectstore.test_rgw

Change-Id: I0a4a33a26b7984854c8561866a6f49e2b4d7ff6d
2015-06-12 18:11:42 +02:00
Victor Stinner
4a392ca17d Port IPMI to Python 3
binascii.hexlify() returns a byte string whereas the code expects a
native string, so Unicode on Python 3. On Python 3, decode the string
from ASCII to get Unicode.

Enable ipmi tests in tox.ini on Python 3.4.

Change-Id: I154723ad42efb61a06b71600975374441920a852
2015-06-12 18:11:42 +02:00
Victor Stinner
5977295daf Port middleware to Python 3
* Fix integer division: status_code/100 => status_code//100
* HTTP body type is bytes. Decode the HTTP body from UTF-8 to use it.
  Encode XML and JSON to UTF-8 to produce the HTTP body (for error
  messages).
* Factorize XML/JSON code a little bit more (ex: add the new
  content_type variable)
* Fix test_app on Python 3: decode HTTP from UTF-8 to load JSON
* tox.ini: add api.v2.test_app to Python 3.4

Change-Id: I4f916cba36306f776b01df915c55e314ade6b6ba
2015-06-12 18:11:42 +02:00
Julien Danjou
191f7bf9cc Remove deprecated Swift middleware
Change-Id: Ifd1861e3df46fad0e44ff9b5cbd58711bbc87c97
2015-06-09 18:05:19 +02:00
Jenkins
89089c2a70 Merge "Fix more tests on Python 3" 2015-06-09 14:05:11 +00:00
Victor Stinner
b47c2cd85e Fix more tests on Python 3
* Fix test_get_connection: max_bytes and backup_count parameters of the
  logging module must be int, not None.
* Fix test_query on Python 3: ast.literal_eval("1+1") now returns 2 on
  Python 3, whereas it raises a ValueError on Python 2. Use a string
  invalid in Python 2 and Python 3 based on the original bug report
  #1221736
* test_swift: fix url_for() mock, it now returns a string for the
  endpoint
* storage.test_get_connection: skip test_three_urls_no_default()
  if the happybase module is missing (it's not compatible with Python 3
  yet)

Enable more tests on Python 3.4:

*  ceilometer.tests.api.v2.test_query
*  ceilometer.tests.dispatcher.test_db
*  ceilometer.tests.dispatcher.test_file
*  ceilometer.tests.dispatcher.test_http
*  ceilometer.tests.objectstore.test_swift
*  ceilometer.tests.storage.test_get_connection

Change-Id: I1d9bdd73bd21ec5dc8ee9823352f6dfe818b8d6b
2015-06-09 11:27:53 +02:00
Ilya Tyaptin
57a9fc5bce Add running functional scripts for defined backend
This CR allows running "functional" tox job for different backends.
Short description about expected workflow:
1. Gate job run ceilometer/ceilometer/tests/functional/hooks/post_test_hook.py
with <backend> parameter.
2. This script run "tox -efunctional" command with defined variable
CEILOMETER_TEST_BACKEND
3. After in "run-functional-tests.sh" setup script for the backend
and testr are runned.

In this CR running testr with pretty_tox.sh script added because
it allows to use subunit-trace output which developed in tempest-lib
and improve useful of testr output.

Partially implements: blueprint ceilometer-functional-tests
Change-Id: Idb66aca0b46779516db2baec856df8223dbe5c13
2015-06-04 16:29:02 +03:00
Jenkins
e71e391a4f Merge "use oslo.log instead of oslo-incubator code" 2015-05-28 21:36:32 +00:00
ZhiQiang Fan
c612727ff8 use oslo.log instead of oslo-incubator code
oslo.log has graduated from oslo-incubator, and openstack.common.log
has been removed from oslo-incubator, so let's use the new one.

NOTE1:openstack.common.log registers its options at import time, but
oslo.log needs to call register_options() explicitly.

NOTE2: split unit test case in tests/objectstore/test_swift_middleware.py
to avoid duplicate cli option register exception, see NOTE1.

Change-Id: Ida30808dbe0c584919755c207ca4ee4b91963a17
2015-05-28 11:08:02 -04:00
Jenkins
68558869a6 Merge "Port test_inspector to Python 3" 2015-05-28 09:31:07 +00:00
Jenkins
b02d6835a6 Merge "Fix usage of dictionary methods on Python 3" 2015-05-28 09:29:03 +00:00
Victor Stinner
ce08e620fa Port test_inspector to Python 3
* Replace contextlib.nested() with contextlib.ExitStack
* Add contextlib2 dependency for Python 2.6 and 2.7 to get ExitStack
* TestLibvirtInspection: set libvirtError because it must be a subclass
  of Exception on Python 3

Enable ceilometer.tests.compute.virt.libvirt.test_inspector on Python 3.

Change-Id: I82f4b911c1b3ede90805150630c222b1dd5f3474
2015-05-28 09:37:22 +02:00
Victor Stinner
bfaefc9492 Fix usage of dictionary methods on Python 3
Convert the result of keys(), values() and items() dict method to list
when a list is expected. On Python 3, these methods now return an
iterator, not a list.

Instead of getting the key with .keys()[0] and then the value with
.values()[0], get both at the same time using .items()[0]. It ensures
that the key is consistent with the value, but it is also more
efficient.

Enable ceilometer.tests.storage.test_impl_sqlalchemy on Python 3.4.

Change-Id: I4bcd3dfbca3e26238cdcdf19801244497dac2729
2015-05-28 09:27:30 +02:00
Victor Stinner
7d70942132 Add oslo.vmware to Python 3 test dependencies
Enable ceilometer.tests.compute.virt.vmware.test_vsphere_operations on
Python 3.4.

Change-Id: If3fbc4c5b821cb700799db5597ca6d259167003e
2015-05-28 01:00:00 +02:00
Jenkins
c4cc3bdab4 Merge "Enable test_swift_middleware on Python 3" 2015-05-27 15:31:02 +00:00
Jenkins
35d7ff3d02 Merge "Clear useless exclude from flake8 ignore in tox" 2015-05-27 15:30:54 +00:00
Jenkins
5efc099db4 Merge "Enable more tests on Python 3" 2015-05-26 15:14:16 +00:00
Jenkins
281a8ecd94 Merge "Initial commit for functional tests" 2015-05-26 14:34:11 +00:00
Victor Stinner
ab2a1bc7ad Enable test_swift_middleware on Python 3
Enable also event_pipeline test.

Change-Id: Iffdbc770bb167f49243d7799bb50dc7c4c65a0dd
2015-05-26 15:19:40 +02:00
Victor Stinner
30159de5cd Enable more tests on Python 3
* Trait.convert_value() now explicitly decodes byte strings from UTF-8:
  it fixes a BytesWarning error when Python 3 is run using -bb command
  line option
* Replace types.NoneType with type(None)
* fileutils.write_to_tempfile() expects content as bytes: encode the
  content on Python 3
* subprocess.Popen.communicate() returns stdout and stderr as bytes:
  check for pattern using byte strings
* Fix verify_signature() on Python 3: encode new signature to ASCII
* Replace "with contextlib.nested(...):" with two nested with,
  contextlib.nested() was removed in Python 3
* Fix import in test_messaging
* tox -e py34 now runs much more tests

Change-Id: If2a16c3b8ca64ca86d8172b36ecbf6298044ec87
2015-05-26 15:19:40 +02:00