robert-min / user_login

0 stars 0 forks source link

성능테스트 #11

Open robert-min opened 1 year ago

robert-min commented 1 year ago

주요 목표

💡현재 하나의 Docker Container로 테스트를 진행하여 동시사용자 수 와 TPS가 낮게 측정될 것으로 예상합니다. 실제 프로덕션은 Replica, LoadBalancing 구성이 필요합니다.

robert-min commented 1 year ago

Vuser : 50 명 POST /auth/login

user50

Vuser : 60 명 POST /auth/login

vuser60
robert-min commented 1 year ago

nGrinder Test Script

# -*- coding:utf-8 -*-

# A simple example using the HTTP plugin that shows the retrieval of a
# single page via HTTP.
#
# This script is automatically generated by ngrinder.
#
# @author admin
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from java.util import Date
from HTTPClient import NVPair, Cookie, CookieModule

from net.grinder.plugin.http import HTTPRequest
from net.grinder.plugin.http import HTTPPluginControl

# Uncomment this to use new experimental HTTP client.
# from org.ngrinder.http import HTTPRequest
# from org.ngrinder.http.cookie import Cookie, CookieManager

control = HTTPPluginControl.getConnectionDefaults()
# if you don't want that HTTPRequest follows the redirection, please modify the following option 0.
# control.followRedirects = 1
# if you want to increase the timeout, please modify the following option.
control.timeout = 6000

test1 = Test(1, "15.165.197.195")
request1 = HTTPRequest()

# Set header datas
headers = [NVPair("Content-type", "application/json")] # Array of NVPair
# Set param datas
params = "{\"email\": \"test@test.com\", \"password\": \"12312312\"}" # Array of NVPair
# Set cookie datas
cookies = [] # Array of Cookie

class TestRunner:
    # initlialize a thread
    def __init__(self):
        test1.record(TestRunner.__call__)
        grinder.statistics.delayReports=True
        pass

    def before(self):
        request1.setHeaders(headers)
        for c in cookies: CookieModule.addCookie(c, HTTPPluginControl.getThreadHTTPClientContext())

    # test method
    def __call__(self):
        self.before()

        result = request1.POST("http://15.165.197.195:8000/auth/login", params)

        # You get the message body using the getText() method.
        # if result.getText().find("HELLO WORLD") == -1 :
        #    raise

        # if you want to print out log.. Don't use print keyword. Instead, use following.
        # grinder.logger.info("Hello World")

        if result.getStatusCode() == 200 :
            return
        elif result.getStatusCode() in (301, 302) :
            grinder.logger.warn("Warning. The response may not be correct. The response code was %d." %  result.getStatusCode())
            return
        else :
            raise