gjacoby126 commented on a change in pull request #499: Phoenix-5272 ALTER INDEX
REBUILD ALL
URL: https://github.com/apache/phoenix/pull/499#discussion_r288316955
##########
File path:
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
##########
@@ -610,7 +615,86 @@ public void testAsyncRebuildTimestamp() throws Exception {
"order by table_name" );
assertFalse(rs.next());
}
-
+
+ @Test
+ public void testAsyncRebuildAll() throws Exception {
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ conn.setAutoCommit(true);
+ String testTable = generateUniqueName();
+
+ String ddl = "create table " + testTable + " (k varchar primary
key, v4 varchar)";
+ Statement stmt = conn.createStatement();
+ stmt.execute(ddl);
+
+ PreparedStatement upsertStmt = conn.prepareStatement("UPSERT INTO
" + testTable + " VALUES(?, ?)");
+ upsertStmt.setString(1, "key1");
+ upsertStmt.setString(2, "val1");
+ upsertStmt.execute();
+
+ String indexName = "R_ASYNCIND_" + generateUniqueName();
+ ddl = "CREATE INDEX " + indexName + " ON " + testTable + " (k,
v4)";
+ stmt.execute(ddl);
+
+ // Check that index value is same as table
+ String val = getIndexValue(conn, indexName, 2);
+ assertEquals("val1", val);
+
+ // Update index value, check that index value is still not updated
+ conn.createStatement()
+ .execute("ALTER INDEX " + indexName + " ON " + testTable +
" DISABLE");
+ upsertStmt = conn.prepareStatement("UPSERT INTO " + testTable + "
VALUES(?, ?)");
+ upsertStmt.setString(1, "key1");
+ upsertStmt.setString(2, "val2");
+ upsertStmt.execute();
+ conn.commit();
+
+ val = getIndexValue(conn, indexName, 2);
+ assertEquals("val1", val);
+
+ // Add extra row to Index
+ upsertStmt = conn.prepareStatement("UPSERT INTO " + indexName + "
VALUES(?, ?)");
+ upsertStmt.setString(1, "key3");
+ upsertStmt.setString(2, "val3");
+ upsertStmt.execute();
+
+ conn.createStatement().execute(
+ "ALTER INDEX " + indexName + " ON " + testTable + "
REBUILD ALL ASYNC");
+
+ String
+ queryTaskTable =
+ "SELECT * FROM " +
SchemaUtil.getTableName(SYSTEM_CATALOG_SCHEMA,
+ PhoenixDatabaseMetaData.SYSTEM_TASK_TABLE);
+ ResultSet rs = conn.createStatement().executeQuery(queryTaskTable);
Review comment:
Miniclusters can be shared between test suites unless you specifically
request otherwise, which this test suite doesn't seem to do (it's not
subclassing one of the OwnCluster suites). Since other test suites can put
tasks in the table, it would be good to not assume that your row is alone.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services