Skip to content

Stabilize integration tests#1329

Merged
fuzzybinary merged 4 commits into
developfrom
jward/integration-test-fixes
Mar 8, 2023
Merged

Stabilize integration tests#1329
fuzzybinary merged 4 commits into
developfrom
jward/integration-test-fixes

Conversation

@fuzzybinary

Copy link
Copy Markdown
Member

What does this PR do?

This attempts to remove flakeyness from our integration tests by fixing 3 major issues:

  1. The TelemetryTest was expecting a very specific set of telemetry in a very specific order. There is a new piece of telemetry that is getting sent on Activity launch that can be sent anywhere in that order. The new test checks that all expected telemetry is there, but ignores any extra telemetry.
  2. Activity and Fragment tests could attempt to capture RUM context while other events were processing, giving them either an incorrect View ID during the capture or "null". Add a (private) method that waits for the RUM queue to process events before continuing to capture the RUM context
  3. The ApplicationLaunchView does not stop until the application_start action is sent, which is highly dependent on how long it takes for it to get written to storage. Because of this, I've split out checking all the regular events from checking any events associated with tracking application launch.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@fuzzybinary
fuzzybinary requested a review from a team as a code owner March 7, 2023 19:01
@fuzzybinary fuzzybinary changed the title Stabilize integrationtests Stabilize integration tests Mar 7, 2023
Set the telemetry test to verify it got all the telemetry it expected, but ignore any extra telemetry it might encounter.
Add a method to allow the RUM event queue to settle before getting the RUM context to avoid testing against bad ViewIds
Consider ApplicationLaunch and regular events separately, since ApplicationLaunch events can be highly order dependent.
@fuzzybinary
fuzzybinary force-pushed the jward/integration-test-fixes branch from 6139221 to 81f6158 Compare March 7, 2023 19:02
if (!executorService.isShutdown) {
val latch = CountDownLatch(1)
// Submit an empty task, and wait for it to complete
executorService.submit {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice trick

" got (${telemetryEvents.size}) which is less than expected."
)
.hasSameSizeAs(expectedTelemetry)
.isGreaterThanOrEqualTo(expectedTelemetry.size)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why number of telemetry events may vary? is it because we send configuration telemetry with delay?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's more that we sometimes can't control what will send telemetry during the integration test. Right now I only ever see 4, with the 4th being something from the Activity. But that doesn't mean other telemetry couldn't sneak its way in.

latch.countDown()
}
try {
latch.await()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we could add a timeout here in case something is blocking the executor indefinitely?

try {
latch.await()
} catch (_: InterruptedException) {
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's not swallow the exception here and at least send it to the Maintainers via internalLogger

fuzzybinary and others added 2 commits March 8, 2023 08:45
…droid/sdk/integration/telemetry/TelemetryTest.kt

Co-authored-by: Nikita Ogorodnikov <[email protected]>
@fuzzybinary
fuzzybinary requested review from 0xnm and xgouchet March 8, 2023 13:49
@fuzzybinary
fuzzybinary merged commit a0e67a9 into develop Mar 8, 2023
@fuzzybinary
fuzzybinary deleted the jward/integration-test-fixes branch March 8, 2023 15:17
@xgouchet xgouchet added this to the 1.18.0 milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants