summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/kubestone/__init__.py0
-rw-r--r--testsuites/kubestone/samples/__init__.py0
-rw-r--r--testsuites/kubestone/samples/deployment_sample.yaml21
-rw-r--r--testsuites/kubestone/samples/pod_sample.yaml11
-rw-r--r--testsuites/kubestone/stress_test.py156
-rw-r--r--testsuites/kubestone/testcases/__init__.py0
-rw-r--r--testsuites/kubestone/testcases/deployment_capacity.yaml25
-rw-r--r--testsuites/posca/testcase_cfg/posca_factor_multistack_storage.yaml2
-rw-r--r--testsuites/posca/testcase_cfg/posca_factor_multistack_storage_parallel.yaml2
-rw-r--r--testsuites/posca/testcase_cfg/posca_factor_ping.yaml2
-rw-r--r--testsuites/posca/testcase_cfg/posca_factor_soak_throughputs.yaml2
-rw-r--r--testsuites/posca/testcase_cfg/posca_factor_system_bandwidth.yaml2
-rw-r--r--testsuites/posca/testcase_cfg/posca_factor_vnf_scale_up.yaml2
-rw-r--r--testsuites/posca/testcase_cfg/posca_feature_moon_resources.yaml2
-rw-r--r--testsuites/posca/testcase_cfg/posca_feature_moon_tenants.yaml2
-rw-r--r--testsuites/posca/testcase_cfg/posca_feature_testpmd_scale_up.yaml2
-rw-r--r--testsuites/posca/testcase_cfg/posca_feature_vnf_scale_out.yaml2
17 files changed, 223 insertions, 10 deletions
diff --git a/testsuites/kubestone/__init__.py b/testsuites/kubestone/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/testsuites/kubestone/__init__.py
diff --git a/testsuites/kubestone/samples/__init__.py b/testsuites/kubestone/samples/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/testsuites/kubestone/samples/__init__.py
diff --git a/testsuites/kubestone/samples/deployment_sample.yaml b/testsuites/kubestone/samples/deployment_sample.yaml
new file mode 100644
index 00000000..f7f95dee
--- /dev/null
+++ b/testsuites/kubestone/samples/deployment_sample.yaml
@@ -0,0 +1,21 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: nginx-deployment
+ labels:
+ app: nginx
+spec:
+ replicas: 3
+ selector:
+ matchLabels:
+ app: nginx
+ template:
+ metadata:
+ labels:
+ app: nginx
+ spec:
+ containers:
+ - name: nginx
+ image: nginx:1.7.9
+ ports:
+ - containerPort: 80
diff --git a/testsuites/kubestone/samples/pod_sample.yaml b/testsuites/kubestone/samples/pod_sample.yaml
new file mode 100644
index 00000000..3035cbb2
--- /dev/null
+++ b/testsuites/kubestone/samples/pod_sample.yaml
@@ -0,0 +1,11 @@
+apiVersion: v1
+kind: Pod
+metadata:
+ name: myapp-pod
+ labels:
+ app: myapp
+spec:
+ containers:
+ - name: myapp-container
+ image: busybox
+ command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600']
diff --git a/testsuites/kubestone/stress_test.py b/testsuites/kubestone/stress_test.py
new file mode 100644
index 00000000..7f5d75fb
--- /dev/null
+++ b/testsuites/kubestone/stress_test.py
@@ -0,0 +1,156 @@
+from kubernetes import client, config
+from utils.k8s_setup import k8s_utils
+
+import os
+import datetime
+import uuid
+
+import utils.logger as log
+import yaml
+import argparse
+
+LOG = log.Logger(__name__).getLogger()
+
+parser = argparse.ArgumentParser(description='kubestone (k8s stress) tests')
+parser.add_argument("-c", "--TEST_CASE",
+ help="The path of test case in form of yaml")
+args = parser.parse_args()
+TEST_CASE = args.TEST_CASE
+TEST_CASE_NAME, TEST_CASE_FORMAT = os.path.splitext(
+ os.path.basename(TEST_CASE))
+OUT_FILE = ("/tmp/bottlenecks_kubestone_" +
+ TEST_CASE_NAME + "_" + str(uuid.uuid4()) + ".out")
+
+
+def test_step_result(num, success_num, during_seconds, result):
+ testdata = {}
+ test_result = {}
+ test_result["number_of_deployments"] = float(num)
+ test_result["success_deployments"] = success_num
+ test_result["success_rate"] = success_num / num
+ test_result["duration_time"] = during_seconds
+ test_result["result"] = result
+ testdata["data_body"] = test_result
+ testdata["testcase"] = TEST_CASE_NAME
+ return testdata
+
+
+def main():
+ INSTALLER_TYPE = os.getenv("INSTALLER_TYPE")
+ K8S_CONFIG_PATH = os.getenv("K8S_CONFIG_PATH")
+ K8S_APPS_API_VERSION = os.getenv("K8S_APPS_API_VERSION")
+ K8S_CORE_API_VERSION = os.getenv("K8S_CORE_API_VERSION")
+ # Get k8s config. If provided in the path indicated by
+ # K8S_CONFIG_PATH, only return the path.
+ if K8S_CONFIG_PATH:
+ k8s_utils.get_config_path(
+ K8S_CONFIG_PATH=K8S_CONFIG_PATH)
+ else:
+ if INSTALLER_TYPE:
+ K8S_CONFIG_PATH = k8s_utils.get_config_path(
+ INSTALLER_TYPE=INSTALLER_TYPE)
+ else:
+ k8s_utils.get_config_path()
+
+ config.load_kube_config(K8S_CONFIG_PATH)
+
+ # Initiate api clients
+ if K8S_APPS_API_VERSION:
+ apps_api = k8s_utils.get_apps_api(K8S_APPS_API_VERSION)
+ else:
+ apps_api = k8s_utils.get_apps_api()
+
+ if K8S_CORE_API_VERSION:
+ core_api = k8s_utils.get_core_api(K8S_CORE_API_VERSION)
+ else:
+ core_api = k8s_utils.get_core_api()
+
+ # Read test case in the form of yaml
+ with open(TEST_CASE) as test_case_file:
+ test_case_yaml = yaml.load(test_case_file)
+ if test_case_yaml['template']:
+ if test_case_yaml['template'].lower() == 'none':
+ deployment_yaml = test_case_yaml
+ else:
+ with open(test_case_yaml['template']) as deployment_file:
+ deployment_yaml = yaml.load(deployment_file)
+ else:
+ deployment_yaml = test_case_yaml
+
+ name = deployment_yaml['metadata']['name']
+ namespace = deployment_yaml['namespace']
+ body = client.V1Deployment()
+ body.api_version = deployment_yaml['apiVersion']
+ body.kind = deployment_yaml['kind']
+ body.metadata = deployment_yaml['metadata']
+ body.spec = deployment_yaml['spec']
+ pretty = True
+
+ # Create namespace
+ namespace_existed = k8s_utils.get_namespace_status(namespace)
+ if namespace_existed[0] == 0 and \
+ 'exception' not in namespace_existed[1].lower():
+ namespace_read = core_api.read_namespace(namespace, pretty=pretty)
+ LOG.info('Namespace {} already exist: \n{}'.format(
+ namespace, namespace_read))
+ else:
+ namespace_body = client.V1Namespace()
+ namespace_body.metadata = {'name': namespace}
+ namespace_created = core_api.create_namespace(
+ namespace_body, pretty=pretty)
+ LOG.info('Namespace has been created:\n{}'.format(
+ namespace_created))
+
+ # Create deployment
+ deployment_existed = k8s_utils.get_deployment_status(name, namespace)
+ if deployment_existed[0] == 0 and \
+ 'exception' not in deployment_existed[1].lower():
+ deployment_read = apps_api.read_namespaced_deployment(
+ name, namespace, pretty=pretty)
+ LOG.info('Deployment {}@{} already exist.'.format(name, namespace))
+ LOG.info('Discription of this deployment is:\n{}'.format(
+ deployment_read))
+ else:
+ deployment_created = apps_api.create_namespaced_deployment(
+ namespace, body, pretty=pretty)
+ LOG.info('Deployment has been created:\n{}'.format(
+ deployment_created))
+
+ # Scale the deployment
+ scaling_steps = deployment_yaml['scaling_steps'].split(',')
+ for step in scaling_steps:
+ start_time = datetime.datetime.now()
+
+ step = int(step)
+ body.spec['replicas'] = step
+ api_response = apps_api.patch_namespaced_deployment_scale(
+ name, namespace, body, pretty=pretty)
+ LOG.info("Deployment replicas is to be scaled to: %s" % step)
+ pods_number = k8s_utils.get_available_pods(name, namespace)
+ while pods_number != step:
+ pods_number = k8s_utils.get_available_pods(name, namespace)
+ LOG.info("Number of available pods are {} out of {}".format(
+ pods_number, step))
+ api_response = apps_api.read_namespaced_deployment_scale(
+ name, namespace, pretty=pretty)
+ LOG.info(
+ "Deployment {}-scaling finished:\n{}".format(
+ step, api_response))
+
+ end_time = datetime.datetime.now()
+ duration_seconds = (start_time - end_time).seconds
+ if pods_number == step:
+ criteria = 'PASS'
+ else:
+ criteria = 'FAIL'
+ test_result_body = test_step_result(
+ step, pods_number, duration_seconds, criteria)
+ k8s_utils.write_json(test_result_body, OUT_FILE)
+ if api_response:
+ LOG.info("Deployment scaling test has been successfuly executed.")
+ LOG.info("Testing results written in: {}".format(OUT_FILE))
+ return
+
+
+if __name__ == '__main__':
+ main()
diff --git a/testsuites/kubestone/testcases/__init__.py b/testsuites/kubestone/testcases/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/testsuites/kubestone/testcases/__init__.py
diff --git a/testsuites/kubestone/testcases/deployment_capacity.yaml b/testsuites/kubestone/testcases/deployment_capacity.yaml
new file mode 100644
index 00000000..2638211a
--- /dev/null
+++ b/testsuites/kubestone/testcases/deployment_capacity.yaml
@@ -0,0 +1,25 @@
+apiVersion: apps/v1
+kind: Deployment
+namespace: bottlenecks-kubestone
+test_type: Horizontal-Scaling
+scaling_steps: 10, 50, 100, 200
+template: None
+metadata:
+ name: nginx-deployment
+ labels:
+ app: nginx
+spec:
+ replicas: 3
+ selector:
+ matchLabels:
+ app: nginx
+ template:
+ metadata:
+ labels:
+ app: nginx
+ spec:
+ containers:
+ - name: nginx
+ image: nginx:1.7.9
+ ports:
+ - containerPort: 80
diff --git a/testsuites/posca/testcase_cfg/posca_factor_multistack_storage.yaml b/testsuites/posca/testcase_cfg/posca_factor_multistack_storage.yaml
index e2f48438..0f90812d 100644
--- a/testsuites/posca/testcase_cfg/posca_factor_multistack_storage.yaml
+++ b/testsuites/posca/testcase_cfg/posca_factor_multistack_storage.yaml
@@ -30,6 +30,6 @@ load_manager:
yardstick_testcase: "storage_bottlenecks"
contexts:
- dashboard: "Bottlenecks-ELK"
+ # dashboard: "Bottlenecks-ELK"
yardstick: "Bottlenecks-Yardstick"
yardstick_envpre: True
diff --git a/testsuites/posca/testcase_cfg/posca_factor_multistack_storage_parallel.yaml b/testsuites/posca/testcase_cfg/posca_factor_multistack_storage_parallel.yaml
index b55b826c..9279320c 100644
--- a/testsuites/posca/testcase_cfg/posca_factor_multistack_storage_parallel.yaml
+++ b/testsuites/posca/testcase_cfg/posca_factor_multistack_storage_parallel.yaml
@@ -28,6 +28,6 @@ load_manager:
yardstick_testcase: "storage_bottlenecks"
contexts:
- dashboard: "Bottlenecks-ELK"
+ # dashboard: "Bottlenecks-ELK"
yardstick: "Bottlenecks-Yardstick"
yardstick_envpre: True
diff --git a/testsuites/posca/testcase_cfg/posca_factor_ping.yaml b/testsuites/posca/testcase_cfg/posca_factor_ping.yaml
index ea70e336..7526f253 100644
--- a/testsuites/posca/testcase_cfg/posca_factor_ping.yaml
+++ b/testsuites/posca/testcase_cfg/posca_factor_ping.yaml
@@ -27,6 +27,6 @@ load_manager:
yardstick_testcase: "ping_bottlenecks"
contexts:
- dashboard: "Bottlenecks-ELK"
+ # dashboard: "Bottlenecks-ELK"
yardstick: "Bottlenecks-Yardstick"
yardstick_envpre: True
diff --git a/testsuites/posca/testcase_cfg/posca_factor_soak_throughputs.yaml b/testsuites/posca/testcase_cfg/posca_factor_soak_throughputs.yaml
index 983b7d76..787a849c 100644
--- a/testsuites/posca/testcase_cfg/posca_factor_soak_throughputs.yaml
+++ b/testsuites/posca/testcase_cfg/posca_factor_soak_throughputs.yaml
@@ -30,6 +30,6 @@ load_manager:
yardstick_testcase: "netperf_soak"
contexts:
- dashboard: "Bottlenecks-ELK"
+# dashboard: "Bottlenecks-ELK"
yardstick: "Bottlenecks-Yardstick"
yardstick_envpre: True
diff --git a/testsuites/posca/testcase_cfg/posca_factor_system_bandwidth.yaml b/testsuites/posca/testcase_cfg/posca_factor_system_bandwidth.yaml
index 04115eda..4eebc339 100644
--- a/testsuites/posca/testcase_cfg/posca_factor_system_bandwidth.yaml
+++ b/testsuites/posca/testcase_cfg/posca_factor_system_bandwidth.yaml
@@ -23,6 +23,6 @@ load_manager:
yardstick_testcase: "netperf_bottlenecks"
contexts:
- dashboard: "Bottlenecks-ELK"
+ # dashboard: "Bottlenecks-ELK"
yardstick: "Bottlenecks-Yardstick"
yardstick_envpre: Flase \ No newline at end of file
diff --git a/testsuites/posca/testcase_cfg/posca_factor_vnf_scale_up.yaml b/testsuites/posca/testcase_cfg/posca_factor_vnf_scale_up.yaml
index 4fd200a5..1cfe30a8 100644
--- a/testsuites/posca/testcase_cfg/posca_factor_vnf_scale_up.yaml
+++ b/testsuites/posca/testcase_cfg/posca_factor_vnf_scale_up.yaml
@@ -21,7 +21,7 @@ test_config:
# - [8, 8192]
# - [10, 10240]
runner_config:
- dashboard: "y"
+ # dashboard: "y"
dashboard_ip:
stack_create: yardstick
yardstick_test_ip:
diff --git a/testsuites/posca/testcase_cfg/posca_feature_moon_resources.yaml b/testsuites/posca/testcase_cfg/posca_feature_moon_resources.yaml
index bbf65ba7..affa5730 100644
--- a/testsuites/posca/testcase_cfg/posca_feature_moon_resources.yaml
+++ b/testsuites/posca/testcase_cfg/posca_feature_moon_resources.yaml
@@ -27,7 +27,7 @@ load_manager:
contexts:
# info that dashboard if have data, we will create the data dashboard.
- dashboard: "Bottlenecks-ELK"
+# dashboard: "Bottlenecks-ELK"
yardstick: "Bottlenecks-yardstick"
moon_monitoring: True
moon_environment:
diff --git a/testsuites/posca/testcase_cfg/posca_feature_moon_tenants.yaml b/testsuites/posca/testcase_cfg/posca_feature_moon_tenants.yaml
index 7feb6e4e..5f7cf5d9 100644
--- a/testsuites/posca/testcase_cfg/posca_feature_moon_tenants.yaml
+++ b/testsuites/posca/testcase_cfg/posca_feature_moon_tenants.yaml
@@ -30,7 +30,7 @@ load_manager:
contexts:
# info that dashboard if have data, we will create the data dashboard.
- dashboard: "Bottlenecks-ELK"
+# dashboard: "Bottlenecks-ELK"
yardstick: "Bottlenecks-yardstick"
moon_monitoring: True
moon_environment:
diff --git a/testsuites/posca/testcase_cfg/posca_feature_testpmd_scale_up.yaml b/testsuites/posca/testcase_cfg/posca_feature_testpmd_scale_up.yaml
index a686b9db..3e7486fa 100644
--- a/testsuites/posca/testcase_cfg/posca_feature_testpmd_scale_up.yaml
+++ b/testsuites/posca/testcase_cfg/posca_feature_testpmd_scale_up.yaml
@@ -34,6 +34,6 @@ load_manager:
contexts:
# info that dashboard if have data, we will create the data dashboard.
- dashboard: "Bottlenecks-ELK"
+# dashboard: "Bottlenecks-ELK"
yardstick: "yardstick_pmd"
yardstick_envpre: Flase
diff --git a/testsuites/posca/testcase_cfg/posca_feature_vnf_scale_out.yaml b/testsuites/posca/testcase_cfg/posca_feature_vnf_scale_out.yaml
index d893ac8a..95d0ce04 100644
--- a/testsuites/posca/testcase_cfg/posca_feature_vnf_scale_out.yaml
+++ b/testsuites/posca/testcase_cfg/posca_feature_vnf_scale_out.yaml
@@ -20,6 +20,6 @@ load_manager:
yardstick_testcase: "tc_heat_rfc2544_ipv4_1rule_1flow_64B_trex_correlated_traffic_scale_out"
contexts:
- dashboard: "Bottlenecks-ELK"
+# dashboard: "Bottlenecks-ELK"
yardstick: "Bottlenecks_yardstick"
yardstick_envpre: False