지속성 테스트(Endurance Test)
지속성 테스트(Endurance Test) 지속성 테스트는 소프트웨어 시스템이 장기간 동안 지속적인 부하 상태에서 어떻게 동작하는지 확인하는 성능 테스트의 한 유형이다. 웹 서버의 지속성 테스트 예시 코드: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 import time import psutil from datetime import datetime class EnduranceTest: def __init__(self, duration_hours=24): self.duration = duration_hours * 3600 # 시간을 초로 변환 self.metrics_history = [] def run_endurance_test(self): """24시간 지속성 테스트 실행""" print(f"테스트 시작: {datetime.now()}") start_time = time.time() while time.time() - start_time < self.duration: # 시스템 메트릭 수집 metrics = self.collect_system_metrics() self.metrics_history.append(metrics) # 성능 저하 검사 if self.detect_performance_degradation(metrics): print("성능 저하 감지!") self.analyze_degradation() # 메모리 누수 검사 if self.detect_memory_leak(metrics): print("메모리 누수 감지!") self.analyze_memory_usage() time.sleep(60) # 1분마다 측정 def collect_system_metrics(self): """시스템 성능 지표 수집""" return { 'timestamp': datetime.now(), 'cpu_usage': psutil.cpu_percent(), 'memory_usage': psutil.virtual_memory().percent, 'disk_io': psutil.disk_io_counters(), 'response_time': self.measure_response_time() } def measure_response_time(self): """시스템 응답 시간 측정""" start_time = time.time() try: # 주요 API 엔드포인트 호출 response = requests.get('http://example.com/api/health') return time.time() - start_time except Exception as e: print(f"응답 시간 측정 실패: {str(e)}") return None 특징과 목적 지속성 테스트의 주요 특징과 목적은 다음과 같다: ...