Exemple #1
0
  protected void assertTablesAreEqual(String prefix, VoltTable expectedRows, VoltTable actualRows) {
    assertEquals(
        prefix
            + "column count mismatch.  Expected: "
            + expectedRows.getColumnCount()
            + " actual: "
            + actualRows.getColumnCount(),
        expectedRows.getColumnCount(),
        actualRows.getColumnCount());

    int i = 0;
    while (expectedRows.advanceRow()) {
      assertTrue(
          prefix + "too few actual rows; expected more than " + (i + 1), actualRows.advanceRow());

      for (int j = 0; j < actualRows.getColumnCount(); j++) {
        String columnName = actualRows.getColumnName(j);
        String colPrefix = prefix + "row " + i + ": column: " + columnName + ": ";
        VoltType actualTy = actualRows.getColumnType(j);
        VoltType expectedTy = expectedRows.getColumnType(j);
        assertEquals(colPrefix + "type mismatch", expectedTy, actualTy);

        Object expectedObj = expectedRows.get(j, expectedTy);
        Object actualObj = expectedRows.get(j, actualTy);
        assertEquals(
            colPrefix + "values not equal: expected: " + expectedObj + ", actual: " + actualObj,
            expectedObj,
            actualObj);
      }

      i++;
    }
    assertFalse(prefix + "too many actual rows; expected only " + i, actualRows.advanceRow());
  }
  public void testStatistics_Procedure() throws Exception {
    Client client = getClient();
    VoltTable results[] = null;
    // 3 seconds translates to 3 billion nanos, which overflows internal
    // values (ENG-1039)
    results = client.callProcedure("GoSleep", 3000, 0, null).getResults();
    results = client.callProcedure("@Statistics", "procedure", 0).getResults();
    // one aggregate table returned
    assertTrue(results.length == 1);
    System.out.println("Test procedures table: " + results[0].toString());

    VoltTable stats = results[0];
    stats.advanceRow();
    // Check for overflow
    long min_time = (Long) stats.get("MIN_EXECUTION_TIME", VoltType.BIGINT);
    long max_time = (Long) stats.get("MAX_EXECUTION_TIME", VoltType.BIGINT);
    long avg_time = (Long) stats.get("AVG_EXECUTION_TIME", VoltType.BIGINT);
    assertTrue("Failed MIN_EXECUTION_TIME > 0, value was: " + min_time, min_time > 0);
    assertTrue("Failed MAX_EXECUTION_TIME > 0, value was: " + max_time, max_time > 0);
    assertTrue("Failed AVG_EXECUTION_TIME > 0, value was: " + avg_time, avg_time > 0);

    // check for reasonable values
    assertTrue(
        "Failed MIN_EXECUTION_TIME > 2,400,000,000ns, value was: " + min_time,
        min_time > 2400000000L);
    assertTrue(
        "Failed MAX_EXECUTION_TIME > 2,400,000,000ns, value was: " + max_time,
        max_time > 2400000000L);
    assertTrue(
        "Failed AVG_EXECUTION_TIME > 2,400,000,000ns, value was: " + avg_time,
        avg_time > 2400000000L);
  }