From e2e235affd2a7d46d2fa61817906034ec4be1a40 Mon Sep 17 00:00:00 2001 From: Ricardo Noriega Date: Tue, 19 Jan 2016 17:41:22 +0100 Subject: Service Function Chaining test cases Change-Id: Id4c8b1bc05e768bdb2b8f17798f13f4d83dcd9d6 Signed-off-by: Ricardo Noriega (cherry picked from commit 805aaa50d226e8c91b69af0252aef68eda1551c3) --- yardstick/benchmark/scenarios/networking/sfc.py | 105 +++++++++++++++++++++ .../scenarios/networking/sfc_compute.bash | 5 + .../scenarios/networking/sfc_pre_setup.bash | 9 ++ .../benchmark/scenarios/networking/sfc_server.bash | 5 + .../benchmark/scenarios/networking/sfc_tacker.bash | 19 ++++ .../scenarios/networking/sfc_teardown.bash | 17 ++++ .../benchmark/scenarios/networking/test-vnfd.yaml | 32 +++++++ 7 files changed, 192 insertions(+) create mode 100644 yardstick/benchmark/scenarios/networking/sfc.py create mode 100755 yardstick/benchmark/scenarios/networking/sfc_compute.bash create mode 100755 yardstick/benchmark/scenarios/networking/sfc_pre_setup.bash create mode 100755 yardstick/benchmark/scenarios/networking/sfc_server.bash create mode 100755 yardstick/benchmark/scenarios/networking/sfc_tacker.bash create mode 100755 yardstick/benchmark/scenarios/networking/sfc_teardown.bash create mode 100644 yardstick/benchmark/scenarios/networking/test-vnfd.yaml (limited to 'yardstick') diff --git a/yardstick/benchmark/scenarios/networking/sfc.py b/yardstick/benchmark/scenarios/networking/sfc.py new file mode 100644 index 000000000..dc032ee5c --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/sfc.py @@ -0,0 +1,105 @@ +import pkg_resources +import logging +import subprocess + +import yardstick.ssh as ssh +from yardstick.benchmark.scenarios import base + +LOG = logging.getLogger(__name__) + + +class Sfc(base.Scenario): + ''' SFC scenario class ''' + + __scenario_type__ = "sfc" + + PRE_SETUP_SCRIPT = 'sfc_pre_setup.bash' + TACKER_SCRIPT = 'sfc_tacker.bash' + SERVER_SCRIPT = 'sfc_server.bash' + TEARDOWN_SCRIPT = "sfc_teardown.bash" + + def __init__(self, scenario_cfg, context_cfg): + self.scenario_cfg = scenario_cfg + self.context_cfg = context_cfg + self.setup_done = False + self.teardown_done = False + + def setup(self): + '''scenario setup''' + self.tacker_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + Sfc.TACKER_SCRIPT) + + self.server_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + Sfc.SERVER_SCRIPT) + + ''' calling Tacker to instantiate VNFs and Service Chains ''' + cmd_tacker = "%s" % (self.tacker_script) + subprocess.call(cmd_tacker, shell=True) + + target = self.context_cfg['target'] + target_user = target.get('user', 'root') + target_pwd = target.get('password', 'octopus') + target_ip = target.get('ip', None) + + ''' webserver start automatically during the vm boot ''' + LOG.info("user:%s, target:%s", target_user, target_ip) + self.server = ssh.SSH(target_user, target_ip, password=target_pwd) + self.server.wait(timeout=600) + self.server.run("cat > ~/server.sh", + stdin=open(self.server_script, "rb")) + cmd_server = "sudo bash server.sh" + LOG.debug("Executing command: %s", cmd_server) + status, stdout, stderr = self.server.execute(cmd_server) + LOG.debug("Output server command: %s", status) + + self.setup_done = True + + def run(self, result): + ''' Creating client and server VMs to perform the test''' + host = self.context_cfg['host'] + host_user = host.get('user', 'cirros') + host_pwd = host.get('password', 'cubswin:)') + host_ip = host.get('ip', None) + + LOG.info("user:%s, host:%s", host_user, host_ip) + self.client = ssh.SSH(host_user, host_ip, password=host_pwd) + self.client.wait(timeout=600) + + if not self.setup_done: + self.setup() + + target = self.context_cfg['target'] + target_ip = target.get('ip', None) + + cmd_client = "curl %s", target_ip + LOG.debug("Executing command: %s", cmd_client) + result = self.client.execute(cmd_client) + LOG.debug("Output client command: %s", result) + + def teardown(self): + ''' for scenario teardown remove tacker VNFs, chains and classifiers''' + self.teardown_script = pkg_resources.resource_filename( + "yardstick.benchmark.scenarios.sfc", + Sfc.TEARDOWN_SCRIPT) + subprocess.call(self.teardown_script, shell=True) + self.teardown_done = True + + +'''def _test(): + + internal test function + logger = logging.getLogger("Sfc Yardstick") + logger.setLevel(logging.DEBUG) + + result = {} + + sfc = Sfc() + sfc.setup() + sfc.run(result) + print result + sfc.teardown() + +if __name__ == '__main__': + _test()''' diff --git a/yardstick/benchmark/scenarios/networking/sfc_compute.bash b/yardstick/benchmark/scenarios/networking/sfc_compute.bash new file mode 100755 index 000000000..eeda3f274 --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/sfc_compute.bash @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +sudo ifconfig br-int up +sudo ip route add 11.0.0.0/24 dev br-int diff --git a/yardstick/benchmark/scenarios/networking/sfc_pre_setup.bash b/yardstick/benchmark/scenarios/networking/sfc_pre_setup.bash new file mode 100755 index 000000000..fcc225504 --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/sfc_pre_setup.bash @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +# download and create image +wget https://www.dropbox.com/s/focu44sh52li7fz/sfc_cloud.qcow2 +glance image-create --name sfc --disk-format qcow2 --container-format bare --file sfc_cloud.qcow2 + +#create flavor +nova flavor-create --is-public true sfc_custom 666 1000 5 2 diff --git a/yardstick/benchmark/scenarios/networking/sfc_server.bash b/yardstick/benchmark/scenarios/networking/sfc_server.bash new file mode 100755 index 000000000..e9b34e032 --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/sfc_server.bash @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +service iptables stop +python -m SimpleHTTPServer 80 diff --git a/yardstick/benchmark/scenarios/networking/sfc_tacker.bash b/yardstick/benchmark/scenarios/networking/sfc_tacker.bash new file mode 100755 index 000000000..df1b4af2b --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/sfc_tacker.bash @@ -0,0 +1,19 @@ +#!/bin/bash +set -e +BASEDIR= `pwd` + +#import VNF descriptor +tacker vnfd-create --vnfd-file ${BASEDIR}/test-vnfd.yaml + +#create instances of the imported VNF +tacker vnf-create --name testVNF1 --vnfd-name test-vnfd +tacker vnf-create --name testVNF2 --vnfd-name test-vnfd + +#create service chain +tacker sfc-create --name chainA --chain testVNF1 +tacker sfc-create --name chainB --chain testVNF2 + +#create classifier +tacker sfc-classifier-create --name myclassA --chain chainA --match dest_port=80,protocol=6 +tacker sfc-classifier-create --name myclassB --chain chainB --match dest_port=22,protocol=6 + diff --git a/yardstick/benchmark/scenarios/networking/sfc_teardown.bash b/yardstick/benchmark/scenarios/networking/sfc_teardown.bash new file mode 100755 index 000000000..4a3924037 --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/sfc_teardown.bash @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +#delete classifier +tacker sfc-classifier-create myclassA +tacker sfc-classifier-create myclassB + +#delete service chain +tacker sfc-delete chainA +tacker sfc-delete chainB + +#delete VNFs +tacker vnf-delete testVNF1 +tacker vnf-delete testVNF2 + +#delete VNF descriptor +tacker vnfd-delete test-vnfd diff --git a/yardstick/benchmark/scenarios/networking/test-vnfd.yaml b/yardstick/benchmark/scenarios/networking/test-vnfd.yaml new file mode 100644 index 000000000..178c671d4 --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/test-vnfd.yaml @@ -0,0 +1,32 @@ +template_name: test-vnfd +description: firewall-example + +service_properties: + Id: firewall-vnfd + vendor: tacker + version: 1 + type: + - firewall +vdus: + vdu1: + id: vdu1 + vm_image: sfc + instance_type: sfc_custom + service_type: firewall + + network_interfaces: + management: + network: sfc-net_mgmt + management: true + + placement_policy: + availability_zone: nova + + auto-scaling: noop + monitoring_policy: noop + failure_policy: respawn + + config: + param0: key0 + param1: key1 + -- cgit 1.2.3-korg