summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
| * | Remove common.exception from common.importutils.Russell Bryant2012-05-021-2/+1
| |/ | | | | | | | | | | | | | | This patch removes the usage of common.exception from common.importutils. Instead of raising exception.NotFound() from importutils.import_class(), just use the built-in ImportError. Change-Id: I95e84908d1f80c5ca3bbac049eda8faa64212ae0
* / New ConfigOpts.find_file() for locating conf filesMark McLoughlin2012-05-011-3/+44
|/ | | | | | | | | | | Most services have the need to locate files like api-paste.ini or policy.json. This new method attempts to find these files by looking alongside the config files already parsed by ConfigOpts and, failing that, falls back to a standard set of directories. Change-Id: I95897816485b88f78854df194cab7872d7c5452a
* Support for directory source of config filesEoghan Glynn2012-04-301-40/+113
| | | | | | | | | | | | | | | | | Implements bp cfg-config-dir Allow multiple config files to be pulled in from a config directory, as opposed to individual config files being explicitly enumerated. This logic is enabled using the --config-dir=/path/to/config CLI option, causing config to be retrived from all matching /path/to/config/*.conf files. Sections may be re-opened across config files, and all config items must reside in an explicitly specified section (i.e. it does not default to [DEFAULT]). This behavior is unchanged. Change-Id: Ia29dffe82dfb4742dcf3e8d36b376d906a2492cf
* Provide file extension when when looking for filesBrian Waldon2012-04-261-0/+10
| | | | | | * Allow an extension to be passed to find_config files, defaulting to '.conf' Change-Id: I022a3b28d9067158e9ed0da741a5e72cb73af167
* Change behavior in utils.import_object().Russell Bryant2012-04-113-20/+50
| | | | | | | | | | | | | | | | | | | Fix bug 972859. Prior to this patch, utils.import_object(foo) and utils.import_class(foo) would return the same thing if foo was the path to a class. This patch changes utils.import_object() to return an instance of the class, instead, also allowing you to pass in arguments to the constructor. This patch also removes the odd behavior of import_object() to be able to also import a module. Instead, a new function import_module() has been added. Finally, the three import helpers have been moved to a new module, importutils. Change-Id: Ia2ea64c965692f8c3a29adec332dd93a83980070
* Move auth_str_equal() to a new authutils module.Russell Bryant2012-04-112-6/+29
| | | | | | | This patch moves auth_str_utils() to a new module, authutils, for helper functions related to authentication. Change-Id: I83f174486269701deed3500f890832a71ff3e315
* Merge "Create openstack.common.timeutils."Jenkins2012-04-112-131/+157
|\
| * Create openstack.common.timeutils.Russell Bryant2012-04-042-131/+157
| | | | | | | | | | | | | | Split time related utility functions out of openstack.common.utils into a new module, timeutils. Change-Id: Ic09952cd48e0b4548e410926cc456cbd515a4e56
* | Merge "Add generic PasteDeploy app and filter factories"Jenkins2012-04-041-0/+109
|\ \ | |/ |/|
| * Add generic PasteDeploy app and filter factoriesMark McLoughlin2012-03-261-0/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These generic factories allow us to dump copied and pasted app_factory and filter_factory methods. The main difference is the paste configuration changes from: [app:myapp] paste.app_factory = myapp:app_factory ... [filter:myfilter] paste.filter_factory = myapp:filter_factory to this: [app:myapp] paste.app_factory = openstack.common.pastedeploy:app_factory openstack.app_factory = myapp:App ... [filter:myfilter] paste.filter_factory = openstack.common.pastedeploy:filter_factory openstack.filter_factory = myapp:Filter Apart from reducing code duplication, this will also allow us to have the generic factories inject other data into the apps and filters. This could implemented as a new feature in PasteDeploy itself - e.g. allow the loadapp() caller supply a python object which is passed on to the factories. In the meantime, Glance has code like this to pass a ConfigOpts instance to factories. Keystone is moving a similar way, as will other projects as they move away from a global config object. Change-Id: I928d1f6da154f0f41edd624e25b8918a0e12cb28
* | Merge "Add greenthread local storage model from nova"Jenkins2012-04-041-0/+53
|\|
| * Add greenthread local storage model from novaMark McLoughlin2012-03-161-0/+53
| | | | | | | | | | | | | | | | | | | | | | Thread local storage is obviously a very useful facility to have available. Nova has a very simple API for this which uses eventlet's corolocal module and weakrefs. This looks to be generally useful and complete, so let's pull it into openstack-common. Change-Id: I52a08124297c9cb79def447436859bd8d2c0b622
* | Make 'yes' also a true booleanSean Dague2012-03-221-2/+11
| | | | | | | | | | | | | | Adds yes, Yes, and all other capitalizations as a true boolean. Updated unit tests to test for these. Change-Id: I97915f870dd6bba612f74f0ceb78f2399fd81a93
* | Merge "Finish implementing MultiStrOpt"Jenkins2012-03-222-7/+127
|\ \
| * | Finish implementing MultiStrOptJohannes Erdfelt2012-03-222-7/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes bug 955308 Previously only multiple string options from the CLI were supported. This change adds support for config files too and merges the results from both CLI and config files. Change-Id: I642408c03ed295fac050105fd4380940e876f228
* | | Merge "Avoid leaking secrets into config logging."Jenkins2012-03-221-3/+9
|\ \ \ | |/ / |/| |
| * | Avoid leaking secrets into config logging.Eoghan Glynn2012-03-221-3/+9
| |/ | | | | | | | | | | | | | | | | Implements bp cfg-password-options Allow options to be declared secret so that their value is obfuscated before logging. Change-Id: Ie2168d218b029d9c12fa5b48342cd5b17b2cc77a
* / Add auth_str_equal() to common utils.Russell Bryant2012-03-191-0/+6
|/ | | | | | | | | | | This function provides a constant-time string comparison. Its primary use case is for authentication to avoid timing vulnerabilities. Similar functions currently exist in keystone, nova, and swift. The three diverged in slight ways immediately after going in. This version comes from keystone, which I consider the "best" version to promote to openstack-common. Change-Id: I39537a21be8a402e34e526466f6b90188344a35d
* Add ConfigOpts.print_help()Mark McLoughlin2012-02-221-0/+10
| | | | | | Keystone uses this optparse method. Change-Id: Ic840b2fb2234a12cd94ca671a8d90cd2affe3a5e
* Promote more complete support for ISO 8601 time.Eoghan Glynn2012-02-201-2/+110
| | | | | | | | | | | | | | | Support for ISO 861 time representation is now duplicated in nova: https://github.com/openstack/nova/commit/c30193fbf and in glance: https://github.com/openstack/glance/commit/f8f9f171 Note this patch introduces a new dependency on python-iso8601, which has already been packaged for Fedora, EPEL and Ubuntu/Debian. Change-Id: I87c32effa97d3b7a8d869522b62c0c6fb31bcef8
* Merge changes I71d99f00,Ib91b5af0Jenkins2012-02-202-7/+33
|\ | | | | | | | | | | * changes: Add git changelog method. Add git vcsversion method.
| * Add git changelog method.Monty Taylor2012-02-092-7/+33
| | | | | | | | Change-Id: I71d99f00b2154bf151a1521016118ba6bd088f79
* | PEP8 cleanup (openstack-common)Zhongyue Luo2012-02-112-4/+4
| | | | | | | | | | | | | | | | | | Fixes bug #930625 Remove backslash continuations in openstack-common. Fix type checking taboos. Change-Id: I49ddb9ff5fa5af760dcfccb52cb4793b71e02f19
* | Disable ConfigParser interpolation (lp#930270)Mark McLoughlin2012-02-101-0/+12
|/ | | | | | | | | | | | This breaks e.g. volume_name_template=volume-%08x instance_name_template=instance-%08x and is not part of the API contract anyway. We use $opt based value interpolation. Change-Id: I7ba566ae7c9a77322b52c67c5e1ffbffb760f0fc
* Split functions to avoid eventlet import.Monty Taylor2012-02-061-1/+2
| | | | | | | | | | Some of these functions are used in setup.py. In a virtualenv based workflow, python setup.py sdist is called to create a tarball which is then installed into the virtualenv. These functions need to be in a separate file so that they can be imported by setup.py without eventlet needing to be installed. Change-Id: I6f7dc9614895b8c91135c62373b98afe55e1fc7d
* Makes common/cfg.py raise AttributeErrorVishvananda Ishaya2012-02-021-0/+5
| | | | | | | * fixes bug 915039 * includes test Change-Id: I67b886be3b5af3763f52fffe54085975d61d61eb
* Add the Mapping interface to cfg.ConfigOptsMark McLoughlin2012-01-271-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implements blueprint cfg-mapping interface With cfg, option values are accessed via attributes on ConfigOpts objects e.g. conf = ConfigOpts() conf.register_opt(StrOpt('foo')) conf() print conf.foo One use case that isn't easily supported with option values represented this way is iterating over all the registered options. Standard interfaces for listing attributes on an object aren't suitable because they will list more than just the options. For this use case alone, it's worth having ConfigOpts implement the mapping interface. That way we can do e.g. for opt, value in conf.items(): print "Option %s = %s" % (opt, value) It's interesting to compare argparse's approach to this problem - option values are attributes on a Namespace object which has no attributes or methods to pollute the namespace of option names. This is a nice approach, but would mean that we would be passing around both a ConfigOpts object and a Namespace object. That's a bit too much overhead, and the mapping interface provides a usable workaround where there is a conflict. Change-Id: Ic113919a20291048f962999229c76884ebdd5ad8
* Merge "Add support to cfg for disabling interspersed args"Jenkins2012-01-231-0/+12
|\
| * Add support to cfg for disabling interspersed argsMark McLoughlin2012-01-231-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implements blueprint cfg-disable-interspersed-args Nova currently relies on cfg being implemented with optparse because it uses optparse's disable_interspersed_args() The use case for this is if you do: $> nova-manage --verbose create --project foo --user bar you want invoking ConfigOpts() to return: ['create', '--project', 'foo', '--user', 'bar'] as the "extra" args rather than aborting when it doesn't recognize the --project arg. This is a reasonable use case for cfg to support and it should just have {disable,enable}_interspersed_args() methods. If we ever switch from optparse to argparse, we'll do something like this: parser.add_argument('--verbose') ... parser.add_argument( 'extra_args', nargs=argparse.REMAINDER if disable_interspersed_args else '*') ... ns = parser.parse_args(...) extra_args = ns.extra_args i.e. we will need an 'extra_args' multi-value positional argument in any case and we'll just pass nargs=REMAINDER if we want trailing options to be included in the extra args. Change-Id: I3ecb7dc18230327cf5aaaa7d832224e64aafa40c
* | Add cfg test case for recursive substitutionMark McLoughlin2012-01-231-0/+8
|/ | | | | | | i.e. test that if blaa='blaa', foo='$blaa' and bar='$foo' that the value of bar after substitutions is 'blaa' Change-Id: I01d370832a871603b7cb47bfb3546f6aaad8c34d
* Get cfg test cases to 100%Mark McLoughlin2012-01-121-5/+91
| | | | | | | | | | | | * Test cfg.find_config_files() sys.argv usage * Test boolean values in cfg config files * Finish off incomplete cfg bad value test case * Test register_opts() and register_cli_opts() * Test the quiet ignoring of option/group re-registration * Test cfg print_usage() * Test explicit option group titles Change-Id: Icbe4b7c48d4785551f06873821d1be758adf942c
* Add cfg test case for exceptions' __str__ methodsMark McLoughlin2012-01-121-0/+39
| | | | | | Increases coverage from 93% to 97% Change-Id: I6a41b31e29238831fe2a888d5d64dc0bffd770c0
* Fix some cfg test case naming conflictsMark McLoughlin2012-01-121-18/+18
| | | | | | | | | | | | | As pointed out by Vish, there are duplicates of: OverridesTestCase::test_default_override OverridesTestCase::test_override SadPathTestCase::test_conf_file_not_found Also, rename the ConfigFileOptsTestCase so it is obvious they don't clash with the tests by the same name in CliOptsTestCase. Change-Id: I1d650d05d32501623cfed8f0b6399858d101ae02
* Add new cfg moduleMark McLoughlin2012-01-101-0/+784
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As described here: http://wiki.openstack.org/CommonConfigModule The module implements an API for defining configuration options and reading values for those options that a user may have set in a config file or on the command line. The module is successfully in use in both Nova and Glance. Some work remains in Nova to switch from using it under a gflags compatible shim layer, but Glance is using it fully. There doesn't appear to be any blockers to other projects moving over to it fairly easily. Swift would perhaps be the next project to tackle. Just to go through potential future compatibility concerns: - Nova (the scroundrel) hackily uses the private ConfigOpts::_oparser in order to disable interspersed args. This was just for nova-manage and can probably be resolved some other way. In any case, Nova shouldn't switch to openstack-common's cfg API until it removes this hack. - the CommonConfigOpts subclass set of logging related options is perhaps assuming too much about what configuration options should be common across all the projects. However, it seems a fairly sane set and the worst that can happen is that projects avoid using it. - the parameters to the Opt constructor fairly closely mirror optparse, but they're fairly generic and shouldn't prevent us from switching to e.g. argparse - stuff like %prog expansion in the ConfigOpt's usage ctor param is a similar concern, but it's a very minor concern. - find_config_files() search path is perhaps too much policy for openstack-common; however, it is probably as generic as it could be and projects which need a different policy can just not use the function On the whole, I think we're in good shape wrt future compatibility. Change-Id: I279a9db7806d80aff3b9b085b4a9e4fb193662f9
* make sure a '_' function is availible for noseJason Kölker2012-01-041-0/+2
|
* add some server testsJason Kölker2011-12-021-0/+20
|
* moar utils testsJason Kölker2011-12-021-0/+53
|
* add utils testJason Kölker2011-12-011-0/+70
|
* add context middleware testsJason Kölker2011-12-012-0/+79
|
* add more coverage to test_extensionsJason Kölker2011-12-011-1/+66
|
* add exceptions test coverageJason Kölker2011-12-011-0/+151
|
* add context 'tests'Jason Kölker2011-12-011-0/+27
|
* add more config testsJason Kölker2011-12-011-3/+61
|
* Rename setup_extensions_test_app so that nosetests ignores itJason Kölker2011-11-301-15/+15
| | | | | Allows the use of openstack.nose_plugin's coloring/output for nosetests should the user desire to not use run_tests.sh/py
* add __init__.py so tests run, remove bin and skeleton from pep8Jason Kölker2011-11-012-0/+0
|
* Merge commit '99b2c6c202b1ec450e5f7bc1c4080f8c36773376'Jason Kölker2011-11-014-24/+110
|\
| * Rajaram/Vinkesh|increased tests for Request and Response serializersRajaram Mallya2011-09-142-9/+17
| |
| * Rajaram/Vinkesh|added config test file from glanceRajaram Mallya2011-09-091-0/+66
| |
| * Rajaram/Vinkesh|Default xmlns for extension serialization can be overriden, ↵Rajaram Mallya2011-09-091-15/+27
| | | | | | | | added default factory for extension middleware
* | merge in upstreamJason Kölker2011-11-013-0/+0
|/