diff options
-rw-r--r-- | sfc/lib/config.py | 5 | ||||
-rw-r--r-- | sfc/lib/utils.py | 28 | ||||
-rw-r--r-- | sfc/tests/functest/config.yaml | 1 | ||||
-rw-r--r-- | sfc/tests/functest/sfc.py | 12 | ||||
-rw-r--r-- | sfc/tests/functest/sfc_one_chain_two_service_functions_different_computes.py | 4 |
5 files changed, 21 insertions, 29 deletions
diff --git a/sfc/lib/config.py b/sfc/lib/config.py index 13c83a7f..e9fcd582 100644 --- a/sfc/lib/config.py +++ b/sfc/lib/config.py @@ -45,6 +45,11 @@ class CommonConfig(object): 'username': self.fuel_master_uname, 'password': self.fuel_master_passwd } + try: + self.fuel_environment = ft_utils.get_parameter_from_yaml( + "defaults.fuel_environment", self.config_file) + except: + self.fuel_environment = None self.flavor = ft_utils.get_parameter_from_yaml( "defaults.flavor", self.config_file) self.ram_size_in_mb = ft_utils.get_parameter_from_yaml( diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py index 00f98985..f4412abf 100644 --- a/sfc/lib/utils.py +++ b/sfc/lib/utils.py @@ -18,6 +18,7 @@ import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils import functest.utils.openstack_utils as os_utils import opnfv.utils.SSHUtils as ssh_utils +import sfc.lib.config as sfc_config logger = ft_logger.Logger("sfc_test_utils").getLogger() @@ -87,7 +88,7 @@ def run_cmd_remote(ip, cmd, username="root", passwd="opnfv"): def get_openstack_node_ips(role): """Get OpenStack Nodes IP Address""" - fuel_env = os.environ.get("FUEL_ENV") + fuel_env = sfc_config.CommonConfig().fuel_environment if fuel_env is not None: cmd = "fuel2 node list -f json -e %s" % fuel_env else: @@ -165,14 +166,14 @@ def create_security_groups(neutron_client, secgroup_name, secgroup_descr): def create_instance(nova_client, name, flavor, image_id, network_id, sg_id, secgroup_name=None, fixed_ip=None, - compute_node='', userdata=None, files=None): + av_zone='', userdata=None, files=None): logger.info("Creating instance '%s'..." % name) logger.debug( "Configuration:\n name=%s \n flavor=%s \n image=%s \n" " network=%s\n secgroup=%s \n hypervisor=%s \n" " fixed_ip=%s\n files=%s\n userdata=\n%s\n" % (name, flavor, image_id, network_id, sg_id, - compute_node, fixed_ip, files, userdata)) + av_zone, fixed_ip, files, userdata)) instance = os_utils.create_instance_and_wait_for_active( flavor, image_id, @@ -180,7 +181,7 @@ def create_instance(nova_client, name, flavor, image_id, network_id, sg_id, name, config_drive=True, userdata=userdata, - av_zone=compute_node, + av_zone=av_zone, fixed_ip=fixed_ip, files=files) @@ -316,7 +317,7 @@ def is_http_blocked(srv_prv_ip, client_ip): return True -def capture_err_logs(ovs_logger, controller_clients, compute_clients, error): +def capture_ovs_logs(ovs_logger, controller_clients, compute_clients, error): timestamp = time.strftime("%Y%m%d-%H%M%S") ovs_logger.dump_ovs_logs(controller_clients, compute_clients, @@ -372,7 +373,7 @@ def ofctl_time_counter(ovs_logger, ssh_conn): @ft_utils.timethis -def capture_time_log(ovs_logger, compute_clients, timeout=200): +def wait_for_classification_rules(ovs_logger, compute_clients, timeout=200): rsps = ofctl_time_counter(ovs_logger, compute_clients[0]) first_RSP = rsps[0] if len(rsps) > 0 else '' while not ((len(rsps) > 1) and @@ -388,21 +389,6 @@ def capture_time_log(ovs_logger, compute_clients, timeout=200): logger.info("classification rules updated") -def get_compute_nodes(nova_client, required_node_number=2): - """Get the compute nodes in the deployment""" - compute_nodes = os_utils.get_hypervisors(nova_client) - - num_compute_nodes = len(compute_nodes) - if num_compute_nodes < 2: - logger.error("There are %s compute nodes in the deployment. " - "Minimum number of nodes to complete the test is 2." - % num_compute_nodes) - return None - - logger.debug("Compute nodes: %s" % compute_nodes) - return compute_nodes - - def setup_compute_node(cidr): logger.info("bringing up br-int iface") run_cmd_on_compute("ifconfig br-int up") diff --git a/sfc/tests/functest/config.yaml b/sfc/tests/functest/config.yaml index 78cf42fb..9acca599 100644 --- a/sfc/tests/functest/config.yaml +++ b/sfc/tests/functest/config.yaml @@ -9,6 +9,7 @@ defaults: fuel_master_ip: 10.20.0.2 fuel_master_uname: root fuel_master_passwd: r00tme + fuel_environment: # Change this to the id of the desired fuel env (1, 2, 3...) image_format: qcow2 url: "http://artifacts.opnfv.org/sfc/demo" vnfd-dir: "vnfd-templates" diff --git a/sfc/tests/functest/sfc.py b/sfc/tests/functest/sfc.py index a4f5b37f..7bb5a5ac 100644 --- a/sfc/tests/functest/sfc.py +++ b/sfc/tests/functest/sfc.py @@ -162,7 +162,7 @@ def main(): logger.info(test_utils.run_cmd('tacker sfc-classifier-list')) # Start measuring the time it takes to implement the classification rules - t1 = threading.Thread(target=test_utils.capture_time_log, + t1 = threading.Thread(target=test_utils.wait_for_classification_rules, args=(ovs_logger, compute_clients,)) try: t1.start() @@ -196,7 +196,7 @@ def main(): else: error = ('\033[91mTEST 1 [FAILED] ==> SSH NOT BLOCKED\033[0m') logger.error(error) - test_utils.capture_err_logs( + test_utils.capture_ovs_logs( ovs_logger, controller_clients, compute_clients, error) results.add_to_summary(2, "FAIL", "SSH Blocked") @@ -206,7 +206,7 @@ def main(): else: error = ('\033[91mTEST 2 [FAILED] ==> HTTP BLOCKED\033[0m') logger.error(error) - test_utils.capture_err_logs( + test_utils.capture_ovs_logs( ovs_logger, controller_clients, compute_clients, error) results.add_to_summary(2, "FAIL", "HTTP works") @@ -233,7 +233,7 @@ def main(): logger.info(test_utils.run_cmd('tacker sfc-classifier-list')) # Start measuring the time it takes to implement the classification rules - t2 = threading.Thread(target=test_utils.capture_time_log, + t2 = threading.Thread(target=test_utils.wait_for_classification_rules, args=(ovs_logger, compute_clients,)) try: t2.start() @@ -249,7 +249,7 @@ def main(): else: error = ('\033[91mTEST 3 [FAILED] ==> HTTP WORKS\033[0m') logger.error(error) - test_utils.capture_err_logs( + test_utils.capture_ovs_logs( ovs_logger, controller_clients, compute_clients, error) results.add_to_summary(2, "FAIL", "HTTP Blocked") @@ -259,7 +259,7 @@ def main(): else: error = ('\033[91mTEST 4 [FAILED] ==> SSH BLOCKED\033[0m') logger.error(error) - test_utils.capture_err_logs( + test_utils.capture_ovs_logs( ovs_logger, controller_clients, compute_clients, error) results.add_to_summary(2, "FAIL", "SSH works") diff --git a/sfc/tests/functest/sfc_one_chain_two_service_functions_different_computes.py b/sfc/tests/functest/sfc_one_chain_two_service_functions_different_computes.py index 63edd7e6..9661ee09 100644 --- a/sfc/tests/functest/sfc_one_chain_two_service_functions_different_computes.py +++ b/sfc/tests/functest/sfc_one_chain_two_service_functions_different_computes.py @@ -224,7 +224,7 @@ def main(): else: error = ('\033[91mTEST 1 [FAILED] ==> HTTP BLOCKED\033[0m') logger.error(error) - test_utils.capture_err_logs( + test_utils.capture_ovs_logs( ovs_logger, controller_clients, compute_clients, error) update_json_results("Test 1: HTTP works", "Failed") @@ -241,7 +241,7 @@ def main(): else: error = ('\033[91mTEST 2 [FAILED] ==> HTTP WORKS\033[0m') logger.error(error) - test_utils.capture_err_logs( + test_utils.capture_ovs_logs( ovs_logger, controller_clients, compute_clients, error) update_json_results("Test 2: HTTP Blocked", "Failed") |