Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid a panic when trying to persist ping-lifetime data after shutdown
This requires threading the error through our internal codebase. Other internals blocking on the queue will still panic if that's not possible. The only other functions that block on the dispatcher should be test functions though.
- Loading branch information
Showing
4 changed files
with
57 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
//! This integration test should model how the RLB is used when embedded in another Rust application | ||
//! (e.g. FOG/Firefox Desktop). | ||
//! | ||
//! We write a single test scenario per file to avoid any state keeping across runs | ||
//! (different files run as different processes). | ||
|
||
mod common; | ||
|
||
use glean::Configuration; | ||
use std::path::PathBuf; | ||
|
||
fn cfg_new(tmpname: PathBuf) -> Configuration { | ||
Configuration { | ||
data_path: tmpname, | ||
application_id: "firefox-desktop".into(), | ||
upload_enabled: true, | ||
max_events: None, | ||
delay_ping_lifetime_io: true, | ||
channel: Some("testing".into()), | ||
server_endpoint: Some("invalid-test-host".into()), | ||
uploader: None, | ||
use_core_mps: false, | ||
} | ||
} | ||
|
||
/// Test scenario: `persist_ping_lifetime_data` called after shutdown. | ||
#[test] | ||
fn delayed_ping_data() { | ||
common::enable_test_logging(); | ||
|
||
// Create a custom configuration to delay ping-lifetime io | ||
let dir = tempfile::tempdir().unwrap(); | ||
let tmpname = dir.path().to_path_buf(); | ||
|
||
common::initialize(cfg_new(tmpname)); | ||
assert!(glean::persist_ping_lifetime_data().is_ok()); | ||
|
||
glean::shutdown(); | ||
assert!(glean::persist_ping_lifetime_data().is_err()); | ||
} |