25 Commits

Author SHA1 Message Date
Illia Khudoshyn
ef656301d6 Add 'merge lists' function
The function added in the patch is to be used as an auxiliary
tool in a forthcoming implementation of distribluted load generation
functionality

Change-Id: I482d0e81a92eb9e783b73120478f98149fbcba96
2015-11-02 11:35:19 +00:00
Bo Chi
4bfbeb271d Refactoring log utils
* Moved log functions from rally/common/utils.py #L137-L234 to rally/common/log.y
* Moved test tunctions form test/unit/common/test_utils.py to test/unit/common/test_log.py

Change-Id: Icac3e87d507a3cf90e27071cb26bc871dac78514
2015-11-01 01:40:30 -05:00
Chris St. Pierre
9ff41768a8 Fix random name bug if task uuid is too short
If the task UUID passed to generate_random_name() was shorter than the
first set of Xs in the pattern, the UUID would be used which would
result in a random name that was too short and thus didn't match the
pattern. This fixes that.

Implements blueprint: consistent-resource-names
Closes-Bug: 1509402
Change-Id: I4f8a4415d565dbf737588a4db56fc2a6dfe893cc
2015-10-26 17:49:04 -05:00
Chris St. Pierre
dca522a99e Enable ddt on random name generator tests
It was already trying to use DDT, it just wasn't enabled for the
class.

Implements blueprint: consistent-resource-names
Change-Id: Ie9c4f59951e4e2e0d82c5aa9b493668f38ea30e6
2015-10-23 10:21:24 -05:00
Andrey Kurilin
2644c666c6 Change message of log_deprecated decorator
It is unclear what is deprecated in current message.

For example, methods `wait_for`, `wait_is_ready` and `wait_for_delete` were
deprecated in https://review.openstack.org/#/c/232438 . Deprecation
messages are equal, so logs are equal too:

    Deprecated, use wait_for_status instead. (deprecated in Rally v0.1.2)

This patch adds deprecated method's name, so it is easier to determine what
method produces deprecation log message.

Also, this patch adds ability to print warning message once, which can be
helpful for deprecated methods used in scenarios.

Change-Id: Id86e984986ecb61e7b92cc61882382179fc8a74b
2015-10-09 17:09:56 +03:00
Chris St. Pierre
18141cb71c Better random resource name generator
This adds a new random name generator that will make it easier to do
out-of-band cleanup of Rally-created resources. It eliminates the
ability for scenarios to specify a custom random name length and
prefix; adds a task-specific portion to the random name; and improves
configurability of random name patterns.

Subsequent commits will implement the new generator.

Implements: blueprint consistent-resource-names
Change-Id: I189474fbb185ab402e3b248421b4188b7ccde7f4
2015-10-07 16:15:08 -05:00
Boris Pavlovic
0ad839d19e [cli] Introduce "rally plugin" show and list commands
This patch does a few things

- Introduce rally.common.plugin.info.InfoMixin
  and adds it to plugin base. It adds method get_info()
  to all plugins. This method returns information about plugin
  such like title, description, arguments, plugin module

- Introduce rally plugin show and list commands that returns
  information about all plugins

- Moves info related methods from rally.common.utils to
  rally.common.plugin.info module

Related-Bug: #1470895
Change-Id: I8db12e3017d241a2b8bc549a817dad817f922437
2015-09-16 14:22:16 -07:00
Yuki Nishiwaki
86e8f94763 Add unit test for common.utils.EnumMixin
Add following unit test for common.utils.EnumMixin
 - Check if the name of variable start underscore (like _a), don't return value in iterate

Change-Id: Ief17f1012a0fd6b7917d5a031e03f45e5d963123
Closes-Bug: #1473331
2015-07-10 18:08:02 +09:00
Jenkins
ac31a82f2d Merge "unit-tests: fix mocks' naming" 2015-06-22 19:56:33 +00:00
Jenkins
e908c5ef25 Merge "utils: make parse_docstring respect multi-line" 2015-06-20 03:47:44 +00:00
Pavel Boldin
9076679fef unit-tests: fix mocks' naming
Fix mocks' argument/decorator naming.

Partial-Bug: #1462956
Change-Id: I8366736f3bc7088f867eec1fc72630dbe1bcf19e
2015-06-19 22:57:34 +03:00
Boris Pavlovic
2aadcf4ebe Add rally.common.plugin.discover module
Move all related to plugins from utils to discover module
and fix the code and tests to make it work

