Package org.ngrinder.model

Examples of org.ngrinder.model.PerfTest


  @Test
  public void testUserDelete() {
    final User user = getTestUser();
    File scriptDirectory = config.getHome().getScriptDirectory(user);
    scriptDirectory.mkdirs();
    PerfTest perfTest = new PerfTest();
    perfTest.setTestName("Hello");
    perfTest.setTagString("Hello,World");
    perfTest = perfTestService.save(user, perfTest);
    userService.delete(user.getUserId());
    assertThat(perfTestService.getOne(perfTest.getId()), nullValue());
    assertThat(scriptDirectory.exists(), is(false));
  }
View Full Code Here


*/
public class PerfTestTest {

  @Test
  public void testGetTargetHostIp() {
    PerfTest test = new PerfTest();
    test.setTargetHosts("aaa.com:1.1.1.1");
    List<String> ipList = test.getTargetHostIP();
    assertThat(ipList.get(0), is("1.1.1.1"));

    test.setTargetHosts(":1.1.1.1");
    ipList = test.getTargetHostIP();
    assertThat(ipList.get(0), is("1.1.1.1"));

    test.setTargetHosts("1.1.1.1");
    ipList = test.getTargetHostIP();
    assertThat(ipList.get(0), is("1.1.1.1"));

    // multiple hosts
    test.setTargetHosts("aaa.com:1.1.1.1,aaabb.com:1.1.1.2");
    ipList = test.getTargetHostIP();
    assertThat(ipList.get(1), is("1.1.1.2"));

    test.setTargetHosts("aaa.com:1.1.1.1,:1.1.1.2");
    ipList = test.getTargetHostIP();
    assertThat(ipList.get(1), is("1.1.1.2"));

    test.setTargetHosts("aaa.com:1.1.1.1,1.1.1.2");
    ipList = test.getTargetHostIP();
    assertThat(ipList.get(1), is("1.1.1.2"));

    test.setTargetHosts("www.test.com:0:0:0:0:0:ffff:3d87:a969,www.test.com:0:0:0:0:0:ffff:a22:4024");
    ipList = test.getTargetHostIP();
    assertThat(ipList.get(1), is("0:0:0:0:0:ffff:a22:4024"));
  }
View Full Code Here

    assertThat(ipList.get(1), is("0:0:0:0:0:ffff:a22:4024"));
  }

  @Test
  public void testAddProgressMessage() {
    PerfTest test = new PerfTest();
    for (int i = 0; i < 1000; i++) {
      test.setLastProgressMessage("HELLO");
      assertThat(test.getProgressMessage().length(), lessThan(ControllerConstants.MAX_STACKTRACE_STRING_SIZE));
    }
  }
View Full Code Here

  }

  @Test
  public void testPerfTestSearchBasedOnStatus() {
    // Given 3 tests with different status
    PerfTest entity = new PerfTest();
    entity.setStatus(Status.FINISHED);
    perfTestRepository.save(entity);
    PerfTest entity2 = new PerfTest();
    entity2.setStatus(Status.CANCELED);
    perfTestRepository.save(entity2);
    PerfTest entity3 = new PerfTest();
    entity3.setStatus(Status.READY);
    perfTestRepository.save(entity3);

    // Then all should be 3
    assertThat(perfTestRepository.findAll().size(), is(3));
    // Then finished and canceled perftest should 2
View Full Code Here

  }

  @SuppressWarnings("serial")
  @Test
  public void testPerfTestTag() {
    PerfTest entity = new PerfTest();
    entity.setTestName("test1");
    entity.setTags(new TreeSet<Tag>() {
      {
        add(new Tag("hello"));
        add(new Tag("world"));
      }
    });
    entity = perfTestRepository.save(entity);
    PerfTest findOne = perfTestRepository.findOne(entity.getId());
    SortedSet<Tag> tags = findOne.getTags();
    assertThat(tags.first(), is(new Tag("hello")));
    assertThat(tags.last(), is(new Tag("world")));
  }
View Full Code Here

  public void testPerfTestTag2() {
    final Tag hello = tagRepository.save(new Tag("hello"));
    final Tag world = tagRepository.save(new Tag("world"));
    final Tag world2 = tagRepository.save(new Tag("world2"));

    PerfTest entity = new PerfTest();
    entity.setTestName("test1");
    entity.setTags(new TreeSet<Tag>() {
      {
        add(hello);
        add(world);
      }
    });
    entity = perfTestRepository.save(entity);
    SortedSet<Tag> tags2 = entity.getTags();
    assertThat(tags2.first(), is(hello));
    assertThat(tags2.last(), is(world));

    PerfTest entity2 = new PerfTest();
    entity2.setTestName("test1");
    entity2.setTags(new TreeSet<Tag>() {
      {
        add(hello);
        add(world2);
      }
    });
View Full Code Here

    assertThat(tagRepository.findAll().size(), is(0));
  }

  @Test
  public void testTagging() {
    PerfTest newPerfTest = newPerfTest("hello", Status.SAVED, new Date());
    newPerfTest.setTagString("HELLO,world");
    createPerfTest(newPerfTest);
    newPerfTest.setTagString("HELLO,WORLD");
    PerfTest updated = createPerfTest(newPerfTest);
    PerfTest perfTestWithTag = perfTestService.getOneWithTag(updated.getId());
    List<Tag> listTags = tagService.getAllTags(getTestUser(), "H");
    assertThat(listTags.size(), is(1));
    assertThat(tagRepository.count(hasPerfTest()), is(1L));
    assertThat(perfTestWithTag.getTags().size(), is(2));
  }
