Expand the passive inventory shown in device details
Rust development slice / linux (push) Failing after 9s
Rust development slice / linux (push) Failing after 9s
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//! Additive JSON observation mapping inside the existing snapshot payload. This
|
||||
//! does not introduce a protobuf tag, a fabricated receive time or a new scope.
|
||||
//! does not introduce a protobuf tag or a fabricated receive time.
|
||||
use anyhow::Result;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
@@ -14,7 +14,12 @@ pub fn observations(inventory: &crate::inventory::LinuxInventory) -> Result<Vec<
|
||||
observation["scope"] = json!(format!("linux.{name}"));
|
||||
// Bound each scope independently. Never drop unsupported/error metadata
|
||||
// or imply that absent/truncated rows were deleted from a device.
|
||||
while serde_json::to_vec(&observation)?.len() > 32768 {
|
||||
let max_bytes = if name == "software" {
|
||||
rmm_domain::inventory_document::SOFTWARE_OBSERVATION_MAX_BYTES
|
||||
} else {
|
||||
32768
|
||||
};
|
||||
while serde_json::to_vec(&observation)?.len() > max_bytes {
|
||||
observation["truncated"] = json!(true);
|
||||
observation["completeness"] = json!("partial");
|
||||
observation["error_code"] = json!("WIRE_SCOPE_LIMIT");
|
||||
@@ -49,7 +54,7 @@ mod tests {
|
||||
fn native_wire_scopes_preserve_quality_time_and_unsupported() {
|
||||
let native = crate::inventory::collect_native();
|
||||
let mapped = observations(&native).unwrap();
|
||||
assert_eq!(mapped.len(), 11);
|
||||
assert_eq!(mapped.len(), 12);
|
||||
let smart = mapped.iter().find(|v| v["scope"] == "linux.smart").unwrap();
|
||||
assert_eq!(smart["quality"], "unsupported");
|
||||
assert!(smart["data"].is_null());
|
||||
@@ -61,7 +66,12 @@ mod tests {
|
||||
);
|
||||
assert!(!observation["source_id"].as_str().unwrap().is_empty());
|
||||
assert!(observation.get("received_at").is_none());
|
||||
assert!(serde_json::to_vec(observation).unwrap().len() <= 32768);
|
||||
let limit = if observation["scope"] == "linux.software" {
|
||||
rmm_domain::inventory_document::SOFTWARE_OBSERVATION_MAX_BYTES
|
||||
} else {
|
||||
32768
|
||||
};
|
||||
assert!(serde_json::to_vec(observation).unwrap().len() <= limit);
|
||||
}
|
||||
let base = snapshot(false).unwrap();
|
||||
assert!(serde_json::from_value::<rmm_domain::Inventory>(base).is_ok());
|
||||
|
||||
Reference in New Issue
Block a user