Skip to content

Commit

Permalink
Do not hide unexpected errors in the check connection (#13903)
Browse files Browse the repository at this point in the history
* Do not hide unexpected errors in the check connection

* Fix test
  • Loading branch information
benmoriceau authored Jun 17, 2022
1 parent 9c1fbea commit 74d16cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import io.airbyte.protocol.models.AirbyteConnectionStatus;
import io.airbyte.protocol.models.AirbyteMessage;
import io.airbyte.protocol.models.AirbyteMessage.Type;
import io.airbyte.workers.*;
import io.airbyte.workers.WorkerConfigs;
import io.airbyte.workers.WorkerConstants;
import io.airbyte.workers.WorkerUtils;
import io.airbyte.workers.exception.WorkerException;
import io.airbyte.workers.internal.AirbyteStreamFactory;
import io.airbyte.workers.internal.DefaultAirbyteStreamFactory;
Expand Down Expand Up @@ -79,7 +81,7 @@ public StandardCheckConnectionOutput run(final StandardCheckConnectionInput inpu
LOGGER.debug("Check connection job received output: {}", output);
return output;
} else {
String message = String.format("Error checking connection, status: %s, exit code: %d", status, exitCode);
final String message = String.format("Error checking connection, status: %s, exit code: %d", status, exitCode);

LOGGER.error(message);
return new StandardCheckConnectionOutput()
Expand All @@ -88,10 +90,8 @@ public StandardCheckConnectionOutput run(final StandardCheckConnectionInput inpu
}

} catch (final Exception e) {
LOGGER.error("Error while checking connection: ", e);
return new StandardCheckConnectionOutput()
.withStatus(Status.FAILED)
.withMessage("Error while getting checking connection, because of: " + e.getMessage());
LOGGER.error("Unexpected error while checking connection: ", e);
throw new WorkerException("Unexpected error while getting checking connection.", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -114,9 +115,8 @@ public void testExceptionThrownInRun() throws WorkerException {
doThrow(new RuntimeException()).when(integrationLauncher).check(jobRoot, WorkerConstants.SOURCE_CONFIG_JSON_FILENAME, Jsons.serialize(CREDS));

final DefaultCheckConnectionWorker worker = new DefaultCheckConnectionWorker(workerConfigs, integrationLauncher, failureStreamFactory);
final StandardCheckConnectionOutput output = worker.run(input, jobRoot);

assertEquals(Status.FAILED, output.getStatus());
assertThrows(WorkerException.class, () -> worker.run(input, jobRoot));
}

@Test
Expand Down

0 comments on commit 74d16cc

Please sign in to comment.