Package net.grinder

Examples of net.grinder.SingleConsole


  @Before
  public void before() throws ConsoleException, InterruptedException {
    sleep(5000);
    startThreadCount = Thread.activeCount();
    console1 = new SingleConsole(getFreePort());
    console2 = new SingleConsole(getFreePort());
    console1.start();
    console2.start();
  }
View Full Code Here


    // Now it should be 1 agents on console2
    assertThat("There must be 1 agents connecting console2", console2.getAllAttachedAgents().size(), is(1));

    console1.shutdown();
    console1 = new SingleConsole(getFreePort());
    console1.start();
    console1.shutdown();

  }
View Full Code Here

  private Integer consolePort;

  @Before
  public void before() {
    consolePort = getFreePort();
    console1 = new SingleConsole(consolePort);
    console1.start();
    sleep(1000);
  }
View Full Code Here

    GrinderClassPathInitializer.initJUnitContext();
    agentConfig = new AgentConfig.NullAgentConfig(1);
    agentConfig.init();
    consolePort = getFreePort();
    agentConfig.setControllerPort(consolePort);
    console1 = new SingleConsole(consolePort);
    console1.start();
    ThreadUtils.sleep(1000);
  }
View Full Code Here

    PerfTest perfTest = perfTestService.getNextRunnablePerfTestPerfTestCandidate();
    perfTest.setScriptName("/hello/world.py");
    assertThat(perfTest, not(nullValue()));

    // Start console
    SingleConsole singleConsole = perfTestRunnable.startConsole(perfTest);
    assertThat(singleConsole, not(nullValue()));
    assertThat(singleConsole.getConsolePort(), is(perfTest.getPort()));

    // Start agents
    perfTest.setAgentCount(1);
    GrinderProperties grinderProperties = perfTestService.getGrinderProperties(perfTest);
    singleConsole.setReportPath(perfTestService.getReportFileDirectory(perfTest));

    // Distribute files
    perfTestService.prepareDistribution(perfTest);
    perfTestRunnable.startAgentsOn(perfTest, grinderProperties, singleConsole);
    sleep(3000);
    perfTestRunnable.distributeFileOn(perfTest, singleConsole);

    singleConsole.addSamplingLifeCyleListener(new SamplingLifeCycleListener() {
      @Override
      public void onSamplingStarted() {
        System.out.println("Sampling is started");
      }

      @Override
      public void onSamplingEnded() {
        ended = true;
      }

      @Override
      public void onSampling(File file, StatisticsSet intervalStatistics, StatisticsSet cumulativeStatistics) {
      }
    });

    // Run test
    perfTestRunnable.runTestOn(perfTest, grinderProperties, singleConsole);
    sleep(10000);
    perfTestService.stop(getTestUser(), currentTest.getId());
    singleConsole.waitUntilAllAgentDisconnected();
    perfTestRunnable.doFinish(false);
    // Waiting for termination


    sleep(5000);
View Full Code Here

  private MockConsoleManager manager;

  @Test
  public void testConsoleManager() {
    int initialSize = manager.getAvailableConsoleSize();
    SingleConsole availableConsole = manager.getAvailableConsole(
        ConsolePropertiesFactory.createEmptyConsoleProperties());
    assertThat(manager.getAvailableConsoleSize(), is(initialSize - 1));
    manager.returnBackConsole("test", availableConsole);
    sleep(1000);
    assertThat(manager.getAvailableConsoleSize(), is(initialSize));
View Full Code Here

  @Test
  public void testConsoleManagerWhenExceedingLimit() {
    // Get all console
    int initialSize = manager.getAvailableConsoleSize();
    SingleConsole availableConsole = null;
    for (int i = 1; i <= initialSize; i++) {
      availableConsole = manager.getAvailableConsole(
          ConsolePropertiesFactory.createEmptyConsoleProperties());
    }
    final SingleConsole lastConsole = availableConsole;
    assertThat(manager.getAvailableConsoleSize(), is(0));
    StopWatch elapseTime = new StopWatch();
    elapseTime.start();
    // Try to get more console, it will take time
    try {
      manager.getAvailableConsole(ConsolePropertiesFactory.createEmptyConsoleProperties());
      fail("should throw Exception");
    } catch (NGrinderRuntimeException e) {
    }
    elapseTime.stop();
    assertThat(elapseTime.getTotalTimeSeconds(), lessThan(3000D));
    // Let's try the case when console is returned back.
    Thread thread = new Thread(new Runnable() {
      @Override
      public void run() {
        try {
          Thread.sleep(1000);
          manager.returnBackConsole("test", lastConsole);
        } catch (InterruptedException e) {
        }

      }
    });
    elapseTime = new StopWatch();
    elapseTime.start();
    thread.start();
    // Try to get more console, it will return console just after console is
    // returned back
    SingleConsole anotherConsole = manager.getAvailableConsole(
        ConsolePropertiesFactory.createEmptyConsoleProperties());
    elapseTime.stop();
    assertThat(elapseTime.getTotalTimeSeconds(), lessThan(3000D));
    assertThat(manager.getAvailableConsoleSize(), is(0));
    manager.returnBackConsole("test", anotherConsole);
View Full Code Here

  private void doCancel(int substep) {
    // When the stop perftest is requested
    perfTestRunnable.setRunnable(new Runnable() {
      @Override
      public void run() {
        SingleConsole singleConsole = consoleManager.getConsoleInUse().get(0);
        SampleModelImplementationEx sampleModelMock = mock(SampleModelImplementationEx.class);
        singleConsole.setSampleModel(sampleModelMock);
        assertThat(singleConsole, notNullValue());
        perfTestController.stop(getTestUser(), String.valueOf(perfTest.getId()));
      }
    }, substep);
    perfTestRunnable.doStart();
View Full Code Here

   * If fails, it marks STOP_BY_ERROR in the given {@link PerfTest} status
   *
   * @param perfTest perftest instance;
   */
  public void doTest(final PerfTest perfTest) {
    SingleConsole singleConsole = null;
    try {
      singleConsole = startConsole(perfTest);
      ScriptHandler prepareDistribution = perfTestService.prepareDistribution(perfTest);
      GrinderProperties grinderProperties = perfTestService.getGrinderProperties(perfTest, prepareDistribution);
      startAgentsOn(perfTest, grinderProperties, checkCancellation(singleConsole));
      distributeFileOn(perfTest, checkCancellation(singleConsole));

      singleConsole.setReportPath(perfTestService.getReportFileDirectory(perfTest));
      runTestOn(perfTest, grinderProperties, checkCancellation(singleConsole));
    } catch (SingleConsoleCancellationException ex) {
      // In case of error, mark the occurs error on perftest.
      doCancel(perfTest, singleConsole);
      notifyFinish(perfTest, StopReason.CANCEL_BY_USER);
View Full Code Here

   */
  SingleConsole startConsole(PerfTest perfTest) {
    perfTestService.markStatusAndProgress(perfTest, START_CONSOLE, "Console is being prepared.");
    // get available consoles.
    ConsoleProperties consoleProperty = perfTestService.createConsoleProperties(perfTest);
    SingleConsole singleConsole = consoleManager.getAvailableConsole(consoleProperty);
    singleConsole.start();
    perfTestService.markPerfTestConsoleStart(perfTest, singleConsole.getConsolePort());
    return singleConsole;
  }
View Full Code Here

TOP

Related Classes of net.grinder.SingleConsole

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.