aboutsummaryrefslogtreecommitdiffstats
path: root/functest_kubernetes/netperf
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2021-05-09 17:15:33 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2021-05-09 17:16:47 +0200
commit3b5c1b115e234d636cb4f2a17d27ced872fee924 (patch)
tree3b54ca7c8e548797ce3d1288e42d7f8694de5b21 /functest_kubernetes/netperf
parent9eb324fe8232aa83f912291f961b5b4686f76169 (diff)
Benchmark Kubernetes Networking Performance
https://github.com/kubernetes/perf-tests/tree/master/network/benchmarks/netperf Change-Id: I6facd567f1c52c5949b53484a1fb107dcf34d622 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest_kubernetes/netperf')
-rw-r--r--functest_kubernetes/netperf/__init__.py0
-rw-r--r--functest_kubernetes/netperf/netperf.py66
2 files changed, 66 insertions, 0 deletions
diff --git a/functest_kubernetes/netperf/__init__.py b/functest_kubernetes/netperf/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/functest_kubernetes/netperf/__init__.py
diff --git a/functest_kubernetes/netperf/netperf.py b/functest_kubernetes/netperf/netperf.py
new file mode 100644
index 00000000..3135a6c5
--- /dev/null
+++ b/functest_kubernetes/netperf/netperf.py
@@ -0,0 +1,66 @@
+#!/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