-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Destination-S3-V2: Bug: Do not hang on stream missing state #51043
Merged
johnny-schmidt
merged 1 commit into
master
from
jschmidt/s3v2/fix-sync-hands-if-stream-missing-state
Jan 10, 2025
+84
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...te-cdk/bulk/core/load/src/test/kotlin/io/airbyte/cdk/load/state/CheckpointManagerUTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.cdk.load.state | ||
|
||
import io.airbyte.cdk.load.command.Append | ||
import io.airbyte.cdk.load.command.DestinationCatalog | ||
import io.airbyte.cdk.load.command.DestinationStream | ||
import io.airbyte.cdk.load.data.ObjectTypeWithEmptySchema | ||
import io.airbyte.cdk.load.file.TimeProvider | ||
import io.airbyte.cdk.load.message.CheckpointMessage | ||
import io.mockk.coEvery | ||
import io.mockk.coVerify | ||
import io.mockk.impl.annotations.MockK | ||
import io.mockk.mockk | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.jupiter.api.Test | ||
|
||
class CheckpointManagerUTest { | ||
@MockK(relaxed = true) lateinit var catalog: DestinationCatalog | ||
@MockK(relaxed = true) lateinit var syncManager: SyncManager | ||
private val outputConsumer: suspend (Reserved<CheckpointMessage>) -> Unit = | ||
mockk<suspend (Reserved<CheckpointMessage>) -> Unit>(relaxed = true) | ||
@MockK(relaxed = true) lateinit var timeProvider: TimeProvider | ||
|
||
@Test | ||
fun `test checkpoint manager does not ignore ready checkpoint after empty one`() = runTest { | ||
// Populate the mock catalog with two streams in order | ||
val stream1 = | ||
DestinationStream( | ||
DestinationStream.Descriptor("test", "stream1"), | ||
importType = Append, | ||
schema = ObjectTypeWithEmptySchema, | ||
generationId = 10L, | ||
minimumGenerationId = 10L, | ||
syncId = 101L | ||
) | ||
val stream2 = | ||
DestinationStream( | ||
DestinationStream.Descriptor("test", "stream2"), | ||
importType = Append, | ||
schema = ObjectTypeWithEmptySchema, | ||
generationId = 10L, | ||
minimumGenerationId = 10L, | ||
syncId = 101L | ||
) | ||
|
||
coEvery { catalog.streams } returns listOf(stream1, stream2) | ||
|
||
val checkpointManager = | ||
DefaultCheckpointManager(catalog, syncManager, outputConsumer, timeProvider) | ||
|
||
// Add a checkpoint for only the second stream | ||
val message = mockk<Reserved<CheckpointMessage>>(relaxed = true) | ||
checkpointManager.addStreamCheckpoint(stream2.descriptor, 1, message) | ||
|
||
// Ensure second stream is data sufficient | ||
val stream2Manager = mockk<StreamManager>(relaxed = true) | ||
coEvery { stream2Manager.areRecordsPersistedUntil(any()) } returns true | ||
coEvery { syncManager.getStreamManager(stream2.descriptor) } returns stream2Manager | ||
|
||
// Ensure { first stream is empty } doesn't block sending the second stream | ||
coEvery { outputConsumer.invoke(any()) } returns Unit | ||
checkpointManager.flushReadyCheckpointMessages() | ||
coVerify { outputConsumer.invoke(message) } | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not need to extend this via
@ExtendWith(MockKExtension::class)
to get the mock annotations working?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not? I stepped through with the debugger and the catalog was populated with a mock that was behaving as expected.