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

Fix flaky test in WebViewRumEventConsumerTest #1724

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -834,12 +834,9 @@ internal class WebViewRumEventConsumerTest {
}

val expectedOffsets = LinkedHashMap<String, Long>()
val expectedOffsetsKeys = fakeViewEvents
.takeLast(WebViewRumEventConsumer.MAX_VIEW_TIME_OFFSETS_RETAIN)
.map { it.view.id }
val expectedOffsetsValues = fakeServerOffsets.takeLast(WebViewRumEventConsumer.MAX_VIEW_TIME_OFFSETS_RETAIN)
val expectedOffsetsKeys = fakeViewEvents.map { it.view.id }
expectedOffsetsKeys.forEachIndexed { index, key ->
expectedOffsets[key] = expectedOffsetsValues[index]
expectedOffsets[key] = fakeServerOffsets[index]
}
whenever(
mockWebViewRumEventMapper.mapEvent(
Expand All @@ -857,8 +854,12 @@ internal class WebViewRumEventConsumerTest {

// Then
val rumEventConsumer = testedConsumer as WebViewRumEventConsumer
// Because the threads are processed in any order,
// we can't guarantee the order of the entries, and can only assert
// the size of the offsets, and the pairs of key values in it
assertThat(rumEventConsumer.offsets.entries)
.containsExactlyElementsOf(expectedOffsets.entries)
.containsAnyElementsOf(expectedOffsets.entries)
.hasSizeLessThanOrEqualTo(WebViewRumEventConsumer.MAX_VIEW_TIME_OFFSETS_RETAIN)
}

// endregion
Expand Down