diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/cloudinfo.py | 94 | ||||
-rw-r--r-- | tools/k8s/load-generator/Dockerfile | 27 | ||||
-rwxr-xr-x | tools/k8s/load-generator/README.md | 24 | ||||
-rwxr-xr-x | tools/k8s/load-generator/config.zpl | 52 | ||||
-rw-r--r-- | tools/k8s/load-generator/csdeployment.yaml | 39 | ||||
-rw-r--r-- | tools/pkt_gen/trex/trex_client.py | 6 |
6 files changed, 239 insertions, 3 deletions
diff --git a/tools/cloudinfo.py b/tools/cloudinfo.py new file mode 100644 index 00000000..18550e78 --- /dev/null +++ b/tools/cloudinfo.py @@ -0,0 +1,94 @@ +# Copyright 2022 The Linux Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +""" +Get Cloud information and save it a file +""" + +import os +import json +from kubernetes import client, config +from kubernetes.client.rest import ApiException +from conf import settings + +def save_kubernetes_info(): + """ + Save Kubernetes Cluster Info + """ + config.load_kube_config(settings.getValue('K8S_CONFIG_FILEPATH')) + with open(os.path.join(settings.getValue('RESULTS_PATH'), + 'cloud_info.txt'), 'a+') as outf: + api = client.CoreV1Api() + try: + node_info = api.list_node() + except ApiException as err: + raise Exception from err + for ni_item in node_info.items: + outf.write("\n ******************************************** \n") + outf.write("\n System Information \n") + sinfo = {'Architecture': ni_item.status.node_info.architecture, + 'Container Runtime Version':ni_item.status.node_info.container_runtime_version, + 'kernel version':ni_item.status.node_info.kernel_version, + 'Kube Proxy Version':ni_item.status.node_info.kube_proxy_version, + 'Kubelet Version':ni_item.status.node_info.kubelet_version, + 'Operating System':ni_item.status.node_info.operating_system, + 'OS Image':ni_item.status.node_info.os_image} + json.dump(sinfo, outf, indent=4) + outf.write("\n List of Addresses \n") + addresses = [] + for addrs in ni_item.status.addresses: + entry = {'address': addrs.address, 'type': addrs.type} + addresses.append(entry) + json.dump(entry, outf, indent=4) + sinfo['List of Addresses'] = entry + outf.write("\n Allocatable Resources \n") + sinfo['Allocatable Resources'] = ni_item.status.allocatable + json.dump(ni_item.status.allocatable, outf, indent=4) + outf.write("\n Available Resources \n") + sinfo['Available Resources'] = ni_item.status.capacity + json.dump(ni_item.status.capacity, outf, indent=4) + api = client.VersionApi() + try: + version_info = api.get_code() + except ApiException as err: + raise Exception from err + outf.write("\n Version Information \n") + vinfo = {'git_commit': version_info.git_commit, 'git_version': version_info.git_version, + 'platform': version_info.platform, 'go_version': version_info.go_version} + #json.dump(vinfo, outf, indent=4) + result = {**sinfo, **vinfo} + return result + +def save_openstack_info(): + """ + Save Openstack Info + """ + return None + +def save_cloud_info(): + """ + Save Cloud Information + """ + if settings.getValue('K8S'): + return save_kubernetes_info() + elif settings.getValue('OPENSTACK'): + return save_openstack_info() + else: + print("Unsupported Cloud") + return None + return 0 + +if __name__ == "__main__": + save_cloud_info() diff --git a/tools/k8s/load-generator/Dockerfile b/tools/k8s/load-generator/Dockerfile new file mode 100644 index 00000000..6212f6b2 --- /dev/null +++ b/tools/k8s/load-generator/Dockerfile @@ -0,0 +1,27 @@ +# Copyright 2022 The Linux Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM debian:bullseye +RUN mkdir -p /opt/spirent/inception +EXPOSE 3357 +EXPOSE 13731 +EXPOSE 13771 +EXPOSE 17731 +RUN apt-get clean && \ + apt-get update && \ + apt-get install -y net-tools procps +COPY ./config.zpl /opt/spirent/inception/config.zpl +COPY ./cloudstress /opt/spirent/inception/cloudstress +WORKDIR /opt/spirent/inception +CMD ["cloudstress", "--conffile", "config.zpl"] diff --git a/tools/k8s/load-generator/README.md b/tools/k8s/load-generator/README.md new file mode 100755 index 00000000..3b03a9b0 --- /dev/null +++ b/tools/k8s/load-generator/README.md @@ -0,0 +1,24 @@ +# Stressor for Cloud-Native Usecases using Spirent Cloudstress
+
+## Updating the configuration
+
+Modify the config.zpl file according to your requirements - configure the required amount of CPU and Memory stresses.
+
+## Building container (if required)
+
+Download the cloudstress binary from the artifacts.
+
+Build using the following command
+
+```sh
+$ docker build --rm -t autocloudstress .
+```
+
+## Using existing container.
+
+Pre-built container exists in dockerhub as: vsperf/autocloudstress:thoth
+
+## Running workloads.
+
+Run the built or existing container as pods.
+Example deployment file: csdeployment.yaml present in this folder.
diff --git a/tools/k8s/load-generator/config.zpl b/tools/k8s/load-generator/config.zpl new file mode 100755 index 00000000..a0dbc281 --- /dev/null +++ b/tools/k8s/load-generator/config.zpl @@ -0,0 +1,52 @@ +# Copyright 2022 Spirent Communications. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +#rfc.zeromq.org/spec:4/ZPL + +generator + cpu + utilization = 100.0 + running = "true" + block + writes_per_sec = 1048576 + write_size = 2M + reads_per_sec = 1048576 + read_size = 2M + queue_depth = 4 + vdev_path = "/tmp" + vdev_size = 1048576000 + file_size = 1000 + running = "true" + pattern = "random" + memory + writes_per_sec = 1048576 + write_size = 2000000 + reads_per_sec = 1048576 + read_size = 2000000 + buffer_size = 250000000 + running = "true" + pattern = "random" + network.client + connections = 10 + threads = 5 + ops_per_connection = 10 + protocol = tcp + writes_per_sec = 1043576 + write_size = 2000000 + reads_per_sec = 1043576 + read_size = 2000000 + running = "true" + network.server + running = "true" diff --git a/tools/k8s/load-generator/csdeployment.yaml b/tools/k8s/load-generator/csdeployment.yaml new file mode 100644 index 00000000..e6d32d5f --- /dev/null +++ b/tools/k8s/load-generator/csdeployment.yaml @@ -0,0 +1,39 @@ +# Copyright 2022 The Linux Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cloudstress-deployment +spec: + selector: + matchLabels: + app: cloudstress + replicas: 2 # tells deployment to run 2 pods matching the template + template: + metadata: + labels: + app: cloudstress + spec: + containers: + - name: cloudstress + image: vsperf/autocloudstress:thoth + resources: + requests: + cpu: "2000m" + memory: "2000Mi" + limits: + cpu: "2000m" + memory: "2000Mi" diff --git a/tools/pkt_gen/trex/trex_client.py b/tools/pkt_gen/trex/trex_client.py index 680497ec..01d4d389 100644 --- a/tools/pkt_gen/trex/trex_client.py +++ b/tools/pkt_gen/trex/trex_client.py @@ -108,7 +108,7 @@ class Trex(ITrafficGenerator): self._stlclient = None self._verification_params = None self._show_packet_data = False - self.trial_results = [] + self.trial_results = {} def show_packet_info(self, packet_a, packet_b): """ @@ -521,8 +521,8 @@ class Trex(ITrafficGenerator): return stats - @staticmethod - def calculate_results(stats): + # @staticmethod + def calculate_results(self, stats): """Calculate results from Trex statistic """ result = OrderedDict() |