aboutsummaryrefslogtreecommitdiffstats
path: root/sfc/tests
diff options
context:
space:
mode:
Diffstat (limited to 'sfc/tests')
-rw-r--r--sfc/tests/functest/config.yaml10
-rw-r--r--sfc/tests/functest/run_tests.py43
-rw-r--r--sfc/tests/functest/sfc_one_chain_two_service_functions_different_computes.py45
-rw-r--r--sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py46
-rw-r--r--sfc/tests/functest/vnfd-templates/test-vnfd-default-params.yaml5
-rw-r--r--sfc/tests/functest/vnfd-templates/test-vnfd1.yaml2
-rw-r--r--sfc/tests/functest/vnfd-templates/test-vnfd2.yaml2
-rw-r--r--sfc/tests/functest/vnfd-templates/test2-vnfd1.yaml2
-rw-r--r--sfc/tests/functest/vnfd-templates/test2-vnfd2.yaml2
9 files changed, 83 insertions, 74 deletions
diff --git a/sfc/tests/functest/config.yaml b/sfc/tests/functest/config.yaml
index b6f9c138..9cc4c5f4 100644
--- a/sfc/tests/functest/config.yaml
+++ b/sfc/tests/functest/config.yaml
@@ -6,10 +6,12 @@ defaults:
vcpu_count: 1
image_name: sfc_nsh_danube
image_file_name: sfc_nsh_danube.qcow2
- 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...)
+ installer:
+ type: fuel
+ ip: 10.20.0.2
+ user: root
+ password: r00tme
+ cluster: 1 # Change this to the id of the desired fuel env (1, 2, 3...)
image_format: qcow2
url: "http://artifacts.opnfv.org/sfc/images"
vnfd-dir: "vnfd-templates"
diff --git a/sfc/tests/functest/run_tests.py b/sfc/tests/functest/run_tests.py
index d0ed35f4..7214dd94 100644
--- a/sfc/tests/functest/run_tests.py
+++ b/sfc/tests/functest/run_tests.py
@@ -17,10 +17,10 @@ import yaml
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.ovs_logger as ovs_log
-import opnfv.utils.SSHUtils as ssh_utils
import sfc.lib.config as sfc_config
-import sfc.lib.utils as utils
+from opnfv.deployment.factory import Factory as DeploymentFactory
parser = argparse.ArgumentParser()
@@ -43,33 +43,34 @@ def push_results(testname, start_time, end_time, criteria, details):
details)
-def get_tackerc_file():
+def fetch_tackerc_file(controller_node):
rc_file = os.path.join(COMMON_CONFIG.sfc_test_dir, 'tackerc')
if not os.path.exists(rc_file):
- logger.info("tackerc file not found, getting it from controller")
- ip = utils.get_openstack_node_ips("controller")
- ssh_conn = ssh_utils.get_ssh_client(ip[0], 'root',
- proxy=COMMON_CONFIG.fuel_proxy)
- ssh_utils.get_file(ssh_conn, "tackerc", rc_file)
+ logger.info("tackerc file not found, fetching it from controller")
+ controller_node.get_file("~/tackerc", rc_file)
else:
logger.info("found tackerc file")
-
return rc_file
-def set_tacker_rc_file_env():
- rc_file = get_tackerc_file()
- with open(rc_file) as f:
- for line in f.readlines():
- if not (line.startswith('#') or len(line) == 1):
- filtered = line.strip().split(' ')
- kv = filtered[1].split('=')
- logger.info("Set shell env %s=%s" % (kv[0], kv[1]))
- os.environ[kv[0]] = kv[1].strip("'")
-
-
def main():
- set_tacker_rc_file_env()
+ 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
+ nodes = (deploymentHandler.get_nodes({'cluster': cluster})
+ if cluster is not None
+ else deploymentHandler.get_nodes())
+
+ a_controller = [node for node in nodes
+ if node.is_controller()][0]
+ rc_file = fetch_tackerc_file(a_controller)
+
+ creds = os_utils.source_credentials(rc_file)
+ logger.info("Updating env with {0}".format(creds))
ovs_logger = ovs_log.OVSLogger(
os.path.join(COMMON_CONFIG.sfc_test_dir, 'ovs-logs'),
COMMON_CONFIG.functest_results_dir)
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 9661ee09..8ec4dffb 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
@@ -10,7 +10,6 @@
import argparse
import os
-import re
import sys
import time
@@ -69,26 +68,6 @@ def setup_availability_zones(nova_client):
return az
-# JIRA: SFC-52 new function
-def modify_vnfd(tacker_vnfd, az):
- try:
- with open(tacker_vnfd, 'r') as stream:
- lines = stream.readlines()
- with open(tacker_vnfd, 'w') as stream:
- for line in lines:
- stream.write(re.sub('nova$', az, line))
-
- except Exception, e:
- logger.error("Problem when changing vnfd %s" % e)
-
-
-# JIRA: SFC-52 new function
-def prepare_tacker_vnfd(nova_client):
- azs = setup_availability_zones(nova_client)
- modify_vnfd(TACKER_VNFD1, azs[0])
- modify_vnfd(TACKER_VNFD2, azs[1])
-
-
def main():
installer_type = os.environ.get("INSTALLER_TYPE")
if installer_type != "fuel":
@@ -143,7 +122,7 @@ def main():
TESTCASE_CONFIG.secgroup_name,
TESTCASE_CONFIG.secgroup_descr)
- prepare_tacker_vnfd(nova_client)
+ availability_zones = setup_availability_zones(nova_client)
test_utils.create_instance(
nova_client, CLIENT, COMMON_CONFIG.flavor,
@@ -170,10 +149,16 @@ def main():
tacker_client,
tosca_file=tosca_file)
- 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',
+ av_zone=availability_zones[0])
+ test_utils.create_vnf_in_av_zone(
+ tacker_client,
+ 'testVNF2',
+ 'test-vnfd2',
+ av_zone=availability_zones[1])
try:
os_tacker.wait_for_vnf(tacker_client, vnf_name='testVNF1')
@@ -193,8 +178,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])
server_ip, client_ip, sf1, sf2 = test_utils.get_floating_ips(
nova_client, neutron_client)
@@ -218,7 +203,7 @@ def main():
time.sleep(100)
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):
logger.info('\033[92mTEST 1 [PASSED] ==> HTTP WORKS\033[0m')
update_json_results("Test 1: HTTP works", "Passed")
else:
@@ -235,7 +220,7 @@ def main():
test_utils.vxlan_firewall(sf1, port="80")
logger.info("Test HTTP again")
- if test_utils.is_http_blocked(srv_prv_ip, client_ip):
+ if test_utils.is_http_blocked(client_ip, srv_prv_ip):
logger.info('\033[92mTEST 2 [PASSED] ==> HTTP Blocked\033[0m')
update_json_results("Test 2: HTTP Blocked", "Passed")
else:
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')
diff --git a/sfc/tests/functest/vnfd-templates/test-vnfd-default-params.yaml b/sfc/tests/functest/vnfd-templates/test-vnfd-default-params.yaml
new file mode 100644
index 00000000..bf9bd868
--- /dev/null
+++ b/sfc/tests/functest/vnfd-templates/test-vnfd-default-params.yaml
@@ -0,0 +1,5 @@
+vdus:
+ vdu1:
+ param:
+ zone: nova
+
diff --git a/sfc/tests/functest/vnfd-templates/test-vnfd1.yaml b/sfc/tests/functest/vnfd-templates/test-vnfd1.yaml
index fd862ea0..79a625fa 100644
--- a/sfc/tests/functest/vnfd-templates/test-vnfd1.yaml
+++ b/sfc/tests/functest/vnfd-templates/test-vnfd1.yaml
@@ -20,7 +20,7 @@ vdus:
management: true
placement_policy:
- availability_zone: nova
+ availability_zone: { get_input: zone }
auto-scaling: noop
monitoring_policy: noop
diff --git a/sfc/tests/functest/vnfd-templates/test-vnfd2.yaml b/sfc/tests/functest/vnfd-templates/test-vnfd2.yaml
index 5451358d..64f799e4 100644
--- a/sfc/tests/functest/vnfd-templates/test-vnfd2.yaml
+++ b/sfc/tests/functest/vnfd-templates/test-vnfd2.yaml
@@ -20,7 +20,7 @@ vdus:
management: true
placement_policy:
- availability_zone: nova
+ availability_zone: { get_input: zone }
auto-scaling: noop
monitoring_policy: noop
diff --git a/sfc/tests/functest/vnfd-templates/test2-vnfd1.yaml b/sfc/tests/functest/vnfd-templates/test2-vnfd1.yaml
index 1d8da125..e8e0626b 100644
--- a/sfc/tests/functest/vnfd-templates/test2-vnfd1.yaml
+++ b/sfc/tests/functest/vnfd-templates/test2-vnfd1.yaml
@@ -22,7 +22,7 @@ vdus:
placement_policy:
# TODO: This availability zone is changed by the test case on the fly.
# See JIRA SFC-73 for more info
- availability_zone: nova
+ availability_zone: { get_input: zone }
auto-scaling: noop
monitoring_policy: noop
diff --git a/sfc/tests/functest/vnfd-templates/test2-vnfd2.yaml b/sfc/tests/functest/vnfd-templates/test2-vnfd2.yaml
index 280fc9e5..93a38acb 100644
--- a/sfc/tests/functest/vnfd-templates/test2-vnfd2.yaml
+++ b/sfc/tests/functest/vnfd-templates/test2-vnfd2.yaml
@@ -22,7 +22,7 @@ vdus:
placement_policy:
# TODO: This availability zone is changed by the test case on the fly.
# See JIRA SFC-73 for more info
- availability_zone: nova
+ availability_zone: { get_input: zone }
auto-scaling: noop
monitoring_policy: noop