validate script 시 서버 500 에러 발생

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

validate script 시 서버 500 에러 발생

dasom
안녕하세요, API 의 저장 기능을 테스트 하는 테스트 스크립트를 .groovy로 작성하였는데 validate script 를 하면 500에러가 발생합니다.

아래는 코드와 Validate Script 의 내용입니다. 감사합니다.

import static net.grinder.script.Grinder.grinder
import static org.junit.Assert.*
import static org.hamcrest.Matchers.*
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.AfterProcess
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread
import groovy.json.JsonOutput
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.OutputStreamWriter
import java.io.InputStreamReader
import java.net.URL
import java.net.HttpURLConnection
import org.junit.Test
import org.junit.runner.RunWith

/**
 * 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
 */
@RunWith(GrinderRunner)
class TestRunner {

    public static GTest test;

    @BeforeProcess
    public static void beforeProcess() {
        test = new GTest(1, "~~")
        grinder.logger.info("before process.")
    }

    @BeforeThread
    public void beforeThread() {
        test.record(this, "test")
        grinder.statistics.delayReports=true
        grinder.logger.info("before thread.")
    }

    @Test
    public void test(){
               
                String query = "<a href="http://~IP~:~PORT~/">http://~IP~:~PORT~/~~";
                String json = "{\"~~~\":\"~~~\",\"~~~\":\"~~~\"}";
               
                URL url = new URL(query);
                HttpURLConnection conn = (HttpURLConnection)url.openConnection();
        conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
        conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setRequestMethod("POST");
       
        OutputStream os = conn.getOutputStream();
        os.write(json.getBytes("UTF-8"));
        os.close();
             
       
        try{
//read the response
        InputStream ins = new BufferedInputStream(conn.getInputStream());
        String result = org.apache.commons.io.IOUtils.toString(ins, "UTF-8");
       
    //grinder.logger.info(result);

        ins.close();
                }catch(Exception e){
                        grinder.logger.info(e.getMessage());
                       
        }
        conn.disconnect();

    }

}


=================================

Tip
2019-01-31 20:18:48,286 INFO  The Grinder version 3.9.1
2019-01-31 20:18:48,290 INFO  Java(TM) SE Runtime Environment 1.8.0_201-b09: Java HotSpot(TM) 64-Bit Server VM (25.201-b09, mixed mode) on Linux amd64 3.10.0-957.1.3.el7.x86_64
2019-01-31 20:18:48,294 INFO  time zone is KST (+0900)
2019-01-31 20:18:48,356 INFO  worker process 0 of agent number 0
2019-01-31 20:18:48,374 INFO  Instrumentation agents: byte code transforming instrumenter for Java; byte code transforming instrumenter for Java
2019-01-31 20:18:48,982 INFO  before process.
2019-01-31 20:18:48,985 INFO  Running "~~.groovy" using GroovyScriptEngine running with groovy version: 2.2.1
2019-01-31 20:18:49,043 INFO  before thread.
2019-01-31 20:18:49,043 INFO  starting, will do 1 run
2019-01-31 20:18:49,043 INFO  Start time is 1548933529043 ms since Epoch
2019-01-31 20:18:49,097 INFO  Server returned HTTP response code: 500 for URL: <a href="http://~IP~:~PORT~/">http://~IP~:~PORT~/~~
2019-01-31 20:18:49,099 INFO  finished 1 run
2019-01-31 20:18:49,101 INFO  elapsed time is 58 ms
2019-01-31 20:18:49,101 INFO  Final statistics for this process:
2019-01-31 20:18:49,107 INFO  
             Tests        Errors       Mean Test    Test Time    TPS          
                                       Time (ms)    Standard                  
                                                    Deviation                
                                                    (ms)                      

Test 1       1            0            48.00        0.00         17.24         "~~위 test~~"

Totals       1            0            48.00        0.00         17.24        

  Tests resulting in error only contribute to the Errors column.          
  Statistics for individual tests can be found in the data file, including
  (possibly incomplete) statistics for erroneous tests. Composite tests  
  are marked with () and not included in the totals.                      



2019-01-31 20:18:48,988 INFO  validation-0: Starting threads
2019-01-31 20:18:49,107 INFO  validation-0: Finished