diff options
author | Thomas Duval <thomas.duval@orange.com> | 2016-09-05 17:13:09 +0200 |
---|---|---|
committer | Thomas Duval <thomas.duval@orange.com> | 2016-09-20 10:38:37 +0200 |
commit | f81ecda07c3203856af134aca2b397711432a58f (patch) | |
tree | 950f15825f3ba1d098e95fa0b7bb256aa28a3a47 | |
parent | 1dcfe5a30a080297a3f31ec9dc38e19ba741107f (diff) |
Add an option to force the name of the logfile.
Change-Id: Iea61a1045c9d60a157725dfc7df8dad5b9ca905a
(cherry picked from commit 347dbd9d0ec41fe4951210eea9dad2b41bf7f142)
-rw-r--r-- | moonclient/Changelog | 5 | ||||
-rw-r--r-- | moonclient/moonclient/__init__.py | 2 | ||||
-rw-r--r-- | moonclient/moonclient/tests.py | 19 | ||||
-rw-r--r-- | moonclient/moonclient/tests/tests_empty_policy_new_user.json | 8 | ||||
-rw-r--r-- | moonclient/moonclient/tests/tests_empty_policy_swift.json | 1 | ||||
-rwxr-xr-x | tests/run_tests.py | 11 |
6 files changed, 35 insertions, 11 deletions
diff --git a/moonclient/Changelog b/moonclient/Changelog index f641f3ad..1326511a 100644 --- a/moonclient/Changelog +++ b/moonclient/Changelog @@ -7,6 +7,11 @@ CHANGES ======= +0.4.0 +----- + +* Add an argument to force the name of the logfile for test command. + 0.3.0 ----- diff --git a/moonclient/moonclient/__init__.py b/moonclient/moonclient/__init__.py index 493f7415..6a9beea8 100644 --- a/moonclient/moonclient/__init__.py +++ b/moonclient/moonclient/__init__.py @@ -1 +1 @@ -__version__ = "0.3.0" +__version__ = "0.4.0" diff --git a/moonclient/moonclient/tests.py b/moonclient/moonclient/tests.py index 7da7d5ec..3ef2aa90 100644 --- a/moonclient/moonclient/tests.py +++ b/moonclient/moonclient/tests.py @@ -43,6 +43,12 @@ class TestsLaunch(Lister): '(examples: /path/to/test.json, /path/to/directory/, ' '"/path/to/*-file.json" -- don\'t forget the quote)', ) + parser.add_argument( + '--logfile', + metavar='<logfile-str>', + help='Force Log filename.', + default=None + ) return parser def __replace_var_in_str(self, data_str): @@ -62,6 +68,8 @@ class TestsLaunch(Lister): return False def take_action(self, parsed_args): + if parsed_args.logfile: + self.logfile_name = parsed_args.logfile self.log.info("Write tests output to {}".format(self.logfile_name)) if parsed_args.self: import sys @@ -103,8 +111,11 @@ class TestsLaunch(Lister): ) def test_file(self, testfile): - self.logfile_name = "/tmp/moonclient_test_{}.log".format(time.strftime("%Y%m%d-%H%M%S")) - self.logfile = open(self.logfile_name, "w") + if not self.logfile_name: + self.logfile_name = "/tmp/moonclient_test_{}.log".format(time.strftime("%Y%m%d-%H%M%S")) + self.logfile = open(self.logfile_name, "a") + self.logfile.write(80*"=" + "\n") + self.logfile.write(testfile + "\n\n") stdout_back = self.app.stdout tests_dict = json.load(open(testfile)) self.log.debug("tests_dict = {}".format(tests_dict)) @@ -184,7 +195,9 @@ class TestsLaunch(Lister): else: command = test["command"] + " " + global_command_options command = self.__replace_var_in_str(command) - self.logfile.write(time.strftime(self.TIME_FORMAT) + " " + "-----> {}\n".format(command)) + self.logfile.write(time.strftime(self.TIME_FORMAT) + " " + + test["name"] + " " + + "-----> {}\n".format(command)) self.log.info(" \\-executing {}".format(command)) self.app.stdout = tmp_filename_fd result_id = self.app.run_subcommand(shlex.split(command)) diff --git a/moonclient/moonclient/tests/tests_empty_policy_new_user.json b/moonclient/moonclient/tests/tests_empty_policy_new_user.json index 96fb37d9..d2ca0e2a 100644 --- a/moonclient/moonclient/tests/tests_empty_policy_new_user.json +++ b/moonclient/moonclient/tests/tests_empty_policy_new_user.json @@ -22,7 +22,7 @@ "description": "Upload the Cirros image in glance" }, { - "name": "nova image-list", + "name": "openstack image list", "external_command": "nova image-list", "result": "(?P<uuid_image>[\\w-]+)\\s+\\| cirros", "description": "Get an Image ID" @@ -130,7 +130,7 @@ }, { "name": "add_subject", - "command": "subject add admin --subject_pass nomoresecrete", + "command": "subject add admin --subject_pass console", "result": "", "description": "", "command_options": "" @@ -959,7 +959,7 @@ { "name": "add_subject", - "command": "subject add admin --subject_pass nomoresecrete", + "command": "subject add admin --subject_pass console", "result": "", "description": "Add admin subject.", "command_options": "" @@ -3442,7 +3442,7 @@ { "auth_name": "demo", "auth_password": "console", - "auth_tenant": "admin", + "auth_tenant": "demo", "description": "Change user to demo" }, diff --git a/moonclient/moonclient/tests/tests_empty_policy_swift.json b/moonclient/moonclient/tests/tests_empty_policy_swift.json index 93b39d6e..6d8de2e4 100644 --- a/moonclient/moonclient/tests/tests_empty_policy_swift.json +++ b/moonclient/moonclient/tests/tests_empty_policy_swift.json @@ -4,6 +4,7 @@ "authz": [ { "auth_name": "admin", + "auth_tenant": "demo", "description": "Change user to admin (just in case...)" }, diff --git a/tests/run_tests.py b/tests/run_tests.py index 8030294f..2ed011be 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -67,11 +67,12 @@ def test_federation(): def test_moon_openstack(): - cmd = "moon test --password console --self" + log_filename = "moonclient_selftest.log" + cmd = "moon test --password console --self --logfile {}".format(log_filename) - ret_val = functest_utils.execute_command(cmd, logger) + ret_val = functest_utils.execute_command(cmd, exit_on_error=False) - return ret_val + return ret_val, open(log_filename, "rt").read() def main(): @@ -88,6 +89,10 @@ def main(): else: logger.info("OS MOON ERROR") test_status = 'FAIL' + logger.info("Errors from OpenStack tests:") + logger.info(result_os[1]) + logger.info("Errors from Federation tests:") + logger.info(result_odl[1]) details = { 'timestart': start_time, |