Ejemplo n.º 1
0
  /**
   * Starts the server going for these tests.
   *
   * @throws Exception If problems occur setting up the server.
   */
  @BeforeClass
  public static void setupServer() throws Exception {
    ParallelStressTest.server = Server.newTestInstance();

    ParallelStressTest.adminEmail = server.getServerProperties().get(ADMIN_EMAIL_KEY);
    ParallelStressTest.adminPassword = server.getServerProperties().get(ADMIN_PASSWORD_KEY);

    ParallelStressTest.manager = (DbManager) server.getContext().getAttributes().get("DbManager");
    String adminUserUri = manager.getUser(adminEmail).toUri(server);
    System.out.print("Creating test data...");
    ParallelStressTest.START_TIMESTAMP = Tstamp.makeTimestamp("2010-01-08T00:00:00.000-10:00");
    ParallelStressTest.END_TIMESTAMP = Tstamp.makeTimestamp("2010-02-08T00:00:00.000-10:00");

    SubSources subSources = new SubSources();
    for (int i = 0; i < NUM_SOURCES; i++) {
      Source source = new Source(sourceNames[i], adminUserUri, true);
      source.addProperty(new Property(Source.SUPPORTS_ENERGY_COUNTERS, "true"));
      sources[i] = source;
      sourceURIs[i] = source.toUri(server);
      subSources.getHref().add(sourceURIs[i]);
      ParallelStressTest.manager.storeSource(source);
    }
    ParallelStressTest.virtualSource =
        new Source(source11Name, adminUserUri, true, true, "", "", "", null, subSources);
    ParallelStressTest.manager.storeSource(virtualSource);

    Date testStart = new Date();
    parallelLoad(TEST_CLIENTS, START_TIMESTAMP, END_TIMESTAMP, 15);
    Date testEnd = new Date();
    double msElapsed = testEnd.getTime() - testStart.getTime();
    System.out.format("Time to insert data: %.1f ms%n", msElapsed);
  }