From 6058a068668f06ffade7142f5028ed252806d806 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 22:56:44 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit hooks --- .../seed-scripts/docker-compose-load.yml | 6 ++-- .../ecr-viewer/seed-scripts/locustfile.py | 35 ++++++++++++------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/containers/ecr-viewer/seed-scripts/docker-compose-load.yml b/containers/ecr-viewer/seed-scripts/docker-compose-load.yml index 8b5c73b6c..dd6b958a4 100644 --- a/containers/ecr-viewer/seed-scripts/docker-compose-load.yml +++ b/containers/ecr-viewer/seed-scripts/docker-compose-load.yml @@ -1,9 +1,9 @@ services: - # The Locust engine is used for load testing purposes. + # The Locust engine is used for load testing purposes. locust-brain: image: locustio/locust ports: - - "8089:8089" + - "8089:8089" volumes: - ./locustfile.py:/home/locust/locustfile.py - ./requirements.txt:/home/locust/requirements.txt @@ -29,4 +29,4 @@ services: - ./locustfile.py:/home/locust/locustfile.py - ./requirements.txt:/home/locust/requirements.txt - ./baseECR/LA:/home/locust/baseECR/LA - command: -f /home/locust/locustfile.py --worker --master-host locust-brain \ No newline at end of file + command: -f /home/locust/locustfile.py --worker --master-host locust-brain diff --git a/containers/ecr-viewer/seed-scripts/locustfile.py b/containers/ecr-viewer/seed-scripts/locustfile.py index b59097425..8cd8f8f8c 100644 --- a/containers/ecr-viewer/seed-scripts/locustfile.py +++ b/containers/ecr-viewer/seed-scripts/locustfile.py @@ -1,20 +1,23 @@ -from locust import HttpUser, task, between -import subprocess import os -import shutil import random -import json +import shutil +import subprocess + +from locust import between +from locust import HttpUser +from locust import task + class EcrViewer(HttpUser): wait_time = between(1, 5) @task def ecr_viewer(self): - self.client.get(f"/ecr-viewer") + self.client.get("/ecr-viewer") @task def orchestration(self): - self.client.get(f"/orchestration") + self.client.get("/orchestration") @task def upload_zip(self): @@ -27,21 +30,26 @@ def upload_zip(self): "message_type": "ecr", } # print(f"Uploading {file}") - file_tuple = { "upload_file": ( file, opened_file.read(), "application/zip") } - response = self.client.post(f"/orchestration/process-zip", data=data, files=file_tuple) + file_tuple = { + "upload_file": (file, opened_file.read(), "application/zip") + } + response = self.client.post( + "/orchestration/process-zip", data=data, files=file_tuple + ) self.tasks.append(check_ecr(self, file, response.json())) - + # Runs at the start of each test. Useful for authentication and setup actions. def on_start(self): subprocess.run(["pip", "install", "-r", "requirements.txt"]) pass + # Check the ecr viewer response for eicr_id and view the ecr def check_ecr(self, file, response): if "detail" in response: - print(f"{file}", response['detail']) + print(f"{file}", response["detail"]) if "message" in response: - print(f"{file}", response['message']) + print(f"{file}", response["message"]) if "processed_values" not in response: print("No processed_values found in response") return @@ -57,6 +65,7 @@ def check_ecr(self, file, response): else: print("No eicr_id found in response") + # Get all the zipped files in the baseECR folder def get_zipped_files(): files = [] @@ -80,7 +89,9 @@ def get_zipped_files(): if os.path.exists(os.path.join(folder_path, "CDA_eICR.xml")): random_number = random.randint(1, 30) - zipped_file = shutil.make_archive(f"{random_number}", 'zip', folder_path) + zipped_file = shutil.make_archive( + f"{random_number}", "zip", folder_path + ) print(f"Zipped {folder_path} to {zipped_file}") files.append(zipped_file) # If neither `bundle.json` nor `CDA_eICR.xml` exists, skip processing