Package org.ngrinder.model

Examples of org.ngrinder.model.PerfTest


  boolean ended = false;

  @Test
  public void testStartConsole() throws IOException {
    // Get perf test
    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);
View Full Code Here


    model.clear();
    long invalidId = 123123123123L;
    controller.getOne(getTestUser(), invalidId, model);
    assertThat(model.get(PARAM_TEST), notNullValue());

    PerfTest createPerfTest = createPerfTest("hello", Status.READY, new Date());
    model.clear();
    controller.getOne(getTestUser(), createPerfTest.getId(), model);
    assertThat(model.get(PARAM_TEST), notNullValue());

  }
View Full Code Here

  }

  @Test
  public void testDeleteTests() {
    String testName = "test1";
    PerfTest test = createPerfTest(testName, Status.READY, new Date());
    ModelMap model = new ModelMap();
    controller.delete(getTestUser(), String.valueOf(test.getId()));
    model.clear();
    PerfTest test1 = createPerfTest(testName, Status.READY, new Date());
    PerfTest test2 = createPerfTest(testName, Status.READY, new Date());
    String delIds = "" + test1.getId() + "," + test2.getId();
    controller.delete(getTestUser(), delIds);

    model.clear();
    controller.getOne(getTestUser(), test1.getId(), model);
    assertThat(((PerfTest) model.get(PARAM_TEST)).getId(), nullValue());
    model.clear();
    controller.getOne(getTestUser(), test2.getId(), model);
    assertThat(((PerfTest) model.get(PARAM_TEST)).getId(), nullValue());
  }
View Full Code Here

  }

  @Test
  public void testSavePerfTestCloneAndLeaveCommentAndStop() {
    String testName = "test1";
    PerfTest test = createPerfTest(testName, Status.READY, null);
    long preId = test.getId();

    PerfTest cloneTest = newPerfTest(testName, Status.READY, null);
    cloneTest.setId(test.getId()); // set cloned test's ID as previous test

    ModelMap model = new ModelMap();
    controller.saveOne(getTestUser(), cloneTest, true, model);
    assertThat(preId, not(cloneTest.getId()));

    // test leave comment
    controller.leaveComment(getTestUser(), cloneTest.getId(), "TestComment", "");
    model.clear();
    controller.getOne(getTestUser(), cloneTest.getId(), model);
    PerfTest testInDB = (PerfTest) model.get(PARAM_TEST);
    assertThat(testInDB.getTestComment(), is("TestComment"));

    // test stop test
    cloneTest.setStatus(Status.TESTING);
    perfTestService.save(getTestUser(), cloneTest);
    controller.stop(getTestUser(), String.valueOf(cloneTest.getId()));
View Full Code Here

   */
  @Test
  public void testSavePerfTestExist() {
    String testName = "test1";
    String newName = "new test1";
    PerfTest test = createPerfTest(testName, Status.READY, new Date());
    test.setTestName(newName);

    PerfTest newTest = new PerfTest();
    newTest.setId(test.getId());
    newTest.setTestName(newName);
    newTest.setStatus(Status.SAVED);
    newTest.setThreshold(test.getThreshold());
    newTest.setDuration(test.getDuration());
    newTest.setVuserPerAgent(test.getVuserPerAgent());
    newTest.setScheduledTime(test.getScheduledTime());
    newTest.setIgnoreSampleCount(test.getIgnoreSampleCount());
    newTest.setTargetHosts(test.getTargetHosts());
    newTest.setScriptName(test.getScriptName());
    newTest.setProcesses(2);
    newTest.setThreads(2);
    newTest.setVuserPerAgent(newTest.getProcesses() * newTest.getThreads());
    newTest.setRegion(config.getRegion());
    newTest.setAgentCount(1);

    ModelMap model = new ModelMap();
    controller.saveOne(getTestUser(), newTest, false, model);
    controller.getOne(getTestUser(), newTest.getId(), model);
    PerfTest testInDB = (PerfTest) model.get(PARAM_TEST);
    assertThat(testInDB.getTestName(), is(newName));
    assertThat(testInDB.getId(), is(test.getId()));

    model.clear();
    newTest.setStatus(Status.READY);
    controller.saveOne(getTestUser(), newTest, false, model);
    controller.getOne(getTestUser(), newTest.getId(), model);
    testInDB = (PerfTest) model.get(PARAM_TEST);
    assertThat(testInDB.getTestName(), is(newName));
    assertThat(testInDB.getId(), is(test.getId()));

    // test status id "START_TESTING", can not be saved.
    newTest.setStatus(Status.START_TESTING);
    try {
      newTest.setStatus(Status.START_TESTING);
View Full Code Here

  }

  @Test
  public void testGetTestListByOtherUser() {
    String testName = "new test1";
    PerfTest test = createPerfTest(testName, Status.READY, new Date());

    ModelMap model = new ModelMap();

    User otherTestUser = new User();
    otherTestUser.setUserId("testUser");
    otherTestUser.setPassword("testUser");
    otherTestUser.setRole(Role.USER);
    otherTestUser = userService.save(otherTestUser);
    otherTestUser.setTimeZone("Asia/Seoul");
    controller.getAll(otherTestUser, null, null, null, new PageRequest(0, 10), model);
    @SuppressWarnings("unchecked")
    Page<PerfTest> testPage = (Page<PerfTest>) model.get("testListPage");
    List<PerfTest> testList = testPage.getContent();

    assertThat(testList.size(), is(0));

    // test no permission for other user
    model.clear();
    try {
      controller.getOne(otherTestUser, test.getId(), model);
      assertTrue(false);
    } catch (NGrinderRuntimeException e) {
      assertTrue(true);
    }
  }
View Full Code Here

  }

  @Test
  public void testGetReportData() {
    String testName = "test1";
    PerfTest test = createPerfTest(testName, Status.FINISHED, new Date());
    ModelMap model = new ModelMap();
    controller.getReport(model, test.getId());

    model.clear();
    controller.getPerfGraph(test.getId(), "TPS,mean_time(ms)", true, 0);

    model.clear();
    controller.getReportSection(getTestUser(), model, test.getId(), 700);
  }
View Full Code Here

  }

  @Test
  public void testGetMonitorData() {
    String testName = "test1";
    PerfTest test = createPerfTest(testName, Status.FINISHED, new Date());
    controller.getMonitorGraph(test.getId(), "127.0.0.1", 0);

    long testId = 123456L;
    controller.getMonitorGraph(testId, "127.0.0.1", 700);
  }
View Full Code Here

  }

  @Test
  public void testDownloadReportData() {
    String testName = "test1";
    PerfTest test = createPerfTest(testName, Status.FINISHED, new Date());
    HttpServletResponse resp = new MockHttpServletResponse();
    try {
      controller.downloadCSV(getTestUser(), test.getId(), resp);
    } catch (IllegalStateException e) {
      // the report file doesn't exist
      assertTrue(true);
    }
    resp.reset();
    controller.downloadLog(getTestUser(), test.getId(), "log", resp);
  }
View Full Code Here

  @Test
  public void testRefreshTestRunning() {
    String testName = "test1";
    // it is not a running test, can not test get statistic data.
    PerfTest test = createPerfTest(testName, Status.TESTING, new Date());
    test.setPort(11011);
    try {
      controller.refreshTestRunning(getTestUser(), test.getId());
    } catch (NullPointerException e) {
      assertTrue(true);
    }
  }
View Full Code Here

TOP

Related Classes of org.ngrinder.model.PerfTest

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.