Skip to content

Add unit tests for new logging in GaugeManager using GaugeCounter. #6953

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

Merged
merged 17 commits into from
May 15, 2025

Conversation

tejasd
Copy link
Contributor

@tejasd tejasd commented May 9, 2025

  • Fixes relevant unit tests - specifically requiring a definite ApplicationProcessState
  • Adds new unit tests for the updated behaviour
  • Deletes unit tests that should be OK to delete.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 9, 2025

Coverage Report 1

Affected Products

  • firebase-perf

    Overall coverage changed from ? (afede6d) to 70.45% (c1870f8) by ?.

    108 individual files with coverage change

    FilenameBase (afede6d)Merge (c1870f8)Diff
    AddTrace.java?0.00%?
    AndroidApplicationInfo.java?34.71%?
    AndroidApplicationInfoOrBuilder.java?0.00%?
    AndroidLogger.java?100.00%?
    AndroidMemoryReading.java?38.36%?
    AndroidMemoryReadingOrBuilder.java?0.00%?
    ApplicationInfo.java?43.81%?
    ApplicationInfoOrBuilder.java?0.00%?
    ApplicationProcessState.java?73.91%?
    AppStartTrace.java?77.55%?
    AppStateMonitor.java?84.97%?
    AppStateUpdateHandler.java?89.29%?
    Clock.java?100.00%?
    ConfigResolver.java?90.33%?
    ConfigurationConstants.java?97.93%?
    ConfigurationFlag.java?80.00%?
    ConsoleUrlGenerator.java?37.50%?
    Constants.java?95.65%?
    Counter.java?90.91%?
    CpuGaugeCollector.java?93.90%?
    CpuMetricReading.java?39.33%?
    CpuMetricReadingOrBuilder.java?0.00%?
    DaggerFirebasePerformanceComponent.java?100.00%?
    DeviceCacheManager.java?76.42%?
    FirebasePerfApplicationInfoValidator.java?92.86%?
    FirebasePerfEarly.java?76.92%?
    FirebasePerfGaugeMetricValidator.java?100.00%?
    FirebasePerfHttpClient.java?93.85%?
    FirebasePerfMetricProto.java?0.00%?
    FirebasePerfNetworkValidator.java?86.67%?
    FirebasePerfOkHttpClient.java?44.90%?
    FirebasePerformance.java?77.17%?
    FirebasePerformanceAttributable.java?0.00%?
    FirebasePerformanceComponent.java?0.00%?
    FirebasePerformanceInitializer.java?28.57%?
    FirebasePerformanceModule.java?100.00%?
    FirebasePerformanceModule_ProvidesConfigResolverFactory.java?0.00%?
    FirebasePerformanceModule_ProvidesFirebaseAppFactory.java?0.00%?
    FirebasePerformanceModule_ProvidesFirebaseInstallationsFactory.java?0.00%?
    FirebasePerformanceModule_ProvidesRemoteConfigComponentFactory.java?0.00%?
    FirebasePerformanceModule_ProvidesRemoteConfigManagerFactory.java?0.00%?
    FirebasePerformanceModule_ProvidesSessionManagerFactory.java?0.00%?
    FirebasePerformanceModule_ProvidesTransportFactoryProviderFactory.java?0.00%?
    FirebasePerformanceSessionSubscriber.kt?22.22%?
    FirebasePerformance_Factory.java?0.00%?
    FirebasePerfRegistrar.java?100.00%?
    FirebasePerfTraceValidator.java?85.87%?
    FirebasePerfUrlConnection.java?44.44%?
    FirebaseSessionsEnforcementCheck.kt?85.71%?
    FirebaseSessionsHelper.kt?100.00%?
    FirstDrawDoneListener.java?85.71%?
    FlgTransport.java?83.33%?
    FragmentStateMonitor.java?94.87%?
    FrameMetricsCalculator.java?96.77%?
    FrameMetricsRecorder.java?76.32%?
    GaugeCounter.kt?92.86%?
    GaugeManager.java?95.56%?
    GaugeMetadata.java?26.85%?
    GaugeMetadataManager.java?100.00%?
    GaugeMetadataOrBuilder.java?0.00%?
    GaugeMetric.java?39.47%?
    GaugeMetricOrBuilder.java?0.00%?
    HttpMetric.java?92.65%?
    ImmutableBundle.java?100.00%?
    InstrHttpInputStream.java?92.45%?
    InstrHttpOutputStream.java?98.00%?
    InstrHttpsURLConnection.java?94.32%?
    InstrHttpURLConnection.java?93.42%?
    InstrumentApacheHttpResponseHandler.java?100.00%?
    InstrumentOkHttpEnqueueCallback.java?100.00%?
    InstrURLConnectionBase.java?94.86%?
    LogWrapper.java?23.08%?
    MemoryGaugeCollector.java?89.83%?
    NetworkConnectionInfo.java?0.00%?
    NetworkConnectionInfoOrBuilder.java?0.00%?
    NetworkRequestMetric.java?49.16%?
    NetworkRequestMetricBuilder.java?95.97%?
    NetworkRequestMetricBuilderUtil.java?75.00%?
    NetworkRequestMetricOrBuilder.java?0.00%?
    Optional.java?86.67%?
    PendingPerfEvent.java?100.00%?
    PerfMetric.java?33.67%?
    PerfMetricOrBuilder.java?0.00%?
    PerfMetricValidator.java?93.85%?
    Performance.kt?7.14%?
    PerfSession.java?93.33%?
    PerfSessionOrBuilder.java?0.00%?
    PreDrawListener.java?94.12%?
    Rate.java?100.00%?
    RateLimiter.java?90.77%?
    RemoteConfigManager.java?91.67%?
    ResourceType.java?0.00%?
    ScreenTraceUtil.java?94.12%?
    SessionAwareObject.java?0.00%?
    SessionManager.java?100.00%?
    SessionVerbosity.java?68.42%?
    StorageUnit.java?57.89%?
    Timer.java?90.63%?
    Trace.java?95.83%?
    TraceMetric.java?43.14%?
    TraceMetricBuilder.java?100.00%?
    TraceMetricOrBuilder.java?0.00%?
    TransportInfo.java?0.00%?
    TransportInfoOrBuilder.java?0.00%?
    TransportManager.java?94.93%?
    URLAllowlist.java?94.44%?
    URLWrapper.java?0.00%?
    Utils.java?78.57%?

