Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update acceptance tests to use new connection scheduling format #16167

Merged
merged 5 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public static ImmutableMap<String, Object> generateSyncMetadata(final StandardSy
metadata.put("connection_id", standardSync.getConnectionId());

final String frequencyString;
if (standardSync.getManual()) {
// TODO(https://github.com/airbytehq/airbyte/issues/2170): handle cron strings properly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this basically relies on us "dual-writing" to the old schedule column, and the linked issue is for the clean-up task that will ultimately deprecate the old schedule column, right?

Would it make sense to update the code here right now to prefer the new column if set, and only fall back to getSchedule if the new column wasn't available?

We could even add some logging that tells us whenever this code had to use the old schedule. That way, when we eventually get around to removing the old schedule, we'll have logs that can help improve our confidence that the column is indeed safe to remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in a separate PR.

if (standardSync.getManual() || standardSync.getSchedule() == null) {
frequencyString = "manual";
} else {
final long intervalInMinutes = TimeUnit.SECONDS.toMinutes(ScheduleHelpers.getIntervalInSecond(standardSync.getSchedule()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import io.airbyte.api.client.model.generated.ConnectionIdRequestBody;
import io.airbyte.api.client.model.generated.ConnectionRead;
import io.airbyte.api.client.model.generated.ConnectionSchedule;
import io.airbyte.api.client.model.generated.ConnectionScheduleData;
import io.airbyte.api.client.model.generated.ConnectionScheduleType;
import io.airbyte.api.client.model.generated.ConnectionState;
import io.airbyte.api.client.model.generated.ConnectionStatus;
import io.airbyte.api.client.model.generated.ConnectionUpdate;
Expand Down Expand Up @@ -455,15 +457,17 @@ public ConnectionRead createConnection(final String name,
final UUID destinationId,
final List<UUID> operationIds,
final AirbyteCatalog catalog,
final ConnectionSchedule schedule)
final ConnectionScheduleType scheduleType,
final ConnectionScheduleData scheduleData)
throws ApiException {
final ConnectionRead connection = apiClient.getConnectionApi().createConnection(
new ConnectionCreate()
.status(ConnectionStatus.ACTIVE)
.sourceId(sourceId)
.destinationId(destinationId)
.syncCatalog(catalog)
.schedule(schedule)
.scheduleType(scheduleType)
.scheduleData(scheduleData)
.operationIds(operationIds)
.name(name)
.namespaceDefinition(NamespaceDefinitionType.CUSTOMFORMAT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.airbyte.api.client.model.generated.AirbyteStream;
import io.airbyte.api.client.model.generated.AttemptInfoRead;
import io.airbyte.api.client.model.generated.ConnectionIdRequestBody;
import io.airbyte.api.client.model.generated.ConnectionScheduleType;
import io.airbyte.api.client.model.generated.ConnectionState;
import io.airbyte.api.client.model.generated.DestinationDefinitionIdRequestBody;
import io.airbyte.api.client.model.generated.DestinationDefinitionRead;
Expand Down Expand Up @@ -142,7 +143,8 @@ void testManualSync() throws Exception {
final DestinationSyncMode destinationSyncMode = DestinationSyncMode.OVERWRITE;
catalog.getStreams().forEach(s -> s.getConfig().syncMode(syncMode).destinationSyncMode(destinationSyncMode));
final UUID connectionId =
testHarness.createConnection(connectionName, sourceId, destinationId, List.of(operationId), catalog, null).getConnectionId();
testHarness.createConnection(connectionName, sourceId, destinationId, List.of(operationId), catalog, ConnectionScheduleType.MANUAL, null)
.getConnectionId();
final JobInfoRead connectionSyncRead = apiClient.getConnectionApi().syncConnection(new ConnectionIdRequestBody().connectionId(connectionId));
waitForSuccessfulJob(apiClient.getJobsApi(), connectionSyncRead.getJob());
testHarness.assertSourceAndDestinationDbInSync(false);
Expand Down Expand Up @@ -187,7 +189,7 @@ void testCheckpointing() throws Exception {
.cursorField(List.of(COLUMN_ID))
.destinationSyncMode(destinationSyncMode));
final UUID connectionId =
testHarness.createConnection(connectionName, sourceId, destinationId, Collections.emptyList(), catalog, null)
testHarness.createConnection(connectionName, sourceId, destinationId, Collections.emptyList(), catalog, ConnectionScheduleType.MANUAL, null)
.getConnectionId();
final JobInfoRead connectionSyncRead1 = apiClient.getConnectionApi()
.syncConnection(new ConnectionIdRequestBody().connectionId(connectionId));
Expand Down Expand Up @@ -269,7 +271,7 @@ void testBackpressure() throws Exception {
final AirbyteCatalog catalog = testHarness.discoverSourceSchema(sourceId);

final UUID connectionId =
testHarness.createConnection(connectionName, sourceId, destinationId, Collections.emptyList(), catalog, null)
testHarness.createConnection(connectionName, sourceId, destinationId, Collections.emptyList(), catalog, ConnectionScheduleType.MANUAL, null)
.getConnectionId();
final JobInfoRead connectionSyncRead1 = apiClient.getConnectionApi()
.syncConnection(new ConnectionIdRequestBody().connectionId(connectionId));
Expand Down
Loading