// 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 std::io::Read; use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread; use std::time;
use crossbeam_channel::{bounded, Sender}; use flate2::read::GzDecoder; use serde_json::Value as JsonValue;
match calls { // First goes through as is. 0 => net::UploadResult::http_status(200), // Second briefly sleeps 1 => {
thread::sleep(time::Duration::from_millis(100));
net::UploadResult::http_status(200)
} // Third one fails 2 => net::UploadResult::http_status(404), // Fourth one fast again 3 => { self.sender.send(decode(body)).unwrap();
net::UploadResult::http_status(200)
} // Last one is the metrics ping, a-ok.
_ => { self.sender.send(decode(body)).unwrap();
net::UploadResult::http_status(200)
}
}
}
}
/// Test scenario: Different timings for upload on success and failure. /// /// The app is initialized, in turn Glean gets initialized without problems. /// A custom ping is submitted multiple times to trigger upload. /// A metrics ping is submitted to get the upload timing data. /// /// And later the whole process is shutdown. #[test] fn upload_timings() {
common::enable_test_logging();
// Create a custom configuration to use a validating uploader. let dir = tempfile::tempdir().unwrap(); let tmpname = dir.path().to_path_buf(); let (tx, rx) = bounded(1);
// Wait for init to finish, // otherwise we might be to quick with calling `shutdown`. let _ = metrics::sample_boolean.test_get_value(None);
// fast
pings::validation.submit(None); // slow
pings::validation.submit(None); // failed
pings::validation.submit(None); // fast
pings::validation.submit(None);
// wait for the last ping let _body = rx.recv().unwrap();
assert_eq!( 3,
metrics::send_success.test_get_value(None).unwrap().count, "Successful pings: two fast, one slow"
);
assert_eq!( 1,
metrics::send_failure.test_get_value(None).unwrap().count, "One failed ping"
);
// This is awkward, but it's what gets us very close to just starting a new process with a // fresh Glean. // This also calls `glean::shutdown();` internally, waiting on the uploader. let data_path = Some(tmpname.display().to_string());
glean_core::glean_test_destroy_glean(false, data_path);
let cfg = ConfigurationBuilder::new(true, tmpname, "glean-upload-timing")
.with_server_endpoint("invalid-test-host")
.with_use_core_mps(false)
.build();
common::initialize(cfg);
assert_eq!( 1,
metrics::shutdown_wait.test_get_value(None).unwrap().count, "Measured time waiting for shutdown exactly once"
);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.