Skip to content

Commit 6cfd1be

Browse files
improve logging in MsSQLTestDatabase
1 parent 6102af1 commit 6cfd1be

File tree

1 file changed

+10
-9
lines changed
  • airbyte-integrations/connectors/source-mssql/src/testFixtures/java/io/airbyte/integrations/source/mssql

1 file changed

+10
-9
lines changed

airbyte-integrations/connectors/source-mssql/src/testFixtures/java/io/airbyte/integrations/source/mssql/MsSQLTestDatabase.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ static public MsSQLTestDatabase in(final BaseImage imageName, final ContainerMod
6969

7070
public MsSQLTestDatabase(final MSSQLServerContainer<?> container) {
7171
super(container);
72+
LOGGER.info("SGX creating new database. databaseId=" + this.databaseId + ", databaseName=" + getDatabaseName());
7273
}
7374

7475
public MsSQLTestDatabase withCdc() {
@@ -104,39 +105,39 @@ public MsSQLTestDatabase withShortenedCapturePollingInterval() {
104105

105106
private void waitForAgentState(final boolean running) {
106107
final String expectedValue = running ? "Running." : "Stopped.";
107-
LOGGER.debug("Waiting for SQLServerAgent state to change to '{}'.", expectedValue);
108+
LOGGER.info(formatLogLine("Waiting for SQLServerAgent state to change to '{}'."), expectedValue);
108109
for (int i = 0; i < MAX_RETRIES; i++) {
109110
try {
110111
final var r = query(ctx -> ctx.fetch("EXEC master.dbo.xp_servicecontrol 'QueryState', N'SQLServerAGENT';").get(0));
111112
if (expectedValue.equalsIgnoreCase(r.getValue(0).toString())) {
112-
LOGGER.debug("SQLServerAgent state is '{}', as expected.", expectedValue);
113+
LOGGER.info(formatLogLine("SQLServerAgent state is '{}', as expected."), expectedValue);
113114
return;
114115
}
115-
LOGGER.debug("Retrying, SQLServerAgent state {} does not match expected '{}'.", r, expectedValue);
116+
LOGGER.info(formatLogLine("Retrying, SQLServerAgent state {} does not match expected '{}'."), r, expectedValue);
116117
} catch (final SQLException e) {
117-
LOGGER.debug("Retrying agent state query after catching exception {}.", e.getMessage());
118+
LOGGER.info(formatLogLine("Retrying agent state query after catching exception {}."), e.getMessage());
118119
}
119120
try {
120121
Thread.sleep(1_000); // Wait one second between retries.
121122
} catch (final InterruptedException e) {
122123
throw new RuntimeException(e);
123124
}
124125
}
125-
throw new RuntimeException("Exhausted retry attempts while polling for agent state");
126+
throw new RuntimeException(formatLogLine("Exhausted retry attempts while polling for agent state"));
126127
}
127128

128129
public MsSQLTestDatabase withWaitUntilMaxLsnAvailable() {
129-
LOGGER.debug("Waiting for max LSN to become available for database {}.", getDatabaseName());
130+
LOGGER.info(formatLogLine("Waiting for max LSN to become available for database {}."), getDatabaseName());
130131
for (int i = 0; i < MAX_RETRIES; i++) {
131132
try {
132133
final var maxLSN = query(ctx -> ctx.fetch("SELECT sys.fn_cdc_get_max_lsn();").get(0).get(0, byte[].class));
133134
if (maxLSN != null) {
134-
LOGGER.debug("Max LSN available for database {}: {}", getDatabaseName(), Lsn.valueOf(maxLSN));
135+
LOGGER.info(formatLogLine("Max LSN available for database {}: {}"), getDatabaseName(), Lsn.valueOf(maxLSN));
135136
return self();
136137
}
137-
LOGGER.debug("Retrying, max LSN still not available for database {}.", getDatabaseName());
138+
LOGGER.info(formatLogLine("Retrying, max LSN still not available for database {}."), getDatabaseName());
138139
} catch (final SQLException e) {
139-
LOGGER.warn("Retrying max LSN query after catching exception {}", e.getMessage());
140+
LOGGER.info(formatLogLine("Retrying max LSN query after catching exception {}"), e.getMessage());
140141
}
141142
try {
142143
Thread.sleep(1_000); // Wait one second between retries.

0 commit comments

Comments
 (0)