gokceni commented on a change in pull request #782: URL: https://github.com/apache/phoenix/pull/782#discussion_r428378817
########## File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java ########## @@ -617,6 +618,125 @@ public void testSplitIndex() throws Exception { } } + @Test + public void testDisableOutputLogging() throws Exception { + if (!mutable || transactional || useSnapshot || localIndex) { + return; + } + + String schemaName = generateUniqueName(); + String dataTableName = generateUniqueName(); + String dataTableFullName = SchemaUtil.getTableName(schemaName, dataTableName); + String indexTableName = generateUniqueName(); + String indexTableFullName = SchemaUtil.getTableName(schemaName, indexTableName); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + + try(Connection conn = DriverManager.getConnection(getUrl(), props)) { + String stmString1 = + "CREATE TABLE " + dataTableFullName + + " (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR, ZIP INTEGER) " + + tableDDLOptions; + conn.createStatement().execute(stmString1); + String upsertQuery = String.format("UPSERT INTO %s VALUES(?, ?, ?)", dataTableFullName); + PreparedStatement stmt1 = conn.prepareStatement(upsertQuery); + + // insert two rows + upsertRow(stmt1, 1); + upsertRow(stmt1, 2); + conn.commit(); + + //create ASYNC + String stmtString2 = + String.format( + "CREATE INDEX %s ON %s (LPAD(UPPER(NAME, 'en_US'),8,'x')||'_xyz') ASYNC ", + indexTableName, dataTableFullName); + conn.createStatement().execute(stmtString2); + conn.commit(); + + // run the index MR job as ONLY so the index doesn't get rebuilt. Should be 2 missing + //rows. We pass in --disable-logging BEFORE to silence the output logging to + // PHOENIX_INDEX_TOOL, since ONLY logs BEFORE the (non-existent in this case) + // rebuild + assertDisableLogging(conn, 0, IndexTool.IndexVerifyType.ONLY, + IndexTool.IndexDisableLoggingType.BEFORE, null, schemaName, dataTableName, indexTableName, + indexTableFullName, 0); + + //now check that disabling logging AFTER leaves only the BEFORE logs on a BOTH run + assertDisableLogging(conn, 2, IndexTool.IndexVerifyType.BOTH, + IndexTool.IndexDisableLoggingType.AFTER, + IndexVerificationOutputRepository.PHASE_BEFORE_VALUE, schemaName, + dataTableName, indexTableName, + indexTableFullName, 0); + + truncateTable(conn, + TableName.valueOf(IndexVerificationOutputRepository.OUTPUT_TABLE_NAME)); + truncateTable(conn, TableName.valueOf(indexTableFullName)); + + //now check that disabling logging BEFORE creates only the AFTER logs on a BOTH run + //the index tool run fails validation at the end because we suppressed the BEFORE logs + //which prevented the rebuild from working properly, but that's ok for this test. + assertDisableLogging(conn, 2, IndexTool.IndexVerifyType.BOTH, + IndexTool.IndexDisableLoggingType.BEFORE, + IndexVerificationOutputRepository.PHASE_AFTER_VALUE, schemaName, + dataTableName, indexTableName, + indexTableFullName, -1); + + truncateTable(conn, TableName.valueOf(IndexVerificationOutputRepository.OUTPUT_TABLE_NAME)); + truncateTable(conn, TableName.valueOf(indexTableFullName)); + + //now check that disabling logging BOTH creates no logs on a BOTH run + assertDisableLogging(conn, 0, IndexTool.IndexVerifyType.BOTH, + IndexTool.IndexDisableLoggingType.BOTH, + IndexVerificationOutputRepository.PHASE_AFTER_VALUE, schemaName, + dataTableName, indexTableName, + indexTableFullName, -1); + + } + } + + public void truncateTable(Connection conn, TableName tableName) throws SQLException, Review comment: Do you want to rename this as deleteAll? It doesn't call truncate as this name suggests ---------------------------------------------------------------- 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: us...@infra.apache.org