Test Logs

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

@44Sergeipakudin

This comment was marked as off-topic.

@44Sergeipakudin

This comment was marked as off-topic.

Copy link
Contributor

github-actions bot commented May 9, 2025

Test Results

  110 files    110 suites   2m 9s ⏱️
  957 tests   957 ✅ 0 💤 0 ❌
1 922 runs  1 922 ✅ 0 💤 0 ❌

Results for commit 9ce45e7.

♻️ This comment has been updated with latest results.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 9, 2025

Size Report 1

Affected Products

  • base

    TypeBase (afede6d)Merge (c1870f8)Diff
    apk (aggressive)?8.80 kB? (?)
    apk (release)?9.77 kB? (?)
  • firebase-perf

    TypeBase (afede6d)Merge (c1870f8)Diff
    aar?322 kB? (?)
    apk (aggressive)?1.71 MB? (?)
    apk (release)?10.7 MB? (?)
  • firebase-sessions

    TypeBase (afede6d)Merge (c1870f8)Diff
    aar?203 kB? (?)
    apk (aggressive)?645 kB? (?)
    apk (release)?6.31 MB? (?)
  • protolite-well-known-types

    TypeBase (afede6d)Merge (c1870f8)Diff
    aar?1.02 MB? (?)
    apk (aggressive)?134 kB? (?)
    apk (release)?1.71 MB? (?)

Test Logs

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

private val gaugeManager: GaugeManager = GaugeManager.getInstance()
private val logger = AndroidLogger.getInstance()
// TODO(b/394127311): Setting this as a var for a unit test. Refactor it.
var gaugeManager: GaugeManager = GaugeManager.getInstance()
Copy link
Contributor

Choose a reason for hiding this comment

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

You could do something like:

var gaugeManager: ...
   internal set

Copy link
Contributor

Choose a reason for hiding this comment

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

And maybe even @set:VisibleForTesting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

import org.robolectric.shadows.ShadowPackageManager;

public class FirebasePerformanceTestBase {
@BeforeClass
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you do it @After instead? Then be a good citizen to other unit tests in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason the unit tests fails on Github Actions (but not locally) with @After. Reverted it and added a TODO.

@tejasd tejasd merged commit 392a771 into fireperf-aqs May 15, 2025
32 checks passed
@tejasd tejasd deleted the td/gm-unit-tests branch May 15, 2025 18:48
tejasd added a commit that referenced this pull request May 15, 2025
…6953)

- Fixes relevant unit tests - specifically requiring a definite
`ApplicationProcessState`
- Adds new unit tests for the updated behaviour
- Deletes unit tests that *should* be OK to delete.
tejasd added a commit that referenced this pull request May 23, 2025
…6953)

- Fixes relevant unit tests - specifically requiring a definite
`ApplicationProcessState`
- Adds new unit tests for the updated behaviour
- Deletes unit tests that *should* be OK to delete.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants