Skip to content

Commit

Permalink
1. fail, pass 컬럼 추가
Browse files Browse the repository at this point in the history
2.backoff ->  minBackoff, maxBackoff 컬럼으로 변경
  • Loading branch information
punkryn committed Apr 27, 2024
1 parent c68a0a2 commit cc4e6a0
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions stress-test/test-result-combiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ def getNameWithoutIteration(fileName: str):

def validateFileName(fileName: str):
nameList = fileName.split('_')
if len(nameList) != 14:
if len(nameList) != 16:
return False
return True

def makeResult(p: Path):
durationDict = dict()
failCountDict = dict()
countDict = dict()

for x in p.iterdir():
Expand All @@ -46,28 +47,33 @@ def makeResult(p: Path):

if fileName not in durationDict:
durationDict[fileName] = 0
failCountDict[fileName] = [0, 0]
countDict[fileName] = 0

with x.open('r', newline='') as f:
df = pd.read_json(f)

# metric_name,timestamp,metric_value,check,error,error_code,group,method,name,proto,scenario,status,subproto,tls_version,url,extra_tags
durationDict[fileName] += df['metrics']['http_req_duration']['values']['avg']
failCountDict[fileName][0] += df['metrics']['http_req_failed']['values']['passes']
failCountDict[fileName][1] += df['metrics']['http_req_failed']['values']['fails']
countDict[fileName] += 1

for key in durationDict:
durationDict[key] = durationDict[key] / countDict[key]
return durationDict
failCountDict[fileName][0] = failCountDict[fileName][0] / countDict[key]
failCountDict[fileName][1] = failCountDict[fileName][1] / countDict[key]
return durationDict, failCountDict

def writeResultFile(p: Path, result: dict):
def writeResultFile(p: Path, durationResult: dict, failResult: dict):
with p.open('w', newline='') as f:
columns = ['lock', 'vus', 'tickets', 'backoff', 'retry', 'waitTime', 'leaseTime', 'duration']
columns = ['lock', 'vus', 'tickets', 'minBackoff', 'maxBackoff', 'retry', 'waitTime', 'leaseTime', 'duration', 'passes', 'fails']
df = pd.DataFrame(columns=columns)

for i, key in enumerate(result):
lock, vus, vusValue, tickets, ticketsValue, backoff, backoffValue, retry, retryValue, waitTime, waitTimeValue, leaseTime, leaseTimeValue = key.split('_')
lock, vus, vusValue, tickets, ticketsValue, minBackoff, minBackoffValue, maxBackoff, maxBackoffValue, retry, retryValue, waitTime, waitTimeValue, leaseTime, leaseTimeValue = key.split('_')

se = pd.Series([lock, vusValue, ticketsValue, backoffValue, retryValue, waitTimeValue, leaseTimeValue, result[key]], index=df.columns)
se = pd.Series([lock, vusValue, ticketsValue, minBackoffValue, maxBackoffValue, retryValue, waitTimeValue, leaseTimeValue, durationResult[key], failResult[key][0], failResult[key][1]], index=df.columns)
df = pd.concat([df, pd.DataFrame([se])], ignore_index=True)
df.to_csv(f)

Expand All @@ -82,8 +88,8 @@ def writeResultFile(p: Path, result: dict):
validateDir(path)
p = Path(path)

result = makeResult(p)
result, failResult = makeResult(p)

path = '/'.join(['./result', 'result_' + sys.argv[1] + '.csv'])
p = Path(path)
writeResultFile(p, result)
writeResultFile(p, result, failResult)

0 comments on commit cc4e6a0

Please sign in to comment.