Skip to content

Commit

Permalink
tolerate missing source catalog used to make the configured catalog (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mfsiega-airbyte authored Dec 29, 2022
1 parent 2deac0f commit baf9d11
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,17 @@ public WebBackendConnectionRead webBackendGetConnection(final WebBackendConnecti
/*
* constructs a full picture of all existing configured + all new / updated streams in the newest
* catalog.
*/
syncCatalog = updateSchemaWithRefreshedDiscoveredCatalog(configuredCatalog, catalogUsedToMakeConfiguredCatalog.get(),
refreshedCatalog.get().getCatalog());
/*
*
* Diffing the catalog used to make the configured catalog gives us the clearest diff between the
* schema when the configured catalog was made and now. In the case where we do not have the
* original catalog used to make the configured catalog, we make due, but using the configured
* catalog itself. The drawback is that any stream that was not selected in the configured catalog
* but was present at time of configuration will appear in the diff as an added stream which is
* confusing. We need to figure out why source_catalog_id is not always populated in the db.
*/
syncCatalog = updateSchemaWithRefreshedDiscoveredCatalog(configuredCatalog, catalogUsedToMakeConfiguredCatalog.orElse(configuredCatalog),
refreshedCatalog.get().getCatalog());

diff = refreshedCatalog.get().getCatalogDiff();
connection.setBreakingChange(refreshedCatalog.get().getBreakingChange());
connection.setStatus(refreshedCatalog.get().getConnectionStatus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,24 @@ void testWebBackendGetConnectionWithDiscoveryAndNewSchemaBreakingChange() throws
assertEquals(expectedWithNewSchemaAndBreakingChange, result);
}

@Test
void testWebBackendGetConnectionWithDiscoveryMissingCatalogUsedToMakeConfiguredCatalog()
throws IOException, ConfigNotFoundException, JsonValidationException {
final UUID newCatalogId = UUID.randomUUID();
when(configRepository.getMostRecentActorCatalogFetchEventForSource(any()))
.thenReturn(Optional.of(new ActorCatalogFetchEvent().withActorCatalogId(newCatalogId)));
when(configRepository.getActorCatalogById(any())).thenReturn(new ActorCatalog().withId(UUID.randomUUID()));
final SourceDiscoverSchemaRead schemaRead =
new SourceDiscoverSchemaRead().catalogDiff(expectedWithNewSchema.getCatalogDiff()).catalog(expectedWithNewSchema.getSyncCatalog())
.breakingChange(false).connectionStatus(ConnectionStatus.ACTIVE);
when(schedulerHandler.discoverSchemaForSourceFromSourceId(any())).thenReturn(schemaRead);
when(connectionsHandler.getConnectionAirbyteCatalog(connectionRead.getConnectionId())).thenReturn(Optional.empty());

final WebBackendConnectionRead result = testWebBackendGetConnection(true, connectionRead,
operationReadList);
assertEquals(expectedWithNewSchema, result);
}

@Test
void testWebBackendGetConnectionWithDiscoveryAndFieldSelectionAddField() throws ConfigNotFoundException,
IOException, JsonValidationException {
Expand Down

0 comments on commit baf9d11

Please sign in to comment.