From 26f0a323165b65c0b9fd1082979a3bd5c45d81b6 Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Fri, 2 Feb 2024 10:26:47 +0100 Subject: [PATCH 1/2] add perf ocp --- nise/generators/ocp/ocp_generator.py | 14 +++++++++----- nise/report.py | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/nise/generators/ocp/ocp_generator.py b/nise/generators/ocp/ocp_generator.py index d1403c84..7160ad0b 100644 --- a/nise/generators/ocp/ocp_generator.py +++ b/nise/generators/ocp/ocp_generator.py @@ -299,11 +299,13 @@ def _gen_nodes(self): def _gen_namespaces(self, nodes): """Create namespaces on specific nodes and keep relationship.""" namespaces = {} + # TODO EVADEBUG for node in nodes: if node.get("namespaces"): for name, _ in node.get("namespaces").items(): - namespace = name - namespaces[namespace] = node + for i in range(250): # todo update this + namespace = f"{name}_eva_{i}" + namespaces[namespace] = node else: num_namespaces = randint(2, 12) for _ in range(num_namespaces): @@ -356,9 +358,10 @@ def _gen_pods(self, namespaces): for namespace, node in namespaces.items(): namespace2pod[namespace] = [] if node.get("namespaces"): - specified_pods = node.get("namespaces").get(namespace).get("pods") or [] + orig_namespace, eva_suffix = namespace.split("_eva_") + specified_pods = node.get("namespaces").get(orig_namespace).get("pods") or [] for specified_pod in specified_pods: - pod = specified_pod.get("pod_name", self.fake.word()) + pod = f"{specified_pod.get('pod_name', self.fake.word())}_{eva_suffix}" namespace2pod[namespace].append(pod) cpu_cores = node.get("cpu_cores") memory_bytes = node.get("memory_bytes") @@ -527,7 +530,8 @@ def _gen_volumes(self, namespaces, namespace2pods): # noqa: R0914,C901 for namespace, node in namespaces.items(): storage_class_default = choice(("gp2", "fast", "slow", "gold")) if node.get("namespaces"): - specified_volumes = node.get("namespaces").get(namespace).get("volumes", []) + orig_namespace = namespace.split("_eva_")[0] + specified_volumes = node.get("namespaces").get(orig_namespace).get("volumes", []) for specified_volume in specified_volumes: volume = specified_volume.get("volume_name", self.fake.word()) volume_request_gig = specified_volume.get("volume_request_gig") diff --git a/nise/report.py b/nise/report.py index 54d3ad57..17240ace 100644 --- a/nise/report.py +++ b/nise/report.py @@ -97,7 +97,8 @@ def create_temporary_copy(path, temp_file_name, temp_dir_name="None"): """Create temporary copy of a file.""" - temp_dir = gettempdir() + temp_dir = "/home/esebesto/work/tasks/2024_01_30_ocp_perf/tmp_nise" + # temp_dir = gettempdir() if temp_dir_name: new_dir = os.path.join(temp_dir, temp_dir_name) if not os.path.exists(new_dir): From 398a384a544f0c89971f9a84eaeddfabcd0e073c Mon Sep 17 00:00:00 2001 From: Eva Sebestova Date: Thu, 15 Feb 2024 17:40:58 +0100 Subject: [PATCH 2/2] small update --- nise/generators/ocp/ocp_generator.py | 11 +++++------ nise/report.py | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/nise/generators/ocp/ocp_generator.py b/nise/generators/ocp/ocp_generator.py index 7160ad0b..2947a96a 100644 --- a/nise/generators/ocp/ocp_generator.py +++ b/nise/generators/ocp/ocp_generator.py @@ -299,12 +299,11 @@ def _gen_nodes(self): def _gen_namespaces(self, nodes): """Create namespaces on specific nodes and keep relationship.""" namespaces = {} - # TODO EVADEBUG for node in nodes: if node.get("namespaces"): for name, _ in node.get("namespaces").items(): - for i in range(250): # todo update this - namespace = f"{name}_eva_{i}" + for i in range(2500): # TODO PERF_NOTE: update this - number of replicas for each namespace + namespace = f"{name}_perf_{i}" namespaces[namespace] = node else: num_namespaces = randint(2, 12) @@ -358,10 +357,10 @@ def _gen_pods(self, namespaces): for namespace, node in namespaces.items(): namespace2pod[namespace] = [] if node.get("namespaces"): - orig_namespace, eva_suffix = namespace.split("_eva_") + orig_namespace, perf_suffix = namespace.split("_perf_") specified_pods = node.get("namespaces").get(orig_namespace).get("pods") or [] for specified_pod in specified_pods: - pod = f"{specified_pod.get('pod_name', self.fake.word())}_{eva_suffix}" + pod = f"{specified_pod.get('pod_name', self.fake.word())}_{perf_suffix}" namespace2pod[namespace].append(pod) cpu_cores = node.get("cpu_cores") memory_bytes = node.get("memory_bytes") @@ -530,7 +529,7 @@ def _gen_volumes(self, namespaces, namespace2pods): # noqa: R0914,C901 for namespace, node in namespaces.items(): storage_class_default = choice(("gp2", "fast", "slow", "gold")) if node.get("namespaces"): - orig_namespace = namespace.split("_eva_")[0] + orig_namespace = namespace.split("_perf_")[0] specified_volumes = node.get("namespaces").get(orig_namespace).get("volumes", []) for specified_volume in specified_volumes: volume = specified_volume.get("volume_name", self.fake.word()) diff --git a/nise/report.py b/nise/report.py index 17240ace..f15571ec 100644 --- a/nise/report.py +++ b/nise/report.py @@ -97,8 +97,8 @@ def create_temporary_copy(path, temp_file_name, temp_dir_name="None"): """Create temporary copy of a file.""" - temp_dir = "/home/esebesto/work/tasks/2024_01_30_ocp_perf/tmp_nise" - # temp_dir = gettempdir() + # PERF_NOTE - if your /tmp dir doesn't have enough space, you may need to specify different temp_dir + temp_dir = gettempdir() if temp_dir_name: new_dir = os.path.join(temp_dir, temp_dir_name) if not os.path.exists(new_dir):