View Full Code Here

  @Test
  public void testGetTestListAll() {
    createPerfTest("new Test1", Status.TESTING, new Date());
    createPerfTest("new Test2", Status.FINISHED, new Date());

    PerfTest candidate = testService.getNextRunnablePerfTestPerfTestCandidate();
    assertThat(candidate, nullValue());

    Pageable pageable = new PageRequest(0, 10);
    Page<PerfTest> testList = testService.getPagedAll(getTestUser(), null, null, null, pageable);
    assertThat(testList.getContent().size(), is(2));
    testList = testService.getPagedAll(getTestUser(), null, null, "F", pageable);
    assertThat(testList.getContent().size(), is(1));

    // test with no paging
    testList = testService.getPagedAll(getTestUser(), null, null, null, null);
    assertThat(testList.getContent().size(), is(2));
    testList = testService.getPagedAll(getTestUser(), null, null, "F", null);
    assertThat(testList.getContent().size(), is(1));

    List<PerfTest> list = testService.getAllTesting();
    assertThat(list.size(), is(1));

    for (PerfTest test : list) {
      long systemTimeMills = System.currentTimeMillis();
      test.setStartTime(new Date(systemTimeMills));

      PerfTest testTemp = testService.getOne(getTestUser(), test.getId());
      assertThat(testTemp.getId(), is(test.getId()));
      assertThat(testTemp.getStartTime().getTime(), is(systemTimeMills));

      testService.markAbnormalTermination(testTemp, StopReason.CANCEL_BY_USER);
      testService.markProgress(testTemp, "this test will be TESTING again");
      testService.markStatusAndProgress(testTemp, Status.TESTING, "this is just test unit");

      List<PerfTest> testingList = testService.getAll(getTestUser(), new Status[]{Status.TESTING});
      assertThat(testingList.size(), is(1));

      Long testCount = testService.count(getTestUser(), new Status[]{Status.TESTING});
      assertThat(testCount, is(1L));

      GrinderProperties properties = testService.getGrinderProperties(test);
      assertThat(properties, not(nullValue()));

    }

    createPerfTest("new Test2", Status.getProcessingOrTestingTestStatus()[0], new Date());
    list = testService.getCurrentlyRunningTest();
    assertThat(list.size(), is(2));

    PerfTest finishedTest = createPerfTest("new Test3", Status.ABNORMAL_TESTING, new Date());
    finishedTest.setPort(0); // need port number for finishing
    list = testService.getAllAbnormalTesting();
    assertThat(list.size(), is(1));

    testService.updatePerfTestAfterTestFinish(finishedTest);
View Full Code Here

  @Test
  public void testTestScriptAll() {
    int maxConcurrent = testService.getMaximumConcurrentTestCount();
    assertThat(maxConcurrent, is(10));

    PerfTest testScript = createPerfTest("new TestScript", Status.READY, new Date());
    testService.addCommentOn(getTestUser(), testScript.getId(), "this is TestScript method", "");

    PerfTest testing = testService.markProgressAndStatus(testScript, Status.TESTING, "It is testing from ready");
    assertThat(testing.getStatus(), is(Status.TESTING));

    File testPath = testService.getDistributionPath(testScript);
    assertThat(testPath, not(nullValue()));

    List<String> fileList = testService.getLogFiles(testScript.getId());
View Full Code Here

  }

  @Test
  public void testCleanUpRuntimeOnlyData() {

    PerfTest test = createPerfTest("new test", Status.READY, new Date());
    test.setAgentState("{\"NC-PL-DEV013\":{\"freeMemory\":2937684,\"totalMemory\":8301204,\"cpuUsedPercentage\":31.234259,\"receivedPerSec\":1874668,\"sentPerSec\":1881129}}");
    test.setMonitorState("{\"127.0.0.1\":{\"freeMemory\":1091352,\"totalMemory\":4042436,\"cpuUsedPercentage\":0.24937657,\"receivedPerSec\":102718,\"sentPerSec\":135072}}");
    test.setRunningSample("{\"process\":1,\"peakTpsForGraph\":2192.0,\"lastSampleStatistics\":[{\"Peak_TPS\":0.0,\"Tests\":2145.0,\"Mean_time_to_first_byte\":0.3142191142191142,\"testDescription\":\"Test1\",\"Response_bytes_per_second\":62205.0,\"Errors\":0.0,\"TPS\":2145.0,\"testNumber\":1,\"Mean_Test_Time_(ms)\":0.4205128205128205}],\"thread\":1,\"cumulativeStatistics\":[{\"Peak_TPS\":2192.0,\"Tests\":197185.0,\"Mean_time_to_first_byte\":0.3229910997286812,\"testDescription\":\"Test1\",\"Response_bytes_per_second\":57481.98148390145,\"Errors\":0.0,\"TPS\":1982.1372925483258,\"testNumber\":1,\"Mean_Test_Time_(ms)\":0.4425539468012273}],\"tpsChartData\":2145.0,\"success\":true,\"totalStatistics\":{\"Peak_TPS\":2192.0,\"Tests\":197185.0,\"Mean_time_to_first_byte\":0.3229910997286812,\"Response_bytes_per_second\":57481.98148390145,\"Errors\":0.0,\"TPS\":1982.1372925483258,\"Mean_Test_Time_(ms)\":0.4425539468012273},\"test_time\":105}");
    perfTestService.save(getTestUser(), test);

    PerfTest testInDB = perfTestService.getOne(test.getId());
    assertTrue(testInDB.getAgentState().length() > 0 && testInDB.getMonitorState().length() > 0);
    test.setAgentState(null);
    test.setMonitorState(null);
    test.setRunningSample(null);
    perfTestService.save(getTestUser(), test);
    testInDB = perfTestService.getOne(test.getId());
    assertTrue(testInDB.getAgentState() == null && testInDB.getMonitorState() == null);

  }
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.