FROM opnfv/functest-kubernetes-smoke
 
+COPY plotperf.py.patch /tmp/plotperf.py.patch
+RUN apk --no-cache add --update py3-matplotlib && \
+    apk --no-cache add --virtual .build-deps --update patch go && \
+    ln -s /usr/bin/python3 /usr/bin/python && \
+    git clone https://github.com/kubernetes/perf-tests && \
+    (cd perf-tests/network/benchmarks/netperf && go build -o /usr/local/bin/launch launch.go) && \
+    curl https://raw.githubusercontent.com/girishkalele/pyplot-docker/master/plotperf.py \
+        --output /usr/local/bin/plotperf.py && \
+    (cd /usr/local/bin && patch -p0 < /tmp/plotperf.py.patch && \
+        mv plotperf.py plotperf && chmod a+x plotperf) && \
+    rm -rf perf-tests /tmp/plotperf.py.patch && \
+    apk del .build-deps
 COPY testcases.yaml /usr/lib/python3.8/site-packages/xtesting/ci/testcases.yaml
 CMD ["run_tests", "-t", "all"]
 
--- /dev/null
+#!/usr/bin/env python
+
+# Copyright (c) 2021 Orange 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
+
+"""
+Benchmarking Kubernetes Networking Performance
+"""
+
+import glob
+import logging
+import os
+import shutil
+import subprocess
+import time
+
+from xtesting.core import testcase
+
+
+class Netperf(testcase.TestCase):
+    """Run Benchmarking Kubernetes Networking Performance"""
+
+    __logger = logging.getLogger(__name__)
+
+    def __init__(self, **kwargs):
+        super(Netperf, self).__init__(**kwargs)
+        self.output_log_name = 'functest-kubernetes.log'
+        self.output_debug_log_name = 'functest-kubernetes.debug.log'
+
+    def check_requirements(self):
+        """Check if launch is in $PATH"""
+        self.is_skipped = not (
+            shutil.which("launch") and shutil.which("plotperf"))
+        if self.is_skipped:
+            self.__logger.warning("launch or plotperf is missing")
+
+    def run(self, **kwargs):
+        self.start_time = time.time()
+        try:
+            if not os.path.exists(self.res_dir):
+                os.makedirs(self.res_dir)
+            cmd = ['launch', '-iterations', '1', '-kubeConfig',
+                   '/root/.kube/config']
+            output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+            self.__logger.info("%s\n%s", " ".join(cmd), output.decode("utf-8"))
+            lfiles = glob.glob(os.path.join(
+                'results_netperf-latest', 'netperf-latest*.csv'))
+            results = max(lfiles, key=os.path.getmtime)
+            shutil.move(results, os.path.join(self.res_dir, 'netperf.csv'))
+            cmd = ['plotperf', '-c',
+                   os.path.join(self.res_dir, 'netperf.csv'),
+                   '-o', self.res_dir, '-s', 'netperf']
+            output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+            self.__logger.info("%s\n%s", " ".join(cmd), output.decode("utf-8"))
+            self.result = 100
+            status = testcase.TestCase.EX_OK
+        except Exception:  # pylint: disable=broad-except
+            self.__logger.exception("Can not run Netperf")
+            self.result = 0
+            status = testcase.TestCase.EX_RUN_ERROR
+        self.stop_time = time.time()
+        return status