Closed Bug 1565240 Opened 6 years ago Closed 6 years ago

Consider adding a way to de-init or reset Glean to the public test API

Categories

(Data Platform and Tools :: Glean: SDK, enhancement, P1)

enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: travis_, Assigned: Dexter)

References

Details

(Whiteboard: [telemetry:glean-rs:m7])

Attachments

(2 files)

This has been discussed a lot, but I think that there is still a real need for this. Some of the latest discussion can be found here in a PR I was working on that ran into the problem head-on.

The TL;DR is that Glean, being implemented the way that it is, can persist state between tests in the same class, as well as between tests in different test classes. I'm sure that this is probably causing us trouble with intermittent test failures, as well as sometimes making the order that tests are ran in significant (which in itself is an issue as we have no good way to control the order in which the tests are ran).

Priority: -- → P3

One possible way to tackle this could be to define a custom JUnit rule, exported by the Glean SDK, that takes care of resetting the Glean state between tests, while keeping implementation details sealed within the Glean SDK.

Whiteboard: [telemetry:glean-rs:m?][telemetry:mobilesdk:m?] → [telemetry:glean-rs:m8]

Nick Alexander pointed us at this example!

A related issue is that failure to call Glean.initialize results in obscure errors in unit tests. Having a standard rule to apply to Glean-using tests would be a good way to plug that hole.

lateinit property applicationContext has not been initialized

    at mozilla.components.service.glean.storages.GenericStorageEngine.getApplicationContext(GenericStorageEngine.kt:40)
    at mozilla.components.service.glean.storages.GenericStorageEngine.deserializeLifetime(GenericStorageEngine.kt:105)
    at mozilla.components.service.glean.storages.GenericStorageEngine$pingLifetimeStorage$2.invoke(GenericStorageEngine.kt:50)
    at mozilla.components.service.glean.storages.GenericStorageEngine$pingLifetimeStorage$2.invoke(GenericStorageEngine.kt:39)
Whiteboard: [telemetry:glean-rs:m8] → [telemetry:glean-rs:m7]
Assignee: nobody → alessio.placitelli
Priority: P3 → P1
Attached file glean-ac PR
Attached file glean-core PR
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: