diff options
Diffstat (limited to 'tests')
7 files changed, 742 insertions, 3 deletions
diff --git a/tests/ci/prepare_env.sh b/tests/ci/prepare_env.sh index d7c60d48f..8b9f887b2 100755 --- a/tests/ci/prepare_env.sh +++ b/tests/ci/prepare_env.sh @@ -16,6 +16,7 @@ : ${EXTERNAL_NETWORK:='admin_floating_net'} : ${USER_NAME:='ubuntu'} : ${SSH_KEY:='/root/.ssh/id_rsa'} +: ${DEPLOY_SCENARIO:='unknown'} # Extract network name from EXTERNAL_NETWORK # e.g. EXTERNAL_NETWORK='ext-net;flat;192.168.0.2;192.168.0.253;192.168.0.1;192.168.0.0/24' @@ -62,7 +63,73 @@ verify_connectivity() { } ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" +if [ "$INSTALLER_TYPE" == "apex" ]; then + # check the connection + verify_connectivity "${INSTALLER_IP}" + + pod_yaml="$YARDSTICK_REPO_DIR/etc/yardstick/nodes/apex_baremetal/pod.yaml" + + # update "ip" according to the CI env + ssh -l root "${INSTALLER_IP}" -i ${SSH_KEY} ${ssh_options} \ + "source /home/stack/stackrc && openstack server list -f yaml" > node_info + + controller_ips=($(awk '/control/{getline; {print $2}}' < node_info | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}')) + compute_ips=($(awk '/compute/{getline; {print $2}}' < node_info | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}')) + odl_ip="" + # Get ODL's cluster default module-shard Leader IP in HA scenario + if [[ ${DEPLOY_SCENARIO} == os-odl-*-ha ]]; then + for ip in "${controller_ips[@]}"; + do + if [[ "$odl_ip" ]]; then + break + fi + for ((i=0; i<${#controller_ips[@]}; i++)); + do + ODL_STATE=$(curl -s -u admin:admin -H "Accept: application/json" -H "Content-Type: application/json" \ + "http://"${ip}":8081/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-"${i}"-shard-default-operational,type=DistributedOperationalDatastore" \ + | grep -o \"RaftState\"\:\"Leader\" | tr ":" "\n" | sed -n '2p' | sed 's/\"//g'); + + if [[ ${ODL_STATE} == "Leader" ]]; then + odl_ip=${ip} + break + fi + done; + done + + if [[ -z "$odl_ip" ]]; then + echo "ERROR: Opendaylight Leader IP is emtpy" + exit 1 + fi + + elif [[ ${DEPLOY_SCENARIO} == *"odl"* ]]; then + odl_ip=${controller_ips[0]} + fi + + if [[ ${controller_ips[0]} ]]; then + sed -i "s|ip1|${controller_ips[0]}|" "${pod_yaml}" + fi + if [[ ${controller_ips[1]} ]]; then + sed -i "s|ip2|${controller_ips[1]}|" "${pod_yaml}" + fi + if [[ ${controller_ips[2]} ]]; then + sed -i "s|ip3|${controller_ips[2]}|" "${pod_yaml}" + fi + if [[ ${compute_ips[0]} ]]; then + sed -i "s|ip4|${compute_ips[0]}|" "${pod_yaml}" + fi + if [[ ${compute_ips[1]} ]]; then + sed -i "s|ip5|${compute_ips[1]}|" "${pod_yaml}" + fi + if [[ ${odl_ip} ]]; then + sed -i "s|ip6|${odl_ip}|" "${pod_yaml}" + fi + + + # update 'key_filename' according to the CI env + sed -i "s|node_keyfile|${SSH_KEY}|" "${pod_yaml}" + +fi if [ "$INSTALLER_TYPE" == "fuel" ]; then # check the connection diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc092.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc092.yaml new file mode 100644 index 000000000..85ec510df --- /dev/null +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc092.yaml @@ -0,0 +1,276 @@ +############################################################################## +## Copyright (c) 2018 Intracom Telecom 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 +############################################################################### +--- + +schema: "yardstick:task:0.1" +description: > + Yardstick TC092 config file; + SDN Controller resilience in HA configuration + +{% set file = file or '/etc/yardstick/pod.yaml' %} +{% set attack_host = attack_host or 'node6' %} + +scenarios: + +- + type: "GeneralHA" + options: + monitors: + - monitor_type: "general-monitor" + monitor_key: "ip-status" + key: "snat" + monitor_time: 50 + host: athena + sla: + max_outage_time: 0 + parameter: + destination_ip: "8.8.8.8" + + - monitor_type: "general-monitor" + monitor_key: "ip-status" + key: "l2" + monitor_time: 50 + host: athena + sla: + max_outage_time: 0 + parameter: + destination_ip: "@private_ip" + + operations: + - operation_type: "general-operation" + key: "get-privateip" + operation_key: "get-privateip" + action_parameter: + server_name: "ares" + return_parameter: + all: "@private_ip" + + + steps: + - actionKey: "get-privateip" + actionType: "operation" + index: 1 + + - actionKey: "l2" + actionType: "monitor" + index: 2 + + - actionKey: "snat" + actionType: "monitor" + index: 3 + + + nodes: + {{attack_host}}: {{attack_host}}.LF + athena: athena.ODLHA1 + runner: + type: Duration + duration: 1 + sla: + action: monitor + +- + type: "GeneralHA" + options: + attackers: + - + fault_type: "kill-process" + process_name: "opendaylight" + key: "kill-process" + host: {{attack_host}} + + monitors: + - monitor_type: "process" + process_name: "opendaylight" + host: {{attack_host}} + key: "monitor-recovery" + monitor_time: 50 + sla: + max_recover_time: 30 + + + - monitor_type: "general-monitor" + monitor_key: "ip-status" + key: "snat" + monitor_time: 70 + host: athena + sla: + max_outage_time: 0 + parameter: + destination_ip: "8.8.8.8" + + - monitor_type: "general-monitor" + monitor_key: "ip-status" + key: "l2" + monitor_time: 70 + host: athena + sla: + max_outage_time: 0 + parameter: + destination_ip: "@private_ip" + + operations: + - operation_type: "general-operation" + key: "start-service" + host: {{attack_host}} + operation_key: "start-service" + action_parameter: + service: "opendaylight" + rollback_parameter: + service: "opendaylight" + + - operation_type: "general-operation" + key: "get-privateip" + operation_key: "get-privateip" + action_parameter: + server_name: "ares" + return_parameter: + all: "@private_ip" + + + + steps: + + - actionKey: "monitor-recovery" + actionType: "monitor" + index: 1 + + - actionKey: "get-privateip" + actionType: "operation" + index: 2 + + - actionKey: "l2" + actionType: "monitor" + index: 3 + + - actionKey: "snat" + actionType: "monitor" + index: 4 + + - actionKey: "kill-process" + actionType: "attacker" + index: 5 + + - actionKey: "start-service" + actionType: "operation" + index: 6 + + + + nodes: + {{attack_host}}: {{attack_host}}.LF + athena: athena.ODLHA1 + runner: + type: Duration + duration: 1 + sla: + action: monitor + +- + type: "GeneralHA" + options: + monitors: + + - monitor_type: "general-monitor" + monitor_key: "ip-status" + key: "l2" + monitor_time: 80 + host: athena + sla: + max_outage_time: 40 + parameter: + destination_ip: "@private_ip" + + operations: + - operation_type: "general-operation" + key: "get-privateip" + operation_key: "get-privateip" + action_parameter: + server_name: "hermes" + return_parameter: + all: "@private_ip" + + - operation_type: "general-operation" + key: "nova-create-instance" + operation_key: "nova-create-instance" + action_parameter: + serverconfig: "hermes yardstick-image yardstick-flavor test_one" + rollback_parameter: + serverconfig: "hermes" + + - operation_type: "general-operation" + key: "add-server-to-secgroup" + operation_key: "add-server-to-secgroup" + action_parameter: + serverconfig: "hermes ODLHA1" + rollback_parameter: + serverconfig: "hermes ODLHA1" + + + steps: + - actionKey: "nova-create-instance" + actionType: "operation" + index: 1 + + - actionKey: "add-server-to-secgroup" + actionType: "operation" + index: 2 + + - actionKey: "get-privateip" + actionType: "operation" + index: 3 + + - actionKey: "l2" + actionType: "monitor" + index: 4 + + nodes: + {{attack_host}}: {{attack_host}}.LF + athena: athena.ODLHA1 + runner: + type: Duration + duration: 1 + sla: + action: monitor + + +contexts: + - + type: Node + name: LF + file: {{file}} + - + name: ODLHA1 + image: yardstick-image + flavor: yardstick-flavor + user: ubuntu + host: athena + placement_groups: + pgrp1: + policy: "availability" + servers: + athena: + floating_ip: true + placement: "pgrp1" + network_ports: + test_one: + - ens0 + + ares: + floating_ip: true + placement: "pgrp1" + network_ports: + test_one: + - ens0 + + networks: + test_one: + cidr: '10.0.1.0/24' + router: 'test_router' + diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc093.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc093.yaml new file mode 100644 index 000000000..a034471aa --- /dev/null +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc093.yaml @@ -0,0 +1,313 @@ +############################################################################## +## Copyright (c) 2018 Intracom Telecom 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 +############################################################################### +--- + +schema: "yardstick:task:0.1" +description: > + Yardstick TC093 config file; + SDN Vswitch resilience in non-HA or HA configuration + +{% set file = file or '/etc/yardstick/pod.yaml' %} +{% set attack_host_cmp_one = attack_host_cmp_one or 'node4' %} +{% set attack_host_cmp_two = attack_host_cmp_two or 'node5' %} +{% set systemd_service_name = systemd_service_name or 'openvswitch-switch'%} + +scenarios: + +- + type: "GeneralHA" + options: + monitors: + + - monitor_type: "general-monitor" + monitor_key: "ip-status" + key: "snat" + monitor_time: 50 + host: athena + sla: + max_outage_time: 0 + parameter: + destination_ip: "8.8.8.8" + + - monitor_type: "general-monitor" + monitor_key: "ip-status" + key: "l2" + monitor_time: 50 + host: athena + sla: + max_outage_time: 0 + parameter: + destination_ip: "@private_ip" + + operations: + - operation_type: "general-operation" + key: "get-privateip" + operation_key: "get-privateip" + action_parameter: + server_name: "ares" + return_parameter: + all: "@private_ip" + + + steps: + - actionKey: "get-privateip" + actionType: "operation" + index: 1 + + - actionKey: "l2" + actionType: "monitor" + index: 2 + + - actionKey: "snat" + actionType: "monitor" + index: 3 + + + nodes: + athena: athena.ODLnoHA1 + runner: + type: Duration + duration: 1 + sla: + action: monitor + + +- + type: "GeneralHA" + options: + attackers: + - + fault_type: "kill-process" + process_name: "openvswitch" + key: "kill-process-cmp-one" + host: {{attack_host_cmp_one}} + + - + fault_type: "kill-process" + process_name: "openvswitch" + key: "kill-process-cmp-two" + host: {{attack_host_cmp_two}} + + monitors: + - monitor_type: "process" + process_name: "openvswitch" + host: {{attack_host_cmp_one}} + key: "monitor-recovery-cmp-one" + monitor_time: 50 + sla: + max_recover_time: 30 + + - monitor_type: "process" + process_name: "openvswitch" + host: {{attack_host_cmp_two}} + key: "monitor-recovery-cmp-two" + monitor_time: 50 + sla: + max_recover_time: 30 + + - monitor_type: "general-monitor" + monitor_key: "ip-status" + key: "snat" + monitor_time: 70 + host: athena + sla: + max_outage_time: 20 + parameter: + destination_ip: "8.8.8.8" + + - monitor_type: "general-monitor" + monitor_key: "ip-status" + key: "l2" + monitor_time: 70 + host: athena + sla: + max_outage_time: 20 + parameter: + destination_ip: "@private_ip" + + operations: + - operation_type: "general-operation" + key: "restart-service-cmp-one" + host: {{attack_host_cmp_one}} + operation_key: "start-service" + action_parameter: + service: {{systemd_service_name ~ " restart"}} + rollback_parameter: + service: "openvswitch" + + - operation_type: "general-operation" + key: "restart-service-cmp-two" + host: {{attack_host_cmp_two}} + operation_key: "start-service" + action_parameter: + service: {{systemd_service_name ~ " restart"}} + rollback_parameter: + service: "openvswitch" + + - operation_type: "general-operation" + key: "get-privateip" + operation_key: "get-privateip" + action_parameter: + server_name: "ares" + return_parameter: + all: "@private_ip" + + + + steps: + + - actionKey: "get-privateip" + actionType: "operation" + index: 1 + + - actionKey: "l2" + actionType: "monitor" + index: 2 + + - actionKey: "snat" + actionType: "monitor" + index: 3 + + - actionKey: "kill-process-cmp-one" + actionType: "attacker" + index: 4 + + - actionKey: "kill-process-cmp-two" + actionType: "attacker" + index: 5 + + - actionKey: "monitor-recovery-cmp-one" + actionType: "monitor" + index: 6 + + - actionKey: "monitor-recovery-cmp-two" + actionType: "monitor" + index: 7 + + + - actionKey: "restart-service-cmp-one" + actionType: "operation" + index: 8 + + - actionKey: "restart-service-cmp-two" + actionType: "operation" + index: 9 + + + nodes: + {{attack_host_cmp_one}}: {{attack_host_cmp_one}}.LF + {{attack_host_cmp_two}}: {{attack_host_cmp_two}}.LF + athena: athena.ODLnoHA1 + runner: + type: Duration + duration: 1 + sla: + action: monitor + +- + type: "GeneralHA" + options: + monitors: + + - monitor_type: "general-monitor" + monitor_key: "ip-status" + key: "l2" + monitor_time: 80 + host: athena + sla: + max_outage_time: 40 + parameter: + destination_ip: "@private_ip" + + operations: + - operation_type: "general-operation" + key: "get-privateip" + operation_key: "get-privateip" + action_parameter: + server_name: "hermes" + return_parameter: + all: "@private_ip" + + - operation_type: "general-operation" + key: "nova-create-instance" + operation_key: "nova-create-instance" + action_parameter: + serverconfig: "hermes yardstick-image yardstick-flavor test_one" + rollback_parameter: + serverconfig: "hermes" + + - operation_type: "general-operation" + key: "add-server-to-secgroup" + operation_key: "add-server-to-secgroup" + action_parameter: + serverconfig: "hermes ODLnoHA1" + rollback_parameter: + serverconfig: "hermes ODLnoHA1" + + + steps: + - actionKey: "nova-create-instance" + actionType: "operation" + index: 1 + + - actionKey: "add-server-to-secgroup" + actionType: "operation" + index: 2 + + - actionKey: "get-privateip" + actionType: "operation" + index: 3 + + - actionKey: "l2" + actionType: "monitor" + index: 4 + + nodes: + athena: athena.ODLnoHA1 + runner: + type: Duration + duration: 1 + sla: + action: monitor + + +contexts: + - + type: Node + name: LF + file: {{file}} + - + name: ODLnoHA1 + image: yardstick-image + flavor: yardstick-flavor + user: ubuntu + host: athena + placement_groups: + pgrp1: + policy: "availability" + servers: + athena: + floating_ip: true + placement: "pgrp1" + network_ports: + test_one: + - ens0 + + ares: + floating_ip: true + placement: "pgrp1" + network_ports: + test_one: + - ens0 + + networks: + test_one: + cidr: '10.0.1.0/24' + router: 'test_router' + diff --git a/tests/opnfv/test_suites/opnfv_os-odl-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-nofeature-ha_daily.yaml index 13cc710f3..f174a90e4 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl-nofeature-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl-nofeature-ha_daily.yaml @@ -62,3 +62,18 @@ test_cases: task_args: huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml", "host": "node1"}' +- + file_name: opnfv_yardstick_tc092.yaml + constraint: + installer: apex + task_args: + default: '{"file": "etc/yardstick/nodes/apex_baremetal/pod.yaml", + "attack_host": "node6"}' +- + file_name: opnfv_yardstick_tc093.yaml + constraint: + installer: apex + task_args: + default: '{"file": "etc/yardstick/nodes/apex_baremetal/pod.yaml", + "attack_host_cmp_one": "node4","attack_host_cmp_two": "node5", + "systemd_service_name": "openvswitch"}' diff --git a/tests/opnfv/test_suites/opnfv_os-odl-nofeature-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-nofeature-noha_daily.yaml index 42a170a89..feb8a6631 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl-nofeature-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl-nofeature-noha_daily.yaml @@ -61,3 +61,11 @@ test_cases: task_args: default: '{"file": "etc/yardstick/nodes/fuel_baremetal/pod.yaml", "attack_host": "node6"}' +- + file_name: opnfv_yardstick_tc093.yaml + constraint: + installer: apex + task_args: + default: '{"file": "etc/yardstick/nodes/apex_baremetal/pod.yaml", + "attack_host_cmp_one": "node4","attack_host_cmp_two": "node5", + "systemd_service_name": "openvswitch"}' diff --git a/tests/unit/network_services/vnf_generic/vnf/test_base.py b/tests/unit/network_services/vnf_generic/vnf/test_base.py index 664373f8f..9ef6473f0 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_base.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_base.py @@ -215,9 +215,11 @@ class TestGenericVNF(unittest.TestCase): with self.assertRaises(TypeError) as exc: # pylint: disable=abstract-class-instantiated base.GenericVNF('vnf1', VNFD['vnfd:vnfd-catalog']['vnfd'][0]) - msg = ("Can't instantiate abstract class GenericVNF with abstract " - "methods collect_kpi, instantiate, scale, terminate, " - "wait_for_instantiate") + + msg = ("Can't instantiate abstract class GenericVNF with abstract methods " + "collect_kpi, instantiate, scale, start_collect, " + "stop_collect, terminate, wait_for_instantiate") + self.assertEqual(msg, str(exc.exception)) diff --git a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py index eb59c2837..38a043d00 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py @@ -1714,6 +1714,64 @@ class TestSampleVnf(unittest.TestCase): self.assertIsNone(sample_vnf.instantiate(scenario_cfg, {})) self.assertEqual(sample_vnf.nfvi_context, context2) + def test__update_collectd_options(self): + scenario_cfg = {'options': + {'collectd': + {'interval': 3, + 'plugins': + {'plugin3': {'param': 3}}}, + 'vnf__0': + {'collectd': + {'interval': 2, + 'plugins': + {'plugin3': {'param': 2}, + 'plugin2': {'param': 2}}}}}} + context_cfg = {'nodes': + {'vnf__0': + {'collectd': + {'interval': 1, + 'plugins': + {'plugin3': {'param': 1}, + 'plugin2': {'param': 1}, + 'plugin1': {'param': 1}}}}}} + expected = {'interval': 1, + 'plugins': + {'plugin3': {'param': 1}, + 'plugin2': {'param': 1}, + 'plugin1': {'param': 1}}} + + vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] + sample_vnf = SampleVNF('vnf__0', vnfd) + sample_vnf._update_collectd_options(scenario_cfg, context_cfg) + self.assertEqual(sample_vnf.setup_helper.collectd_options, expected) + + def test__update_options(self): + options1 = {'interval': 1, + 'param1': 'value1', + 'plugins': + {'plugin3': {'param': 3}, + 'plugin2': {'param': 1}, + 'plugin1': {'param': 1}}} + options2 = {'interval': 2, + 'param2': 'value2', + 'plugins': + {'plugin4': {'param': 4}, + 'plugin2': {'param': 2}, + 'plugin1': {'param': 2}}} + expected = {'interval': 1, + 'param1': 'value1', + 'param2': 'value2', + 'plugins': + {'plugin4': {'param': 4}, + 'plugin3': {'param': 3}, + 'plugin2': {'param': 1}, + 'plugin1': {'param': 1}}} + + vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] + sample_vnf = SampleVNF('vnf1', vnfd) + sample_vnf._update_options(options2, options1) + self.assertEqual(options2, expected) + @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time") @mock.patch("yardstick.ssh.SSH") def test_wait_for_instantiate_empty_queue(self, ssh, *args): |