Skip to content

Commit

Permalink
[tools] add 'kudu table scan'
Browse files Browse the repository at this point in the history
  • Loading branch information
laiyingchun authored and acelyc111 committed Jan 5, 2019
1 parent 678dbac commit 0148894
Show file tree
Hide file tree
Showing 2 changed files with 390 additions and 9 deletions.
28 changes: 28 additions & 0 deletions src/kudu/tools/kudu-tool-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ TEST_F(ToolTest, TestModeHelp) {
"rename_table.*Rename a table",
"rename_column.*Rename a column",
"list.*List tables",
"scan.*Scan rows from a table",
};
NO_FATALS(RunTestHelp("table", kTableModeRegexes));
}
Expand Down Expand Up @@ -2130,6 +2131,7 @@ TEST_F(ToolTest, TestMasterList) {
// (2)rename a table
// (3)rename a column
// (4)list tables
// (5)scan a table
TEST_F(ToolTest, TestDeleteTable) {
NO_FATALS(StartExternalMiniCluster());
shared_ptr<KuduClient> client;
Expand Down Expand Up @@ -2311,6 +2313,32 @@ TEST_F(ToolTest, TestListTables) {
}
}

TEST_F(ToolTest, TestScanTable) {
NO_FATALS(StartExternalMiniCluster());
shared_ptr<KuduClient> client;
ASSERT_OK(cluster_->CreateClient(nullptr, &client));
string master_addr = cluster_->master()->bound_rpc_addr().ToString();

const string& kTableName = "kudu.table.scan";

// Create the src table and write some data to it.
TestWorkload ww(cluster_.get());
ww.set_table_name(kTableName);
ww.set_num_replicas(1);
ww.set_write_pattern(TestWorkload::INSERT_SEQUENTIAL_ROWS);
ww.Setup();
ww.Start();
ASSERT_EVENTUALLY([&](){
ASSERT_GE(ww.rows_inserted(), 10000);
});
ww.StopAndJoin();

string errout;
NO_FATALS((RunActionStderrString(
Substitute("table scan $0 $1", master_addr, kTableName), &errout)));
ASSERT_STR_CONTAINS(errout, Substitute("Total count: $0", ww.rows_inserted()));
}

Status CreateLegacyHmsTable(HmsClient* client,
const string& hms_database_name,
const string& hms_table_name,
Expand Down
Loading

0 comments on commit 0148894

Please sign in to comment.