Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 2 additions & 34 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ commands:
sudo apt update
sudo apt install --yes --no-install-recommends \
python3-pip \
python3.10-venv
python3.10-venv \
faketime

- run:
name: Install nextest
Expand Down Expand Up @@ -117,39 +118,6 @@ commands:
name: Run Rust sample
command: |
cargo run -p sample
- run:
name: Run Rust RLB test
command: |
glean-core/rlb/tests/test-shutdown-blocking.sh
- run:
name: Run Rust RLB crash test
command: |
glean-core/rlb/tests/test-thread-crashing.sh
- run:
name: Run Rust RLB delayed ping data test
command: |
glean-core/rlb/tests/test-delayed-ping-data.sh
- run:
name: Run Rust RLB flush test
command: |
glean-core/rlb/tests/test-ping-lifetime-flush.sh
- run:
name: Run Rust RLB enabled-pings test
command: |
glean-core/rlb/tests/test-enabled-pings.sh
- run:
name: Run Rust RLB pending-gets-removed test
command: |
glean-core/rlb/tests/test-pending-gets-removed.sh
- run:
name: Run Rust RLB mps-delay test
command: |
sudo apt install -y faketime
glean-core/rlb/tests/test-mps-delay.sh
- run:
name: Run Rust Rkv open test
command: |
glean-core/tests/test-rkv-cases.sh

install-rustup:
steps:
Expand Down
96 changes: 95 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resolver = "2"
members = [
"glean-core",
"glean-core/rlb",
"glean-core/rlb-tests",
"glean-core/bundle",
"glean-core/bundle-android",
"glean-core/build",
Expand Down
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ else
cargo nextest run --all $(addprefix --target ,$(GLEAN_BUILD_TARGET))
endif

test-rust-examples: glean-core/rlb/tests/*.sh ## Run Rust example tests
@for file in $^; do \
echo "=== $${file} ==="; \
./$$file || exit 1; \
done

test-rust-with-logs: ## Run all Rust tests with debug logging and single-threaded
RUST_LOG=glean,glean_core cargo test --all -- --nocapture --test-threads=1 $(addprefix --target ,$(GLEAN_BUILD_TARGET))

Expand Down
19 changes: 19 additions & 0 deletions glean-core/rlb-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "glean-tests"
version = "0.1.0"
edition = "2024"
publish = false
license = "MPL-2.0"

[dependencies]
glean = { path = "../rlb" }
env_logger = { version = "0.10.0", default-features = false, features = ["humantime"] }
flate2 = "1.0.19"
libc = "0.2"
log = "0.4.8"
once_cell = "1.18.0"
serde_json = "1.0.44"

[dev-dependencies]
assert_cmd = "2.1.2"
tempfile = "3.1.0"
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ use std::env;
use std::path::PathBuf;

use once_cell::sync::Lazy;
use tempfile::Builder;

use glean::{private::PingType, ClientInfoMetrics, ConfigurationBuilder};
use glean::{ClientInfoMetrics, ConfigurationBuilder, private::PingType};

#[cfg(unix)]
mod unix {
Expand All @@ -38,42 +37,44 @@ mod unix {
value: *mut c_void,
) -> c_int;

#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pthread_create(
native: *mut libc::pthread_t,
attr: *const libc::pthread_attr_t,
f: extern "C" fn(*mut c_void) -> *mut c_void,
value: *mut c_void,
) -> c_int {
let name = c"pthread_create".as_ptr();
let symbol = libc::dlsym(libc::RTLD_NEXT, name);
if symbol.is_null() {
panic!("dlsym failed to load `pthread_create` name. Nothing we can do, we abort.");
unsafe {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is now inside an edition = 2024 crate, so it requires the extra unsafe wrapping. Otherwise the code is unchanged.

let name = c"pthread_create".as_ptr();
let symbol = libc::dlsym(libc::RTLD_NEXT, name);
if symbol.is_null() {
panic!("dlsym failed to load `pthread_create` name. Nothing we can do, we abort.");
}

let real_pthread_create = *(&symbol as *const *mut _ as *const pthread_ft);

// thread 1 = glean.initialize
// thread 2 = ping directory processor
// thread 3 = MPS
// thread 4 = uploader for first metrics ping <- this is the one we want to fail
// thread 5 = uploader for health pings <- this is the one we want to fail
// thread 6 = uploader for prototype ping <- this is the one we want to fail
// thread 7 = post-init uploader <- this needs to fail, too
// thread 8 = shutdown wait thread
const TO_BLOCK: &[u32] = &[4, 5, 6, 7];

let spawned = ALLOW_THREAD_SPAWNED.fetch_add(1, Ordering::SeqCst);
if TO_BLOCK.contains(&spawned) {
return -1;
}

real_pthread_create(native, attr, f, value)
}

let real_pthread_create = *(&symbol as *const *mut _ as *const pthread_ft);

// thread 1 = glean.initialize
// thread 2 = ping directory processor
// thread 3 = MPS
// thread 4 = uploader for first metrics ping <- this is the one we want to fail
// thread 5 = uploader for health pings <- this is the one we want to fail
// thread 6 = uploader for prototype ping <- this is the one we want to fail
// thread 7 = post-init uploader <- this needs to fail, too
// thread 8 = shutdown wait thread
const TO_BLOCK: &[u32] = &[4, 5, 6, 7];

let spawned = ALLOW_THREAD_SPAWNED.fetch_add(1, Ordering::SeqCst);
if TO_BLOCK.contains(&spawned) {
return -1;
}

real_pthread_create(native, attr, f, value)
}
}

pub mod glean_metrics {
use glean::{private::BooleanMetric, CommonMetricData, Lifetime};
use glean::{CommonMetricData, Lifetime, private::BooleanMetric};

#[allow(non_upper_case_globals)]
pub static sample_boolean: once_cell::sync::Lazy<BooleanMetric> =
Expand Down Expand Up @@ -109,16 +110,10 @@ fn main() {
env_logger::init();

let mut args = env::args().skip(1);

let data_path = if let Some(path) = args.next() {
PathBuf::from(path)
} else {
let root = Builder::new().prefix("simple-db").tempdir().unwrap();
root.path().to_path_buf()
};
let data_path = PathBuf::from(args.next().expect("need data path"));

_ = &*PrototypePing;
let cfg = ConfigurationBuilder::new(true, data_path, "org.mozilla.glean_core.example")
let cfg = ConfigurationBuilder::new(true, data_path, "crashing.threads")
.with_server_endpoint("invalid-test-host")
.with_use_core_mps(true)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use std::{env, process};
use once_cell::sync::Lazy;

use flate2::read::GzDecoder;
use glean::{net, private::PingType, ClientInfoMetrics, ConfigurationBuilder};
use glean::{ClientInfoMetrics, ConfigurationBuilder, net, private::PingType};

pub mod glean_metrics {
use glean::{private::CounterMetric, CommonMetricData, Lifetime};
use glean::{CommonMetricData, Lifetime, private::CounterMetric};

#[allow(non_upper_case_globals)]
pub static sample_counter: once_cell::sync::Lazy<CounterMetric> =
Expand Down
Loading
Loading