diff options
-rw-r--r-- | ansible/group_vars/all.yml | 1 | ||||
-rw-r--r-- | ansible/install-inventory.ini | 3 | ||||
-rw-r--r-- | ansible/install.yaml | 59 | ||||
-rw-r--r-- | samples/lmbench.yaml | 33 | ||||
-rwxr-xr-x | yardstick/benchmark/scenarios/availability/ha_tools/fault_process_kill.bash | 4 | ||||
-rw-r--r-- | yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py | 111 | ||||
-rw-r--r-- | yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py | 107 |
7 files changed, 298 insertions, 20 deletions
diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 9f5293272..596560508 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -7,6 +7,7 @@ release: xenial normal_image_file: "{{ workspace }}/yardstick-image.img"
nsb_image_file: "{{ workspace }}/yardstick-nsb-image.img"
ubuntu_image_file: /tmp/workspace/yardstick/yardstick-trusty-server.raw
+installation_mode: "{{ INSTALLATION_MODE | default('baremetal') }}"
proxy_env:
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin
http_proxy: "{{ lookup('env', 'http_proxy') }}"
diff --git a/ansible/install-inventory.ini b/ansible/install-inventory.ini index e15a2e96a..4e8629428 100644 --- a/ansible/install-inventory.ini +++ b/ansible/install-inventory.ini @@ -17,8 +17,9 @@ jumphost [all:vars] arch_amd64=amd64 arch_arm64=arm64 -inst_mode_container=container inst_mode_baremetal=baremetal +inst_mode_container=container +inst_mode_container_pull=container_pull ubuntu_archive={"amd64": "http://archive.ubuntu.com/ubuntu/", "arm64": "http://ports.ubuntu.com/ubuntu-ports/"} # Uncomment credentials below if needed # ansible_user=root diff --git a/ansible/install.yaml b/ansible/install.yaml index fa8419b53..0800ee534 100644 --- a/ansible/install.yaml +++ b/ansible/install.yaml @@ -15,7 +15,6 @@ - hosts: jumphost become: yes vars: - installation_mode: "{{ INSTALLATION_MODE | default('baremetal') }}" yardstick_dir: "{{ YARDSTICK_DIR | default('/home/opnfv/repos/yardstick') }}" virtual_environment: "{{ VIRTUAL_ENVIRONMENT | default(False) }}" nsb_dir: "{{ NSB_DIR | default('/opt/nsb_bin/') }}" @@ -28,27 +27,30 @@ state: directory owner: root mode: 0777 + when: + - installation_mode != inst_mode_container_pull roles: - - add_repos_jumphost - - install_dependencies_jumphost - - install_yardstick - - configure_uwsgi - - configure_nginx - - configure_gui - - download_trex - - install_trex - - configure_rabbitmq + - { role: add_repos_jumphost, when: installation_mode != inst_mode_container_pull } + - { role: install_dependencies_jumphost, when: installation_mode != inst_mode_container_pull } + - { role: install_yardstick, when: installation_mode != inst_mode_container_pull } + - { role: configure_uwsgi, when: installation_mode != inst_mode_container_pull } + - { role: configure_nginx, when: installation_mode != inst_mode_container_pull } + - { role: configure_gui, when: installation_mode != inst_mode_container_pull } + - { role: download_trex, when: installation_mode != inst_mode_container_pull } + - { role: install_trex, when: installation_mode != inst_mode_container_pull } + - { role: configure_rabbitmq, when: installation_mode != inst_mode_container_pull } + post_tasks: - service: name: nginx state: restarted - when: installation_mode != inst_mode_container + when: installation_mode == inst_mode_baremetal - shell: uwsgi -i /etc/yardstick/yardstick.ini - when: installation_mode != inst_mode_container + when: installation_mode == inst_mode_baremetal - name: Prepare baremetal and standalone servers @@ -106,6 +108,7 @@ include_role: name: build_yardstick_image tasks_from: pre_build.yml + when: installation_mode != inst_mode_container - hosts: chroot_image @@ -120,6 +123,7 @@ include_role: name: build_yardstick_image tasks_from: "cloudimg_modify_{{ img_property }}.yml" + when: installation_mode != inst_mode_container - hosts: jumphost @@ -130,3 +134,34 @@ include_role: name: build_yardstick_image tasks_from: post_build.yml + when: installation_mode != inst_mode_container + + +- name: start yardstick container on jumphost + hosts: jumphost + + tasks: + - include_role: + name: install_dependencies_jumphost + when: installation_mode == inst_mode_container_pull + + - include_role: + name: docker + when: installation_mode == inst_mode_container_pull + + - name: Start yardstick container + docker_container: + name: yardstick + pull: yes + recreate: yes + image: "{{ yardstick_docker_image|default('opnfv/yardstick:latest') }}" + state: started + restart_policy: always + privileged: yes + interactive: yes + volumes: + - "{{ openrc_file|default('/dev/null') }}:/etc/yardstick/openstack.creds:ro" + - /var/run/docker.sock:/var/run/docker.sock + - /opt:/opt + - /etc/localtime:/etc/localtime:ro + when: installation_mode == inst_mode_container_pull diff --git a/samples/lmbench.yaml b/samples/lmbench.yaml index ea2966b24..7050243f9 100644 --- a/samples/lmbench.yaml +++ b/samples/lmbench.yaml @@ -9,6 +9,13 @@ --- # Sample benchmark task config file # measure memory read latency and memory bandwidth using lmbench +# can be used both on Openstack and Kubernetes with "context_type" + +{% set context_type = context_type or "Heat" %} +{% set separator = separator or "." %} +{% if context_type == "Kubernetes" %} +{% set separator = "-" %} +{% endif %} schema: "yardstick:task:0.1" @@ -19,7 +26,7 @@ scenarios: test_type: "latency" stop_size: 32.0 - host: demeter.demo + host: demeter{{ separator }}demo runner: type: Arithmetic @@ -39,7 +46,7 @@ scenarios: test_type: "bandwidth" benchmark: "wr" - host: demeter.demo + host: demeter{{ separator }}demo runner: type: Arithmetic @@ -55,7 +62,24 @@ scenarios: action: monitor context: + type: {{ context_type }} name: demo + {% if context_type == "Kubernetes" %} + servers: + demeter: + image: opnfv/yardstick-image-k8s + resources: + limits: + cpu: 1 + memory: 1Gi + requests: + cpu: 1 + memory: 1Gi + command: /bin/bash + args: ['-c', 'mkdir /root/.ssh; cp /tmp/.ssh/authorized_keys ~/.ssh/.; + chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; service ssh restart; + while true ; do sleep 10000; done'] + {% else %} image: yardstick-image flavor: yardstick-flavor user: ubuntu @@ -71,6 +95,5 @@ context: networks: test: - cidr: '10.0.1.0/24' - - + cidr: "10.0.1.0/24" + {% endif %} diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/fault_process_kill.bash b/yardstick/benchmark/scenarios/availability/ha_tools/fault_process_kill.bash index d34ce9338..cda469cf9 100755 --- a/yardstick/benchmark/scenarios/availability/ha_tools/fault_process_kill.bash +++ b/yardstick/benchmark/scenarios/availability/ha_tools/fault_process_kill.bash @@ -16,7 +16,7 @@ set -e process_name=$1 if [ "$process_name" = "keystone" ]; then - for pid in $(ps aux | grep "keystone" | grep -iv heartbeat | grep -iv monitor | grep -v grep | grep -v /bin/sh | awk '{print $2}'); \ + for pid in $(ps aux | grep "keystone" | grep -iv monitor | grep -v grep | grep -v /bin/sh | awk '{print $2}'); \ do kill -9 "${pid}" done @@ -26,7 +26,7 @@ elif [ "$process_name" = "haproxy" ]; then kill -9 "${pid}" done else - for pid in $(pgrep -fa [^-_a-zA-Z0-9]${process_name} | grep -iv heartbeat | awk '{print $1}'); + for pid in $(pgrep -fa [^-_a-zA-Z0-9]${process_name} | awk '{print $1}'); do kill -9 "${pid}" done diff --git a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py index 29533808c..7548b338a 100644 --- a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py +++ b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py @@ -587,3 +587,114 @@ class IxNextgen(object): # pragma: no cover self.ixnet.execute('start', '/traffic') # pylint: disable=unnecessary-lambda utils.wait_until_true(lambda: self.is_traffic_running()) + + def add_topology(self, name, vports): + log.debug("add_topology: name='%s' ports='%s'", name, vports) + obj = self.ixnet.add(self.ixnet.getRoot(), 'topology') + self.ixnet.setMultiAttribute(obj, '-name', name, '-vports', vports) + self.ixnet.commit() + return obj + + def add_device_group(self, topology, name, multiplier): + log.debug("add_device_group: tpl='%s', name='%s', multiplier='%s'", + topology, name, multiplier) + + obj = self.ixnet.add(topology, 'deviceGroup') + self.ixnet.setMultiAttribute(obj, '-name', name, '-multiplier', + multiplier) + self.ixnet.commit() + return obj + + def add_ethernet(self, dev_group, name): + log.debug( + "add_ethernet: device_group='%s' name='%s'", dev_group, name) + obj = self.ixnet.add(dev_group, 'ethernet') + self.ixnet.setMultiAttribute(obj, '-name', name) + self.ixnet.commit() + return obj + + def add_ipv4(self, ethernet, name='', + addr=None, addr_step=None, addr_direction='increment', + prefix=None, prefix_step=None, prefix_direction='increment', + gateway=None, gw_step=None, gw_direction='increment'): + log.debug("add_ipv4: ethernet='%s' name='%s'", ethernet, name) + obj = self.ixnet.add(ethernet, 'ipv4') + if name != '': + self.ixnet.setAttribute(obj, '-name', name) + self.ixnet.commit() + + if addr_step is not None: + # handle counter pattern + _address = self.ixnet.getAttribute(obj, '-address') + self.ixnet.setMultiAttribute(_address, '-clearOverlays', 'true', + '-pattern', 'counter') + + address_counter = self.ixnet.add(_address, 'counter') + self.ixnet.setMultiAttribute(address_counter, + '-start', addr, + '-step', addr_step, + '-direction', addr_direction) + elif addr is not None: + # handle single value + _address = self.ixnet.getAttribute(obj, '-address') + self.ixnet.setMultiAttribute(_address + '/singleValue', '-value', + addr) + + if prefix_step is not None: + # handle counter pattern + _prefix = self.ixnet.getAttribute(obj, '-prefix') + self.ixnet.setMultiAttribute(_prefix, '-clearOverlays', 'true', + '-pattern', 'counter') + prefix_counter = self.ixnet.add(_prefix, 'counter') + self.ixnet.setMultiAttribute(prefix_counter, + '-start', prefix, + '-step', prefix_step, + '-direction', prefix_direction) + elif prefix is not None: + # handle single value + _prefix = self.ixnet.getAttribute(obj, '-prefix') + self.ixnet.setMultiAttribute(_prefix + '/singleValue', '-value', + prefix) + + if gw_step is not None: + # handle counter pattern + _gateway = self.ixnet.getAttribute(obj, '-gatewayIp') + self.ixnet.setMultiAttribute(_gateway, '-clearOverlays', 'true', + '-pattern', 'counter') + + gateway_counter = self.ixnet.add(_gateway, 'counter') + self.ixnet.setMultiAttribute(gateway_counter, + '-start', gateway, + '-step', gw_step, + '-direction', gw_direction) + elif gateway is not None: + # handle single value + _gateway = self.ixnet.getAttribute(obj, '-gatewayIp') + self.ixnet.setMultiAttribute(_gateway + '/singleValue', '-value', + gateway) + + self.ixnet.commit() + return obj + + def add_pppox_client(self, xproto, auth, user, pwd): + log.debug( + "add_pppox_client: xproto='%s', auth='%s', user='%s', pwd='%s'", + xproto, auth, user, pwd) + obj = self.ixnet.add(xproto, 'pppoxclient') + self.ixnet.commit() + + if auth == 'pap': + auth_type = self.ixnet.getAttribute(obj, '-authType') + self.ixnet.setMultiAttribute(auth_type + '/singleValue', '-value', + auth) + pap_user = self.ixnet.getAttribute(obj, '-papUser') + self.ixnet.setMultiAttribute(pap_user + '/singleValue', '-value', + user) + pap_pwd = self.ixnet.getAttribute(obj, '-papPassword') + self.ixnet.setMultiAttribute(pap_pwd + '/singleValue', '-value', + pwd) + else: + raise NotImplementedError() + + self.ixnet.commit() + return obj diff --git a/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py b/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py index 92ceeae83..d04dfd42b 100644 --- a/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py +++ b/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py @@ -186,6 +186,113 @@ class TestIxNextgen(unittest.TestCase): self.assertIn([64, 64, 75], output) self.assertIn([512, 512, 25], output) + def test_add_topology(self): + self.ixnet_gen.ixnet.add.return_value = 'obj' + self.ixnet_gen.add_topology('topology 1', 'vports') + self.ixnet_gen.ixnet.add.assert_called_once_with('my_root', 'topology') + self.ixnet_gen.ixnet.setMultiAttribute.assert_called_once_with( + 'obj', '-name', 'topology 1', '-vports', 'vports') + self.ixnet_gen.ixnet.commit.assert_called_once() + + def test_add_device_group(self): + self.ixnet_gen.ixnet.add.return_value = 'obj' + self.ixnet_gen.add_device_group('topology', 'device group 1', '1') + self.ixnet_gen.ixnet.add.assert_called_once_with('topology', + 'deviceGroup') + self.ixnet_gen.ixnet.setMultiAttribute.assert_called_once_with( + 'obj', '-name', 'device group 1', '-multiplier', '1') + self.ixnet_gen.ixnet.commit.assert_called_once() + + def test_add_ethernet(self): + self.ixnet_gen.ixnet.add.return_value = 'obj' + self.ixnet_gen.add_ethernet('device_group', 'ethernet 1') + self.ixnet_gen.ixnet.add.assert_called_once_with('device_group', + 'ethernet') + self.ixnet_gen.ixnet.setMultiAttribute.assert_called_once_with( + 'obj', '-name', 'ethernet 1') + self.ixnet_gen.ixnet.commit.assert_called_once() + + def test_add_ipv4(self): + self.ixnet_gen.ixnet.add.return_value = 'obj' + self.ixnet_gen.add_ipv4('ethernet 1', name='ipv4 1') + self.ixnet_gen.ixnet.add.assert_called_once_with('ethernet 1', 'ipv4') + self.ixnet_gen.ixnet.setAttribute.assert_called_once_with('obj', + '-name', + 'ipv4 1') + self.assertEqual(self.ixnet.commit.call_count, 2) + + def test_add_ipv4_single(self): + self.ixnet_gen.ixnet.add.return_value = 'obj' + self.ixnet_gen.ixnet.getAttribute.return_value = 'attr' + self.ixnet_gen.add_ipv4('ethernet 1', name='ipv4 1', addr='100.1.1.100', + prefix='24', gateway='100.1.1.200') + self.ixnet_gen.ixnet.add.assert_called_once_with('ethernet 1', 'ipv4') + self.ixnet_gen.ixnet.setAttribute.assert_called_once_with('obj', + '-name', + 'ipv4 1') + self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call( + 'attr/singleValue', '-value', '100.1.1.100') + self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call( + 'attr/singleValue', '-value', '24') + self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call( + 'attr/singleValue', '-value', '100.1.1.200') + + self.assertEqual(self.ixnet.commit.call_count, 2) + + def test_add_ipv4_counter(self): + self.ixnet_gen.ixnet.add.return_value = 'obj' + self.ixnet_gen.ixnet.getAttribute.return_value = 'attr' + self.ixnet_gen.add_ipv4('ethernet 1', name='ipv4 1', + addr='100.1.1.100', + addr_step='1', + addr_direction='increment', + prefix='24', + gateway='100.1.1.200', + gw_step='1', + gw_direction='increment') + self.ixnet_gen.ixnet.add.assert_any_call('ethernet 1', 'ipv4') + self.ixnet_gen.ixnet.setAttribute.assert_called_once_with('obj', + '-name', + 'ipv4 1') + self.ixnet_gen.ixnet.add.assert_any_call('attr', 'counter') + self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call('obj', '-start', + '100.1.1.100', + '-step', '1', + '-direction', + 'increment') + self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call( + 'attr/singleValue', '-value', '24') + self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call('obj', '-start', + '100.1.1.200', + '-step', '1', + '-direction', + 'increment') + self.assertEqual(self.ixnet.commit.call_count, 2) + + def test_add_pppox_client(self): + self.ixnet_gen.ixnet.add.return_value = 'obj' + self.ixnet_gen.ixnet.getAttribute.return_value = 'attr' + self.ixnet_gen.add_pppox_client('ethernet 1', 'pap', 'user', 'pwd') + self.ixnet_gen.ixnet.add.assert_called_once_with('ethernet 1', + 'pppoxclient') + + self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call( + 'attr/singleValue', '-value', 'pap') + self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call( + 'attr/singleValue', '-value', 'user') + self.ixnet_gen.ixnet.setMultiAttribute.assert_any_call( + 'attr/singleValue', '-value', 'pwd') + + self.assertEqual(self.ixnet.commit.call_count, 2) + + def test_add_pppox_client_invalid_auth(self): + self.ixnet_gen.ixnet.add.return_value = 'obj' + self.ixnet_gen.ixnet.getAttribute.return_value = 'attr' + self.assertRaises(NotImplementedError, self.ixnet_gen.add_pppox_client, + 'ethernet 1', 'invalid_auth', 'user', 'pwd') + + self.ixnet_gen.ixnet.setMultiAttribute.assert_not_called() + @mock.patch.object(IxNetwork, 'IxNet') def test_connect(self, mock_ixnet): mock_ixnet.return_value = self.ixnet |