Skip to content

Commit

Permalink
[risk=low][no ticket] Can't get app usage row count when we don't pop…
Browse files Browse the repository at this point in the history
…ulate the table (#8978)
  • Loading branch information
jmthibault79 authored Dec 3, 2024
1 parent f14c19f commit ac2f956
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,10 @@ public int getTableRowCount(String tableName) {

@Override
public int getAppUsageRowCount(String tableName) {
if (!workbenchConfigProvider.get().reporting.exportTerraDataWarehouse) {
return 0;
}

var queryString =
"SELECT count(*) "
+ "FROM `"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
import com.google.common.collect.ImmutableSet;
import jakarta.persistence.EntityManager;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.time.Clock;
import java.time.Instant;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Handler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import java.util.logging.StreamHandler;
Expand Down Expand Up @@ -106,13 +104,12 @@ public void setup() {
.executeQuery(any(QueryJobConfiguration.class));

logCapturingStream = new ByteArrayOutputStream();
Handler[] handlers = LOGGER.getParent().getHandlers();
customLogHandler = new StreamHandler(logCapturingStream, new SimpleFormatter());
LOGGER.addHandler(customLogHandler);
}

@Test
public void testVerifyBatch_verified() throws Exception {
public void testVerifyBatch_verified() {
createTableEntries(ACTUAL_COUNT);
assertThat(
reportingVerificationService.verifyBatchesAndLog(
Expand All @@ -137,7 +134,7 @@ public void testVerifyBatch_verified() throws Exception {
}

@Test
public void testVerifyBatch_fail() throws Exception {
public void testVerifyBatch_fail() {
createTableEntries(ACTUAL_COUNT * 2);
assertThat(
reportingVerificationService.verifyBatchesAndLog(
Expand Down Expand Up @@ -177,7 +174,7 @@ private void createTableEntries(long count) {
}

/** Gets the captured log. */
private static String getTestCapturedLog() throws IOException {
private static String getTestCapturedLog() {
customLogHandler.flush();
return logCapturingStream.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public WorkbenchConfig workbenchConfig() {
final WorkbenchConfig workbenchConfig = WorkbenchConfig.createEmptyConfig();
workbenchConfig.reporting.dataset = "wb_reporting";
workbenchConfig.reporting.maxRowsPerInsert = 2;
workbenchConfig.reporting.exportTerraDataWarehouse = true;
workbenchConfig.server.projectId = "rw-wb-unit-test";
workbenchConfig.billing.accountId = WORKSPACE__BILLING_ACCOUNT_ID;
return workbenchConfig;
Expand Down

0 comments on commit ac2f956

Please sign in to comment.