diff options
Diffstat (limited to 'sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py')
-rw-r--r-- | sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py index e112e07b..a91b457b 100644 --- a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py +++ b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py @@ -20,6 +20,7 @@ import opnfv.utils.ovs_logger as ovs_log import sfc.lib.config as sfc_config import sfc.lib.utils as test_utils from sfc.lib.results import Results +from opnfv.deployment.factory import Factory as DeploymentFactory """ logging configuration """ @@ -32,6 +33,22 @@ TESTCASE_CONFIG = sfc_config.TestcaseConfig('sfc_two_chains_SSH_and_HTTP') def main(): + deploymentHandler = DeploymentFactory.get_handler( + COMMON_CONFIG.installer_type, + COMMON_CONFIG.installer_ip, + COMMON_CONFIG.installer_user, + installer_pwd=COMMON_CONFIG.installer_password) + + cluster = COMMON_CONFIG.installer_cluster + openstack_nodes = (deploymentHandler.get_nodes({'cluster': cluster}) + if cluster is not None + else deploymentHandler.get_nodes()) + + controller_nodes = [node for node in openstack_nodes + if node.is_controller()] + compute_nodes = [node for node in openstack_nodes + if node.is_compute()] + results = Results(COMMON_CONFIG.line_length) results.add_to_summary(0, "=") results.add_to_summary(2, "STATUS", "SUBTEST") @@ -51,8 +68,9 @@ def main(): '\033[91mexport INSTALLER_IP=<ip>\033[0m') sys.exit(1) - test_utils.setup_compute_node(TESTCASE_CONFIG.subnet_cidr) - test_utils.configure_iptables() + test_utils.setup_compute_node(TESTCASE_CONFIG.subnet_cidr, compute_nodes) + test_utils.configure_iptables(controller_nodes) + test_utils.download_image(COMMON_CONFIG.url, COMMON_CONFIG.image_path) _, custom_flv_id = os_utils.get_or_create_flavor( @@ -69,10 +87,8 @@ def main(): nova_client = os_utils.get_nova_client() tacker_client = os_tacker.get_tacker_client() - controller_clients = test_utils.get_ssh_clients("controller", - COMMON_CONFIG.fuel_proxy) - compute_clients = test_utils.get_ssh_clients("compute", - COMMON_CONFIG.fuel_proxy) + controller_clients = test_utils.get_ssh_clients(controller_nodes) + compute_clients = test_utils.get_ssh_clients(compute_nodes) ovs_logger = ovs_log.OVSLogger( os.path.join(COMMON_CONFIG.sfc_test_dir, 'ovs-logs'), @@ -112,8 +128,8 @@ def main(): COMMON_CONFIG.vnfd_dir, TESTCASE_CONFIG.test_vnfd_blue) os_tacker.create_vnfd(tacker_client, tosca_file=tosca_blue) - os_tacker.create_vnf(tacker_client, 'testVNF1', vnfd_name='test-vnfd1') - os_tacker.create_vnf(tacker_client, 'testVNF2', vnfd_name='test-vnfd2') + test_utils.create_vnf_in_av_zone(tacker_client, 'testVNF1', 'test-vnfd1') + test_utils.create_vnf_in_av_zone(tacker_client, 'testVNF2', 'test-vnfd2') try: os_tacker.wait_for_vnf(tacker_client, vnf_name='testVNF1') @@ -141,8 +157,8 @@ def main(): 'protocol': 6 }) - logger.info(test_utils.run_cmd('tacker sfc-list')) - logger.info(test_utils.run_cmd('tacker sfc-classifier-list')) + logger.info(test_utils.run_cmd('tacker sfc-list')[1]) + logger.info(test_utils.run_cmd('tacker sfc-classifier-list')[1]) # Start measuring the time it takes to implement the classification rules t1 = threading.Thread(target=test_utils.wait_for_classification_rules, @@ -174,7 +190,7 @@ def main(): t1.join() logger.info("Test SSH") - if test_utils.is_ssh_blocked(srv_prv_ip, client_ip): + if test_utils.is_ssh_blocked(client_ip, srv_prv_ip): results.add_to_summary(2, "PASS", "SSH Blocked") else: error = ('\033[91mTEST 1 [FAILED] ==> SSH NOT BLOCKED\033[0m') @@ -184,7 +200,7 @@ def main(): results.add_to_summary(2, "FAIL", "SSH Blocked") logger.info("Test HTTP") - if not test_utils.is_http_blocked(srv_prv_ip, client_ip): + if not test_utils.is_http_blocked(client_ip, srv_prv_ip): results.add_to_summary(2, "PASS", "HTTP works") else: error = ('\033[91mTEST 2 [FAILED] ==> HTTP BLOCKED\033[0m') @@ -213,7 +229,7 @@ def main(): 'protocol': 6 }) - logger.info(test_utils.run_cmd('tacker sfc-classifier-list')) + logger.info(test_utils.run_cmd('tacker sfc-classifier-list')[1]) # Start measuring the time it takes to implement the classification rules t2 = threading.Thread(target=test_utils.wait_for_classification_rules, @@ -227,7 +243,7 @@ def main(): t2.join() logger.info("Test HTTP") - if test_utils.is_http_blocked(srv_prv_ip, client_ip): + if test_utils.is_http_blocked(client_ip, srv_prv_ip): results.add_to_summary(2, "PASS", "HTTP Blocked") else: error = ('\033[91mTEST 3 [FAILED] ==> HTTP WORKS\033[0m') @@ -237,7 +253,7 @@ def main(): results.add_to_summary(2, "FAIL", "HTTP Blocked") logger.info("Test SSH") - if not test_utils.is_ssh_blocked(srv_prv_ip, client_ip): + if not test_utils.is_ssh_blocked(client_ip, srv_prv_ip): results.add_to_summary(2, "PASS", "SSH works") else: error = ('\033[91mTEST 4 [FAILED] ==> SSH BLOCKED\033[0m') |