mirror of
https://github.com/rustfs/rustfs.git
synced 2026-10-12 15:48:35 +00:00
fix(connect): return profile capture result directly (#8182)
* fix(connect): return profile capture result directly Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * style(connect): normalize profile capture formatting Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * fix(tests): use async mutex for thread profiles Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * test(connect): widen diagnostic timing budgets Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> --------- Co-authored-by: zhi22915 <qiuzgang@gmail.com>
This commit is contained in:
@@ -1796,7 +1796,7 @@ mod tests {
|
||||
async fn top_disk_job_collects_service_io_and_preserves_signed_nonce() {
|
||||
let now = Utc::now();
|
||||
let mut top = disk_envelope();
|
||||
top.parameters.duration_millis = 200;
|
||||
top.parameters.duration_millis = 1_000;
|
||||
top.create_time = now.to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
|
||||
top.expire_time = (now + chrono::Duration::seconds(30)).to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
|
||||
top.parameters.consent_expires_at =
|
||||
|
||||
@@ -1408,7 +1408,7 @@ mod tests {
|
||||
let task_cancel = cancel.clone();
|
||||
let state_root = state.path().to_path_buf();
|
||||
let task = tokio::spawn(async move { super::request_local_runtime_profile(&state_root, request, &task_cancel).await });
|
||||
tokio::time::timeout(Duration::from_secs(10), async {
|
||||
tokio::time::timeout(Duration::from_secs(30), async {
|
||||
loop {
|
||||
if super::super::profile_cpu::CollectorLease::acquire().is_err() {
|
||||
break;
|
||||
|
||||
@@ -1480,7 +1480,8 @@ async fn execute_connect_profile(options: ConnectProfileOpts) -> Result<()> {
|
||||
enabled_build_features(),
|
||||
),
|
||||
};
|
||||
let export = {
|
||||
|
||||
{
|
||||
let capture = async {
|
||||
match options.tool {
|
||||
ConnectProfileTool::Cpu => {
|
||||
@@ -1517,8 +1518,7 @@ async fn execute_connect_profile(options: ConnectProfileOpts) -> Result<()> {
|
||||
}
|
||||
result = capture.as_mut() => result?,
|
||||
}
|
||||
};
|
||||
export
|
||||
}
|
||||
};
|
||||
let tool = export.tool;
|
||||
let outcome = export.outcome;
|
||||
|
||||
@@ -35,7 +35,7 @@ use tokio_util::sync::CancellationToken;
|
||||
#[cfg(target_os = "linux")]
|
||||
use zip::ZipArchive;
|
||||
|
||||
static CAPTURE_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
|
||||
static CAPTURE_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
|
||||
|
||||
fn request() -> ProfileCaptureRequest {
|
||||
let now = SystemTime::now().duration_since(UNIX_EPOCH).expect("current time").as_secs() as i64;
|
||||
@@ -88,7 +88,7 @@ async fn tokio_thread_scope_remains_explicitly_unsupported() {
|
||||
#[cfg(target_os = "linux")]
|
||||
#[tokio::test]
|
||||
async fn native_thread_scope_exports_bounded_redacted_state_counts() {
|
||||
let _capture = CAPTURE_LOCK.lock().unwrap();
|
||||
let _capture = CAPTURE_LOCK.lock().await;
|
||||
let key = connect::DeviceIdentity::generate();
|
||||
let result = capture_thread_profile(&request(), ThreadProfileScope::NativeThreads, &CancellationToken::new())
|
||||
.expect("native thread result");
|
||||
@@ -126,7 +126,7 @@ async fn native_thread_scope_exports_bounded_redacted_state_counts() {
|
||||
#[cfg(target_os = "linux")]
|
||||
#[test]
|
||||
fn native_thread_scope_honors_the_monotonic_deadline() {
|
||||
let _capture = CAPTURE_LOCK.lock().unwrap();
|
||||
let _capture = CAPTURE_LOCK.blocking_lock();
|
||||
let mut expired = request();
|
||||
expired.duration = Duration::from_nanos(1);
|
||||
expired.sample_period = Duration::from_nanos(1);
|
||||
@@ -166,7 +166,7 @@ fn thread_profile_rejects_wrong_negotiation_and_cancellation() {
|
||||
#[cfg(target_has_atomic = "64")]
|
||||
#[test]
|
||||
fn service_runtime_profile_observes_the_supplied_two_worker_runtime() {
|
||||
let _capture = CAPTURE_LOCK.lock().unwrap();
|
||||
let _capture = CAPTURE_LOCK.blocking_lock();
|
||||
let runtime = tokio::runtime::Builder::new_multi_thread()
|
||||
.worker_threads(2)
|
||||
.enable_all()
|
||||
|
||||
Reference in New Issue
Block a user