naver / ngrinder

enterprise level performance testing solution
naver.github.io/ngrinder
Apache License 2.0
1.96k stars 473 forks source link

"Script error" of Groovy script #282

Open tjqiulu opened 6 years ago

tjqiulu commented 6 years ago

when run the groovy sample test as follow ` import net.grinder.script.GTest import net.grinder.scriptengine.groovy.junit.GrinderRunner import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread import net.grinder.util.GrinderUtils import org.junit.Before import org.junit.Test import org.junit.runner.RunWith

import static org.junit.Assert.*

import static net.grinder.script.Grinder.grinder

@RunWith(GrinderRunner) class TestSth{

public static GTest test

// This method is executed once per a process.
@BeforeProcess
public static void beforeClass() {
    test = new GTest(1, "test Thread");
    //test.record(request);
    grinder.logger.info("before process.");
}

// This method is executed once per a thread.
@BeforeThread
public void beforeThread() {
    grinder.statistics.delayReports=true;
    grinder.logger.info("before thread.");
}

@Test
public void test()
{
    String seid="000000000000000000000000000000000000"

    String threadId = GrinderUtils.threadUniqId
    String leftStr = "${threadId}".padLeft(36,seid)
    grinder.logger.info("ThreadId is:"+leftStr)
    assertTrue(true)
}

} `

i get the error from red icon Console is being prepared. Console is started on port 12002 1 agents are starting. 1 agents are ready. All necessary files are being distributed.

Stopped by error 2018-04-03 16:59:07

I continue trace the error in log of console

2018-04-03 16:59:07,823 INFO ScriptHandler.java:153 : 127.0.0.1/rest/download/2/src/test/groovy/TestSth.groovy is being written in C:\Users\lqiu.ngrinder\perftest\0_999\50\dist for test 502018-04-03 16:59:07,842 INFO PerfTestService.java:656 : File write is completed in C:\Users\lqiu.ngrinder\perftest\0_999\50\dist2018-04-03 16:59:07,848 INFO PerfTestService.java:629 : Grinder Properties : {grinder.threads=1, grinder.numberOfOldLogs=1, grinder.jvm.classpath=., grinder.test.id=test_50, grinder.sleepTimeVariation=0.2, grinder.runs=1, grinder.useConsole=true, grinder.script=TestSth.groovy, grinder.jvm=java, grinder.security=false, grinder.processIncrement=0, grinder.sleepTimeFactor=1, ngrinder.etc.hosts=, grinder.user=admin, grinder.reportTimesToConsole=true, grinder.debug.singleprocess=false, grinder.processes=1, grinder.ignoreSampleCount=0, grinder.reportToConsole.interval=500, grinder.agents=1, grinder.dcrinstrumentation=true, grinder.logProcessStreams=true} 2018-04-03 16:59:07,849 INFO AgentManager.java:405 : 1 agents are starting for user admin2018-04-03 16:59:07,849 INFO AgentManager.java:407 : - Agent BEI-4BLHGH22018-04-03 16:59:09,267 INFO Home.java:241 : C:\Users\lqiu.ngrinder\perftest\0_999\50\report is created.2018-04-03 16:59:10,906 INFO Home.java:241 : C:\Users\lqiu.ngrinder\perftest\0_999\50\logs is created.2018-04-03 16:59:14,247 ERROR PerfTestRunnable.java:347 : Abnormal test 50 due to SCRIPT_ERROR2018-04-03 16:59:14,924 INFO PerfTestRunnable.java:412 : Terminate 502018-04-03 16:59:14,927 INFO PerfTestService.java:961 : Total Statistics for test 50 is {}2018-04-03 16:59:19,667 WARN PerfTestService.java:713 : Report TPS for test 50 does not exist.

I can pass in validate the script part. and infact from download test log, which of are passed and no error.

ztkmkoo commented 5 years ago

Same case. Any solution?

for nGrinder-groovy 3.4