Add xrally_kubernetes_full 50/70850/2
authorCédric Ollivier <cedric.ollivier@orange.com>
Sat, 22 Aug 2020 14:36:19 +0000 (16:36 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Sat, 22 Aug 2020 16:54:26 +0000 (18:54 +0200)
It iterates 10 times all operations run by xrally_kubernetes.
Now times, concurrenty and count can be set via testcases.yaml.

It creates a new containers functest-kubernetes-benchamrking as
Functest.

Change-Id: Ibfd493b987a359a3f16c2d8db0aef6b8e90b7e92
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit a0f76d884c1f13c27e906136d3418f12b5342fc4)

.travis.yml
ansible/site.yml
build.sh
docker/benchmarking/Dockerfile [new file with mode: 0644]
docker/benchmarking/hooks/post_checkout [new file with mode: 0644]
docker/benchmarking/testcases.yaml [new file with mode: 0644]
functest_kubernetes/rally/all-in-one.yaml
functest_kubernetes/rally/rally_kubernetes.py
requirements.txt
tox.ini

index fca1b2d..f1c504d 100644 (file)
@@ -122,3 +122,17 @@ jobs:
           --platforms linux/amd64 \
           --template ${DOCKER_USERNAME}/functest-kubernetes-smoke:ARCH-hunter \
           --target ${DOCKER_USERNAME}/functest-kubernetes-smoke:hunter
+    - stage: build functest-kubernetes-benchmarking image
+      script: bash build.sh
+      env:
+        - REPO="${DOCKER_USERNAME}"
+        - amd64_dirs="docker/benchmarking"
+        - arm_dirs=""
+        - arm64_dirs=""
+    - stage: publish functest-kubernetes-benchmarking manifests
+      script: >
+        manifest-tool push from-args \
+          --platforms linux/amd64 \
+          --template \
+        ${DOCKER_USERNAME}/functest-kubernetes-benchmarking:ARCH-hunter \
+          --target ${DOCKER_USERNAME}/functest-kubernetes-benchmarking:hunter
index 33b7454..78b1c36 100644 (file)
@@ -20,7 +20,7 @@
               - name: functest-kubernetes-core
                 ref_arg: BRANCH
                 path: docker/core
-          - name: build opnfv/functest-kubernetes-healthcheck
+          - name: build containers
             containers:
               - name: functest-kubernetes-healthcheck
                 ref_arg:
               - name: functest-kubernetes-security
                 ref_arg: BRANCH
                 path: docker/security
-          - name: build containers
+          - name: build opnfv/functest-kubernetes-smoke
             containers:
               - name: functest-kubernetes-smoke
                 ref_arg:
                 path: docker/smoke
+          - name: build opnfv/functest-kubernetes-benchmarking
+            containers:
+              - name: functest-kubernetes-benchmarking
+                ref_arg:
+                path: docker/benchmarking
       suites:
         - container: functest-kubernetes-healthcheck
           tests:
@@ -48,6 +53,9 @@
           tests:
             - kube_hunter
             - kube_bench
+        - container: functest-kubernetes-benchmarking
+          tests:
+            - xrally_kubernetes_full
         - container: functest-kubernetes-cnf
           tests:
             - k8s_vims
index 50c32ea..c8d4875 100644 (file)
--- a/build.sh
+++ b/build.sh
@@ -8,7 +8,9 @@ docker/core \
 docker/healthcheck \
 docker/smoke \
 docker/cnf \
-docker/security"}
+docker/security \
+docker/benchmarking"}
+arm_dirs=${arm_dirs-${amd64_dirs}}
 arm64_dirs=${arm64_dirs-${amd64_dirs}}
 build_opts=(--pull=true --no-cache --force-rm=true)
 
@@ -41,6 +43,9 @@ ${repo}/functest-kubernetes-core:arm64-hunter|g" {} +
 find . -name Dockerfile -exec sed -i \
     -e "s|opnfv/functest-kubernetes-healthcheck:hunter|\
 ${repo}/functest-kubernetes-healthcheck:arm64-hunter|g" {} +
