/**
   * Constructor for benchmark instance. Configures VoltDB client and prints configuration.
   *
   * @param config Parsed & validated CLI options.
   */
  public AsyncBenchmark(KVConfig config) {
    this.config = config;

    ClientConfig clientConfig = new ClientConfig("", "", new StatusListener());

    if (config.autotune) {
      clientConfig.enableAutoTune();
      clientConfig.setAutoTuneTargetInternalLatency(config.latencytarget);
    } else {
      clientConfig.setMaxTransactionsPerSecond(config.ratelimit);
    }
    client = ClientFactory.createClient(clientConfig);

    periodicStatsContext = client.createStatsContext();
    fullStatsContext = client.createStatsContext();

    processor =
        new PayloadProcessor(
            config.keysize,
            config.minvaluesize,
            config.maxvaluesize,
            config.entropy,
            config.poolsize,
            config.usecompression);

    System.out.print(HORIZONTAL_RULE);
    System.out.println(" Command Line Configuration");
    System.out.println(HORIZONTAL_RULE);
    System.out.println(config.getConfigDumpString());
  }
 public void testAggregatesOnEmptyTable() throws IOException, ProcCallException {
   String[] aggs = {"count", "sum", "min", "max"};
   String[] tables = {"P1", "R1"};
   for (String table : tables) {
     Client client = getClient();
     for (int i = 0; i < aggs.length; ++i) {
       String query = String.format("select %s(%s.NUM) from %s", aggs[i], table, table);
       VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
       if (aggs[i].equals("count")) {
         assertEquals(0, results[0].asScalarLong());
       } else {
         final VoltTableRow row = results[0].fetchRow(0);
         row.get(0, results[0].getColumnType(0));
         if (!isHSQL()) {
           assertTrue(row.wasNull());
         }
       }
     }
     // Do avg separately since the column is a float and makes
     // asScalarLong() unhappy
     String query = String.format("select avg(%s.NUM) from %s", table, table);
     VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
     results[0].advanceRow();
     @SuppressWarnings("unused")
     final double value = ((Number) results[0].get(0, results[0].getColumnType(0))).doubleValue();
     if (!isHSQL()) {
       assertTrue(results[0].wasNull());
     }
   }
 }
  public void testCatalogUpdateAfterRejoin() throws Exception {
    System.out.println("testCatalogUpdateAfterRejoin");
    VoltProjectBuilder builder = getBuilderForTest();

    LocalCluster cluster = new LocalCluster("rejoin.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI);
    boolean success = cluster.compile(builder);
    assertTrue(success);
    MiscUtils.copyFile(
        builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("rejoin.xml"));

    try {
      cluster.startUp();

      for (int ii = 0; ii < 3; ii++) {
        cluster.shutDownSingleHost(1);
        Thread.sleep(1000);
        cluster.recoverOne(1, 0, "localhost");

        File newCatalog = new File(Configuration.getPathToCatalogForTest("rejoin.jar"));
        File deployment = new File(Configuration.getPathToCatalogForTest("rejoin.xml"));

        Client client = ClientFactory.createClient();
        client.createConnection("localhost");

        VoltTable[] results = client.updateApplicationCatalog(newCatalog, deployment).getResults();
        assertTrue(results.length == 1);
        client.close();
      }
    } finally {
      cluster.shutDown();
    }
  }
  public void testRejoinSysprocButFail() throws Exception {
    VoltProjectBuilder builder = getBuilderForTest();
    boolean success = builder.compile(Configuration.getPathToCatalogForTest("rejoin.jar"), 1, 1, 0);
    assertTrue(success);
    MiscUtils.copyFile(
        builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("rejoin.xml"));

    VoltDB.Configuration config = new VoltDB.Configuration();
    config.m_pathToCatalog = Configuration.getPathToCatalogForTest("rejoin.jar");
    config.m_pathToDeployment = Configuration.getPathToCatalogForTest("rejoin.xml");
    config.m_isRejoinTest = true;
    ServerThread localServer = new ServerThread(config);

    localServer.start();
    localServer.waitForInitialization();

    Client client = ClientFactory.createClient();
    client.createConnection("localhost");

    SyncCallback scb = new SyncCallback();
    success = false;
    while (!success) {
      success = client.callProcedure(scb, "@Rejoin", "localhost", config.m_internalPort + 1);
      if (!success) Thread.sleep(100);
    }

    scb.waitForResponse();
    ClientResponse response = scb.getResponse();
    assertTrue(response.getStatusString().contains("Unable to find down node"));

    client.close();
    localServer.shutdown();
    localServer.join();
  }
 public void testGiantDelete() throws IOException, ProcCallException {
   /*
    * Times out with valgrind
    */
   if (isValgrind()) {
     return;
   }
   Client client = getClient(1000 * 60 * 10);
   for (int i = 0; i < 100; i++) {
     client.callProcedure("InsertBatch", 200000, 0, i * 200000);
   }
   try {
     client.callProcedure("Delete");
   } catch (ProcCallException pce) {
     pce.printStackTrace();
     fail("Expected to be able to delete large batch but failed");
   }
   // Test repeatability
   for (int i = 0; i < 100; i++) {
     client.callProcedure("InsertBatch", 200000, 0, i * 200000);
   }
   try {
     client.callProcedure("Delete");
   } catch (ProcCallException pce) {
     pce.printStackTrace();
     fail("Expected to be able to delete large batch but failed");
   }
 }
  /**
   * add 20 shuffled rows
   *
   * @throws InterruptedException
   */
  private void load(Client client)
      throws NoConnectionsException, ProcCallException, IOException, InterruptedException {
    int pkey = 0;
    a_int.clear();
    a_inline_str.clear();
    a_pool_str.clear();

    boolean async = true;

    for (int i = 0; i < 20; i++) {
      a_int.add(i);
      a_inline_str.add("a_" + i);
      a_pool_str.add(simpleString + i);
    }

    Collections.shuffle(a_int);
    Collections.shuffle(a_inline_str);
    Collections.shuffle(a_pool_str);

    for (int i = 0; i < 20; i++) {
      SyncCallback cb = new SyncCallback();
      client.callProcedure(
          cb, "InsertO1", pkey, a_int.get(i), a_inline_str.get(i), a_pool_str.get(i));

      if (!async) {
        cb.waitForResponse();
        VoltTable vt = cb.getResponse().getResults()[0];
        assertTrue(vt.getRowCount() == 1);
      }
      pkey = pkey + 1;
    }

    client.drain();
  }
Exemple #7
0
 /**
  * Get connection to servers in cluster.
  *
  * @param config
  * @param servers
  * @return client
  * @throws Exception
  */
 public static Client getClient(ClientConfig config, String[] servers, int port) throws Exception {
   final Client client = ClientFactory.createClient(config);
   for (String server : servers) {
     client.createConnection(server.trim(), port);
   }
   return client;
 }
  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);
  }
 public void testInvalidCalls() throws Exception {
   System.out.println("\n\nTESTING INVALID CALLS\n\n\n");
   Client client = getFullyConnectedClient();
   //
   // invalid selector
   //
   try {
     // No selector at all.
     client.callProcedure("@Statistics");
     fail();
   } catch (ProcCallException ex) {
     // All badness gets turned into ProcCallExceptions, so we need
     // to check specifically for this error, otherwise things that
     // crash the cluster also turn into ProcCallExceptions and don't
     // trigger failure (ENG-2347)
     assertEquals(
         "Incorrect number of arguments to @Statistics (expects 2, received 0)", ex.getMessage());
   }
   try {
     // extra stuff
     client.callProcedure("@Statistics", "table", 0, "OHHAI");
     fail();
   } catch (ProcCallException ex) {
     assertEquals(
         "Incorrect number of arguments to @Statistics (expects 2, received 3)", ex.getMessage());
   }
   try {
     // Invalid selector
     client.callProcedure("@Statistics", "garbage", 0);
     fail();
   } catch (ProcCallException ex) {
   }
 }
  public void exitOnError(String err) {
    prt(err);

    // cancel periodic stats printing
    timer.cancel();

    // block until all outstanding txns return
    try {
      client.drain();
    } catch (NoConnectionsException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // print the summary results
    try {
      printResults();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // close down the client connections
    try {
      client.close();
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Exemple #11
0
 public Client getClient(long timeout, ClientAuthHashScheme scheme, boolean useAdmin)
     throws IOException {
   final Random r = new Random();
   String listener = null;
   if (useAdmin) {
     listener = m_config.getAdminAddress(r.nextInt(m_config.getListenerCount()));
   } else {
     listener = m_config.getListenerAddress(r.nextInt(m_config.getListenerCount()));
   }
   ClientConfig config = new ClientConfigForTest(m_username, m_password, scheme);
   config.setConnectionResponseTimeout(timeout);
   config.setProcedureCallTimeout(timeout);
   final Client client = ClientFactory.createClient(config);
   // Use the port generated by LocalCluster if applicable
   try {
     client.createConnection(listener);
   }
   // retry once
   catch (ConnectException e) {
     if (useAdmin) {
       listener = m_config.getAdminAddress(r.nextInt(m_config.getListenerCount()));
     } else {
       listener = m_config.getListenerAddress(r.nextInt(m_config.getListenerCount()));
     }
     client.createConnection(listener);
   }
   m_clients.add(client);
   return client;
 }
  public static void main(String[] args) throws Exception {
    VoltDB.setDefaultTimezone();

    config = new SchemaChangeConfig();
    config.parse("SchemaChangeClient", args);

    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setProcedureCallTimeout(30 * 60 * 1000); // 30 min
    client = ClientFactory.createClient(clientConfig);
    String[] servers = config.servers.split(",");
    for (String server : servers) {
      server = server.trim();
      client.createConnection(server);
    }

    // get the topo
    topo = getCluterTopology(client);

    // kick this off with a random schema
    VoltTable t = catalogChange(null, true);

    for (int i = 0; i < 50; i++) {
      // make sure the table is full and mess around with it
      loadTable(t);

      for (int j = 0; j < 50; j++) {
        String tableName = TableHelper.getTableName(t);

        // deterministically sample some rows
        VoltTable preT = sample(t);
        // System.out.printf("First sample:\n%s\n", preT.toFormattedString());

        // move to an entirely new table or migrated schema
        t = catalogChange(t, (j == 0) && (rand.nextInt(5) == 0));

        // if the table has been migrated, check the data
        if (TableHelper.getTableName(t).equals(tableName)) {
          VoltTable guessT = t.clone(4096 * 1024);
          // System.out.printf("Empty clone:\n%s\n", guessT.toFormattedString());

          TableHelper.migrateTable(preT, guessT);
          // System.out.printf("Java migration:\n%s\n", guessT.toFormattedString());

          // deterministically sample the same rows
          VoltTable postT = sample(t);
          // System.out.printf("Second sample:\n%s\n", postT.toFormattedString());

          postT.resetRowPosition();
          preT.resetRowPosition();
          StringBuilder sb = new StringBuilder();
          if (!TableHelper.deepEqualsWithErrorMsg(postT, guessT, sb)) {
            System.err.println(sb.toString());
            assert (false);
          }
        }
      }
    }

    client.close();
  }
  public void validateRankFunction(String sql, int expectedCol) throws Exception {
    Client client = getClient();

    long input[][] = expected.clone();
    shuffleArrayOfLongs(input);
    ClientResponse cr;
    VoltTable vt;

    cr = client.callProcedure("@AdHoc", "TRUNCATE TABLE T");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    for (long[] row : input) {
      cr = client.callProcedure("T.insert", row[colA], row[colB], row[colC]);
      assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    }
    cr = client.callProcedure("@AdHoc", sql);
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    vt = cr.getResults()[0];
    for (int rowIdx = 0; vt.advanceRow(); rowIdx += 1) {
      String msg = String.format("Row %d:", rowIdx);
      assertEquals(msg, expected[rowIdx][colA], vt.getLong(0));
      assertEquals(msg, expected[rowIdx][colB], vt.getLong(1));
      assertEquals(msg, expected[rowIdx][colC], vt.getLong(2));
      assertEquals(msg, expected[rowIdx][expectedCol], vt.getLong(3));
    }
  }
  public void testExplain() throws IOException, ProcCallException {
    Client client = getClient();
    VoltTable vt = null;

    String[] strs = {
      "SELECT COUNT(*) FROM T1 order by A_INT", "SELECT COUNT(*) FROM T1 order by A_INT"
    };

    vt = client.callProcedure("@Explain", (Object[]) strs).getResults()[0];
    while (vt.advanceRow()) {
      System.out.println(vt);
      String plan = vt.getString("EXEcution_PlaN");
      assertTrue(plan.contains("RETURN RESULTS TO STORED PROCEDURE"));
      // Validate bypass of no-op sort on single-row result.
      assertFalse(plan.contains("ORDER BY (SORT)"));
      assertTrue(plan.contains("TABLE COUNT"));
    }

    // test the index count node
    vt = client.callProcedure("@Explain", "SELECT COUNT(*) FROM t3 where I3 < 100").getResults()[0];
    while (vt.advanceRow()) {
      System.out.println(vt);
      String plan = vt.getString(0);
      assertTrue(plan.contains("INDEX COUNT"));
    }

    // test expression index usage
    vt = client.callProcedure("@Explain", "SELECT * FROM t3 where I3 + I4 < 100").getResults()[0];
    while (vt.advanceRow()) {
      System.out.println(vt);
      String plan = vt.getString(0);
      assertTrue(plan.contains("INDEX SCAN"));
    }
  }
 public void closeClient() {
   // cancel periodic stats printing
   try {
     timer.cancel();
   } catch (Exception e) {
     String msg = "In closeOldClient exception = '" + e.getMessage() + "'.";
     prt(msg);
   }
   try {
     client.drain();
   } catch (NoConnectionsException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (InterruptedException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   // close down the client connections
   try {
     client.close();
   } catch (InterruptedException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
  public void testRankWithTimestamp() throws Exception {
    Client client = getClient();

    long baseTime = TimestampType.millisFromJDBCformat("1953-06-10 00:00:00");
    long input[][] = expected.clone();
    shuffleArrayOfLongs(input);
    ClientResponse cr;
    VoltTable vt;
    for (long[] row : input) {
      cr =
          client.callProcedure(
              "T_TIMESTAMP.insert",
              row[colA],
              row[colB],
              new TimestampType(baseTime + row[colB] * 1000));
      assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    }
    String sql =
        "select A, B, C, rank() over (partition by A order by C) as R from T_TIMESTAMP ORDER BY A, B, C, R;";
    cr = client.callProcedure("@AdHoc", sql);
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    vt = cr.getResults()[0];
    assertEquals(expected.length, vt.getRowCount());
    for (int rowIdx = 0; vt.advanceRow(); rowIdx += 1) {
      String msg = String.format("Row %d:", rowIdx);
      assertEquals(msg, expected[rowIdx][colA], vt.getLong(0));
      assertEquals(msg, expected[rowIdx][colB], vt.getLong(1));
      assertEquals(msg, baseTime + expected[rowIdx][colB] * 1000, vt.getTimestampAsLong(2));
      assertEquals(msg, expected[rowIdx][colR_A], vt.getLong(3));
    }
  }
  public void readyToExit() {
    // block until all outstanding txns return
    try {
      client.drain();
    } catch (NoConnectionsException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    if (config.checkdata) summary4qa();

    try {
      client.drain();
    } catch (NoConnectionsException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // close down the client connections
    try {
      client.close();
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    System.exit(0);
  }
  /**
   * Check the result of a query that has only an OFFSET and no LIMIT clause. This is done by
   * executing the query with and without the offset clause, and then skipping past the offset rows
   * in the expected table here on the client side.
   */
  private static void doOffsetAndCheck(Client client, String stmt)
      throws IOException, InterruptedException, ProcCallException {
    String stmtNoOffset = stmt.substring(0, stmt.indexOf("OFFSET"));
    VoltTable expectedTable = client.callProcedure("@AdHoc", stmtNoOffset).getResults()[0];
    int rowCountBeforeOffset = expectedTable.getRowCount();

    int[] offsets = {0, 1, 5, 10, 11, 15};
    for (int offset : offsets) {
      VoltTable actualTable = client.callProcedure("@AdHoc", stmt, offset).getResults()[0];
      int expectedRowCount = Math.max(rowCountBeforeOffset - offset, 0);
      assertEquals(
          "Actual table has wrong number of rows: ", expectedRowCount, actualTable.getRowCount());
      if (actualTable.getRowCount() == 0) continue;

      // non-empty result.
      // Advance expected table past offset
      // then compare what's left.
      actualTable.resetRowPosition();
      for (int i = 0; i < offset; ++i) expectedTable.advanceRow();

      while (actualTable.advanceRow() && expectedTable.advanceRow()) {
        assertEquals(expectedTable.getLong(0), actualTable.getLong(0));
        assertEquals(expectedTable.getLong(1), actualTable.getLong(1));
      }
    }
  }
 // Make sure date and random number APIs return deterministic results
 public void testDeterminismInAPI() throws IOException, ProcCallException {
   Client client = getClient();
   // should fail if both copies don't return the same result or if an
   // exception is thrown
   VoltTable[] results = client.callProcedure("EvilDeterminism", 1).getResults();
   assertEquals(1, results[0].getRowCount());
 }
  public void testIOStatistics() throws Exception {
    System.out.println("\n\nTESTING IO STATS\n\n\n");
    Client client = getFullyConnectedClient();

    // Based on doc, not code
    // HOST_ID, SITE_ID, and PARTITION_ID all differ.  Fixed to match
    // reality so tests would pass, but, ugh.
    ColumnInfo[] expectedSchema = new ColumnInfo[9];
    expectedSchema[0] = new ColumnInfo("TIMESTAMP", VoltType.BIGINT);
    expectedSchema[1] = new ColumnInfo("HOST_ID", VoltType.INTEGER);
    expectedSchema[2] = new ColumnInfo("HOSTNAME", VoltType.STRING);
    expectedSchema[3] = new ColumnInfo("CONNECTION_ID", VoltType.BIGINT);
    expectedSchema[4] = new ColumnInfo("CONNECTION_HOSTNAME", VoltType.STRING);
    expectedSchema[5] = new ColumnInfo("BYTES_READ", VoltType.BIGINT);
    expectedSchema[6] = new ColumnInfo("MESSAGES_READ", VoltType.BIGINT);
    expectedSchema[7] = new ColumnInfo("BYTES_WRITTEN", VoltType.BIGINT);
    expectedSchema[8] = new ColumnInfo("MESSAGES_WRITTEN", VoltType.BIGINT);
    VoltTable expectedTable = new VoltTable(expectedSchema);

    VoltTable[] results = null;
    //
    // iostats
    //
    results = client.callProcedure("@Statistics", "iostats", 0).getResults();
    System.out.println("Test iostats table: " + results[0].toString());
    // one aggregate table returned
    assertEquals(1, results.length);
    validateSchema(results[0], expectedTable);
  }
  public void testStarvationStatistics() throws Exception {
    System.out.println("\n\nTESTING STARVATION STATS\n\n\n");
    Client client = getFullyConnectedClient();

    ColumnInfo[] expectedSchema = new ColumnInfo[10];
    expectedSchema[0] = new ColumnInfo("TIMESTAMP", VoltType.BIGINT);
    expectedSchema[1] = new ColumnInfo("HOST_ID", VoltType.INTEGER);
    expectedSchema[2] = new ColumnInfo("HOSTNAME", VoltType.STRING);
    expectedSchema[3] = new ColumnInfo("SITE_ID", VoltType.INTEGER);
    expectedSchema[4] = new ColumnInfo("COUNT", VoltType.BIGINT);
    expectedSchema[5] = new ColumnInfo("PERCENT", VoltType.FLOAT);
    expectedSchema[6] = new ColumnInfo("AVG", VoltType.BIGINT);
    expectedSchema[7] = new ColumnInfo("MIN", VoltType.BIGINT);
    expectedSchema[8] = new ColumnInfo("MAX", VoltType.BIGINT);
    expectedSchema[9] = new ColumnInfo("STDDEV", VoltType.BIGINT);
    VoltTable expectedTable = new VoltTable(expectedSchema);

    VoltTable[] results = null;
    //
    // STARVATION
    //
    results = client.callProcedure("@Statistics", "STARVATION", 0).getResults();
    // one aggregate table returned
    assertEquals(1, results.length);
    System.out.println("Test STARVATION table: " + results[0].toString());
    validateSchema(results[0], expectedTable);
    // One row per site, we don't use HSID though, so hard to do straightforward
    // per-site unique check.  Finesse it.
    // We also get starvation stats for the MPI, so we need to add a site per host.
    assertEquals(HOSTS * (SITES + 1), results[0].getRowCount());
    results[0].advanceRow();
    Map<String, String> columnTargets = new HashMap<String, String>();
    columnTargets.put("HOSTNAME", results[0].getString("HOSTNAME"));
    validateRowSeenAtAllHosts(results[0], columnTargets, false);
  }
 // verify correct behavior on invalid command
 public void testProfCtlInvalidCommand() throws Exception {
   Client client = getClient();
   ClientResponse resp = client.callProcedure("@ProfCtl", "MakeAPony");
   @SuppressWarnings("unused")
   VoltTable vt = resp.getResults()[0];
   assertTrue(true);
 }
 // Pretty lame test but at least invoke the procedure.
 // "@Quiesce" is used more meaningfully in TestExportSuite.
 public void testQuiesce() throws IOException, ProcCallException {
   Client client = getClient();
   VoltTable results[] = client.callProcedure("@Quiesce").getResults();
   assertEquals(1, results.length);
   results[0].advanceRow();
   assertEquals(results[0].get(0, VoltType.BIGINT), new Long(0));
 }
 public void testUpdateLogging() throws Exception {
   Client client = getClient();
   VoltTable results[] = null;
   results = client.callProcedure("@UpdateLogging", m_loggingConfig).getResults();
   for (VoltTable result : results) {
     assertEquals(0, result.asScalarLong());
   }
 }
 private void initUniqueTable(Client client)
     throws NoConnectionsException, IOException, ProcCallException {
   client.callProcedure("tu.insert", 10, 2);
   client.callProcedure("tu.insert", 20, 1);
   client.callProcedure("tu.insert", 30, 1);
   client.callProcedure("tu.insert", 40, 3);
   client.callProcedure("tu.insert", 50, 1);
 }
 public void testStatistics_iostats() throws Exception {
   Client client = getClient();
   VoltTable results[] = null;
   results = client.callProcedure("@Statistics", "iostats", 0).getResults();
   // one aggregate table returned
   assertTrue(results.length == 1);
   System.out.println("Test iostats table: " + results[0].toString());
 }
  public void testENG1808() throws IOException, ProcCallException {
    Client client = this.getClient();

    client.callProcedure("A.insert", 1, 1);

    VoltTable result = client.callProcedure("@AdHoc", "select I from A limit 0").getResults()[0];

    assertEquals(0, result.getRowCount());
  }
 public void testMultiPartitionInsert() throws IOException, ProcCallException {
   Client client = getClient();
   VoltTable[] results =
       client.callProcedure("InsertMultiPart", 1, "desc", 100, 14.5).getResults();
   assertEquals(1, results[0].asScalarLong());
   results = client.callProcedure("SelectMultiPart").getResults();
   System.out.println(results[0].toString());
   assertEquals(1, results[0].getRowCount());
 }
Exemple #29
0
  public void test_Interface(
      String[] my_options, String[] my_data, int invalidLineCnt, int validLineCnt)
      throws Exception {
    try {
      BufferedWriter out_csv = new BufferedWriter(new FileWriter(path_csv));
      for (String aMy_data : my_data) {
        out_csv.write(aMy_data + "\n");
      }
      out_csv.flush();
      out_csv.close();
    } catch (Exception e) {
      System.err.print(e.getMessage());
    }

    CSVLoader.testMode = true;
    CSVLoader.main(my_options);
    // do the test

    VoltTable modCount;
    modCount = client.callProcedure("@AdHoc", "SELECT * FROM BLAH;").getResults()[0];
    System.out.println("data inserted to table BLAH:\n" + modCount);
    int rowct = modCount.getRowCount();

    // Call validate partitioning to check if we are good.
    VoltTable valTable;
    valTable = client.callProcedure("@ValidatePartitioning", null, null).getResults()[0];
    System.out.println("Validate for BLAH:\n" + valTable);
    while (valTable.advanceRow()) {
      long miscnt = valTable.getLong("MISPARTITIONED_ROWS");
      assertEquals(miscnt, 0);
    }

    BufferedReader csvreport = new BufferedReader(new FileReader(CSVLoader.pathReportfile));
    int lineCount = 0;
    String line;
    String promptMsg = "Number of rows successfully inserted:";
    String promptFailMsg = "Number of rows that could not be inserted:";
    int invalidlinecnt = 0;

    while ((line = csvreport.readLine()) != null) {
      if (line.startsWith(promptMsg)) {
        String num = line.substring(promptMsg.length());
        lineCount = Integer.parseInt(num.replaceAll("\\s", ""));
      }
      if (line.startsWith(promptFailMsg)) {
        String num = line.substring(promptFailMsg.length());
        invalidlinecnt = Integer.parseInt(num.replaceAll("\\s", ""));
      }
    }
    csvreport.close();
    System.out.println(String.format("The rows infected: (%d,%s)", lineCount, rowct));
    assertEquals(lineCount, rowct);
    // assert validLineCnt specified equals the successfully inserted lineCount
    assertEquals(validLineCnt, lineCount);
    assertEquals(invalidLineCnt, invalidlinecnt);
  }
 public void testInvalidProcedureName() throws IOException {
   Client client = getClient();
   try {
     client.callProcedure("@SomeInvalidSysProcName", "1", "2");
   } catch (Exception e2) {
     assertEquals("Procedure @SomeInvalidSysProcName was not found", e2.getMessage());
     return;
   }
   fail("Expected exception.");
 }