TCP 스트레스 테스트

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

TCP 스트레스 테스트

bacd
package org.ngrinder;

import static net.grinder.script.Grinder.grinder
import static org.junit.Assert.*
import static org.hamcrest.Matchers.*
import net.grinder.plugin.http.HTTPRequest
import net.grinder.plugin.http.HTTPPluginControl;
import net.grinder.script.GTest
import net.grinder.script.Grinder
import net.grinder.scriptengine.groovy.junit.GrinderRunner
import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread
// import static net.grinder.util.GrinderUtils.* // You can use this if you're using nGrinder after 3.2.3
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith

import HTTPClient.HTTPResponse
import HTTPClient.NVPair

/**
 * 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
        public static Socket socket;

               @BeforeProcess
        public static void beforeProcess() {
                test = new GTest(1, "Test1")
                grinder.logger.info("before process.")
        }
     
     @BeforeThread
      public void beforeThread() {
             socket = new Socket();
             test.record(this, "doConnect");
      }
     public doConnect(Socket socket,  InetSocketAddress inetSocketAddress ) {
        socket.connect(inetSocketAddress, 10003)
      }

     @Test
      public void test(){
          InetSocketAddress inetSocketAddress = new InetSocketAddress("192.168.1.10", 10003)
          doConnect(socket, inetSocketAddress);
          assertThat(socket.isConnected(), is(true))
       }
}

스크립터는 위와 같이 구성 한 후 테스트 진행 하게 되면 다음과 같은 로그가 생성되고
에러가 발생합니다. 어떤 부분이 문제 일까요?

2014-12-09 10:28:43,991 INFO  Running "tcp.groovy" using GroovyScriptEngine running with groovy version: 2.2.1
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  starting, will do 1 run
2014-12-09 10:28:44,225 INFO  Start time is 1418088524228 ms since Epoch
2014-12-09 10:28:44,287 ERROR already connected
java.net.SocketException: already connected
        at java_net_Socket$connect$7.call(Unknown Source) ~[na:na]
        at org.ngrinder.TestRunner.doConnect(tcp.groovy:47) ~[na:na]
        at org.ngrinder.TestRunner$doConnect$3.callCurrent(Unknown Source) ~[na:na]
        at org.ngrinder.TestRunner.test(tcp.groovy:53) ~[na:na]
        at net.grinder.scriptengine.groovy.junit.GrinderRunner.run(GrinderRunner.java:170) ~[ngrinder-groovy-3.3.jar:na]
        at net.grinder.scriptengine.groovy.GroovyScriptEngine$GroovyWorkerRunnable.run(GroovyScriptEngine.java:148) ~[ngrinder-groovy-3.3.jar:na]
        at net.grinder.engine.process.GrinderThread.run(GrinderThread.java:118) ~[grinder-core-3.9.1.jar:na]
2014-12-09 10:28:44,287 ERROR already connected
java.net.SocketException: already connected
        at java_net_Socket$connect$6.call(Unknown Source) ~[na:na]
        at org.ngrinder.TestRunner.doConnect(tcp.groovy:47) ~[na:na]
        at org.ngrinder.TestRunner$doConnect$0.callCurrent(Unknown Source) ~[na:na]
        at org.ngrinder.TestRunner.test(tcp.groovy:53) ~[na:na]
        at net.grinder.scriptengine.groovy.junit.GrinderRunner.run(GrinderRunner.java:170) ~[ngrinder-groovy-3.3.jar:na]
        at net.grinder.scriptengine.groovy.GroovyScriptEngine$GroovyWorkerRunnable.run(GroovyScriptEngine.java:148) ~[ngrinder-groovy-3.3.jar:na]
        at net.grinder.engine.process.GrinderThread.run(GrinderThread.java:118) ~[grinder-core-3.9.1.jar:na]
2014-12-09 10:28:44,287 INFO  finished 1 run
2014-12-09 10:28:44,287 INFO  finished 1 run
2014-12-09 10:28:44,303 ERROR already connected
java.net.SocketException: already connected
        at java_net_Socket$connect$12.call(Unknown Source) ~[na:na]
        at org.ngrinder.TestRunner.doConnect(tcp.groovy:47) ~[na:na]
        at org.ngrinder.TestRunner$doConnect$8.callCurrent(Unknown Source) ~[na:na]
        at org.ngrinder.TestRunner.test(tcp.groovy:53) ~[na:na]
        at net.grinder.scriptengine.groovy.junit.GrinderRunner.run(GrinderRunner.java:170) ~[ngrinder-groovy-3.3.jar:na]
        at net.grinder.scriptengine.groovy.GroovyScriptEngine$GroovyWorkerRunnable.run(GroovyScriptEngine.java:148) ~[ngrinder-groovy-3.3.jar:na]
        at net.grinder.engine.process.GrinderThread.run(GrinderThread.java:118) ~[grinder-core-3.9.1.jar:na]
2014-12-09 10:28:44,303 INFO  finished 1 run
2014-12-09 10:28:44,303 ERROR already connected
java.net.SocketException: already connected
        at java_net_Socket$connect$10.call(Unknown Source) ~[na:na]
        at org.ngrinder.TestRunner.doConnect(tcp.groovy:47) ~[na:na]
        at org.ngrinder.TestRunner$doConnect.callCurrent(Unknown Source) ~[na:na]
        at org.ngrinder.TestRunner.test(tcp.groovy:53) ~[na:na]
        at net.grinder.scriptengine.groovy.junit.GrinderRunner.run(GrinderRunner.java:170) ~[ngrinder-groovy-3.3.jar:na]
        at net.grinder.scriptengine.groovy.GroovyScriptEngine$GroovyWorkerRunnable.run(GroovyScriptEngine.java:148) ~[ngrinder-groovy-3.3.jar:na]
        at net.grinder.engine.process.GrinderThread.run(GrinderThread.java:118) ~[grinder-core-3.9.1.jar:na]
2014-12-09 10:28:44,303 INFO  finished 1 run
2014-12-09 10:28:44,303 ERROR Socket closed
java.net.SocketException: Socket closed
        at java_net_Socket$connect$20.call(Unknown Source) ~[na:na]
        at org.ngrinder.TestRunner.doConnect(tcp.groovy:47) ~[na:na]
        at org.ngrinder.TestRunner$doConnect$0.callCurrent(Unknown Source) ~[na:na]
        at org.ngrinder.TestRunner.test(tcp.groovy:53) ~[na:na]
        at net.grinder.scriptengine.groovy.junit.GrinderRunner.run(GrinderRunner.java:170) ~[ngrinder-groovy-3.3.jar:na]
        at net.grinder.scriptengine.groovy.GroovyScriptEngine$GroovyWorkerRunnable.run(GroovyScriptEngine.java:148) ~[ngrinder-groovy-3.3.jar:na]
        at net.grinder.engine.process.GrinderThread.run(GrinderThread.java:118) ~[grinder-core-3.9.1.jar:na]
2014-12-09 10:28:44,303 INFO  finished 1 run

이사입니다.
Reply | Threaded
Open this post in threaded view
|

Re: TCP 스트레스 테스트

Choe Jungyeon
public static Socket socket; 에서 static을 제거하시거나 connection을 test 내에서 구현하셔야할 듯 합니다.
고맙습니다.