aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ansible/roles/install_yardstick/tasks/main.yml6
-rw-r--r--docker/k8s/Dockerfile39
-rw-r--r--yardstick/common/kubernetes_utils.py25
-rw-r--r--yardstick/orchestrator/kubernetes.py4
-rw-r--r--yardstick/tests/unit/common/test_kubernetes_utils.py48
-rw-r--r--yardstick/tests/unit/orchestrator/test_kubernetes.py3
6 files changed, 110 insertions, 15 deletions
diff --git a/ansible/roles/install_yardstick/tasks/main.yml b/ansible/roles/install_yardstick/tasks/main.yml
index 973b2b027..0975efaea 100644
--- a/ansible/roles/install_yardstick/tasks/main.yml
+++ b/ansible/roles/install_yardstick/tasks/main.yml
@@ -41,7 +41,7 @@
pip:
requirements: "{{ yardstick_dir }}/requirements.txt"
virtualenv: "{{ yardstick_dir }}/virtualenv"
- async: 300
+ async: 600
poll: 0
register: pip_installer
when: virtual_environment == True
@@ -49,7 +49,7 @@
- name: Install Yardstick requirements
pip:
requirements: "{{ yardstick_dir }}/requirements.txt"
- async: 300
+ async: 600
poll: 0
register: pip_installer
when: virtual_environment == False
@@ -59,7 +59,7 @@
jid: "{{ pip_installer.ansible_job_id }}"
register: job_result
until: job_result.finished
- retries: 100
+ retries: 150
- name: Install Yardstick code (venv)
pip:
diff --git a/docker/k8s/Dockerfile b/docker/k8s/Dockerfile
new file mode 100644
index 000000000..2f8d9b161
--- /dev/null
+++ b/docker/k8s/Dockerfile
@@ -0,0 +1,39 @@
+##############################################################################
+# Copyright (c) 2018 Huawei Technologies Co.,Ltd 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
+##############################################################################
+
+FROM ubuntu:16.04
+
+LABEL image=opnfv/yardstick-image-k8s
+
+ARG BRANCH=master
+
+# GIT repo directory
+ENV CLONE_DEST="/opt/tempT"
+
+RUN apt-get update && apt-get install -y \
+ git bc bonnie++ fio gcc iperf3 ethtool \
+ iproute2 linux-tools-common linux-tools-generic \
+ lmbench make netperf patch perl rt-tests stress \
+ sysstat iputils-ping openssh-server sudo && \
+ apt-get -y autoremove && apt-get clean
+
+RUN rm -rf -- ${CLONE_DEST}
+RUN git clone https://github.com/kdlucas/byte-unixbench.git ${CLONE_DEST}
+RUN mkdir -p ${CLONE_DEST}/UnixBench/
+
+RUN git clone https://github.com/beefyamoeba5/ramspeed.git ${CLONE_DEST}/RAMspeed
+WORKDIR ${CLONE_DEST}/RAMspeed/ramspeed-2.6.0
+RUN mkdir -p ${CLONE_DEST}/RAMspeed/ramspeed-2.6.0/temp
+RUN bash build.sh
+
+RUN git clone https://github.com/beefyamoeba5/cachestat.git ${CLONE_DEST}/Cachestat
+
+WORKDIR /
+
+CMD /bin/bash
diff --git a/yardstick/common/kubernetes_utils.py b/yardstick/common/kubernetes_utils.py
index 35e590f2b..f5b0443ea 100644
--- a/yardstick/common/kubernetes_utils.py
+++ b/yardstick/common/kubernetes_utils.py
@@ -75,15 +75,18 @@ def create_service(template,
raise
-def delete_service(name,
- namespace='default',
- **kwargs): # pragma: no cover
+def delete_service(name, namespace='default', skip_codes=None, **kwargs):
+ skip_codes = [] if not skip_codes else skip_codes
core_v1_api = get_core_api()
try:
body = client.V1DeleteOptions()
core_v1_api.delete_namespaced_service(name, namespace, body, **kwargs)
- except ApiException:
- LOG.exception('Delete Service failed')
+ except ApiException as e:
+ if e.status in skip_codes:
+ LOG.info(e.reason)
+ else:
+ raise exceptions.KubernetesApiException(
+ action='delete', resource='Service')
def get_service_list(namespace='default', **kwargs):
@@ -223,14 +226,18 @@ def create_custom_resource_definition(body):
action='create', resource='CustomResourceDefinition')
-def delete_custom_resource_definition(name):
+def delete_custom_resource_definition(name, skip_codes=None):
+ skip_codes = [] if not skip_codes else skip_codes
api = get_extensions_v1beta_api()
body_obj = client.V1DeleteOptions()
try:
api.delete_custom_resource_definition(name, body_obj)
- except ApiException:
- raise exceptions.KubernetesApiException(
- action='delete', resource='CustomResourceDefinition')
+ except ApiException as e:
+ if e.status in skip_codes:
+ LOG.info(e.reason)
+ else:
+ raise exceptions.KubernetesApiException(
+ action='delete', resource='CustomResourceDefinition')
def get_custom_resource_definition(kind):
diff --git a/yardstick/orchestrator/kubernetes.py b/yardstick/orchestrator/kubernetes.py
index 8d9fc41c9..7b1450230 100644
--- a/yardstick/orchestrator/kubernetes.py
+++ b/yardstick/orchestrator/kubernetes.py
@@ -308,7 +308,7 @@ class ServiceNodePortObject(object):
k8s_utils.create_service(self.template)
def delete(self):
- k8s_utils.delete_service(self._name)
+ k8s_utils.delete_service(self._name, skip_codes=[404])
class CustomResourceDefinitionObject(object):
@@ -349,7 +349,7 @@ class CustomResourceDefinitionObject(object):
k8s_utils.create_custom_resource_definition(self._template)
def delete(self):
- k8s_utils.delete_custom_resource_definition(self._name)
+ k8s_utils.delete_custom_resource_definition(self._name, skip_codes=[404])
class NetworkObject(object):
diff --git a/yardstick/tests/unit/common/test_kubernetes_utils.py b/yardstick/tests/unit/common/test_kubernetes_utils.py
index bdc2c12d5..42aa9f7e0 100644
--- a/yardstick/tests/unit/common/test_kubernetes_utils.py
+++ b/yardstick/tests/unit/common/test_kubernetes_utils.py
@@ -121,6 +121,23 @@ class DeleteCustomResourceDefinitionTestCase(base.BaseUnitTestCase):
mock_delete_crd.delete_custom_resource_definition.\
assert_called_once_with('name', 'del_obj')
+ @mock.patch.object(client, 'V1DeleteOptions', return_value='del_obj')
+ @mock.patch.object(kubernetes_utils, 'get_extensions_v1beta_api')
+ @mock.patch.object(kubernetes_utils, 'LOG')
+ def test_execute_skip_exception(self, mock_log, mock_get_api, mock_delobj):
+ mock_delete_crd = mock.Mock()
+ mock_delete_crd.delete_custom_resource_definition.side_effect = rest.ApiException(
+ status=404)
+
+ mock_get_api.return_value = mock_delete_crd
+ kubernetes_utils.delete_custom_resource_definition('name', skip_codes=[404])
+
+ mock_delobj.assert_called_once()
+ mock_delete_crd.delete_custom_resource_definition.assert_called_once_with(
+ 'name', 'del_obj')
+
+ mock_log.info.assert_called_once()
+
class GetCustomResourceDefinitionTestCase(base.BaseUnitTestCase):
@@ -250,3 +267,34 @@ class DeletePodTestCase(base.BaseUnitTestCase):
mock_get_api.return_value = mock_api
kubernetes_utils.delete_pod(mock.ANY, skip_codes=[404])
+
+
+class DeleteServiceTestCase(base.BaseUnitTestCase):
+ @mock.patch.object(client, "V1DeleteOptions")
+ @mock.patch.object(kubernetes_utils, 'get_core_api')
+ def test_execute_correct(self, mock_get_api, mock_options):
+ mock_api = mock.Mock()
+ mock_get_api.return_value = mock_api
+ mock_options.return_value = None
+ kubernetes_utils.delete_service("name", "default", None)
+ mock_api.delete_namespaced_service.assert_called_once_with(
+ "name", 'default', None)
+
+ @mock.patch.object(kubernetes_utils, 'get_core_api')
+ def test_execute_exception(self, mock_get_api):
+ mock_api = mock.Mock()
+ mock_api.delete_namespaced_service.side_effect = rest.ApiException(status=200)
+
+ mock_get_api.return_value = mock_api
+ with self.assertRaises(exceptions.KubernetesApiException):
+ kubernetes_utils.delete_service(mock.ANY, skip_codes=[404])
+
+ @mock.patch.object(kubernetes_utils, 'get_core_api')
+ @mock.patch.object(kubernetes_utils, 'LOG')
+ def test_execute_skip_exception(self, mock_log, mock_get_api):
+ mock_api = mock.Mock()
+ mock_api.delete_namespaced_service.side_effect = rest.ApiException(status=404)
+
+ mock_get_api.return_value = mock_api
+ kubernetes_utils.delete_service(mock.ANY, skip_codes=[404])
+ mock_log.info.assert_called_once()
diff --git a/yardstick/tests/unit/orchestrator/test_kubernetes.py b/yardstick/tests/unit/orchestrator/test_kubernetes.py
index a73a4a132..5a6f8c6a0 100644
--- a/yardstick/tests/unit/orchestrator/test_kubernetes.py
+++ b/yardstick/tests/unit/orchestrator/test_kubernetes.py
@@ -611,7 +611,8 @@ class ServiceNodePortObjectTestCase(base.BaseUnitTestCase):
def test_delete(self, mock_delete_service):
nodeport_object = kubernetes.ServiceNodePortObject('fake_name')
nodeport_object.delete()
- mock_delete_service.assert_called_once_with('fake_name-service')
+ mock_delete_service.assert_called_once_with('fake_name-service',
+ skip_codes=[404])
class KubernetesTemplate(base.BaseUnitTestCase):