Skip to content

Commit

Permalink
td/util: Consolidate QE client
Browse files Browse the repository at this point in the history
Summary: There's two separate QE check functions. Lets use the verse one as the default

Differential Revision: D65419563

fbshipit-source-id: 9b33682aa657f39fe799e1fe05e094fd8590b9ca
  • Loading branch information
Aniket Mathur authored and facebook-github-bot committed Nov 13, 2024
1 parent 3994f21 commit 5055b06
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions td_util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod knobs;
pub mod no_hash;
pub mod prelude;
pub mod project;
pub mod qe;
pub mod schedules;
pub mod string;
pub mod supertd_events;
Expand Down
42 changes: 42 additions & 0 deletions td_util/src/qe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apache
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
* of this source tree.
*/

pub enum QEParamValue {
Bool,
String(String),
Int(i64),
}

#[cfg(all(fbcode_build, target_os = "linux"))]
pub fn evaluate_qe(unit_id: u64, universe: &str, param: &str, expect: QEParamValue) -> bool {
use sandcastle_qe2_client::QE2;
use tracing::info;

let qe = crate::executor::run_as_sync(QE2::from_unit_id(unit_id, &[universe]));
let ret = match expect {
QEParamValue::Bool => qe.get_bool(universe, param, false),
QEParamValue::String(expect) => {
let qe_value = qe.get_string(universe, param, "");
qe_value == expect
}
QEParamValue::Int(expect) => {
let qe_value = qe.get_int(universe, param, 0);
qe_value == expect
}
};

info!("Check {param} from QE {universe}: {ret}");
crate::scuba!(event: VERSE_QE_CHECK, data: json!({ "param": param, "universe": universe, "result": ret }));
ret
}

#[cfg(not(all(fbcode_build, target_os = "linux")))]
pub fn evaluate_qe(unit_id: u64, universe: &str, param: &str, expect: QEParamValue) -> bool {
return false;
}

0 comments on commit 5055b06

Please sign in to comment.