summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Piwowarczyk <m.piwowarczy@samsung.com>2018-09-24 17:02:24 +0200
committerMarcin Piwowarczyk <m.piwowarczy@samsung.com>2018-12-14 13:07:13 +0100
commite9cc6ca372e627673113cc36d582732968b74600 (patch)
treeadd181f27f45e8588be4be9dbc77950d6e4dc1f1
parent84e159eca926b83d5e53839c451da620d96642ff (diff)
Execute functional test jobs running under python3HEADmaster
Functional tests are executed by trovestack script, which uses python in default OS version which is 2.7. This change wraps python in tox and executes trovestack int_tests in virtual enviroment, starting them in python3. Any future python version change could be managed by tox framework. Change-Id: I3a849978241d3d0669ef9e1c802ff504ac3c32cb Signed-off-by: Marcin Piwowarczyk <m.piwowarczy@samsung.com>
Notes
Notes (review): Code-Review+2: Bartosz Zurkowski <b.zurkowski@samsung.com> Code-Review+2: Dariusz Król <dkrol3@gmail.com> Workflow+1: Dariusz Król <dkrol3@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Fri, 14 Dec 2018 22:41:43 +0000 Reviewed-on: https://review.openstack.org/604816 Project: openstack/trove Branch: refs/heads/master
-rw-r--r--integration/tests/integration/tests/util/services.py6
-rw-r--r--roles/trove-devstack/tasks/main.yml4
-rw-r--r--tox.ini11
-rw-r--r--trove/common/utils.py6
-rw-r--r--trove/tests/api/configurations.py2
-rw-r--r--trove/tests/api/replication.py7
-rw-r--r--trove/tests/scenario/helpers/mysql_helper.py2
-rw-r--r--trove/tests/scenario/helpers/sql_helper.py3
-rw-r--r--trove/tests/scenario/runners/configuration_runners.py2
-rw-r--r--trove/tests/scenario/runners/module_runners.py15
-rw-r--r--trove/tests/scenario/runners/test_runners.py17
-rw-r--r--trove/tests/util/event_simulator.py2
-rw-r--r--trove/tests/util/server_connection.py3
13 files changed, 50 insertions, 30 deletions
diff --git a/integration/tests/integration/tests/util/services.py b/integration/tests/integration/tests/util/services.py
index f5f8cbf..6e8f1da 100644
--- a/integration/tests/integration/tests/util/services.py
+++ b/integration/tests/integration/tests/util/services.py
@@ -189,12 +189,12 @@ class Service(object):
189 # as python /path/to/executable args, so the entry is 189 # as python /path/to/executable args, so the entry is
190 # /path/to/executable 190 # /path/to/executable
191 actual_command = self.cmd[proc_name_index].split("/")[-1] 191 actual_command = self.cmd[proc_name_index].split("/")[-1]
192 print actual_command 192 print(actual_command)
193 proc_command = ["/usr/bin/pgrep", "-f", actual_command] 193 proc_command = ["/usr/bin/pgrep", "-f", actual_command]
194 print proc_command 194 print(proc_command)
195 proc = start_proc(proc_command, shell=False) 195 proc = start_proc(proc_command, shell=False)
196 line = proc.stdout.readline() 196 line = proc.stdout.readline()
197 print line 197 print(line)
198 # pgrep only returns a pid. if there is no pid, it'll return nothing 198 # pgrep only returns a pid. if there is no pid, it'll return nothing
199 return len(line) != 0 199 return len(line) != 0
200 200
diff --git a/roles/trove-devstack/tasks/main.yml b/roles/trove-devstack/tasks/main.yml
index 7ee9164..0113283 100644
--- a/roles/trove-devstack/tasks/main.yml
+++ b/roles/trove-devstack/tasks/main.yml
@@ -5,5 +5,5 @@
5 export PATH_DEVSTACK_SRC=$DEST/devstack 5 export PATH_DEVSTACK_SRC=$DEST/devstack
6 export TROVE_RESIZE_TIME_OUT={{trove_resize_time_out}} 6 export TROVE_RESIZE_TIME_OUT={{trove_resize_time_out}}
7 7
8 cd $DEST/trove/integration/scripts 8 cd $DEST/trove
9 ./trovestack gate-tests {{trove_test_datastore}} {{trove_test_group}} 9 tox -etrovestack -vv -- gate-tests {{trove_test_datastore}} {{trove_test_group}}
diff --git a/tox.ini b/tox.ini
index 5a7d7ca..1ced348 100644
--- a/tox.ini
+++ b/tox.ini
@@ -123,3 +123,14 @@ deps =
123 -c{toxinidir}/lower-constraints.txt 123 -c{toxinidir}/lower-constraints.txt
124 -r{toxinidir}/test-requirements.txt 124 -r{toxinidir}/test-requirements.txt
125 -r{toxinidir}/requirements.txt 125 -r{toxinidir}/requirements.txt
126
127[testenv:trovestack]
128basepython = python3
129skip_install = True
130changedir = {toxinidir}/integration/scripts
131passenv = *
132commands =
133 pip install --no-binary :all: {toxinidir} \
134 -c/opt/stack/trove/test-upper-constraints.txt \
135 -chttps://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt
136 ./trovestack {posargs} \ No newline at end of file
diff --git a/trove/common/utils.py b/trove/common/utils.py
index 484c044..7710923 100644
--- a/trove/common/utils.py
+++ b/trove/common/utils.py
@@ -185,14 +185,14 @@ class MethodInspector(object):
185 185
186 186
187def build_polling_task(retriever, condition=lambda value: value, 187def build_polling_task(retriever, condition=lambda value: value,
188 sleep_time=1, time_out=None): 188 sleep_time=1, time_out=0):
189 start_time = time.time() 189 start_time = time.time()
190 190
191 def poll_and_check(): 191 def poll_and_check():
192 obj = retriever() 192 obj = retriever()
193 if condition(obj): 193 if condition(obj):
194 raise loopingcall.LoopingCallDone(retvalue=obj) 194 raise loopingcall.LoopingCallDone(retvalue=obj)
195 if time_out is not None and time.time() - start_time > time_out: 195 if time_out > 0 and time.time() - start_time > time_out:
196 raise exception.PollTimeOut 196 raise exception.PollTimeOut
197 197
198 return loopingcall.BackOffLoopingCall( 198 return loopingcall.BackOffLoopingCall(
@@ -202,7 +202,7 @@ def build_polling_task(retriever, condition=lambda value: value,
202 202
203 203
204def poll_until(retriever, condition=lambda value: value, 204def poll_until(retriever, condition=lambda value: value,
205 sleep_time=1, time_out=None): 205 sleep_time=1, time_out=0):
206 """Retrieves object until it passes condition, then returns it. 206 """Retrieves object until it passes condition, then returns it.
207 207
208 If time_out_limit is passed in, PollTimeOut will be raised once that 208 If time_out_limit is passed in, PollTimeOut will be raised once that
diff --git a/trove/tests/api/configurations.py b/trove/tests/api/configurations.py
index 1a7dbaa..c2dc968 100644
--- a/trove/tests/api/configurations.py
+++ b/trove/tests/api/configurations.py
@@ -138,7 +138,7 @@ def _test_configuration_is_applied_to_instance(instance, configuration_id):
138 resp, body = instance_info.dbaas.client.last_response 138 resp, body = instance_info.dbaas.client.last_response
139 print(resp) 139 print(resp)
140 print(body) 140 print(body)
141 return json.loads(body)['type'] 141 return json.loads(body.decode())['type']
142 142
143 # check the config values are correct 143 # check the config values are correct
144 for key, value in actual_values: 144 for key, value in actual_values:
diff --git a/trove/tests/api/replication.py b/trove/tests/api/replication.py
index 57b0662..9a16a2e 100644
--- a/trove/tests/api/replication.py
+++ b/trove/tests/api/replication.py
@@ -53,7 +53,7 @@ def _get_user_count(server_info):
53 ' where user like \\\"slave_%\\\"\\\'') 53 ' where user like \\\"slave_%\\\"\\\'')
54 server = create_server_connection(server_info.id) 54 server = create_server_connection(server_info.id)
55 stdout, stderr = server.execute(cmd) 55 stdout, stderr = server.execute(cmd)
56 return int(stdout.rstrip()) 56 return int(stdout)
57 57
58 58
59def slave_is_running(running=True): 59def slave_is_running(running=True):
@@ -364,10 +364,7 @@ class DetachReplica(object):
364 cmd = "mysql -BNq -e \\\'select @@read_only\\\'" 364 cmd = "mysql -BNq -e \\\'select @@read_only\\\'"
365 server = create_server_connection(slave_instance.id) 365 server = create_server_connection(slave_instance.id)
366 stdout, stderr = server.execute(cmd) 366 stdout, stderr = server.execute(cmd)
367 if (stdout.rstrip() != "0"): 367 return stdout.rstrip() == "0"
368 return False
369 else:
370 return True
371 poll_until(check_not_read_only) 368 poll_until(check_not_read_only)
372 369
373 370
diff --git a/trove/tests/scenario/helpers/mysql_helper.py b/trove/tests/scenario/helpers/mysql_helper.py
index 7fada68..60f202c 100644
--- a/trove/tests/scenario/helpers/mysql_helper.py
+++ b/trove/tests/scenario/helpers/mysql_helper.py
@@ -20,7 +20,7 @@ class MysqlHelper(SqlHelper):
20 20
21 def __init__(self, expected_override_name, report): 21 def __init__(self, expected_override_name, report):
22 super(MysqlHelper, self).__init__(expected_override_name, report, 22 super(MysqlHelper, self).__init__(expected_override_name, report,
23 'mysql') 23 'mysql+pymysql')
24 24
25 def get_helper_credentials(self): 25 def get_helper_credentials(self):
26 return {'name': 'lite', 'password': 'litepass', 'database': 'firstdb'} 26 return {'name': 'lite', 'password': 'litepass', 'database': 'firstdb'}
diff --git a/trove/tests/scenario/helpers/sql_helper.py b/trove/tests/scenario/helpers/sql_helper.py
index 325fb03..a158d96 100644
--- a/trove/tests/scenario/helpers/sql_helper.py
+++ b/trove/tests/scenario/helpers/sql_helper.py
@@ -27,7 +27,8 @@ class SqlHelper(TestHelper):
27 27
28 DATA_COLUMN_NAME = 'value' 28 DATA_COLUMN_NAME = 'value'
29 29
30 def __init__(self, expected_override_name, report, protocol, port=None): 30 def __init__(self, expected_override_name, report,
31 protocol="mysql+pymysql", port=None):
31 super(SqlHelper, self).__init__(expected_override_name, report) 32 super(SqlHelper, self).__init__(expected_override_name, report)
32 33
33 self.protocol = protocol 34 self.protocol = protocol
diff --git a/trove/tests/scenario/runners/configuration_runners.py b/trove/tests/scenario/runners/configuration_runners.py
index 40fba06..a2c9c5f 100644
--- a/trove/tests/scenario/runners/configuration_runners.py
+++ b/trove/tests/scenario/runners/configuration_runners.py
@@ -144,7 +144,7 @@ class ConfigurationRunner(TestRunner):
144 configuration.has_field('description', six.string_types) 144 configuration.has_field('description', six.string_types)
145 configuration.has_field('values', dict) 145 configuration.has_field('values', dict)
146 configuration.has_field('datastore_name', six.string_types) 146 configuration.has_field('datastore_name', six.string_types)
147 configuration.has_field('datastore_version_id', unicode) 147 configuration.has_field('datastore_version_id', six.text_type)
148 configuration.has_field('datastore_version_name', six.string_types) 148 configuration.has_field('datastore_version_name', six.string_types)
149 149
150 self.assert_equal(name, result.name) 150 self.assert_equal(name, result.name)
diff --git a/trove/tests/scenario/runners/module_runners.py b/trove/tests/scenario/runners/module_runners.py
index c6483e3..e780651 100644
--- a/trove/tests/scenario/runners/module_runners.py
+++ b/trove/tests/scenario/runners/module_runners.py
@@ -17,6 +17,7 @@
17import os 17import os
18from proboscis import SkipTest 18from proboscis import SkipTest
19import re 19import re
20import six
20import tempfile 21import tempfile
21import time 22import time
22 23
@@ -43,7 +44,7 @@ class ModuleRunner(TestRunner):
43 self.MODULE_BINARY_SUFFIX = '_bin_auto' 44 self.MODULE_BINARY_SUFFIX = '_bin_auto'
44 self.MODULE_BINARY_SUFFIX2 = self.MODULE_BINARY_SUFFIX + '_2' 45 self.MODULE_BINARY_SUFFIX2 = self.MODULE_BINARY_SUFFIX + '_2'
45 self.MODULE_BINARY_CONTENTS = os.urandom(20) 46 self.MODULE_BINARY_CONTENTS = os.urandom(20)
46 self.MODULE_BINARY_CONTENTS2 = '\x00\xFF\xea\x9c\x11\xfeok\xb1\x8ax' 47 self.MODULE_BINARY_CONTENTS2 = b'\x00\xFF\xea\x9c\x11\xfeok\xb1\x8ax'
47 48
48 self.module_name_order = [ 49 self.module_name_order = [
49 {'suffix': self.MODULE_BINARY_SUFFIX, 50 {'suffix': self.MODULE_BINARY_SUFFIX,
@@ -1283,12 +1284,12 @@ class ModuleRunner(TestRunner):
1283 if 'contents' in expected and expected['contents']: 1284 if 'contents' in expected and expected['contents']:
1284 with open(filename, 'rb') as fh: 1285 with open(filename, 'rb') as fh:
1285 contents = fh.read() 1286 contents = fh.read()
1286 # convert contents into bytearray to work with py27 1287
1287 # and py34 1288 expected = expected['contents']
1288 contents = bytes([ord(item) for item in contents]) 1289 if isinstance(expected, six.string_types):
1289 expected_contents = bytes( 1290 expected = expected.encode()
1290 [ord(item) for item in expected['contents']]) 1291
1291 self.assert_equal(expected_contents, contents, 1292 self.assert_equal(expected, contents,
1292 "Unexpected contents for %s" % 1293 "Unexpected contents for %s" %
1293 module_name) 1294 module_name)
1294 finally: 1295 finally:
diff --git a/trove/tests/scenario/runners/test_runners.py b/trove/tests/scenario/runners/test_runners.py
index 58e079a..43a4fec 100644
--- a/trove/tests/scenario/runners/test_runners.py
+++ b/trove/tests/scenario/runners/test_runners.py
@@ -145,7 +145,7 @@ class RunnerFactory(object):
145 # Only fail silently if it's something we expect, 145 # Only fail silently if it's something we expect,
146 # such as a missing override class. Anything else 146 # such as a missing override class. Anything else
147 # shouldn't be suppressed. 147 # shouldn't be suppressed.
148 l_msg = ie.message.lower() 148 l_msg = str(ie).lower()
149 if (load_type and load_type not in l_msg) or ( 149 if (load_type and load_type not in l_msg) or (
150 'no module named' not in l_msg and 150 'no module named' not in l_msg and
151 'cannot be found' not in l_msg): 151 'cannot be found' not in l_msg):
@@ -401,7 +401,16 @@ class TestRunner(object):
401 """Assert that two lists contain same elements 401 """Assert that two lists contain same elements
402 (with same multiplicities) ignoring the element order. 402 (with same multiplicities) ignoring the element order.
403 """ 403 """
404 return cls.assert_equal(sorted(expected), sorted(actual), message) 404 # Sorts the elements of a given list, including dictionaries.
405 # For dictionaries sorts based on dictionary key.
406 # example:
407 # [1, 3, 2] -> [1, 2, 3]
408 # ["b", "a", "c"] -> ["a", "b", "c"]
409 # [{'b':'y'},{'a':'x'}] -> [{'a':'x'},{'b':'y'}]
410 sort = lambda object: sorted(object, key=lambda e: sorted(e.keys())
411 if isinstance(e, dict) else e)
412
413 return cls.assert_equal(sort(expected), sort(actual), message)
405 414
406 @classmethod 415 @classmethod
407 def assert_equal(cls, expected, actual, message=None): 416 def assert_equal(cls, expected, actual, message=None):
@@ -506,7 +515,7 @@ class TestRunner(object):
506 if client: 515 if client:
507 # Make sure that the client_cmd comes from the same client that 516 # Make sure that the client_cmd comes from the same client that
508 # was passed in, otherwise asserting the client code may fail. 517 # was passed in, otherwise asserting the client code may fail.
509 cmd_clz = client_cmd.im_self 518 cmd_clz = client_cmd.__self__
510 cmd_clz_name = cmd_clz.__class__.__name__ 519 cmd_clz_name = cmd_clz.__class__.__name__
511 client_attrs = [attr[0] for attr in inspect.getmembers( 520 client_attrs = [attr[0] for attr in inspect.getmembers(
512 client.real_client) 521 client.real_client)
@@ -700,7 +709,7 @@ class TestRunner(object):
700 return False 709 return False
701 710
702 def _poll_while(self, instance_id, expected_status, 711 def _poll_while(self, instance_id, expected_status,
703 sleep_time=1, time_out=None): 712 sleep_time=1, time_out=0):
704 poll_until(lambda: not self._has_status(instance_id, expected_status), 713 poll_until(lambda: not self._has_status(instance_id, expected_status),
705 sleep_time=sleep_time, time_out=time_out) 714 sleep_time=sleep_time, time_out=time_out)
706 715
diff --git a/trove/tests/util/event_simulator.py b/trove/tests/util/event_simulator.py
index d21254d..79f5a4b 100644
--- a/trove/tests/util/event_simulator.py
+++ b/trove/tests/util/event_simulator.py
@@ -227,7 +227,7 @@ def fake_sleep(time_to_sleep):
227 227
228 228
229def fake_poll_until(retriever, condition=lambda value: value, 229def fake_poll_until(retriever, condition=lambda value: value,
230 sleep_time=1, time_out=None): 230 sleep_time=1, time_out=0):
231 """Fakes out poll until.""" 231 """Fakes out poll until."""
232 from trove.common import exception 232 from trove.common import exception
233 slept_time = 0 233 slept_time = 0
diff --git a/trove/tests/util/server_connection.py b/trove/tests/util/server_connection.py
index 6eed366..156b8c9 100644
--- a/trove/tests/util/server_connection.py
+++ b/trove/tests/util/server_connection.py
@@ -48,7 +48,8 @@ class ServerSSHConnection(object):
48 def execute(self, cmd): 48 def execute(self, cmd):
49 exe_cmd = "%s %s %s" % (tests.SSH_CMD, self.ip_address, cmd) 49 exe_cmd = "%s %s %s" % (tests.SSH_CMD, self.ip_address, cmd)
50 print("RUNNING COMMAND: %s" % exe_cmd) 50 print("RUNNING COMMAND: %s" % exe_cmd)
51 return util.process(exe_cmd) 51 stdout, stderr = util.process(exe_cmd)
52 return (stdout.decode(), stderr.decode())
52 53
53 54
54class OpenVZServerConnection(object): 55class OpenVZServerConnection(object):