Skip to content

dataconnect: fix two flaky tests due to their failure to wait for FirebaseAuth to be initialized #6835

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

Conversation

dconeybe
Copy link
Contributor

@dconeybe dconeybe commented Apr 4, 2025

This PR fixes two tests in AuthIntegrationTest.kt that would flakily fail: queryShouldRetryOnUnauthenticated and mutationShouldRetryOnUnauthenticated.

The fix was to ensure that FirebaseAuth was ready in the FirebaseDataConnect instance before starting the test. I had thought that the test was already doing this because the signIn() method calls awaitAuthReady() on a FirebaseDataConnect object; however, the test actually used a different FirebaseDataConnect object and no call to awaitAuthReady() was made on it. As a result, occasionally the query would be executed before FirebaseAuth was ready and in those cases the test would fail. The fix was to simply call awaitAuthReady() on the other FirebaseDataConnect object that was used by the test to run the query.

Googlers can see b/399689249 for more details.

…ebaseDataConnect instance in queryShouldRetryOnUnauthenticated and mutationShouldRetryOnUnauthenticated
Copy link
Contributor

github-actions bot commented Apr 4, 2025

📝 PRs merging into main branch

Our main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released.

1 similar comment
Copy link
Contributor

github-actions bot commented Apr 4, 2025

📝 PRs merging into main branch

Our main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released.

@dconeybe dconeybe changed the title dataconnect: AuthIntegrationTest.kt: wait for auth to be ready on the *proper* Fir… dataconnect: fix two flaky tests due to their failure to wait for FirebaseAuth to be initialized Apr 4, 2025
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 4, 2025

Coverage Report 1

Affected Products

  • firebase-dataconnect

    Overall coverage changed from ? (9a07498) to 14.80% (9bb9fb6) by ?.

    60 individual files with coverage change

    FilenameBase (9a07498)Merge (9bb9fb6)Diff
    AlphanumericStringUtil.kt?0.00%?
    AnyValue.kt?0.00%?
    AnyValueSerializer.kt?0.00%?
    Comparisons.kt?0.00%?
    ConnectorConfig.kt?33.33%?
    CoroutineExceptionHandler.kt?50.00%?
    DataConnectAppCheck.kt?71.43%?
    DataConnectAuth.kt?71.43%?
    DataConnectCredentialsTokenManager.kt?32.32%?
    DataConnectException.kt?0.00%?
    DataConnectGrpcClient.kt?0.00%?
    DataConnectGrpcMetadata.kt?65.82%?
    DataConnectGrpcRPCs.kt?0.00%?
    DataConnectOperationException.kt?0.00%?
    DataConnectOperationFailureResponse.kt?0.00%?
    DataConnectOperationFailureResponseImpl.kt?0.00%?
    DataConnectPathSegment.kt?0.00%?
    DataConnectSettings.kt?33.33%?
    DataConnectUntypedData.kt?0.00%?
    DataConnectUntypedVariables.kt?0.00%?
    ExperimentalFirebaseDataConnect.kt?0.00%?
    FirebaseDataConnect.kt?50.00%?
    FirebaseDataConnectFactory.kt?29.17%?
    FirebaseDataConnectImpl.kt?46.67%?
    FirebaseDataConnectRegistrar.kt?100.00%?
    GeneratedConnector.kt?0.00%?
    GeneratedMutation.kt?0.00%?
    GeneratedOperation.kt?0.00%?
    GeneratedQuery.kt?0.00%?
    Globals.kt?0.00%?
    JavaTimeLocalDateSerializer.kt?0.00%?
    KotlinxDatetimeLocalDateSerializer.kt?0.00%?
    LiveQueries.kt?0.00%?
    LiveQuery.kt?0.00%?
    LocalDate.kt?0.00%?
    LocalDateSerializer.kt?0.00%?
    Logger.kt?73.68%?
    LogLevel.kt?72.73%?
    MutationRef.kt?0.00%?
    MutationRefImpl.kt?12.36%?
    NullableReference.kt?40.00%?
    NullOutputStream.kt?0.00%?
    OperationRef.kt?0.00%?
    OperationRefImpl.kt?20.45%?
    OptionalVariable.kt?0.00%?
    ProtoStructDecoder.kt?0.00%?
    ProtoStructEncoder.kt?0.00%?
    ProtoUtil.kt?0.00%?
    QueryManager.kt?0.00%?
    QueryRef.kt?0.00%?
    QueryRefImpl.kt?14.08%?
    QuerySubscription.kt?0.00%?
    QuerySubscriptionImpl.kt?0.00%?
    QuerySubscriptionInternal.kt?0.00%?
    ReferenceCounted.kt?0.00%?
    RegisteredDataDeserialzer.kt?0.00%?
    SequencedReference.kt?0.00%?
    SuspendingLazy.kt?31.58%?
    TimestampSerializer.kt?0.00%?
    UUIDSerializer.kt?0.00%?

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/e9WYdCgVVv.html

Copy link
Contributor

github-actions bot commented Apr 4, 2025

Test Results

   66 files     66 suites   1m 17s ⏱️
  552 tests   551 ✅ 1 💤 0 ❌
1 104 runs  1 102 ✅ 2 💤 0 ❌

Results for commit 020dc70.

♻️ This comment has been updated with latest results.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

firebase-dataconnect/src/androidTest/kotlin/com/google/firebase/dataconnect/AuthIntegrationTest.kt:130

  • Ensure that dataConnect is always an instance of FirebaseDataConnectInternal to avoid a potential ClassCastException. If there's any risk of a different type, consider using a safe cast and handling the error.
(dataConnect as FirebaseDataConnectInternal).awaitAuthReady()

firebase-dataconnect/src/androidTest/kotlin/com/google/firebase/dataconnect/AuthIntegrationTest.kt:159

  • Ensure that dataConnect is always an instance of FirebaseDataConnectInternal to avoid a potential ClassCastException. If there's any risk of a different type, consider using a safe cast and handling the error.
(dataConnect as FirebaseDataConnectInternal).awaitAuthReady()

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 4, 2025

Size Report 1

Affected Products

  • base

    TypeBase (9a07498)Merge (9bb9fb6)Diff
    apk (aggressive)?8.80 kB? (?)
    apk (release)?9.77 kB? (?)
  • firebase-dataconnect

    TypeBase (9a07498)Merge (9bb9fb6)Diff
    aar?712 kB? (?)
    apk (aggressive)?440 kB? (?)
    apk (release)?10.0 MB? (?)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/oudy6Dco0j.html

@dconeybe dconeybe merged commit f826b40 into main Apr 8, 2025
40 checks passed
@dconeybe dconeybe deleted the dconeybe/dataconnect/QueryShouldRetryOnUnauthenticatedFlakyTestFix branch April 8, 2025 21:07
@firebase firebase locked and limited conversation to collaborators May 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants