aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Noriega <ricardo.noriega.de.soto@ericsson.com>2016-01-19 17:41:22 +0100
committerJörgen Karlsson <jorgen.w.karlsson@ericsson.com>2016-01-29 18:28:12 +0000
commit805aaa50d226e8c91b69af0252aef68eda1551c3 (patch)
tree86fabb60b05b71e8e632887b31c69512577b93a6
parentf879c91a15dfd0de24367dd098c8c796851f9769 (diff)
Service Function Chaining test cases
Change-Id: Id4c8b1bc05e768bdb2b8f17798f13f4d83dcd9d6 Signed-off-by: Ricardo Noriega <ricardo.noriega.de.soto@ericsson.com>
-rw-r--r--tests/sfc/sfc_TC02.yaml36
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_sfc.py55
-rw-r--r--yardstick/benchmark/scenarios/networking/sfc.py105
-rwxr-xr-xyardstick/benchmark/scenarios/networking/sfc_compute.bash5
-rwxr-xr-xyardstick/benchmark/scenarios/networking/sfc_pre_setup.bash9
-rwxr-xr-xyardstick/benchmark/scenarios/networking/sfc_server.bash5
-rwxr-xr-xyardstick/benchmark/scenarios/networking/sfc_tacker.bash19
-rwxr-xr-xyardstick/benchmark/scenarios/networking/sfc_teardown.bash17
-rw-r--r--yardstick/benchmark/scenarios/networking/test-vnfd.yaml32
9 files changed, 283 insertions, 0 deletions
diff --git a/tests/sfc/sfc_TC02.yaml b/tests/sfc/sfc_TC02.yaml
new file mode 100644
index 000000000..85e6eeb52
--- /dev/null
+++ b/tests/sfc/sfc_TC02.yaml
@@ -0,0 +1,36 @@
+#SFC test case using Tacker as Orchestrator and Netvirt as classifier
+
+schema: "yardstick:task:0.1"
+
+scenarios:
+-
+ type: sfc
+
+ host: http_client.sfc
+ target: http_server.sfc
+
+ runner:
+ type: Iteration
+ iterations: 1
+ interval: 1
+
+contexts:
+-
+ name: sfc
+ placement_groups:
+ pgrp1:
+ policy: "availability"
+ servers:
+ http_client:
+ flavor: m1.tiny
+ image: cirros-0.3.3
+ floating_ip: true
+ placement: "pgrp1"
+ http_server:
+ flavor: sfc_custom
+ image: sfc
+ floating_ip: true
+ placement: "pgrp1"
+ networks:
+ net_mgmt:
+ cidr: '11.0.0.0/24'
diff --git a/tests/unit/benchmark/scenarios/networking/test_sfc.py b/tests/unit/benchmark/scenarios/networking/test_sfc.py
new file mode 100644
index 000000000..adce0824a
--- /dev/null
+++ b/tests/unit/benchmark/scenarios/networking/test_sfc.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+
+##############################################################################
+# Copyright (c) 2015 Ericsson AB 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
+##############################################################################
+
+# Unittest for yardstick.benchmark.scenarios.networking.sfc
+
+import mock
+import unittest
+
+from yardstick.benchmark.scenarios.networking import sfc
+
+
+class SfcTestCase(unittest.TestCase):
+
+ def setUp(self):
+ scenario_cfg = dict()
+ context_cfg = dict()
+
+ # Used in Sfc.setup()
+ context_cfg['target'] = dict()
+ context_cfg['target']['user'] = 'root'
+ context_cfg['target']['password'] = 'octopus'
+ context_cfg['target']['ip'] = None
+
+ # Used in Sfc.run()
+ context_cfg['host'] = dict()
+ context_cfg['host']['user'] = 'cirros'
+ context_cfg['host']['password'] = 'cubslose:)'
+ context_cfg['host']['ip'] = None
+ context_cfg['target'] = dict()
+ context_cfg['target']['ip'] = None
+
+ self.sfc = sfc.Sfc(scenario_cfg=scenario_cfg, context_cfg=context_cfg)
+
+ @mock.patch('yardstick.benchmark.scenarios.networking.sfc.ssh')
+ def test_run_for_success(self, mock_ssh):
+ # Mock a successfull SSH in Sfc.setup() and Sfc.run()
+ mock_ssh.SSH().execute.return_value = (0, '100', '')
+
+ result = {}
+ self.sfc.run(result)
+
+
+def main():
+ unittest.main()
+
+if __name__ == '__main__':
+ main()
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
+