mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2026-10-25 14:20:05 -05:00
Merge pull request #1130 from LibreQoE/fix_topo_4
Fix topology runtime effective-network generation mismatch
This commit is contained in:
4 files changed
+83
-9
No files matched your search
@@ -15,7 +15,7 @@ use lqos_config::{
|
||||
TopologyEffectiveNodeState, TopologyEffectiveStateFile, TopologyQueueVisibilityPolicy,
|
||||
TopologyRuntimeStatusFile, TopologyShapingCircuitInput, TopologyShapingDeviceInput,
|
||||
TopologyShapingInputsFile, TopologyShapingResolutionSource, circuit_anchors_path,
|
||||
compute_effective_network_generation, detect_shaping_cpus, plan_top_level_assignments,
|
||||
compute_effective_network_file_generation, detect_shaping_cpus, plan_top_level_assignments,
|
||||
topology_auto_attachment_option, topology_effective_network_path,
|
||||
topology_effective_state_path, topology_runtime_status_path, topology_shaping_inputs_path,
|
||||
};
|
||||
|
||||
@@ -35,11 +35,6 @@ pub fn publish_effective_topology_artifacts(
|
||||
let effective_state_value = serde_json::to_value(&artifacts.effective)?;
|
||||
|
||||
let effective_network_path = topology_effective_network_path(config);
|
||||
let effective_generation = artifacts
|
||||
.effective_network
|
||||
.as_ref()
|
||||
.map(compute_effective_network_generation)
|
||||
.transpose()?;
|
||||
|
||||
let shaping_inputs_path = topology_shaping_inputs_path(config);
|
||||
let shaping_inputs = build_shaping_inputs(config, artifacts)?;
|
||||
@@ -88,6 +83,21 @@ pub fn publish_effective_topology_artifacts(
|
||||
})?;
|
||||
}
|
||||
|
||||
let effective_generation = if artifacts.effective_network.is_some() {
|
||||
Some(
|
||||
compute_effective_network_file_generation(&effective_network_path).with_context(
|
||||
|| {
|
||||
format!(
|
||||
"Unable to compute effective topology generation from {:?}",
|
||||
effective_network_path
|
||||
)
|
||||
},
|
||||
)?,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
match prepared_shaping_inputs {
|
||||
Some((shaping_inputs, shaping_inputs_value)) => {
|
||||
let current_shaping_inputs = TopologyShapingInputsFile::load(config).ok();
|
||||
|
||||
@@ -589,6 +589,70 @@
|
||||
assert!(topology_runtime_status_path(&config).exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn publish_runtime_status_hashes_existing_equal_effective_network_file() {
|
||||
let lqos_directory = unique_temp_dir("lqos-topology-runtime-status-existing-network");
|
||||
let config = Config {
|
||||
lqos_directory: lqos_directory.to_string_lossy().to_string(),
|
||||
state_directory: None,
|
||||
..Config::default()
|
||||
};
|
||||
fs::write(
|
||||
lqos_directory.join("ShapedDevices.csv"),
|
||||
concat!(
|
||||
"Circuit ID,Circuit Name,Device ID,Device Name,Parent Node,Parent Node ID,Anchor Node ID,MAC,IPv4,IPv6,Download Min Mbps,Upload Min Mbps,Download Max Mbps,Upload Max Mbps,Comment\n",
|
||||
"\"circuit-1\",\"Circuit 1\",\"device-1\",\"Device 1\",\"Tower 1\",\"tower-1\",\"tower-1\",\"aa:bb:cc:dd:ee:ff\",\"192.0.2.10/32\",\"\",\"10\",\"10\",\"100\",\"100\",\"\"\n",
|
||||
),
|
||||
)
|
||||
.expect("ShapedDevices.csv should write");
|
||||
|
||||
let mut artifacts = sample_runtime_artifacts();
|
||||
artifacts.effective_network = Some(json!({
|
||||
"Tower 1": {
|
||||
"id": "tower-1",
|
||||
"name": "Tower 1",
|
||||
"downloadBandwidthMbps": -0.0,
|
||||
"uploadBandwidthMbps": 100.0,
|
||||
"children": {}
|
||||
}
|
||||
}));
|
||||
let effective_network_path = topology_effective_network_path(&config);
|
||||
let existing_effective_network = r#"{
|
||||
"Tower 1": {
|
||||
"id": "tower-1",
|
||||
"name": "Tower 1",
|
||||
"downloadBandwidthMbps": 0.0,
|
||||
"uploadBandwidthMbps": 100.0,
|
||||
"children": {}
|
||||
}
|
||||
}"#;
|
||||
fs::create_dir_all(
|
||||
effective_network_path
|
||||
.parent()
|
||||
.expect("effective network path should have a parent"),
|
||||
)
|
||||
.expect("effective network state directory should exist");
|
||||
fs::write(
|
||||
&effective_network_path,
|
||||
existing_effective_network,
|
||||
)
|
||||
.expect("existing effective network should write");
|
||||
|
||||
publish_effective_topology_artifacts(&config, &artifacts, "generation-1")
|
||||
.expect("ready status should publish");
|
||||
let ready = TopologyRuntimeStatusFile::load(&config).expect("ready status should load");
|
||||
assert!(ready.ready);
|
||||
assert_eq!(
|
||||
fs::read_to_string(&effective_network_path)
|
||||
.expect("effective network should remain readable"),
|
||||
existing_effective_network,
|
||||
);
|
||||
let effective_network_generation =
|
||||
compute_effective_network_file_generation(&effective_network_path)
|
||||
.expect("effective network generation should compute from published file");
|
||||
assert_eq!(ready.effective_generation, effective_network_generation);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn publish_marks_runtime_not_ready_when_shaping_inputs_are_absent() {
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
TopologyCanonicalRateInputSource, TopologyCanonicalStateFile, TopologyEditorNode,
|
||||
TopologyEditorStateFile, TopologyEffectiveAttachmentState, TopologyEffectiveNodeState,
|
||||
TopologyEffectiveStateFile, TopologyQueueVisibilityPolicy, TopologyRuntimeStatusFile,
|
||||
TopologyShapingResolutionSource, topology_auto_attachment_option as auto_attachment_option,
|
||||
topology_effective_network_path, topology_effective_state_path, topology_runtime_status_path,
|
||||
topology_shaping_inputs_path,
|
||||
TopologyShapingResolutionSource, compute_effective_network_file_generation,
|
||||
topology_auto_attachment_option as auto_attachment_option, topology_effective_network_path,
|
||||
topology_effective_state_path, topology_runtime_status_path, topology_shaping_inputs_path,
|
||||
};
|
||||
use lqos_overrides::{TopologyAttachmentMode, TopologyOverridesFile};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
Reference in new issue
Block a user