summaryrefslogtreecommitdiff
path: root/taskflow/tests/unit/test_utils.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove sixTakashi Kajinami2022-05-181-2/+1
| | | | | | | | This library no longer supports Python 2, thus usage of six can be removed. This also removes workaround about pickle library used in Python 2 only. Change-Id: I19d298cf0f402d65f0b142dea0bf35cf992332a9
* Replace assertEqual(None, *) with assertIsNone in testsweiweigu2016-07-121-2/+2
| | | | | | | | Replace assertEqual(None, *) with assertIsNone in tests to have more clear messages in case of failure. Change-Id: I74452af6d840bcf612fd3bb2521db9134460dd63 Closes-Bug: #1280522
* Allow for alterations in decider 'area of influence'Joshua Harlow2016-01-091-18/+0
| | | | | | | | Christmas came early. Closes-Bug: #1479466 Change-Id: I931d826690c925f022dbfffe9afb7bf41345b1d0
* Change name of misc.ensure_dict to misc.safe_copy_dictJoshua Harlow2015-12-141-5/+12
| | | | Change-Id: I2ff3b9bb4d0b8143163e4bf370f10c74e79dbd31
* Add optional 'defer_reverts' behaviorGreg Hill2015-11-171-0/+24
| | | | | | | | | | | This makes it possible to REVERT a subflow and have it also revert the parent flow if the parent flow doesn't have its own retry strategy. We will probably want to make this new behavior the default or only behavior in a future release. Change-Id: Iea5ac366380ba7396a87d0185703549fb0c2f825
* Fix order of assertEqual for unit.test_*lin-hua-cheng2015-10-171-7/+7
| | | | | | | First parameter should be the expected value. Change-Id: I2941296e38c3245da298cc64aeb5636fbc4b2eb6 Partial-Bug: #1357117
* Small refactoring of 'merge_uri' utility functionJoshua Harlow2015-05-021-0/+36
| | | | | | | | Perform some small adjustments/cleanups and add some unit tests to ensure this function keeps operating as expected. Change-Id: I496bd6844072f57624de31fc7ddb0362f163cc53
* Merge "Added a map and a reduce task"Jenkins2015-03-141-0/+15
|\
| * Added a map and a reduce taskMin Pae2015-03-121-0/+15
| | | | | | | | | | | | | | - Added a MapFunctorTask and ReduceFunctorTask to mimic the python builtin functions map and reduce, respectively Change-Id: I29cd1249e1671aedfd2d25460d746b8d2154df2b
* | Fix lookup scoping multi-match orderingJoshua Harlow2015-02-241-0/+18
|/ | | | | | | | | | | | | | | | | When look-up is occurring the possible provider ordering is used instead of the scope returned provider ordering. This causes incorrect matches when look-up argument names that are produced by multiple providers (at the same scope level) all providing the same requirement name. The scope order should be enforced as the de-facto order and not the order that the storage unit finds (which is hash based and varies depending on hash ordering). Closes-Bug: #1425326 Change-Id: I15f1ee5515758bdc470c0f7dd7a2f616923e5628
* Refactor parts of the periodic workerJoshua Harlow2015-02-221-0/+18
| | | | | | | | | | | | | | Perform some adjustments to the periodic worker type to make it easier to later change and make it better in the future. These changes hopefully also reduce complexity and increase understandability. In part this deprecates providing a tombstone via __init__() since that will restrict future enhancements we can make (in retrospect we need more internal control over that argument & type to build better workers). Change-Id: I1965e157c303c2a45b9950e9f4a921c638f57fd1
* Improve multilock class and its associated unit testJoshua Harlow2015-02-131-0/+36
| | | | | | | | | | | | | | | | | | In the multilock unit test check that all values were acquired (as expected). Also use a class constant for the number of threads to spin up when testing timing overlaps and use the module constant for the duration to wait (to try to trigger overlaps) and use a new helper utility function to make it more obvious what is happening in the multilock release method. Also swaps out the usage of time.time in the lock utils unit test to attempt to use monotonic time (when it can be used) so that false positives are unable to happen (using time.time it is possible for time to go backwards and cause a non-existent overlap to appear). Change-Id: Ifb3967e1c1da41e1b7ac0793fc6a99f84de2a907
* Remove need to inherit/adjust netutils split0.6.1Joshua Harlow2015-01-051-1/+1
| | | | | | | | | | | | The code we had for adjusting the netutils urlsplit function to add in a params method/property is no longer needed as that functionality is now pushed into the oslo.utils repo/package where it can be maintained there in a more proper manner instead; so we can now remove our adjustment code and just use the upstream code instead. Change-Id: I5ca05c0ac6a6221157a737ba20814cfd63adf51e
* Move over to using oslo.utils [reflection, uuidutils]Joshua Harlow2014-12-181-255/+0
| | | | | | | | | | | | | | The reflection module is now part of oslo.utils so we should remove our local version and use that version instead; this also goes for the uuidutils module which is now part of oslo.utils as well so we no longer need our local version copied from the incubator... Note that one reflection method `find_subclasses` which was to specific to taskflow is now moved to the misc utility module instead of its prior home in the reflection module. Change-Id: I069881c80b0b2916cc0c414992b80171f7eeb79f
* Use a tiny clamp helper to clamp the 'on_progress' valueJoshua Harlow2014-12-131-0/+29
| | | | | | | | | | Add a misc.clamp function that will clamp a value to a given range (it can also call a callback if clamping occurs). Use it to clamp the progress value that was previously clamped with a set of customized logic that can now be replaced with a more generalized logic that can be shared. Change-Id: I8369dbb61f73a60932d9e15c8b4d06db249ea38e
* When creating daemon threads use the bundled threading_utilsJoshua Harlow2014-11-191-3/+2
| | | | | | | | | | | Instead of creating daemon threads using the threads module directly use our small utility file to create the daemon thread on our behalf and set the appropriate attributes to ensure it's a daemon thread. This change replaces the existing locations where we were doing this manually and uses the threading_utils helper function uniformly instead. Change-Id: I535cee8a63407f753cf812df53c4f5bc83e0c9ae
* Remove attrdict and just use existing typesJoshua Harlow2014-10-181-108/+0
| | | | | | | | | | | | In order to make it simpler (and less code) just prefer to use object types that already exist instead of trying to make dictionaries also behave like objects. For those that really need this kind of functionality: https://pypi.python.org/pypi/attrdict Change-Id: Ib7ddfa517f0500082fafac2c3e53fd6a158a6ddf
* Hoist the notifier to its own moduleJoshua Harlow2014-10-181-84/+0
| | | | | | | | | | | | | | | | | | | | The notifier module needs to be hoisted out of the misc utility file so that it can be depended on existing by users in a well defined (non-utility) location. This change does this hoisting process & creates a new module and places the existing code there, then creates a deprecated proxy that exists at the old location (this will be removed in the next version + 1). In a future change (in 0.5) we can remove this old location and remove all references to the previous location (until then we must keep the old location being used to ensure subclass checks and other types checks function properly). Part of blueprint top-level-types Change-Id: I47fac110adf7cec5c859c2e055c1ceb1f25a7fbd
* Move failure to its own type specific moduleJoshua Harlow2014-10-181-44/+3
| | | | | | | | | | | | | | | | | | | | The failure module needs to be hoisted out of the misc utility file so that it can be depended on existing by users in a well defined (non-utility) location. This change does this hoisting process & creates a new module and places the existing code there, then creates a deprecated proxy that exists at the old location (this will be removed in the next version + 1). In a future change (in 0.5) we can remove this old location and remove all references to the previous location (until then we must keep the old location being used to ensure subclass checks and other types checks function properly). Part of blueprint top-level-types Change-Id: I7d13ad1e9e5f5ecc90ab81949cc92ddf7309f13c
* Ensure the cachedproperty creation/setting is thread-safeJoshua Harlow2014-09-051-0/+33
| | | | | | | | | | | | When the cachedproperty descriptor is attached to an object that needs to be only created/set by one thread at a time we should ensure that this is done safely by using a lock to prevent multiple threads from creating and assigning the associated attribute. Fixes bug 1366156 Change-Id: I0545683f83402097f54c34a6b737904e6edd85b3
* Use __qualname__ where appropriateJoshua Harlow2014-08-271-4/+52
| | | | | | | | | | | | | | | | | The __qualname__ attribute simplifies the determination of an objects class name and callable name and is useful in python 3.x to be able to use since it can correctly identify names better than the python 2.x __name__ attribute can. Adds a few tests in to ensure that the usage of __qualname__ where available functions as expected. See: http://legacy.python.org/dev/peps/pep-3155/ Fixes bug 1341441 Change-Id: Ic6942cbbc8e35d65fb3ac603ff1dfc8e20c194a3
* Move the stopwatch tests to test_typesJoshua Harlow2014-07-031-43/+0
| | | | | | | | | Since the stopwatch is a type in the time module we should move the test for it from utils test to the test that is used to test all the various types. Change-Id: Id462baaada2784bf2af1da9c8548a2393c1af7fb
* Create a top level time typeJoshua Harlow2014-06-201-6/+7
| | | | | | | | | | | | Create a time module under types and place the stop watch class and timeout classes there so that we can have a single location where generic types that do things with time can be located. Part of blueprint top-level-types Change-Id: I8eb7e897c0354b20a7fa0d061434006e775d5e94
* Ensure cachedproperty descriptor picks up docstringsJoshua Harlow2014-06-021-0/+20
| | | | | | Closes-Bug: #1325677 Change-Id: I6366dea5458adec30e945a9834e15da946813461
* Add tests for the misc.cachedproperty descriptorJoshua Harlow2014-05-201-0/+59
| | | | | | Add a few tests that verify it is working as expected. Change-Id: I6c062f84f7c2a6baf8fc9a697ebe2d715f82d332
* Integrate urlparse for configuration augmentationJoshua Harlow2014-04-281-0/+45
| | | | | | | | | | | | | | | Allow the uri passed to various entrypoints to itself contain most of the configuration for that entrypoint by using the RFC 3986 uri format to allow for additional parameters to be used in configuring and selecting those entrypoints. Also bring over network_utils from oslo since it provides a more compliant url splitting support. Part of blueprint persistence-uris Change-Id: I8e5d8584d2cac4f9b338fa155f220cdfd52bb7d9
* Allow jobboard event notificationJoshua Harlow2014-04-211-16/+16
| | | | | | | | | | | | | | | | | | | Instead of requiring iteration to be able to list new jobs and existing jobs so that they can be claimed, allow for attaching callbacks to the jobboard where instead of requiring iteration those callbacks will be automatically called by the jobboard internally when events are recieved. Breaking change: renames transition notifier to notifier since it is really not just a notifier for transitions but is a generic notifier of events occuring (and details about those events). This is an internal api so its not expected that this will cause any issues (it's not expected for external users to be creating instances of this class). Implements bp board-notification Change-Id: I2384d5e335ed9d17e29fec9a78699e3156fa225c
* Revert "Move taskflow.utils.misc.Failure to its own module"Jeremy Stanley2014-03-311-3/+2
| | | | | | | | | | | | This reverts commit 42ca240e8157b840c298d14fbf478ae570376633 which was a breaking change in a library consumed by other OpenStack projects with no deprecation or backwards compatibility considerations. It was able to merge because openstack/taskflow is apparently not yet part of the integrated gate via the proposed I202f4809afd689155e2cc4a00fc704fd772a0e92 change. Change-Id: I96cf36dc317499df91e43502efc85221f8177395 Closes-Bug: #1300161
* Move taskflow.utils.misc.Failure to its own moduleIvan A. Melnikov2014-03-311-2/+3
| | | | | | | | | | Failure class is important part of TaskFlow API, so it should be more visible and accessible. Breaking change: any client that used taskflow.utils.misc.Failure should be updated. Change-Id: Ib30000c9246bbcb227b34dfb0aba4d0b950bf926
* Rewrite assertion for same elements in sequencesIvan A. Melnikov2014-03-221-0/+19
| | | | | | | | | | | | New version is able to compare sequences whith elements that are not hashable and cannot be compared (so that sorted() does not work). For that, a utility function that caluclates difference between two sequences was added. This function was also used in retry.ForEachBase. The assertion was also renamed to assertItemsEqual, which matches same assertion that was added in python 2.7. Change-Id: I2b1b811190e9dc51718e4ca17ffc5c9015c34dc4
* Remove extraneous vim configuration commentsyangxurong2014-02-141-2/+0
| | | | | | | | | Remove line containing comment - # vim: tabstop=4 shiftwidth=4 softtabstop=4 Change-Id: I7581cc88b8de433d5609ed06c6570b0b45c13573 Closes-Bug:#1229324
* Doc strings and comments clean-upskudriashev2014-01-261-4/+4
| | | | | | | | * Added missing period for doc strings * Correct syntax errors * Remove H402 from flake8 ignore list Change-Id: Ia8592bf99378e3658d6cca2ceb148bf9eb0b5de8
* Capture task durationJoshua Harlow2013-12-091-0/+42
| | | | | | | | | | | Record how long a task took to execute (or fail) by adding a new listener (and associated refactoring) that can be used to record these time statistics in storage. blueprint capture-task-duration Change-Id: I9c556e5dcbad924380ae4b94ffb03bc22edad50a
* Fixes how instances methods are not deregisteredJoshua Harlow2013-12-041-0/+125
| | | | | | | | | | | | | It appears that instance methods do not get removed due to not passing the 'is' check, so switch to using a new reflection utility method which can handle this equality check in a way that actually works. Also adds tests to make sure this does not occur again. Closes-Bug: 1257550 Change-Id: Iab47dd62cb61de0d93d0fe8d90e59772beebeaeb
* Improve is_valid_attribute_name utility functionIvan A. Melnikov2013-11-221-0/+31
| | | | | | | | - don't allow python keywords; - use ascii symbols only, no national letters or digits; - code cleanup. Change-Id: Ibf863edb6fd06257df05ca3c490f87f1c097144f
* Fix up python 3.3 incompatabilitiesJoshua Harlow2013-11-211-4/+10
| | | | | | | | | | | | Make the python 3.3 testing work by selectively disabling & including eventlet, switch to testtools and testrepository which has 2.6, 2.7, 3.2+ unified testing support so that we can correctly run our tests in all supported python versions. Closes-Bug: #1251660 Co-authored-by: Alexander Gorodnev <agorodnev@griddynamics.com> Change-Id: I23b6f04387cfd3bf6b5a044edffa446ca897ce3a
* Update code to comply with hacking 0.8.0Ivan A. Melnikov2013-11-081-35/+35
| | | | | | | Replace assertEquals and assertNotEquals with assertEqual and assertNotEqual (new rule, H234), and fix indentation. Change-Id: I86177325dee3aa00af5df8b3085acd478994ee34
* Support for optional task argumentsIvan A. Melnikov2013-10-221-9/+14
| | | | | | | | | We used to ignore optional task arguments (arguments of 'execute' method with default value). With this change flow author can pass such arguments to task by mentioning them in 'requires' and/or 'rebind' task constructor parameters. Change-Id: Ib92f87eb05623d30db6f1691d75c11376d45c87a
* Also allow "_" to be valid identifierJoshua Harlow2013-10-151-0/+66
| | | | | | | | | | | | A "_" is a valid python identifier as long as it is not the first letter of the given attribute (as an attribute dict doesn't have the concept of protected/private variables). Also include a few links and comments as to why the restrictions are inplace. Change-Id: I23f17113cedb99b2817bad0c464a43d10af6722c
* Python3 compatibility for utils.reflectionIvan A. Melnikov2013-10-101-1/+1
| | | | | | | | | | | Refactor taskflow.utils.reflection to use six and py3-compatible constructs. Breaking change: drop class name from result of get_callable_name for unbound methods. One can't get class name for unbound method in python 3. Change-Id: I98c5b33e7ee4520caf365aa87c9859ec967990de
* No module name for builtin type and exception namesIvan A. Melnikov2013-10-101-13/+10
| | | | | | | | Make utils.reflection.get_class_name() return just type name (without module) for builtin exceptions and types. This makes output less clumsy and makes this function return same strings for python 2 and 3. Change-Id: Ibc599ed34c804cf2cf2ab67e7466a48ebe7f6df3
* Remove decorators and move to utilsJoshua Harlow2013-10-071-2/+2
| | | | | | | | | | | | | In order to avoid the circular import in threading utils move the decorators functionality to utils/misc and move the locking functionality to utils/lock_utils and then use these functions from the threading util (and elsewhere). Fixes bug: 1236080 Change-Id: I9e71c2ba15782cbb6dd5ab7e1264b77ed47bc29e
* Wrapping and serializing failuresIvan A. Melnikov2013-10-041-0/+83
| | | | | | | | | | | | * save task failures to sqlalchemy backend and restore them from there; * for any wrapped exception use common WrappedFailre exception type, which makes it easier to handle particular exception types; * several minor improvements. Affects-db: this change adds db migration that looses exception information for saved task details. Change-Id: I575282002e6999646bbf51f492b82a7e3525787a
* Engine, task, linear_flow unificationJoshua Harlow2013-09-051-40/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to move away from the existing flows having their own implementation of running, start moving the existing flows to be patterns that only structure tasks (and impose constraints about how the group of tasks can run) in useful ways. Let the concept of running those patterns be handled by an engine instead of being handled by the flow itself. This will allow for varying engines to be able to run flows in whichever way the engine chooses (as long as the constraints set up by the flow are observed). Currently threaded flow and graph flow are broken by this commit, since they have not been converted to being a structure of tasks + constraints. The existing engine has not yet been modified to run those structures either, work is underway to remediate this. Part of: blueprint patterns-and-engines Followup bugs that must be addressed: Bug: 1221448 Bug: 1221505 Change-Id: I3a8b96179f336d1defe269728ebae0caa3d832d7
* Split utils moduleIvan A. Melnikov2013-09-031-30/+27
| | | | | | | | | | | | | | | In this commit we split utils module into several parts: - flow_utils, with code used in running flows; - threading_utils, with code that helps in working with threads; - reflection, with code that inspects python objects metadata; - misc, with all the other code that used to live in utils.py. We also move graph_utils into taskflow.utils package. This commit just moves code around. It should not change any logic (with exception of complex_graph example). Change-Id: Iebfe45395f0ff502bc00fc7ae14829130b2c6abe
* Add get_required_callable_args utility functionIvan A. Melnikov2013-08-271-8/+57
| | | | | | | | | | Move code that gets callable args from functor task to utils.py and enhance it to support more use cases. We do not rely on naming conventions for 'self' and 'cls' parameters any more; we look at the collable if it is bound method instead. Change-Id: Ie1a9a7cc727b5fbc2780aba28b1d0253e5bc0ea4
* Add get_callable_name utility functionIvan A. Melnikov2013-08-271-0/+64
| | | | | | | Code that makes name from a callable was moved from functor task to utils and enhanced to better support more use cases. Change-Id: I1280a31553c5051079e60b31cd1796f51485f040
* Use the same root test class.Joshua Harlow2013-08-261-2/+2
| | | | | | | | | | | Instead of being strongly tied to unittest2 make it easier for taskflow to switch to another root class (testr?) by abstracting out the unittest2 usage. This also enables some useful functionality to exist in that root test class that other tasks can take advantage of. Change-Id: I381b6fb07e47f984b44cde439a17f39a1c1d32ac
* Add a basic rollback accumlator test.Joshua Harlow2013-05-241-0/+58