+find . -name Dockerfile -exec sed -i \
+    -e "s|opnfv/functest-kubernetes-smoke:hunter|\
+${repo}/functest-kubernetes-smoke:arm64-hunter|g" {} +
 for dir in ${arm64_dirs}; do
     (cd "${dir}" && docker build "${build_opts[@]}" \
         -t "${repo}/functest-kubernetes-${dir##**/}:arm64-hunter" .)
@@ -62,6 +67,9 @@ ${repo}/functest-kubernetes-core:arm-hunter|g" {} +
 find . -name Dockerfile -exec sed -i \
     -e "s|opnfv/functest-kubernetes-healthcheck:hunter|\
 ${repo}/functest-kubernetes-healthcheck:arm-hunter|g" {} +
+find . -name Dockerfile -exec sed -i \
+    -e "s|opnfv/functest-kubernetes-smoke:hunter|\
+${repo}/functest-kubernetes-smoke:arm-hunter|g" {} +
 for dir in ${arm_dirs}; do
     (cd "${dir}" && docker build "${build_opts[@]}" \
         -t "${repo}/functest-kubernetes-${dir##**/}:arm-hunter" .)
diff --git a/docker/benchmarking/Dockerfile b/docker/benchmarking/Dockerfile
new file mode 100644 (file)
index 0000000..f0a3b79
--- /dev/null
@@ -0,0 +1,4 @@
+FROM opnfv/functest-kubernetes-smoke:hunter
+
+COPY testcases.yaml /usr/lib/python2.7/site-packages/xtesting/ci/testcases.yaml
+CMD ["run_tests", "-t", "all"]
diff --git a/docker/benchmarking/hooks/post_checkout b/docker/benchmarking/hooks/post_checkout
new file mode 100644 (file)
index 0000000..6598f04
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+from="${DOCKER_REPO%/*}/functest-kubernetes-smoke:${DOCKER_TAG}"
+sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile
+
+exit $?
diff --git a/docker/benchmarking/testcases.yaml b/docker/benchmarking/testcases.yaml
new file mode 100644 (file)
index 0000000..f480009
--- /dev/null
@@ -0,0 +1,25 @@
+---
+tiers:
+    -
+        name: benchmarking
+        order: 1
+        description: >-
+            A set of benchmarking tests integrated from xRally for Kubernetes
+            platform.
+        testcases:
+            -
+                case_name: xrally_kubernetes_full
+                project_name: functest
+                criteria: 100
+                blocking: false
+                description: >-
+                    All in one tasks for checking basic functionality of
+                    Kubernetes cluster.
+                dependencies:
+                    - DEPLOY_SCENARIO: 'k8-*'
+                run:
+                    name: xrally_kubernetes
+                    args:
+                        times: 10
+                        concurrency: 4
+                        namespaces_count: 3
index 9437f76..ae4157f 100644 (file)
@@ -8,16 +8,16 @@ subtasks:
       Kubernetes.list_namespaces: {}
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
 
   - title: Run a single workload with create/read/delete namespace
     scenario:
       Kubernetes.create_and_delete_namespace: {}
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
 
   - title: Run a single workload with create/read/delete pod
     scenario:
