diff --git a/.zuul.yaml b/.zuul.yaml index 10c1fc3bcd..6ead5b3665 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -64,7 +64,6 @@ required-projects: - openstack/devstack-gate - openstack/diskimage-builder - - openstack/python-troveclient - openstack/tripleo-image-elements - openstack/trove - openstack/trove-dashboard @@ -85,7 +84,6 @@ required-projects: - openstack/tempest - openstack/diskimage-builder - - openstack/python-troveclient - openstack/tripleo-image-elements - openstack/trove - openstack/trove-dashboard @@ -328,7 +326,6 @@ parent: devstack-tempest timeout: 7800 required-projects: &base_required_projects - - openstack/python-troveclient - openstack/trove - openstack/trove-tempest-plugin - openstack/tempest diff --git a/integration/scripts/files/elements/ubuntu-guest/extra-data.d/15-trove-dep b/integration/scripts/files/elements/ubuntu-guest/extra-data.d/15-trove-dep index bf71faa779..5a0c1ecdcd 100755 --- a/integration/scripts/files/elements/ubuntu-guest/extra-data.d/15-trove-dep +++ b/integration/scripts/files/elements/ubuntu-guest/extra-data.d/15-trove-dep @@ -17,27 +17,12 @@ REQUIREMENTS_FILE=${TROVESTACK_SCRIPTS}/../../requirements.txt sudo -Hiu ${HOST_USERNAME} dd if=${REQUIREMENTS_FILE} of=${TMP_HOOKS_PATH}/requirements.txt -# Grab the upper constraints file, but don't fail if we can't find it. -# If we are running in the CI environment, $DEST will be set and stackrc -# will use $DEST/requirements as the location for the requirements repo. -# Use that as it will help us chain a job with something that is changing UC. - UC_FILE=upper-constraints.txt +UC_DIR=$(pwd) +UC_BRANCH=${TROVE_BRANCH##stable/} -if [ -f "${DEST}/requirements/${UC_FILE}" ]; then - echo "Found ${DEST}/requirements/${UC_FILE}, using that" - sudo -Hiu ${HOST_USERNAME} dd if="${DEST}/requirements/${UC_FILE}" \ - of="${TMP_HOOKS_PATH}/${UC_FILE}" -else - UC_DIR=$(pwd) - UC_BRANCH=${TROVE_BRANCH##stable/} - - set +e - curl -L -o "${UC_DIR}/${UC_FILE}" "https://releases.openstack.org/constraints/upper/${UC_BRANCH}" - set -e - - if [ -f "${UC_DIR}/${UC_FILE}" ]; then - sudo -Hiu ${HOST_USERNAME} dd if="${UC_DIR}/${UC_FILE}" of=${TMP_HOOKS_PATH}/${UC_FILE} - rm -f "${UC_DIR}/${UC_FILE}" - fi +curl -L -o "${UC_DIR}/${UC_FILE}" "https://releases.openstack.org/constraints/upper/${UC_BRANCH}" +if [ -f "${UC_DIR}/${UC_FILE}" ]; then + sudo -Hiu ${HOST_USERNAME} dd if="${UC_DIR}/${UC_FILE}" of=${TMP_HOOKS_PATH}/${UC_FILE} + rm -f "${UC_DIR}/${UC_FILE}" fi diff --git a/integration/scripts/trovestack b/integration/scripts/trovestack index 24ab6c70c7..4f6273e652 100755 --- a/integration/scripts/trovestack +++ b/integration/scripts/trovestack @@ -188,8 +188,6 @@ function dump_env() { done exclaim "Dumping pip modules:" pip freeze | sort - exclaim "Dumping domain list:" - openstack --os-cloud=devstack-admin domain list exclaim "Dumping configuration completed" set -e fi @@ -764,6 +762,10 @@ function cmd_test_init() { exclaim "Creating Test Flavors." add_test_flavors + + exclaim "Re-installing python-troveclient from git" + pip3 uninstall -y python-troveclient + pip3 install -U git+https://opendev.org/openstack/python-troveclient@master#egg=python-troveclient } function cmd_build_image() { @@ -1207,8 +1209,9 @@ function cmd_kick_start() { fi exclaim "Running kick-start for $DATASTORE_TYPE" - dump_env cmd_test_init "${DATASTORE_TYPE}" "${DATASTORE_VERSION}" + + dump_env } # Start functional test. The guest image should be created and registered in diff --git a/requirements.txt b/requirements.txt index 8c85b838ed..c53d8f7ccc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,6 +22,7 @@ python-swiftclient>=3.2.0 # Apache-2.0 python-designateclient>=2.7.0 # Apache-2.0 python-neutronclient>=6.7.0 # Apache-2.0 python-glanceclient>=2.8.0 # Apache-2.0 +python-troveclient>=2.2.0 # Apache-2.0 iso8601>=0.1.11 # MIT jsonschema>=2.6.0 # MIT Jinja2>=2.10 # BSD License (3 clause) diff --git a/test-upper-constraints.txt b/test-upper-constraints.txt deleted file mode 100644 index b7d3f09bad..0000000000 --- a/test-upper-constraints.txt +++ /dev/null @@ -1 +0,0 @@ -git+https://opendev.org/openstack/python-troveclient@master#egg=python-troveclient diff --git a/tox.ini b/tox.ini index b3c66c42db..9971f08c2a 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,6 @@ setenv = VIRTUAL_ENV={envdir} usedevelop = True install_command = pip install \ - -c{env:TEST_UPPER_CONSTRAINTS_FILE:{toxinidir}/test-upper-constraints.txt} \ -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt} \ -U {opts} {packages} deps = -r{toxinidir}/requirements.txt @@ -56,7 +55,7 @@ ignore-path = .venv,.tox,.git,dist,doc,*egg-info,tools,etc,build,*.po,*.pot,inte show-source = True # H301 is ignored on purpose. # The rest of the ignores are TODOs. -ignore = F821,H301,H404,H405,H501,E402,W503,E731 +ignore = E402,E731,F601,F821,H301,H404,H405,H501,W503,W504,W605 enable-extensions = H203,H106 builtins = _ # add *.yaml for playbooks/trove-devstack-base.yaml, as it will be matched by diff --git a/trove/common/limits.py b/trove/common/limits.py index 5bd6166686..4549a7e2b0 100644 --- a/trove/common/limits.py +++ b/trove/common/limits.py @@ -146,6 +146,7 @@ class Limit(object): "resetTime": int(self.next_request or self._get_time()), } + # "Limit" format is a dictionary with the HTTP verb, human-readable URI, # a regular-expression to match, value and unit of measure (PER_DAY, etc.) DEFAULT_LIMITS = [ diff --git a/trove/common/utils.py b/trove/common/utils.py index a5e1a1d4a7..999c149197 100644 --- a/trove/common/utils.py +++ b/trove/common/utils.py @@ -58,6 +58,7 @@ def build_jinja_environment(): env.globals['min'] = min return env + ENV = build_jinja_environment() diff --git a/trove/db/__init__.py b/trove/db/__init__.py index 60bb4473c7..c632b5061a 100644 --- a/trove/db/__init__.py +++ b/trove/db/__init__.py @@ -85,4 +85,5 @@ class Queryable(object): return lambda model, **conditions: Query( model, query_func=getattr(get_db_api(), item), **conditions) + db_query = Queryable() diff --git a/trove/flavor/models.py b/trove/flavor/models.py index f26760dade..a25e05654a 100644 --- a/trove/flavor/models.py +++ b/trove/flavor/models.py @@ -34,7 +34,7 @@ class Flavor(object): try: client = create_nova_client(context) self.flavor = client.flavors.get(flavor_id) - except nova_exceptions.NotFound as e: + except nova_exceptions.NotFound: raise exception.NotFound(uuid=flavor_id) except nova_exceptions.ClientException as e: raise exception.TroveError(str(e)) diff --git a/trove/guestagent/common/sql_query.py b/trove/guestagent/common/sql_query.py index 2ad291e912..2143668260 100644 --- a/trove/guestagent/common/sql_query.py +++ b/trove/guestagent/common/sql_query.py @@ -419,8 +419,8 @@ class SetServerVariable(object): else: return "SET GLOBAL %s=%s" % (self.key, self.value) -# Miscellaneous queries that need no parameters. +# Miscellaneous queries that need no parameters. FLUSH = "FLUSH PRIVILEGES;" ROOT_ENABLED = ("SELECT User FROM mysql.user " "WHERE User = 'root' AND Host != 'localhost';") diff --git a/trove/guestagent/datastore/experimental/couchdb/service.py b/trove/guestagent/datastore/experimental/couchdb/service.py index cf74f22b7d..71c6d8a85f 100644 --- a/trove/guestagent/datastore/experimental/couchdb/service.py +++ b/trove/guestagent/datastore/experimental/couchdb/service.py @@ -229,7 +229,7 @@ class CouchDBAdmin(object): 'username': user.name, 'password': user.password}, shell=True) - except exception.ProcessExecutionError as pe: + except exception.ProcessExecutionError: LOG.exception("Error creating user: %s.", user.name) for database in user.databases: diff --git a/trove/guestagent/datastore/experimental/db2/service.py b/trove/guestagent/datastore/experimental/db2/service.py index 688b7fef9d..d863a073fa 100644 --- a/trove/guestagent/datastore/experimental/db2/service.py +++ b/trove/guestagent/datastore/experimental/db2/service.py @@ -451,7 +451,7 @@ class DB2Admin(object): system.CREATE_USER_COMMAND % { 'login': user.name, 'login': user.name, 'passwd': user.password}, shell=True) - except exception.ProcessExecutionError as pe: + except exception.ProcessExecutionError: LOG.exception("Error creating user: %s.", user.name) continue @@ -495,7 +495,7 @@ class DB2Admin(object): LOG.debug("Revoked access for user:%(user)s on " "database:%(db)s.", {'user': userName, 'db': mydb.name}) - except exception.ProcessExecutionError as pe: + except exception.ProcessExecutionError: LOG.debug("Error occurred while revoking access to %s.", mydb.name) try: diff --git a/trove/guestagent/datastore/experimental/redis/system.py b/trove/guestagent/datastore/experimental/redis/system.py index e10d38457a..f2cbe0ff60 100644 --- a/trove/guestagent/datastore/experimental/redis/system.py +++ b/trove/guestagent/datastore/experimental/redis/system.py @@ -32,6 +32,6 @@ REDIS_PACKAGE = '' SERVICE_CANDIDATES = ['redis-server', 'redis'] OS = get_os() -if OS is 'redhat': +if OS == 'redhat': REDIS_CONFIG = '/etc/redis.conf' REDIS_PACKAGE = 'redis' diff --git a/trove/instance/tasks.py b/trove/instance/tasks.py index c26062000d..46960fa802 100644 --- a/trove/instance/tasks.py +++ b/trove/instance/tasks.py @@ -122,5 +122,6 @@ class InstanceTasks(object): 'Build error: Port.', is_error=True) + # Dissuade further additions at run-time. InstanceTask.__init__ = None diff --git a/trove/taskmanager/models.py b/trove/taskmanager/models.py index 16ffb1789e..4c424f3bce 100755 --- a/trove/taskmanager/models.py +++ b/trove/taskmanager/models.py @@ -566,13 +566,13 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin): backup_info = None if backup_id is not None: - backup = bkup_models.Backup.get_by_id(self.context, backup_id) - backup_info = {'id': backup_id, - 'instance_id': backup.instance_id, - 'location': backup.location, - 'type': backup.backup_type, - 'checksum': backup.checksum, - } + backup = bkup_models.Backup.get_by_id(self.context, backup_id) + backup_info = {'id': backup_id, + 'instance_id': backup.instance_id, + 'location': backup.location, + 'type': backup.backup_type, + 'checksum': backup.checksum, + } self._guest_prepare(flavor['ram'], volume_info, packages, databases, users, backup_info, config.config_contents, root_password, diff --git a/trove/tests/examples/snippets.py b/trove/tests/examples/snippets.py index cf255936e3..27fc75b353 100644 --- a/trove/tests/examples/snippets.py +++ b/trove/tests/examples/snippets.py @@ -183,35 +183,35 @@ def make_client(user): def write_snippet(get_replace_list, client, name, url, method, status, reason, func, *func_args): - """ - 'name' is the name of the file, while 'url,' 'method,' 'status,' - and 'reason' are expected values that are asserted against. - If func_args is present, it is a list of lists, each one of which - is passed as the *args to the two invocations of "func". - """ - func_args = func_args or [] - snippet_writer = SnippetWriter(conf, get_replace_list) - results = [] - client.client.snippet_writer = snippet_writer - client.client.name = name - args = func_args - result = func(client, *args) + """ + 'name' is the name of the file, while 'url,' 'method,' 'status,' + and 'reason' are expected values that are asserted against. + If func_args is present, it is a list of lists, each one of which + is passed as the *args to the two invocations of "func". + """ + func_args = func_args or [] + snippet_writer = SnippetWriter(conf, get_replace_list) + results = [] + client.client.snippet_writer = snippet_writer + client.client.name = name + args = func_args + result = func(client, *args) - # Now write the snippet (if this happens earlier we can't replace - # data such as the instance ID). - client.client.write_snippet() - with Check() as check: - check.equal(client.client.old_info['url'], url) - check.equal(client.client.old_info['method'], method) - check.equal(client.client.old_info['response_headers'].status, - status) - check.equal(client.client.old_info['response_headers'].reason, - reason) - results.append(result) - # To prevent this from writing a snippet somewhere else... - client.client.name = "junk" + # Now write the snippet (if this happens earlier we can't replace + # data such as the instance ID). + client.client.write_snippet() + with Check() as check: + check.equal(client.client.old_info['url'], url) + check.equal(client.client.old_info['method'], method) + check.equal(client.client.old_info['response_headers'].status, + status) + check.equal(client.client.old_info['response_headers'].reason, + reason) + results.append(result) + # To prevent this from writing a snippet somewhere else... + client.client.name = "junk" - return results + return results JSON_INDEX = 0 diff --git a/trove/tests/fakes/guestagent.py b/trove/tests/fakes/guestagent.py index 75bc2602d1..aa7f9cf57c 100644 --- a/trove/tests/fakes/guestagent.py +++ b/trove/tests/fakes/guestagent.py @@ -92,9 +92,9 @@ class FakeGuest(object): LOG.debug("Updating attributes") self._check_username(username) if (username, hostname) not in self.users: - raise rd_exception.UserNotFound( - "User %s@%s cannot be found on the instance." - % (username, hostname)) + raise rd_exception.UserNotFound( + "User %s@%s cannot be found on the instance." + % (username, hostname)) new_name = user_attrs.get('name') new_host = user_attrs.get('host') new_password = user_attrs.get('password') diff --git a/trove/tests/unittests/api/common/test_limits.py b/trove/tests/unittests/api/common/test_limits.py index e90840cde9..8921422f23 100644 --- a/trove/tests/unittests/api/common/test_limits.py +++ b/trove/tests/unittests/api/common/test_limits.py @@ -307,36 +307,38 @@ class ParseLimitsTest(BaseLimitTestSuite): def test_multiple_rules(self): # Test that parse_limits() handles multiple rules correctly. try: - l = limits.Limiter.parse_limits('(get, *, .*, 20, minute);' - '(PUT, /foo*, /foo.*, 10, hour);' - '(POST, /bar*, /bar.*, 5, second);' - '(Say, /derp*, /derp.*, 1, day)') + result = limits.Limiter.parse_limits( + '(get, *, .*, 20, minute);' + '(PUT, /foo*, /foo.*, 10, hour);' + '(POST, /bar*, /bar.*, 5, second);' + '(Say, /derp*, /derp.*, 1, day)' + ) except ValueError as e: assert False, str(e) # Make sure the number of returned limits are correct - self.assertEqual(4, len(l)) + self.assertEqual(4, len(result)) # Check all the verbs... expected = ['GET', 'PUT', 'POST', 'SAY'] - self.assertEqual(expected, [t.verb for t in l]) + self.assertEqual(expected, [t.verb for t in result]) # ...the URIs... expected = ['*', '/foo*', '/bar*', '/derp*'] - self.assertEqual(expected, [t.uri for t in l]) + self.assertEqual(expected, [t.uri for t in result]) # ...the regexes... expected = ['.*', '/foo.*', '/bar.*', '/derp.*'] - self.assertEqual(expected, [t.regex for t in l]) + self.assertEqual(expected, [t.regex for t in result]) # ...the values... expected = [20, 10, 5, 1] - self.assertEqual(expected, [t.value for t in l]) + self.assertEqual(expected, [t.value for t in result]) # ...and the units... expected = [limits.PER_MINUTE, limits.PER_HOUR, limits.PER_SECOND, limits.PER_DAY] - self.assertEqual(expected, [t.unit for t in l]) + self.assertEqual(expected, [t.unit for t in result]) class LimiterTest(BaseLimitTestSuite): diff --git a/trove/tests/unittests/backup/test_backup_models.py b/trove/tests/unittests/backup/test_backup_models.py index baee820ab8..98d44476fb 100644 --- a/trove/tests/unittests/backup/test_backup_models.py +++ b/trove/tests/unittests/backup/test_backup_models.py @@ -37,6 +37,7 @@ def _prep_conf(current_time): instance_id = 'INSTANCE-' + current_time return _context, instance_id + BACKUP_NAME = 'WORKS' BACKUP_NAME_2 = 'IT-WORKS' BACKUP_NAME_3 = 'SECOND-LAST-ONE' diff --git a/trove/tests/util/event_simulator.py b/trove/tests/util/event_simulator.py index 79f5a4ba36..92bb572d46 100644 --- a/trove/tests/util/event_simulator.py +++ b/trove/tests/util/event_simulator.py @@ -181,6 +181,7 @@ class Coroutine(object): self.my_sem.release() self.caller_sem.acquire() # Wait for it to finish. + # Main global thread to run. main_greenlet = None @@ -238,7 +239,7 @@ def fake_poll_until(retriever, condition=lambda value: value, fake_sleep(sleep_time) slept_time += sleep_time if time_out and slept_time >= time_out: - raise exception.PollTimeOut() + raise exception.PollTimeOut() def run_main(func):