Deduplicate logger nodes and tags when merging configs
When merging new configuration snippets with an existing config, it is
really easy to end up with duplicated nodes or tags. This is generally
not what the user actually wants, they just want things to work. So,
deduplicate those when merging.
Turns out, the way we were merging configuration before was both slow
and hard to update to deduplicate things. It ended up being easier to
transform the config into an intermediate representation which is more
suited to deduplication, and then transform it back to a flatbuffer.
This sets us up to do this efficiently inside the log reader too if we
want.
Change-Id: Ia8636569493e82c55d4e92f046fbbb09e1fb4c7a
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/configuration_test.cc b/aos/configuration_test.cc
index c1f00be..64b286e 100644
--- a/aos/configuration_test.cc
+++ b/aos/configuration_test.cc
@@ -1342,4 +1342,17 @@
EXPECT_TRUE(IsNodeFromConfiguration(&config_single_node.message(), nullptr));
}
+// Tests that we can use a utility to remove individual channels from a
+// multi-node config.
+TEST_F(ConfigurationTest, MultinodeMerge) {
+ FlatbufferDetachedBuffer<Configuration> config =
+ ReadConfig(ArtifactPath("aos/testdata/multinode_merge.json"));
+
+ EXPECT_EQ(
+ absl::StripSuffix(util::ReadFileToStringOrDie(ArtifactPath(
+ "aos/testdata/multinode_merge_expected.json")),
+ "\n"),
+ FlatbufferToJson(config, {.multi_line = true}));
+}
+
} // namespace aos::configuration::testing