Change-Id: Ifaed1fadfa0760f121cb1584cb4d8ae3fee8768d
2015-06-17 11:19:05 +00:00
Pavel Boldin
eee3cf1ae9 utils: make parse_docstring respect multi-line
Make `parse_docstring' respect multi-line param docs and fix it not matching
the **kwargs.

Change-Id: Ic6cd6e89f94ff0656126b08b4fe563562cbd655c
2015-06-11 01:14:04 +03:00
Ilya Shakhat
71d01a6a23 Make plugins location configurable
The patch introduces CLI option --plugin-paths to specify the list of
folders with plugins.

Co-Authored-By: Roman Vasilets <rvasilets@mirantis.com>
Co-Authored-By: Ilya Shakhat <ishakhat@mirantis.com>

Change-Id: Iee39217bfe3e5c77e6925910f3998942541387a3
2015-06-05 01:21:24 +03:00
Jenkins
5101f71c94 Merge "Add function decorator `log_deprecated_args'" 2015-04-22 22:33:18 +00:00
Pavel Boldin
3db7200ab6 Add function decorator `log_deprecated_args'
Add decorator `log_deprecated_args' that issues a message whenever
the decorated function is called with deprecated keyword arguments
supplied.  Message is issued only once or per each call depending
on the configuration.

Change-Id: Icedf72c40d9255f8d82233ebf640165d4827d53b
2015-04-22 17:11:23 +03:00
Hugh Ma
98cde5e8c5 Data structs declared with constructor replaced with literal
Changes:
  - list() declarations replaced with []
  - dict() declarations replaced with {}
  - Added N351 to hacking for literal rule along with checks, test hacking, and to readme
  - Minor fix to incorrect path in hacking guidelines pointing to test_hacking.py

Change-Id: Ie7b9201d61b6f2024217b6f4117605eb52fa916a
Closes-Bug: #1437515
2015-04-14 10:49:17 -07:00
Boris Pavlovic
7ce9ec92b4 Improve hacking and remove useless unit tests
* Remove tests/unit/aas and test/unit/fixture
  fixtures are not used so just remove them
  aas - didn't have __init__.py files so these
  tests were not executed at all. By the way
  code related to this tests was removed earlier
  in this patch:
  https://review.openstack.org/#/c/152847/

* Remove all old py3 related hacking rules
  Now we have unit & functional jobs that checks them

* Add new hacking rule that protect us from usage of '

* Unified signature of all hacking methods
  (otherwise we are not able to make decorator)

* Add hacking rules decorator for skiping 3 types of lines:
  empty, commented, and with # noqa comment

Change-Id: I6bf2cc123325a4980edeb066a6c31aa685858f5b
2015-03-16 14:55:17 +03:00
Jenkins
14fa3bd655 Merge "Replace ' with " in tests/unit/[common,deploy,doc,fixtures]" 2015-02-04 10:07:33 +00:00
jacobliberman
3498071401 Replace ' with " in tests/unit/[common,deploy,doc,fixtures]
Partial bug: 1405884

Change-Id: I0100649c32bb911dab345c40492aa148ed1832c6
2015-02-03 10:48:15 -06:00
Mikhail Dubov
e2a204d35b Refactor rally.api
* Move API methods to classes, make them @classmethod
* s/deploy/deployment

Also modify unit tests.

We leave the old API methods for compability, but they are going to be
deprecated in Rally v0.0.2.

Change-Id: I44155575621c715af1109690ed2788663a4c36c3
2015-02-03 15:34:49 +03:00
Andrey Kurilin
712a6fa482 Fix all py3 related issues
This patch makes output of `tox -epy34` to finish with following message:
>  py34: commands succeeded
>  congratulations :)

