diff options
author | xudan <xudan16@huawei.com> | 2017-05-23 08:28:58 -0400 |
---|---|---|
committer | xudan <xudan16@huawei.com> | 2017-05-24 00:05:26 -0400 |
commit | ed7de0f59902094646ec53e0c3af192538833611 (patch) | |
tree | 31dcfaa749cc7de9ca1ad6fc1d0e7fb490c6bafe | |
parent | bd5ff3bd10fffd84e79dad47be4d6fb7eea66d26 (diff) |
SDNVPN test cases failed in CI
JIRA: DOVETAIL-439
1. SDNVPN test cases run in CI failed, because the file
/home/opnfv/repos/sdnvpn/sdnvpn/test/functest/config.yaml is empty.
2. copy the file userconfig/sdnvpn_config_testcase1/2/4/8.yaml
to /home/opnfv/repos/sdnvpn/sdnvpn/test/functest/config.yaml in Functest container
Change-Id: Ie904f83c755efc0d9e0abe5dcd44fe4a5056123e
Signed-off-by: xudan <xudan16@huawei.com>
-rw-r--r-- | dovetail/container.py | 2 | ||||
-rw-r--r-- | dovetail/test_runner.py | 32 | ||||
-rw-r--r-- | dovetail/testcase.py | 28 | ||||
-rw-r--r-- | dovetail/testcase/sdnvpn.tc001.yml | 2 | ||||
-rw-r--r-- | dovetail/testcase/sdnvpn.tc002.yml | 2 | ||||
-rw-r--r-- | dovetail/testcase/sdnvpn.tc003.yml | 2 | ||||
-rw-r--r-- | dovetail/testcase/sdnvpn.tc004.yml | 2 | ||||
-rw-r--r-- | dovetail/testcase/sdnvpn.tc008.yml | 2 | ||||
-rw-r--r-- | userconfig/pod.yaml.sample (renamed from userconfig/sample_pod.yaml) | 0 |
9 files changed, 39 insertions, 33 deletions
diff --git a/dovetail/container.py b/dovetail/container.py index 11c64f49..d91c184b 100644 --- a/dovetail/container.py +++ b/dovetail/container.py @@ -148,7 +148,7 @@ class Container(object): cls.logger.debug("Can just use password in %s.", pod_file) config_volume = \ ' -v %s:%s ' % (dovetail_config['userconfig_dir'], - dovetail_config["functest"]['config']['dir']) + dovetail_config[type]['config']['dir']) hosts_config = "" hosts_config_path = os.path.abspath( diff --git a/dovetail/test_runner.py b/dovetail/test_runner.py index cfc49018..0482c2ca 100644 --- a/dovetail/test_runner.py +++ b/dovetail/test_runner.py @@ -28,6 +28,23 @@ class DockerRunner(object): def create_log(cls): cls.logger = dt_logger.Logger(__name__ + '.DockerRunner').getLogger() + def pre_copy(self, container_id=None, dest_path=None, + src_file=None, exist_file=None): + if not dest_path: + self.logger.error("There has no dest_path in %s config file.", + self.testcase.name()) + return None + if src_file: + self.testcase.mk_src_file() + file_path = dt_cfg.dovetail_config[self.type]['result']['dir'] + src_path = os.path.join(file_path, src_file) + if exist_file: + file_path = dt_cfg.dovetail_config[self.type]['config']['dir'] + src_path = os.path.join(file_path, exist_file) + + Container.pre_copy(container_id, src_path, dest_path) + return dest_path + def run(self): if dt_cfg.dovetail_config['offline']: exist = Container.check_image_exist(self.testcase.validate_type()) @@ -47,12 +64,15 @@ class DockerRunner(object): self.logger.debug('container id:%s', container_id) - dest_path = self.testcase.pre_copy_dest_path() - if dest_path: - self.testcase.mk_src_file() - src_path = self.testcase.pre_copy_src_path(self.type) - ret, msg = Container.pre_copy(container_id, src_path, - dest_path) + dest_path = self.testcase.pre_copy_path("dest_path") + src_file_name = self.testcase.pre_copy_path("src_file") + exist_file_name = self.testcase.pre_copy_path("exist_src_file") + + if src_file_name or exist_file_name: + if not self.pre_copy(container_id, dest_path, src_file_name, + exist_file_name): + return + if not self.testcase.prepared(): prepare_failed = False cmds = self.testcase.pre_condition() diff --git a/dovetail/testcase.py b/dovetail/testcase.py index 408599fc..2ceb8f20 100644 --- a/dovetail/testcase.py +++ b/dovetail/testcase.py @@ -115,24 +115,12 @@ class Testcase(object): self.name()) return pre_condition - def pre_copy_src_path(self, test_type): + def pre_copy_path(self, key_name): try: - pre_copy_src_file = \ - self.testcase['validate']['pre_copy']['src_file'] - result_dir = dt_cfg.dovetail_config[test_type]['result']['dir'] - except KeyError as e: - self.logger.error('src file Key error %s', e) - return None - src_path = os.path.join(result_dir, pre_copy_src_file) - return src_path - - def pre_copy_dest_path(self): - try: - pre_copy_dest_path = \ - self.testcase['validate']['pre_copy']['dest_path'] + path = self.testcase['validate']['pre_copy'][key_name] except KeyError: - pre_copy_dest_path = '' - return pre_copy_dest_path + return None + return path def post_condition(self): try: @@ -148,7 +136,7 @@ class Testcase(object): return post_condition def mk_src_file(self): - testcase_src_file = self.testcase['validate']['pre_copy']['src_file'] + testcase_src_file = self.pre_copy_path('src_file') try: file_path = os.path.join(dt_cfg.dovetail_config['result_dir'], testcase_src_file) @@ -158,12 +146,10 @@ class Testcase(object): self.logger.debug('save testcases %s', sub_test) src_file.write(sub_test + '\n') self.logger.debug('save testcases to %s', file_path) + return file_path except Exception: self.logger.error('Failed to save: %s', file_path) - - src_file_path = os.path.join(dt_cfg.dovetail_config['result_dir'], - testcase_src_file) - return src_file_path + return None def run(self): runner = TestRunnerFactory.create(self) diff --git a/dovetail/testcase/sdnvpn.tc001.yml b/dovetail/testcase/sdnvpn.tc001.yml index a453838a..25a636d3 100644 --- a/dovetail/testcase/sdnvpn.tc001.yml +++ b/dovetail/testcase/sdnvpn.tc001.yml @@ -6,7 +6,7 @@ dovetail.sdnvpn.tc001: type: functest testcase: bgpvpn pre_copy: - src_file: sdnvpn_config_testcase1.yaml + exist_src_file: sdnvpn_config_testcase1.yaml dest_path: /home/opnfv/repos/sdnvpn/sdnvpn/test/functest/config.yaml report: sub_testcase_list: diff --git a/dovetail/testcase/sdnvpn.tc002.yml b/dovetail/testcase/sdnvpn.tc002.yml index 0e4cb51e..79846513 100644 --- a/dovetail/testcase/sdnvpn.tc002.yml +++ b/dovetail/testcase/sdnvpn.tc002.yml @@ -6,7 +6,7 @@ dovetail.sdnvpn.tc002: type: functest testcase: bgpvpn pre_copy: - src_file: sdnvpn_config_testcase2.yaml + exist_src_file: sdnvpn_config_testcase2.yaml dest_path: /home/opnfv/repos/sdnvpn/sdnvpn/test/functest/config.yaml report: sub_testcase_list: diff --git a/dovetail/testcase/sdnvpn.tc003.yml b/dovetail/testcase/sdnvpn.tc003.yml index 3da7ccd1..4ae3926d 100644 --- a/dovetail/testcase/sdnvpn.tc003.yml +++ b/dovetail/testcase/sdnvpn.tc003.yml @@ -6,7 +6,7 @@ dovetail.sdnvpn.tc003: type: functest testcase: bgpvpn pre_copy: - src_file: sdnvpn_config_testcase3.yaml + exist_src_file: sdnvpn_config_testcase3.yaml dest_path: /home/opnfv/repos/sdnvpn/sdnvpn/test/functest/config.yaml report: sub_testcase_list: diff --git a/dovetail/testcase/sdnvpn.tc004.yml b/dovetail/testcase/sdnvpn.tc004.yml index 6e6727d2..4c7d8d46 100644 --- a/dovetail/testcase/sdnvpn.tc004.yml +++ b/dovetail/testcase/sdnvpn.tc004.yml @@ -6,7 +6,7 @@ dovetail.sdnvpn.tc004: type: functest testcase: bgpvpn pre_copy: - src_file: sdnvpn_config_testcase4.yaml + exist_src_file: sdnvpn_config_testcase4.yaml dest_path: /home/opnfv/repos/sdnvpn/sdnvpn/test/functest/config.yaml report: sub_testcase_list: diff --git a/dovetail/testcase/sdnvpn.tc008.yml b/dovetail/testcase/sdnvpn.tc008.yml index 80b01d7b..e8050977 100644 --- a/dovetail/testcase/sdnvpn.tc008.yml +++ b/dovetail/testcase/sdnvpn.tc008.yml @@ -6,7 +6,7 @@ dovetail.sdnvpn.tc008: type: functest testcase: bgpvpn pre_copy: - src_file: sdnvpn_config_testcase8.yaml + exist_src_file: sdnvpn_config_testcase8.yaml dest_path: /home/opnfv/repos/sdnvpn/sdnvpn/test/functest/config.yaml report: sub_testcase_list: diff --git a/userconfig/sample_pod.yaml b/userconfig/pod.yaml.sample index 26636a6b..26636a6b 100644 --- a/userconfig/sample_pod.yaml +++ b/userconfig/pod.yaml.sample |