개요
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPRequest
from net.grinder.plugin.http import HTTPPluginControl
from net.grinder.script.Grinder import grinder
from HTTPClient import NVPair
from java.util import Random, Date
from time import gmtime, strftime
import uuid
test1 = Test(1, "JSON POST TEST")
from org.slf4j import LoggerFactory
from ch.qos.logback.classic import Level
from ch.qos.logback.classic import Logger
class TestRunner:
def __init__(self):
logger = LoggerFactory.getLogger("worker");
logger.setLevel(Level.ERROR);
def __call__(self):
grinder.statistics.delayReports = 1
strTime = strftime("%Y-%m-%d %H:%M:%S", gmtime())
body = "mjkim"
uv = uuid.uuid5(uuid.NAMESPACE_DNS, 'Section' + strTime)
url= "/v2/log"
version = "2.0.0"
projectName = "aEnDGvLIl23gBqMC"
normal="""{
"projectName": \""""+projectName+"""\",
"logVersion" : "v2",
"projectVersion": \""""+version+"""\",
"body": \"Normal Log """+body+"""\",
"host": "***.***.***.***",
"logSource": "logncrash-logSource",
"logType": "SESSION",
"logLevel": "INFO",
"SessionID": \""""+uv.urn[9:]+"""\",
"Carrier": "SKTelecom",
"DeviceModel": "SHV-E210S",
"sendtime": \""""+strTime+"""\",
"CountryCode": "kr",
"NetworkType" : "Wi-Fi",
"CountryCode":"kr",
"CrashStyle" : "android-java",
"SymMethod" : "proguard",
"Platform": "Android OS 4.4.4"
}"""
requestGet = test1.wrap(HTTPRequest(url="http://***.***.***.***"))
try:
result = requestGet.POST(url, normal, ( NVPair('Content-Type', 'application/json'), NVPair('Connection', 'close')))
except Exception, e:
grinder.logger.info("Got an Exception", e)
grinder.sleep(0)