Issues:
 * module "__builtin__" was renamed to "builtins" in Python 3

   Related modules:
    - rally.api
    - tests.unit.benchmark.scenarios.vm.test_utils

 * function "map"/"filter" returns "builtins.map"/"builtins.filter" object
   in Python 3 instead of list in Python 2. "builtins.map" and
   "builtins.filter" object is not subscriptable and has no len(), so list
   comprehension is preferable to use and py2/py3 compatible way.

   Related modules:
    - rally.benchmark.context.sahara.sahara_edp
    - rally.benchmark.processing.plot
    - rally.benchmark.sla.base
    - rally.benchmark.types
    - rally.cmd.commands.task
    - rally.cmd.commands.verify
    - tests.unit.benchmark.scenarios.test_base
    - tests.unit.benchmark.wrappers.test_keystone
    - tests.unit.cmd.commands.test_task
    - tests.unit.cmd.commands.test_verify

 * dict.keys()/dict.values() returns "dict_keys"/"dict_values" object in
   Python 3 instead of list in Python 2. so list(dict) and
   list(dict.values()) should be used instead.

   Related modules:
    - rally.benchmark.scenarios.utils
    - rally.benchmark.scenarios.vm.vmtasks
    - tests.unit.cmd.commands.test_show
    - tests.unit.common.test_broker
    - tests.unit.deploy.engines.test_fuel
    - tests.unit.fakes

 * Some changes was made in Python 3 related to data model, so we should
   change our inspect code. See code changes for more details

   Related modules:
    - rally.cmd.cliutils
    - rally.common.utils

 * ConfigParser is more strict for duplicate items in Python 3, so
   duplicates are removed

   Related files:
    - rally/verification/tempest/config.ini

 * Exception object doesn't have "message" attribute in Python 3, so
   if we want to get it, the most proper way is using "getattr"

   Related modules:
    - rally.verification.tempest.config

 * "mock.MagicMock" is not sortable in Python 3, so we should add required
   attributes to fix that.

   Related modules:
    - tests.unit.benchmark.context.test_base

 * assertSequenceEqual assertation method was added in tests.unit.test to
   compare sequence objects

   Related modules:
    - tests.unit.benchmark.context.cleanup.test_resources
    - tests.unit.benchmark.scenarios.nova.test_utils

 * function "range" returns "range" object in Python 3 instead of list
   in Python 2.

   Related modules:
    - tests.unit.benchmark.processing.test_utils

 * keyword arguments should be transmitted to self.assertRaises as kwargs,
   not like a dict

   Related modules:
    - tests.unit.benchmark.scenarios.dummy.test_dummy

Additional changes:
 * Python 2.6 was added to setup.cfg, since Rally supports it.
 * py33, py34 environments were added to tox.ini
 * wrong ignore path was removed from tox.ini
 * made items of bash complition sorted

Several tests are skipped in Python 3 env. For more details see notes in code:
 - tests.unit.benchmark.processing.test_plot.PlotTestCase.test__process_main_time
 - tests.unit.benchmark.processing.test_plot.PlotTestCase.test__process_atomic_time
 - tests.unit.common.test_utils.MethodClassTestCase.test_method_class_for_class_level_method

During porting Rally to Python3, several issues found and fixed in
TempestContext and its unit tests:

 - If process of cleanup is failed, exception is handled and cleanup is
   marked as successfull. This issue was fixed and CleanUpException was
   added to rally.exception module
 - Cleanup was called with wrong path.

Change-Id: If04e873790dcb4c9c882d4be4bf40479deedd36d
2015-01-26 15:18:36 +00:00
Andrey Kurilin
0f7c504bee Fix py3k issues
1) Module urllib2 is missed in Python 3, so it should be replaced by other
   http lib. "requests" is good library for such stuff, which supports both
   Python 2.* and Python 3.*

2) Function 'rally.common.utils.parse_docstring' uses built-in function
   'filter'. This function returns different types in Python 2.* and
   Python 3.*. Since results are used as a list, 'filter' should be replaced
   by list comprehension.

3) Extend H330 hacking rule to chech 'dict.iterkeys()', 'dict.itervalues()'
   and 'dict.iterlist()'. Also, fixed all places, which are failed in terms
   of this rule.

4) Function object does not have 'func_code' attribute in Python 3, but
   '__code__' attribute exist in both Python 2 and Python 3

Also, 3 tests are broken due to new release(1.6.0) of oslo.config, so we
need to skip them to unblock our gates until new version of oslo.config will
be released with appropriate fix.

Closes-Bug: #1405919

Change-Id: Icc42e220ac3f15ae6c838a4698b3c9578177513c
2015-01-06 13:01:30 +02:00
li,chen
63378f526d use function next() instead of next() method on iterator objects
Python 3 introduced a next() function to replace the next() method on
iterator objects. Rather than calling the method on the iterator, the next()
function is called with the iterable object as it's sole parameter, which
calls the underlying __next__() method.

The next() function was backported to Python 2.6 which allows us to use either
the 2.x or 3.x way simultaneously.

Change-Id: I945225b1b0c6c39842a77f4a136e9431b798229f
Closes-Bug: #1403074
2015-01-02 15:41:25 +02:00
liyingjun
a7e2a8e4f5 Move files to common lib(Part 3)
Move utils to common directory.

Change-Id: Ifaf71ea4a2a1acc85ceb2af6ed978d3e08666b41
2014-12-31 09:21:14 +08:00