@@ -25,11 +25,11 @@ subtasks:
         image: kubernetes/pause
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/read/delete replication controller
@@ -39,11 +39,11 @@ subtasks:
         replicas: 2
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/scale/delete replication controller
@@ -54,11 +54,11 @@ subtasks:
         scale_replicas: 3
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/read/delete replicaset
@@ -68,11 +68,11 @@ subtasks:
         replicas: 1
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/scale/delete replicaset
@@ -83,11 +83,11 @@ subtasks:
         scale_replicas: 2
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title:
@@ -98,11 +98,11 @@ subtasks:
         mount_path: /opt/check
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: >-
@@ -125,7 +125,7 @@ subtasks:
         times: 1
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/read/delete pod with secret volume
@@ -138,11 +138,11 @@ subtasks:
         mount_path: /opt/check
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/check/delete pod with secret volume
@@ -159,11 +159,11 @@ subtasks:
         error_regexp: No such file
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: >-
@@ -188,7 +188,7 @@ subtasks:
         times: 1
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title:
@@ -206,11 +206,11 @@ subtasks:
             test
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: >-
@@ -237,7 +237,7 @@ subtasks:
         times: 1
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/read/delete deployment
@@ -247,11 +247,11 @@ subtasks:
         replicas: 2
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/rollout/delete deployment
@@ -271,11 +271,11 @@ subtasks:
               value: "true"
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/read/delete statefulset
@@ -285,11 +285,11 @@ subtasks:
         replicas: 2
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/scale/delete statefulset
@@ -300,11 +300,11 @@ subtasks:
         scale_replicas: 2
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/read/delete job
@@ -316,11 +316,11 @@ subtasks:
           - "SUCCESS"
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/check/delete clusterIP service
@@ -331,11 +331,11 @@ subtasks:
         protocol: TCP
     runner:
       constant:
-        concurrency: 1
-        times: 2
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: >-
@@ -353,7 +353,7 @@ subtasks:
         times: 1
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
 
   - title: Run a single workload with create/check/delete NodePort service
@@ -365,9 +365,9 @@ subtasks:
         request_timeout: 10
     runner:
       constant:
-        concurrency: 1
-        times: 1
+        concurrency: {{ concurrency }}
+        times: {{ times }}
     contexts:
       namespaces:
-        count: 3
+        count: {{ namespaces_count }}
         with_serviceaccount: true
index e7a903d..556d29c 100644 (file)
@@ -11,6 +11,7 @@ import logging
 import os
 import time
 
+from jinja2 import Template
 import pkg_resources
 from rally import api
 from rally import exceptions
@@ -26,6 +27,10 @@ class RallyKubernetes(testcase.TestCase):
 
     __logger = logging.getLogger(__name__)
 
+    concurrency = 1
+    times = 1
+    namespaces_count = 1
+
     def __init__(self, **kwargs):
         super(RallyKubernetes, self).__init__(**kwargs)
         self.dir_results = "/home/opnfv/functest/results"
@@ -53,10 +58,15 @@ class RallyKubernetes(testcase.TestCase):
                 "Cannot check env heath: %s",
                 result['existing@kubernetes']['message'])
             return
-        input_task = open(
-            pkg_resources.resource_filename(
-                'functest_kubernetes', 'rally/all-in-one.yaml')).read()
-        task = yaml.safe_load(input_task)
+        # pylint: disable=bad-continuation
+        with open(pkg_resources.resource_filename(
+                'functest_kubernetes', 'rally/all-in-one.yaml')) as tfile:
+            template = Template(tfile.read())
+        task = yaml.safe_load(template.render(
+            concurrency=kwargs.get("concurrency", self.concurrency),
+            times=kwargs.get("times", self.times),
+            namespaces_count=kwargs.get(
+                "namespaces_count", self.namespaces_count)))
         rapi.task.validate(deployment='my-kubernetes', config=task)
         task_instance = rapi.task.create(deployment='my-kubernetes')
         rapi.task.start(
index 742dcbf..60c38eb 100644 (file)
@@ -6,3 +6,4 @@ xtesting # Apache-2.0
 rally
 xrally-kubernetes
 kubernetes # Apache-2.0
+Jinja2 # BSD License (3 clause)
diff --git a/tox.ini b/tox.ini
index 3f6c193..dbf22e6 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -32,7 +32,6 @@ basepython = python2.7
 files =
   .travis.yml
   docker
-  functest_kubernetes/rally/all-in-one.yaml
 commands =
   yamllint {[testenv:yamllint]files}