Add standard diagnostics and typed restart planning
This commit is contained in:
@@ -1629,8 +1629,6 @@ mod windows_contract_tests {
|
||||
crate::job_signer::JobSigner::load_or_create(&temp.join("key.pem")).unwrap(),
|
||||
),
|
||||
};
|
||||
crate::script_library::tests::revision_plan_contract(&state, &principal, assets[0], assets[1])
|
||||
.await;
|
||||
let mut request = input();
|
||||
request.targets.asset_ids = assets.clone();
|
||||
let view = plan(&state, &principal, tenant, request.clone())
|
||||
@@ -1729,6 +1727,8 @@ mod windows_contract_tests {
|
||||
.execute(&admin)
|
||||
.await
|
||||
.unwrap();
|
||||
crate::script_library::tests::revision_plan_contract(&state, &principal, assets[0], assets[1])
|
||||
.await;
|
||||
let view = plan(&state, &principal, tenant, profiled).await.unwrap();
|
||||
let profile_id = Uuid::parse_str(view["plan_id"].as_str().unwrap()).unwrap();
|
||||
let bytes: Vec<u8> =
|
||||
|
||||
@@ -259,7 +259,58 @@ pub(crate) mod tests {
|
||||
) {
|
||||
let tenant = p.tenant;
|
||||
let initial = list(s, p, tenant, PageQuery::default()).await.unwrap();
|
||||
let template = &initial["items"][0];
|
||||
let items = initial["items"].as_array().unwrap();
|
||||
assert_eq!(items.len(), 13);
|
||||
let template = items
|
||||
.iter()
|
||||
.find(|item| item["name"] == "Windows-Updates installieren")
|
||||
.unwrap();
|
||||
for (prefix, interpreter, asset) in [
|
||||
("Linux · ", "posix_sh", linux),
|
||||
("Windows · ", "powershell", windows),
|
||||
] {
|
||||
let revisions: Vec<_> = items
|
||||
.iter()
|
||||
.filter(|item| item["name"].as_str().unwrap().starts_with(prefix))
|
||||
.collect();
|
||||
assert_eq!(revisions.len(), 6);
|
||||
for row in revisions {
|
||||
let identity = if row["name"] == "Windows · Betriebssystem-Updatebedarf anzeigen" {
|
||||
"system"
|
||||
} else {
|
||||
"agent_service"
|
||||
};
|
||||
assert_eq!(row["interpreter"], interpreter);
|
||||
assert_eq!(row["execution_identity"], identity);
|
||||
assert_eq!(row["version"], 1);
|
||||
let id = Uuid::parse_str(row["revision_id"].as_str().unwrap()).unwrap();
|
||||
let selection = Selection {
|
||||
targets: Targets {
|
||||
asset_ids: vec![asset],
|
||||
},
|
||||
schedule: Schedule {
|
||||
not_before: Utc::now(),
|
||||
start_before: Utc::now() + Duration::minutes(30),
|
||||
},
|
||||
rollout: Rollout {
|
||||
max_parallel: 1,
|
||||
halt_after_failures: 1,
|
||||
},
|
||||
reason: "standard diagnostic library contract".into(),
|
||||
max_runtime_seconds: 120,
|
||||
max_output_bytes: 65536,
|
||||
};
|
||||
let planned = plan(s, p, tenant, id, selection).await;
|
||||
if identity == "system" {
|
||||
assert_eq!(planned.unwrap_err().0, StatusCode::FORBIDDEN);
|
||||
} else {
|
||||
assert_eq!(
|
||||
planned.unwrap()["plan_payload"]["script_revision"]["script_sha256"],
|
||||
row["script_sha256"]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert_eq!(template["name"], "Windows-Updates installieren");
|
||||
assert_eq!(template["interpreter"], "powershell");
|
||||
let native = script(
|
||||
|
||||
Reference in New Issue
Block a user