aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/vnf/router/test_controller
diff options
context:
space:
mode:
authorShuya Nakama <shuya.nakama@okinawaopenlabs.org>2017-08-25 14:26:30 +0000
committerShuya Nakama <shuya.nakama@okinawaopenlabs.org>2017-08-29 07:19:48 +0000
commit0a56dfd7f42d6a6d849e5cf3f82b0863c8a62ffe (patch)
tree2361c11c016f4101487787c9ea7676c4d696902d /functest/opnfv_tests/vnf/router/test_controller
parentcb239a2a5ec46086ce8c046e2db4cb7eb7b18181 (diff)
Refactor the vyos_vrouter to adopt VNF abstraction
JIRA: FUNCTEST-788 1.Modifying code of vyos_vrouter to inherit vnf abstraction class. 2.Adding vyos_vrouter code from our repo to functest. 3.Adding unit test of vyos_vrouter. 4.Doing test of modified vyos_vrouter codes on our labs. Change-Id: I77e4be8b2a140ea0176c607f2be736599f893ace Signed-off-by: Shuya Nakama <shuya.nakama@okinawaopenlabs.org>
Diffstat (limited to 'functest/opnfv_tests/vnf/router/test_controller')
-rw-r--r--functest/opnfv_tests/vnf/router/test_controller/__init__.py0
-rw-r--r--functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py137
2 files changed, 137 insertions, 0 deletions
diff --git a/functest/opnfv_tests/vnf/router/test_controller/__init__.py b/functest/opnfv_tests/vnf/router/test_controller/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/functest/opnfv_tests/vnf/router/test_controller/__init__.py
diff --git a/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py b/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py
new file mode 100644
index 000000000..236447e0c
--- /dev/null
+++ b/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py
@@ -0,0 +1,137 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2017 Okinawa Open Laboratory and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+
+"""vrouter function test execution module"""
+
+import logging
+import time
+import yaml
+
+from functest.opnfv_tests.vnf.router.utilvnf import Utilvnf
+from functest.opnfv_tests.vnf.router.vnf_controller.vnf_controller import (
+ VnfController)
+
+
+class FunctionTestExec(object):
+ """vrouter function test execution class"""
+
+ logger = logging.getLogger(__name__)
+
+ def __init__(self, util_info):
+ self.logger.debug("init test exec")
+ self.util = Utilvnf()
+ credentials = util_info["credentials"]
+ self.vnf_ctrl = VnfController(util_info)
+
+ test_cmd_map_file = open(self.util.vnf_data_dir +
+ self.util.opnfv_vnf_data_dir +
+ self.util.command_template_dir +
+ self.util.test_cmd_map_yaml_file,
+ 'r')
+ self.test_cmd_map_yaml = yaml.safe_load(test_cmd_map_file)
+ test_cmd_map_file.close()
+
+ self.util.set_credentials(credentials["username"],
+ credentials["password"],
+ credentials["auth_url"],
+ credentials["tenant_name"],
+ credentials["region_name"])
+
+ with open(self.util.test_env_config_yaml) as file_fd:
+ test_env_config_yaml = yaml.safe_load(file_fd)
+ file_fd.close()
+
+ self.protocol_stable_wait = test_env_config_yaml.get("general").get(
+ "protocol_stable_wait")
+
+ def config_target_vnf(self, target_vnf, reference_vnf, test_kind):
+ self.logger.debug("Configuration to target vnf")
+ test_info = self.test_cmd_map_yaml[target_vnf["os_type"]]
+ test_cmd_file_path = test_info[test_kind]["pre_command_target"]
+ target_parameter_file_path = test_info[test_kind]["parameter_target"]
+ prompt_file_path = test_info["prompt"]
+
+ return self.vnf_ctrl.config_vnf(target_vnf,
+ reference_vnf,
+ test_cmd_file_path,
+ target_parameter_file_path,
+ prompt_file_path)
+
+ def config_reference_vnf(self, target_vnf, reference_vnf, test_kind):
+ self.logger.debug("Configuration to reference vnf")
+ test_info = self.test_cmd_map_yaml[reference_vnf["os_type"]]
+ test_cmd_file_path = test_info[test_kind]["pre_command_reference"]
+ reference_parameter_file_path = test_info[test_kind][
+ "parameter_reference"]
+ prompt_file_path = test_info["prompt"]
+
+ return self.vnf_ctrl.config_vnf(reference_vnf,
+ target_vnf,
+ test_cmd_file_path,
+ reference_parameter_file_path,
+ prompt_file_path)
+
+ def result_check(self, target_vnf, reference_vnf, test_kind, test_list):
+ test_info = self.test_cmd_map_yaml[target_vnf["os_type"]]
+ target_parameter_file_path = test_info[test_kind]["parameter_target"]
+ prompt_file_path = test_info["prompt"]
+ check_rule_file_path_list = []
+
+ for test in test_list:
+ check_rule_file_path_list.append(test_info[test_kind][test])
+
+ return self.vnf_ctrl.result_check(target_vnf,
+ reference_vnf,
+ check_rule_file_path_list,
+ target_parameter_file_path,
+ prompt_file_path)
+
+ def run(self, target_vnf, reference_vnf_list, test_info, test_list):
+ test_result_data = {}
+ test_kind = test_info["protocol"]
+ for reference_vnf in reference_vnf_list:
+ self.logger.debug("Start config command " +
+ target_vnf["vnf_name"] + " and " +
+ reference_vnf["vnf_name"])
+
+ result = self.config_target_vnf(target_vnf,
+ reference_vnf,
+ test_kind)
+ if not result:
+ return False, test_result_data
+
+ result = self.config_reference_vnf(target_vnf,
+ reference_vnf,
+ test_kind)
+ if not result:
+ return False, test_result_data
+
+ self.logger.debug("Finish config command.")
+
+ self.logger.debug("Waiting for protocol stable.")
+ time.sleep(self.protocol_stable_wait)
+
+ self.logger.debug("Start check method")
+
+ (result, res_dict_data_list) = self.result_check(target_vnf,
+ reference_vnf,
+ test_kind,
+ test_list)
+
+ test_result_data = {"test_kind": test_info["test_kind"],
+ "protocol": test_info["protocol"],
+ "result": res_dict_data_list}
+
+ if not result:
+ self.logger.debug("Error check method.")
+ return False, test_result_data
+
+ self.logger.debug("Finish check method.")
+
+ return True, test_result_data