From 09f7bae4e05bde830ff75df1858b51c9ec9b5655 Mon Sep 17 00:00:00 2001 From: Watchtek Date: Tue, 14 Oct 2025 18:01:38 +0900 Subject: [PATCH 1/4] Remove option after upgrade selenium version(not required) --- load_check.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/load_check.py b/load_check.py index 294eef4..9cf06ac 100644 --- a/load_check.py +++ b/load_check.py @@ -24,16 +24,13 @@ class MultipleTest(unittest.TestCase): print("1. [필수 입력] Chrome 위치 (e.g., /opt/chrome-linux64/chrome, D:\\tmp\\chrome-win64\\chrome.exe): ") self.binary_location = input().strip() - print("\n2. [필수 입력] webdriver 위치 (e.g., /opt/chromedriver-linux64/chromedriver, D:\\tmp\\chromedriver-win64\\chromedriver.exe): ") - self.webdriver_path = input().strip() - - print("\n3. [필수 입력] 테스트 대상 웹 (e.g., https://example.com:8443/): ") + print("\n2. [필수 입력] 테스트 대상 웹 (e.g., https://example.com:8443/): ") self.dc_address = input() # A list is created to store multiple account configurations. self.account_configs = [] # print("\n[필수 입력] 계정 정보를 한 줄씩 입력하세요. (포맷: 유형 / 아이디, 비번 / 세션 수)") - print("\n4. [필수 입력] 계정유형(1-어드민,2-(지역)관리자,3-사용자) / 계정 접속정보 / 커넥션 비중") + print("\n3. [필수 입력] 계정유형(1-어드민,2-(지역)관리자,3-사용자) / 계정 접속정보 / 커넥션 비중") print("ex) 1 / admin, admin / 3") print("ex) 2 / watchall, watchall / 3") print("ex) 3 / monitor, monitor / 4") @@ -68,14 +65,14 @@ class MultipleTest(unittest.TestCase): print(f"잘못된 입력 형식입니다: '{user_input}'. 해당 줄은 무시됩니다.") # New inputs for connection management - print("\n5. [선택] 테스트 유형(기본값: 일반접속): 일반 접속(1), 일시 접속(2), 부하 화면 접근(3)") + print("\n4. [선택] 테스트 유형(기본값: 일반접속): 일반 접속(1), 일시 접속(2), 부하 화면 접근(3)") try: self.function_to_execute = int(input().strip()) except ValueError: print("잘못된 입력입니다. 기본값 '일반 접속(1)'으로 설정합니다.") self.function_to_execute = 1 - print("\n6. [선택] 커넥션 수 / 테스트 시간(분)(기본값: 30개 / 120분)") + print("\n5. [선택] 커넥션 수 / 테스트 시간(분)(기본값: 30개 / 120분)") try: pool_input = input().strip().split('/') self.max_connections = int(pool_input[0].strip()) if pool_input[0].strip() else 30 @@ -477,7 +474,7 @@ class MultipleTest(unittest.TestCase): if sys.platform.startswith('linux'): # Check if the operating system is Linux options.add_argument("--no-sandbox") options.add_argument("--disable-dev-shm-usage") - driver = webdriver.Chrome(executable_path=self.webdriver_path, options=options) + driver = webdriver.Chrome(options=options) driver.instance_number = driver_instance_number # Attach instance number to driver for logging driver.user_id = user_id # Attach user ID to driver for logging driver.implicitly_wait(10) # Common implicit wait for this driver -- GitLab From 25aafdc368d4330186e1bcad9c4e4014d11a76e5 Mon Sep 17 00:00:00 2001 From: Watchtek Date: Wed, 15 Oct 2025 11:13:38 +0900 Subject: [PATCH 2/4] Library version upgrade --- .trivyignore | 2 +- requirements.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.trivyignore b/.trivyignore index 2224c14..326053c 100644 --- a/.trivyignore +++ b/.trivyignore @@ -1,3 +1,3 @@ # https://trivy.dev/v0.65/docs/configuration/filtering/#by-finding-ids # Accept the risk until 2026-01-01 -CVE-2025-50181 exp:2026-01-01 +# CVE-2025-50181 exp:2026-01-01 diff --git a/requirements.txt b/requirements.txt index 66d0e32..589f1a4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -selenium==3.141.0 -urllib3==1.26.19 +selenium==4.36.0 +urllib3==2.5.0 \ No newline at end of file -- GitLab From 0478506c273278ae9fddbcfb8b0cf82a095266fe Mon Sep 17 00:00:00 2001 From: Watchtek Date: Wed, 15 Oct 2025 16:55:24 +0900 Subject: [PATCH 3/4] Check accessible to web before test start --- load_check.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 3 ++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/load_check.py b/load_check.py index 9cf06ac..b2dd18b 100644 --- a/load_check.py +++ b/load_check.py @@ -7,6 +7,8 @@ import unittest import random import os from datetime import datetime +import requests +import urllib3 from selenium import webdriver from selenium.webdriver.common.by import By @@ -26,6 +28,11 @@ class MultipleTest(unittest.TestCase): print("\n2. [필수 입력] 테스트 대상 웹 (e.g., https://example.com:8443/): ") self.dc_address = input() + if self.check_http_status(self.dc_address): + pass + else: + print("EMS 접속이 원할하지 않습니다. 프로그램을 종료합니다") + sys.exit(1) # A list is created to store multiple account configurations. self.account_configs = [] @@ -96,6 +103,53 @@ class MultipleTest(unittest.TestCase): os.makedirs(self.screenshots_folder, exist_ok=True) self.screenshot_base_dir = self.screenshots_folder + def check_http_status(self, url: str, max_retry: int = 3, ignore_cert: bool = True) -> bool: # pylint: disable=R0201 + """ + Checks the HTTP status of the given URL. + Follows redirects, retries up to `max_retry` times if the final status is not 200, + and optionally ignores SSL certificate validation. + + Args: + url (str): The target URL to check. + max_retry (int): Maximum number of retries if status is not 200. Defaults to 3. + ignore_cert (bool): If True, SSL certificate errors are ignored. Defaults to True. + + Returns: + bool: True if the final HTTP status is 200, otherwise False. + """ + + # Disable SSL certificate warnings (optional) + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + + for attempt in range(1, max_retry + 1): + try: + # HEAD request first + response = requests.head( + url, allow_redirects=True, timeout=5, verify=not ignore_cert + ) + + # Some servers may not support HEAD properly + if response.status_code >= 400 or response.status_code == 405: + response = requests.get( + url, allow_redirects=True, timeout=5, verify=not ignore_cert + ) + + # print(f"Attempt {attempt}: {response.status_code} ({response.url})") + + # ✅ Success only if final status == 200 + if response.status_code == 200: + return True + + except requests.exceptions.RequestException as e: + print(f"Attempt {attempt}: Error - {e}") + + # Wait a bit before retrying + if attempt < max_retry: + time.sleep(1) + + # ❌ All retries failed or never got 200 + return False + def setUp(self): self._get_user_inputs() # Initialize a list to hold driver instances for each thread diff --git a/requirements.txt b/requirements.txt index 589f1a4..8983552 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ selenium==4.36.0 -urllib3==2.5.0 \ No newline at end of file +urllib3==2.5.0 +requests==2.32.5 \ No newline at end of file -- GitLab From a719087cf69ef6821ac89f857f4e77e6b325a30f Mon Sep 17 00:00:00 2001 From: Watchtek Date: Wed, 15 Oct 2025 16:59:23 +0900 Subject: [PATCH 4/4] solved R0022 --- load_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/load_check.py b/load_check.py index b2dd18b..7b429c7 100644 --- a/load_check.py +++ b/load_check.py @@ -103,7 +103,7 @@ class MultipleTest(unittest.TestCase): os.makedirs(self.screenshots_folder, exist_ok=True) self.screenshot_base_dir = self.screenshots_folder - def check_http_status(self, url: str, max_retry: int = 3, ignore_cert: bool = True) -> bool: # pylint: disable=R0201 + def check_http_status(self, url: str, max_retry: int = 3, ignore_cert: bool = True) -> bool: """ Checks the HTTP status of the given URL. Follows redirects, retries up to `max_retry` times if the final status is not 200, -- GitLab