Beef up config validator
It was performing relatively unsophisticated checks. Make it so that it
can catch more subtle issues with timestamp channel configurations.
Change-Id: Ie42fba108c6bcb0d1cad2484dc435bac10a003ba
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/aos/network/message_bridge_test_common.json b/aos/network/message_bridge_test_common.json
index dad1675..9bb0863 100644
--- a/aos/network/message_bridge_test_common.json
+++ b/aos/network/message_bridge_test_common.json
@@ -75,28 +75,33 @@
{
"name": "/pi1/aos/remote_timestamps/pi2/pi1/aos/aos-message_bridge-Timestamp",
"type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
"source_node": "pi1",
"frequency": 15
},
{
"name": "/pi2/aos/remote_timestamps/pi1/pi2/aos/aos-message_bridge-Timestamp",
"type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
"source_node": "pi2",
"frequency": 15
},
{
"name": "/pi1/aos/remote_timestamps/pi2/test/aos-examples-Ping",
"type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
"source_node": "pi1"
},
{
"name": "/pi2/aos/remote_timestamps/pi1/test/aos-examples-Pong",
"type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
"source_node": "pi2"
},
{
"name": "/pi1/aos/remote_timestamps/pi2/unreliable/aos-examples-Ping",
"type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
"source_node": "pi1"
},
{
diff --git a/aos/util/BUILD b/aos/util/BUILD
index b46cd14..dda6f83 100644
--- a/aos/util/BUILD
+++ b/aos/util/BUILD
@@ -505,11 +505,8 @@
srcs = ["config_validator.cc"],
target_compatible_with = ["@platforms//os:linux"],
deps = [
- "//aos:init",
+ ":config_validator_lib",
"//aos:json_to_flatbuffer",
- "//aos/events:simulated_event_loop",
- "//aos/events/logging:log_reader",
- "//aos/events/logging:log_writer",
"//aos/testing:googletest",
"@com_github_gflags_gflags//:gflags",
"@com_github_google_glog//:glog",
@@ -538,3 +535,49 @@
"//aos/events/logging:log_writer",
],
)
+
+flatbuffer_cc_library(
+ name = "config_validator_config_fbs",
+ srcs = ["config_validator_config.fbs"],
+ target_compatible_with = ["@platforms//os:linux"],
+ visibility = ["//visibility:public"],
+)
+
+cc_library(
+ name = "config_validator_lib",
+ testonly = True,
+ srcs = ["config_validator_lib.cc"],
+ hdrs = ["config_validator_lib.h"],
+ deps = [
+ ":config_validator_config_fbs",
+ ":simulation_logger",
+ "//aos/events:simulated_event_loop",
+ "//aos/events/logging:log_reader",
+ "//aos/events/logging:log_writer",
+ "//aos/network:timestamp_channel",
+ "//aos/testing:tmpdir",
+ "@com_github_google_glog//:glog",
+ "@com_google_googletest//:gtest",
+ ],
+)
+
+cc_test(
+ name = "config_validator_lib_test",
+ srcs = ["config_validator_lib_test.cc"],
+ data = [
+ "//aos/util/test_data:multinode_common_logger",
+ "//aos/util/test_data:multinode_extraneous_timestamp",
+ "//aos/util/test_data:multinode_invalid_timestamp_logger_list",
+ "//aos/util/test_data:multinode_no_logged_timestamps",
+ "//aos/util/test_data:multinode_no_statistics",
+ "//aos/util/test_data:multinode_timestamp_typo",
+ "//aos/util/test_data:valid_multinode_config",
+ "//aos/util/test_data:valid_singlenode_config",
+ ],
+ deps = [
+ ":config_validator_lib",
+ "//aos:json_to_flatbuffer",
+ "//aos/testing:googletest",
+ "//aos/testing:path",
+ ],
+)
diff --git a/aos/util/config_validator.cc b/aos/util/config_validator.cc
index d5bd6ba..df21ba0 100644
--- a/aos/util/config_validator.cc
+++ b/aos/util/config_validator.cc
@@ -1,16 +1,9 @@
-#include <chrono>
-
-#include "aos/configuration.h"
-#include "aos/events/logging/log_reader.h"
-#include "aos/events/logging/log_writer.h"
-#include "aos/events/simulated_event_loop.h"
-#include "aos/init.h"
#include "aos/json_to_flatbuffer.h"
-#include "aos/network/team_number.h"
-#include "gflags/gflags.h"
-#include "gtest/gtest.h"
+#include "aos/util/config_validator_lib.h"
DEFINE_string(config, "", "Name of the config file to replay using.");
+DEFINE_string(validation_config, "{}",
+ "JSON config to use to validate the config.");
/* This binary is used to validate that all of the
needed remote timestamps channels are in the config
to log the timestamps.
@@ -26,9 +19,11 @@
const aos::FlatbufferDetachedBuffer<aos::Configuration> config =
aos::configuration::ReadConfig(FLAGS_config);
- aos::SimulatedEventLoopFactory factory(&config.message());
-
- factory.RunFor(std::chrono::seconds(1));
+ const aos::FlatbufferDetachedBuffer<aos::util::ConfigValidatorConfig>
+ validator_config =
+ aos::JsonToFlatbuffer<aos::util::ConfigValidatorConfig>(
+ FLAGS_validation_config);
+ aos::util::ConfigIsValid(&config.message(), &validator_config.message());
}
// TODO(milind): add more tests, the above one doesn't
diff --git a/aos/util/config_validator_config.fbs b/aos/util/config_validator_config.fbs
new file mode 100644
index 0000000..cda84b2
--- /dev/null
+++ b/aos/util/config_validator_config.fbs
@@ -0,0 +1,55 @@
+namespace aos.util;
+
+// This file defines a schema for what to validate when we run the
+// config_validator against an AOS config.
+// The primary purpose of this config is to allow the user to specify what
+// sets of nodes they expect to be able to log on so that we can validate the
+// logging configurations. In the future this may also include flags to indicate
+// how aggressively to do certain checks.
+//
+// This flatbuffer should not exist in serialized form anywhere, and so is
+// safe to modify in non-backwards-compatible ways.
+
+// Species a set of nodes that you should be able to combine the logs from and
+// subsequently replay. E.g., this allows you to write a check that says
+// "If you combine logs from pi2 & pi4, you should be able to replay data from
+// nodes pi2, pi4, and pi6"; or
+// "When logs from all nodes are combined, you should be able to replay data
+// for all nodes;" or
+// "Each node should log all the data needed to replay its own data"
+// (this would require muliple LoggerNodeSetValidation's).
+//
+// Each LoggerNodeSetValidation table represents a single set of logging nodes
+// that should be able to replay data on some number of other nodes. An empty
+// list of loggers or replay_nodes indicates "all nodes." The above examples
+// could then be represented by, e.g.:
+// "pi2 & pi4 -> pi2, pi4, & pi6":
+// {"loggers": ["pi2", "pi4"], "replay_nodes": ["pi2", "pi4", "pi6"]}
+// "all -> all": {"logger": [], "replay_nodes": []}
+// "each node -> itself": [
+// {"logger": ["pi1"], "replay_nodes": ["pi1"]},
+// {"logger": ["pi2"], "replay_nodes": ["pi2"]},
+// {"logger": ["pi3"], "replay_nodes": ["pi3"]},
+// {"logger": ["pi4"], "replay_nodes": ["pi4"]}]
+table LoggerNodeSetValidation {
+ loggers:[string] (id: 0);
+ replay_nodes:[string] (id: 1);
+}
+
+// This table specifies which
+table LoggingConfigValidation {
+ // If true, all channels should be logged by some valid set of loggers.
+ // Essentially, this is checking that no channels are configured to be
+ // NOT_LOGGED except for remote timestamp channels.
+ all_channels_logged:bool = true (id: 0);
+ // A list of all the sets of logger nodes that we care about. Typically this
+ // should at least include an entry that says that "logs from all nodes should
+ // combine to allow you to replay all nodes."
+ logger_sets:[LoggerNodeSetValidation] (id: 1);
+}
+
+table ConfigValidatorConfig {
+ logging:LoggingConfigValidation (id: 0);
+}
+
+root_type ConfigValidatorConfig;
diff --git a/aos/util/config_validator_lib.cc b/aos/util/config_validator_lib.cc
new file mode 100644
index 0000000..0f90ed6
--- /dev/null
+++ b/aos/util/config_validator_lib.cc
@@ -0,0 +1,292 @@
+#include "aos/util/config_validator_lib.h"
+
+#include <chrono>
+
+#include "aos/events/logging/log_reader.h"
+#include "aos/events/logging/log_writer.h"
+#include "aos/events/simulated_event_loop.h"
+#include "aos/network/remote_message_generated.h"
+#include "aos/network/timestamp_channel.h"
+#include "aos/testing/tmpdir.h"
+#include "aos/util/simulation_logger.h"
+
+DECLARE_bool(validate_timestamp_logger_nodes);
+
+namespace aos::util {
+
+namespace {
+void RunSimulationAndExit(const aos::Configuration *config) {
+ aos::SimulatedEventLoopFactory factory(config);
+
+ factory.RunFor(std::chrono::seconds(1));
+
+ std::exit(EXIT_SUCCESS);
+}
+
+// Checks if either the node is in the specified list of node names or if the
+// list is empty (in which case it is treated as matching all nodes).
+bool NodeInList(
+ const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *list,
+ const aos::Node *node) {
+ if (list == nullptr || list->size() == 0) {
+ return true;
+ }
+ for (const flatbuffers::String *name : *list) {
+ if (name->string_view() == node->name()->string_view()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+} // namespace
+
+void ConfigIsValid(const aos::Configuration *config,
+ const ConfigValidatorConfig *validation_config) {
+ ASSERT_TRUE(config->has_channels())
+ << "An AOS config must have channels. If you have a valid use-case for "
+ "channels with no channels, please write a design proposal.";
+
+ // First, we do some sanity checks--these are likely to indicate a malformed
+ // config, and so catching them early with a clear error message is likely to
+ // help.
+
+ // The set of all channels that are required by the channels that are
+ // configured--these are the remote timestamp channels that *must* be present,
+ // and ideally there are no other channels present.
+ std::set<const Channel *> required_timestamp_channels;
+ // The set of all channels that *look* like remote timestamp channels. This
+ // may include channels that are improperly configured and thus have typos &
+ // aren't actually going to do anything at runtime.
+ std::set<const Channel *> configured_timestamp_channels;
+ bool validation_failed = false;
+ for (size_t channel_index = 0; channel_index < config->channels()->size();
+ ++channel_index) {
+ const aos::Channel *channel = config->channels()->Get(channel_index);
+ ASSERT_TRUE(channel->has_name()) << "All AOS channels must have a name.";
+ ASSERT_TRUE(channel->has_type()) << "All AOS channels must have a type.";
+
+ const bool channel_looks_like_remote_message_channel =
+ channel->type()->string_view() ==
+ message_bridge::RemoteMessage::GetFullyQualifiedName();
+
+ const bool check_for_not_logged_channels =
+ !validation_config->has_logging() ||
+ validation_config->logging()->all_channels_logged();
+ const bool channel_is_not_logged =
+ channel->logger() == aos::LoggerConfig::NOT_LOGGED;
+ if (check_for_not_logged_channels) {
+ if (channel_looks_like_remote_message_channel != channel_is_not_logged) {
+ LOG(WARNING)
+ << "Channel " << configuration::StrippedChannelToString(channel)
+ << " is " << EnumNameLoggerConfig(channel->logger()) << " but "
+ << (channel_looks_like_remote_message_channel ? "is" : "is not")
+ << " a remote timestamp channel. This is almost certainly wrong.";
+ validation_failed = true;
+ }
+ }
+
+ if (channel_looks_like_remote_message_channel) {
+ configured_timestamp_channels.insert(channel);
+ } else {
+ if (channel->has_destination_nodes()) {
+ // TODO(james): Technically the timestamp finder should receive a
+ // non-empty application name. However, there are no known users that
+ // care at this moment.
+ message_bridge::ChannelTimestampFinder timestamp_finder(
+ config, "",
+ configuration::GetNode(config,
+ channel->source_node()->string_view()));
+ for (const Connection *connection : *channel->destination_nodes()) {
+ switch (connection->timestamp_logger()) {
+ case LoggerConfig::NOT_LOGGED:
+ case LoggerConfig::LOCAL_LOGGER:
+ if (connection->has_timestamp_logger_nodes()) {
+ LOG(WARNING)
+ << "Connections that are "
+ << EnumNameLoggerConfig(connection->timestamp_logger())
+ << " should not have remote timestamp logger nodes "
+ "populated. This is for the connection to "
+ << connection->name()->string_view() << " on "
+ << configuration::StrippedChannelToString(channel);
+ validation_failed = true;
+ }
+ break;
+ case LoggerConfig::REMOTE_LOGGER:
+ case LoggerConfig::LOCAL_AND_REMOTE_LOGGER:
+ if (!connection->has_timestamp_logger_nodes() ||
+ connection->timestamp_logger_nodes()->size() != 1 ||
+ connection->timestamp_logger_nodes()->Get(0)->string_view() !=
+ channel->source_node()->string_view()) {
+ LOG(WARNING)
+ << "Connections that are "
+ << EnumNameLoggerConfig(connection->timestamp_logger())
+ << " should have exactly 1 remote timestamp logger node "
+ "populated, and that node should be the source_node ("
+ << channel->source_node()->string_view()
+ << "). This is for the connection to "
+ << connection->name()->string_view() << " on "
+ << configuration::StrippedChannelToString(channel);
+ validation_failed = true;
+ }
+ // TODO(james): This will be overly noisy, as it ends up
+ // CHECK-failing.
+ required_timestamp_channels.insert(CHECK_NOTNULL(
+ timestamp_finder.ForChannel(channel, connection)));
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ // Check that all of the things that look like timestamp channels are indeed
+ // required.
+ // Note: Because ForChannel() will die if a required channel is not present,
+ // we do not do a separate check that all the required channels exist.
+ for (const auto &channel : configured_timestamp_channels) {
+ if (required_timestamp_channels.count(channel) == 0) {
+ LOG(WARNING) << "Timestamp channel "
+ << configuration::StrippedChannelToString(channel)
+ << " was specified in the config but is not used.";
+ validation_failed = true;
+ }
+ }
+
+ if (validation_failed) {
+ FAIL() << "Remote timestamp linting failed.";
+ return;
+ }
+
+ // Because the most common way for simulation to fail involves it dying, force
+ // it to fail in a slightly more controlled manner.
+ ASSERT_EXIT(RunSimulationAndExit(config),
+ ::testing::ExitedWithCode(EXIT_SUCCESS), "");
+
+ if (!validation_config->has_logging() || !configuration::MultiNode(config)) {
+ return;
+ }
+
+ // We will run all the logger configs in two modes:
+ // 1) We don't send any data on any non-infrastructure channels; this confirms
+ // that the logs are readable in the absence of any user applications being
+ // present.
+ // 2) We confirm that we can generate a good logfile that actually has data
+ // on every channel (some checks in the LogReader may not get hit if there
+ // is no data on a given channel).
+ const std::string log_path = aos::testing::TestTmpDir() + "/logs/";
+ for (const bool send_data_on_channels : {false, true}) {
+ SCOPED_TRACE(send_data_on_channels);
+ for (const LoggerNodeSetValidation *logger_set :
+ *validation_config->logging()->logger_sets()) {
+ SCOPED_TRACE(aos::FlatbufferToJson(logger_set));
+ aos::SimulatedEventLoopFactory factory(config);
+ std::vector<std::unique_ptr<LoggerState>> loggers;
+ if (logger_set->has_loggers() && logger_set->loggers()->size() > 0) {
+ std::vector<std::string> logger_nodes;
+ for (const auto &node : *logger_set->loggers()) {
+ logger_nodes.push_back(node->str());
+ }
+ loggers = MakeLoggersForNodes(&factory, logger_nodes, log_path);
+ } else {
+ loggers = MakeLoggersForAllNodes(&factory, log_path);
+ }
+
+ std::vector<std::unique_ptr<EventLoop>> test_loops;
+ std::map<std::string, std::vector<std::unique_ptr<RawSender>>>
+ test_senders;
+
+ if (send_data_on_channels) {
+ // Make a sender on every non-infrastructure channel on every node
+ // (including channels that may not be observable by the current logger
+ // set).
+ for (const aos::Node *node : configuration::GetNodes(config)) {
+ test_loops.emplace_back(factory.MakeEventLoop("", node));
+ for (const aos::Channel *channel : *config->channels()) {
+ // TODO(james): Make a more sophisticated check for "infrastructure"
+ // channels than just looking for a "/aos" in the channel--we don't
+ // accidentally want to spam nonsense data onto any timestamp
+ // channels, though.
+ if (configuration::ChannelIsSendableOnNode(channel, node) &&
+ channel->name()->str().find("/aos") == std::string::npos &&
+ channel->logger() != LoggerConfig::NOT_LOGGED) {
+ test_senders[node->name()->str()].emplace_back(
+ test_loops.back()->MakeRawSender(channel));
+ RawSender *sender =
+ test_senders[node->name()->str()].back().get();
+ test_loops.back()->OnRun([sender, channel]() {
+ flatbuffers::DetachedBuffer buffer =
+ JsonToFlatbuffer("{}", channel->schema());
+ sender->CheckOk(sender->Send(buffer.data(), buffer.size()));
+ });
+ }
+ }
+ }
+ }
+
+ factory.RunFor(std::chrono::seconds(2));
+
+ // Get all of the loggers to close before trying to read the logfiles.
+ loggers.clear();
+
+ // Confirm that we can read the log, and that if we put data in it that we
+ // can find data on all the nodes that the user cares about.
+ logger::LogReader reader(logger::SortParts(logger::FindLogs(log_path)));
+ SimulatedEventLoopFactory replay_factory(reader.configuration());
+ reader.RegisterWithoutStarting(&replay_factory);
+
+ // Find every channel we deliberately sent data on, and if it is for a
+ // node that we care about, confirm that we get it during replay.
+ std::vector<std::unique_ptr<EventLoop>> replay_loops;
+ std::vector<std::unique_ptr<RawFetcher>> fetchers;
+ for (const aos::Node *node :
+ configuration::GetNodes(replay_factory.configuration())) {
+ // If the user doesn't care about this node, don't check it.
+ if (!NodeInList(logger_set->replay_nodes(), node)) {
+ continue;
+ }
+ replay_loops.emplace_back(replay_factory.MakeEventLoop("", node));
+ for (const auto &sender : test_senders[node->name()->str()]) {
+ const aos::Channel *channel = configuration::GetChannel(
+ replay_factory.configuration(), sender->channel(), "", node);
+ fetchers.emplace_back(replay_loops.back()->MakeRawFetcher(channel));
+ }
+ }
+
+ std::vector<std::pair<const aos::Node *, std::unique_ptr<RawFetcher>>>
+ remote_fetchers;
+ for (const auto &fetcher : fetchers) {
+ for (auto &loop : replay_loops) {
+ const Connection *connection =
+ configuration::ConnectionToNode(fetcher->channel(), loop->node());
+ if (connection != nullptr) {
+ remote_fetchers.push_back(std::make_pair(
+ loop->node(), loop->MakeRawFetcher(fetcher->channel())));
+ }
+ }
+ }
+
+ replay_factory.Run();
+
+ for (auto &fetcher : fetchers) {
+ EXPECT_TRUE(fetcher->Fetch())
+ << "Failed to log or replay any data on "
+ << configuration::StrippedChannelToString(fetcher->channel());
+ }
+
+ for (auto &pair : remote_fetchers) {
+ EXPECT_TRUE(pair.second->Fetch())
+ << "Failed to log or replay any data on "
+ << configuration::StrippedChannelToString(pair.second->channel())
+ << " from remote node " << logger::MaybeNodeName(pair.first) << ".";
+ }
+
+ reader.Deregister();
+
+ // Clean up the logs.
+ UnlinkRecursive(log_path);
+ }
+ }
+}
+
+} // namespace aos::util
diff --git a/aos/util/config_validator_lib.h b/aos/util/config_validator_lib.h
new file mode 100644
index 0000000..61658e5
--- /dev/null
+++ b/aos/util/config_validator_lib.h
@@ -0,0 +1,12 @@
+#ifndef AOS_UTIL_CONFIG_VALIDATOR_H_
+#define AOS_UTIL_CONFIG_VALIDATOR_H_
+
+#include "aos/configuration.h"
+#include "aos/util/config_validator_config_generated.h"
+#include "gtest/gtest.h"
+namespace aos::util {
+
+void ConfigIsValid(const aos::Configuration *config,
+ const ConfigValidatorConfig *validation_config);
+} // namespace aos::util
+#endif // AOS_UTIL_CONFIG_VALIDATOR_H_
diff --git a/aos/util/config_validator_lib_test.cc b/aos/util/config_validator_lib_test.cc
new file mode 100644
index 0000000..c68695c
--- /dev/null
+++ b/aos/util/config_validator_lib_test.cc
@@ -0,0 +1,189 @@
+#include "aos/util/config_validator_lib.h"
+
+#include "aos/json_to_flatbuffer.h"
+#include "aos/testing/path.h"
+#include "gtest/gtest-spi.h"
+
+using aos::testing::ArtifactPath;
+namespace aos::util::testing {
+
+// Check that a reasonably normal config passes the config validator with a
+// reasonable set of checks turned on.
+TEST(ConfigValidatorTest, NoErrorOnValidConfigs) {
+ const FlatbufferDetachedBuffer<Configuration> config =
+ configuration::ReadConfig(
+ ArtifactPath("aos/util/test_data/valid_multinode_config.json"));
+ const FlatbufferDetachedBuffer<ConfigValidatorConfig> validator_config =
+ JsonToFlatbuffer<ConfigValidatorConfig>(R"json({"logging": {
+ "all_channels_logged": true,
+ "logger_sets": [
+ {
+ "loggers": [],
+ "replay_nodes": []
+ },
+ {
+ "loggers": ["pi1"],
+ "replay_nodes": ["pi1"]
+ },
+ {
+ "loggers": ["pi2"],
+ "replay_nodes": ["pi2"]
+ }
+ ]}})json");
+ ConfigIsValid(&config.message(), &validator_config.message());
+}
+
+// Check that a reasonably normal single-node config passes the config validator
+// with a reasonable set of checks turned on.
+TEST(ConfigValidatorTest, NoErrorOnValidSingleNodeConfig) {
+ const FlatbufferDetachedBuffer<Configuration> config =
+ configuration::ReadConfig(
+ ArtifactPath("aos/util/test_data/valid_singlenode_config.json"));
+ const FlatbufferDetachedBuffer<ConfigValidatorConfig> validator_config =
+ JsonToFlatbuffer<ConfigValidatorConfig>(R"json({"logging": {
+ "all_channels_logged": true,
+ "logger_sets": [
+ {
+ "loggers": [],
+ "replay_nodes": []
+ }
+ ]}})json");
+ ConfigIsValid(&config.message(), &validator_config.message());
+}
+
+// Checks that the validator fails if the message bridge statistics channels are
+// missing.
+TEST(ConfigValidatorTest, FailOnMissingStatisticsChannels) {
+ EXPECT_FATAL_FAILURE(
+ {
+ const FlatbufferDetachedBuffer<Configuration> config =
+ configuration::ReadConfig(ArtifactPath(
+ "aos/util/test_data/multinode_no_statistics.json"));
+ const FlatbufferDetachedBuffer<ConfigValidatorConfig> validator_config =
+ JsonToFlatbuffer<ConfigValidatorConfig>("{}");
+ ConfigIsValid(&config.message(), &validator_config.message());
+ },
+ "Statistics");
+}
+
+// Checks that the validator fails if a timestamp channel has a typo and so
+// doesn't exist.
+TEST(ConfigValidatorTest, FailOnTimestampTypo) {
+ EXPECT_DEATH(
+ {
+ const FlatbufferDetachedBuffer<Configuration> config =
+ configuration::ReadConfig(ArtifactPath(
+ "aos/util/test_data/multinode_timestamp_typo.json"));
+ const FlatbufferDetachedBuffer<ConfigValidatorConfig> validator_config =
+ JsonToFlatbuffer<ConfigValidatorConfig>("{}");
+ ConfigIsValid(&config.message(), &validator_config.message());
+ },
+ "not found in config");
+}
+
+// Checks that the validator fails if there is a RemoteMessage channel that is
+// *not* a timestamp channel (Since this is almost always a typo).
+TEST(ConfigValidatorTest, FailOnExtraneousTimestampChannel) {
+ EXPECT_FATAL_FAILURE(
+ {
+ const FlatbufferDetachedBuffer<Configuration> config =
+ configuration::ReadConfig(ArtifactPath(
+ "aos/util/test_data/multinode_extraneous_timestamp.json"));
+ const FlatbufferDetachedBuffer<ConfigValidatorConfig> validator_config =
+ JsonToFlatbuffer<ConfigValidatorConfig>("{}");
+ ConfigIsValid(&config.message(), &validator_config.message());
+ },
+ "linting failed");
+}
+
+// Checks that the validator fails on timestamp logger nodes that won't really
+// log the timestamps.
+TEST(ConfigValidatorTest, FailOnInvalidRemoteTimestampLogger) {
+ EXPECT_FATAL_FAILURE(
+ {
+ const FlatbufferDetachedBuffer<Configuration> config =
+ configuration::ReadConfig(
+ ArtifactPath("aos/util/test_data/"
+ "multinode_invalid_timestamp_logger_list.json"));
+ const FlatbufferDetachedBuffer<ConfigValidatorConfig> validator_config =
+ JsonToFlatbuffer<ConfigValidatorConfig>(R"json({"logging": {
+ "all_channels_logged": true,
+ "logger_sets": [
+ {
+ "loggers": [],
+ "replay_nodes": []
+ }
+ ]}})json");
+ ConfigIsValid(&config.message(), &validator_config.message());
+ },
+ "linting failed");
+}
+
+// Checks that if you attempt to log on pi2 but expect it to have data for pi1
+// then the test fails (at least, for a config which does not forward all the
+// channels between the nodes).
+TEST(ConfigValidatorTest, FailOnNormalInsufficientLogging) {
+ EXPECT_NONFATAL_FAILURE(
+ {
+ const FlatbufferDetachedBuffer<Configuration> config =
+ configuration::ReadConfig(
+ ArtifactPath("aos/util/test_data/valid_multinode_config.json"));
+ const FlatbufferDetachedBuffer<ConfigValidatorConfig> validator_config =
+ JsonToFlatbuffer<ConfigValidatorConfig>(R"json({"logging": {
+ "all_channels_logged": true,
+ "logger_sets": [
+ {
+ "loggers": ["pi2"],
+ "replay_nodes": ["pi1"]
+ }
+ ]}})json");
+ ConfigIsValid(&config.message(), &validator_config.message());
+ },
+ "Failed to log");
+}
+
+// Checks that if we have a node that is configured to log all the data from all
+// the nodes that the test passes.
+TEST(ConfigValidatorTest, PassCommonLoggerNode) {
+ const FlatbufferDetachedBuffer<Configuration> config =
+ configuration::ReadConfig(
+ ArtifactPath("aos/util/test_data/multinode_common_logger.json"));
+ const FlatbufferDetachedBuffer<ConfigValidatorConfig> validator_config =
+ JsonToFlatbuffer<ConfigValidatorConfig>(R"json({"logging": {
+ "all_channels_logged": true,
+ "logger_sets": [
+ {
+ "loggers": ["pi2"],
+ "replay_nodes": ["pi1"]
+ },
+ {
+ "loggers": [],
+ "replay_nodes": []
+ }
+ ]}})json");
+ ConfigIsValid(&config.message(), &validator_config.message());
+}
+
+// Sets up a config that will not actually log sufficient timestamp data to
+// support full replay, and ensures that we identify that.
+TEST(ConfigValidatorTest, FailOnInsufficientConfiguredTimestampData) {
+ EXPECT_NONFATAL_FAILURE(
+ {
+ const FlatbufferDetachedBuffer<Configuration> config =
+ configuration::ReadConfig(ArtifactPath(
+ "aos/util/test_data/multinode_no_logged_timestamps.json"));
+ const FlatbufferDetachedBuffer<ConfigValidatorConfig> validator_config =
+ JsonToFlatbuffer<ConfigValidatorConfig>(R"json({"logging": {
+ "all_channels_logged": true,
+ "logger_sets": [
+ {
+ "loggers": [],
+ "replay_nodes": []
+ }
+ ]}})json");
+ ConfigIsValid(&config.message(), &validator_config.message());
+ },
+ R"json(Failed to log or replay any data on { "name": "/test", "type": "aos.examples.Ping" } from remote node pi2)json");
+}
+
+} // namespace aos::util::testing
diff --git a/aos/util/config_validator_macro.bzl b/aos/util/config_validator_macro.bzl
index 453c5c2..16861c6 100644
--- a/aos/util/config_validator_macro.bzl
+++ b/aos/util/config_validator_macro.bzl
@@ -1,4 +1,4 @@
-def config_validator_rule(name, config, extension = ".bfbs", visibility = None):
+def config_validator_rule(name, config, logger_sets = [{}], check_for_not_logged_channels = False, extension = ".bfbs", visibility = None):
'''
Macro to take a config and pass it to the config validator to validate that it will work on a real system.
@@ -9,10 +9,11 @@
config: config rule that needs to be validated, e.g. "//aos/events:pingpong_config",
'''
config_file = config + extension
+ config_json = json.encode({"logging": {"all_channels_logged": check_for_not_logged_channels, "logger_sets": logger_sets}})
native.genrule(
name = name,
outs = [name + ".txt"],
- cmd = "$(location //aos/util:config_validator) --config $(location %s) > $@" % config_file,
+ cmd = "$(location //aos/util:config_validator) --config $(location %s) --validation_config='%s' && touch $@" % (config_file, config_json),
srcs = [config_file],
tools = ["//aos/util:config_validator"],
testonly = True,
diff --git a/aos/util/simulation_logger.cc b/aos/util/simulation_logger.cc
index e459978..1f55ece 100644
--- a/aos/util/simulation_logger.cc
+++ b/aos/util/simulation_logger.cc
@@ -1,11 +1,12 @@
#include "aos/util/simulation_logger.h"
+#include "aos/events/logging/logfile_utils.h"
namespace aos::util {
LoggerState::LoggerState(aos::SimulatedEventLoopFactory *factory,
const aos::Node *node, std::string_view output_folder)
: event_loop_(factory->MakeEventLoop("logger", node)),
namer_(std::make_unique<aos::logger::MultiNodeFilesLogNamer>(
- absl::StrCat(output_folder, "/", node->name()->string_view(), "/"),
+ absl::StrCat(output_folder, "/", logger::MaybeNodeName(node), "/"),
event_loop_.get())),
logger_(std::make_unique<aos::logger::Logger>(event_loop_.get())) {
event_loop_->SkipTimingReport();
diff --git a/aos/util/test_data/BUILD b/aos/util/test_data/BUILD
new file mode 100644
index 0000000..016dd07
--- /dev/null
+++ b/aos/util/test_data/BUILD
@@ -0,0 +1,28 @@
+load("//aos:config.bzl", "aos_config")
+
+[
+ aos_config(
+ name = name,
+ src = name + "_source.json",
+ flatbuffers = [
+ "//aos/network:remote_message_fbs",
+ "//aos/events:ping_fbs",
+ "//aos/network:message_bridge_client_fbs",
+ "//aos/network:message_bridge_server_fbs",
+ "//aos/network:timestamp_fbs",
+ ],
+ target_compatible_with = ["@platforms//os:linux"],
+ visibility = ["//visibility:public"],
+ deps = ["//aos/events:aos_config"],
+ )
+ for name in [
+ "valid_multinode_config",
+ "valid_singlenode_config",
+ "multinode_no_statistics",
+ "multinode_timestamp_typo",
+ "multinode_extraneous_timestamp",
+ "multinode_invalid_timestamp_logger_list",
+ "multinode_common_logger",
+ "multinode_no_logged_timestamps",
+ ]
+]
diff --git a/aos/util/test_data/multinode_common_logger_source.json b/aos/util/test_data/multinode_common_logger_source.json
new file mode 100644
index 0000000..81aa065
--- /dev/null
+++ b/aos/util/test_data/multinode_common_logger_source.json
@@ -0,0 +1,156 @@
+{
+ "channels": [
+ {
+ "name": "/pi1/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi1",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi2",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi1",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi1"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi2",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi1",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi2"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.ServerStatistics",
+ "source_node": "pi1",
+ "frequency": 2
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.ServerStatistics",
+ "source_node": "pi2",
+ "frequency": 2
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.ClientStatistics",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.ClientStatistics",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/pi1/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos/remote_timestamps/pi1/pi2/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/test/aos-examples-Ping",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1"
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi1",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi2",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/test",
+ "type": "aos.examples.Ping",
+ "source_node": "pi1",
+ "logger": "LOCAL_AND_REMOTE_LOGGER",
+ "logger_nodes": ["pi2"],
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi1"]
+ }
+ ],
+ "max_size": 20480
+ }
+ ],
+ "maps": [
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi1"
+ },
+ "rename": {
+ "name": "/pi1/aos"
+ }
+ },
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi2"
+ },
+ "rename": {
+ "name": "/pi2/aos"
+ }
+ }
+ ],
+ "nodes": [
+ {
+ "name": "pi1"
+ },
+ {
+ "name": "pi2"
+ }
+ ]
+}
diff --git a/aos/util/test_data/multinode_extraneous_timestamp_source.json b/aos/util/test_data/multinode_extraneous_timestamp_source.json
new file mode 100644
index 0000000..2e889d0
--- /dev/null
+++ b/aos/util/test_data/multinode_extraneous_timestamp_source.json
@@ -0,0 +1,161 @@
+{
+ "channels": [
+ {
+ "name": "/pi1/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi1",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi2",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi1",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi1"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi2",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi1",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi2"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.ServerStatistics",
+ "source_node": "pi1",
+ "frequency": 2
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.ServerStatistics",
+ "source_node": "pi2",
+ "frequency": 2
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.ClientStatistics",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.ClientStatistics",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/pi1/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/pi1/aos/os-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos/remote_timestamps/pi1/pi2/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/test/aos-examples-Ping",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1"
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi1",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi2",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/test",
+ "type": "aos.examples.Ping",
+ "source_node": "pi1",
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi1"]
+ }
+ ],
+ "max_size": 20480
+ }
+ ],
+ "maps": [
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi1"
+ },
+ "rename": {
+ "name": "/pi1/aos"
+ }
+ },
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi2"
+ },
+ "rename": {
+ "name": "/pi2/aos"
+ }
+ }
+ ],
+ "nodes": [
+ {
+ "name": "pi1"
+ },
+ {
+ "name": "pi2"
+ }
+ ]
+}
diff --git a/aos/util/test_data/multinode_invalid_timestamp_logger_list_source.json b/aos/util/test_data/multinode_invalid_timestamp_logger_list_source.json
new file mode 100644
index 0000000..e501437
--- /dev/null
+++ b/aos/util/test_data/multinode_invalid_timestamp_logger_list_source.json
@@ -0,0 +1,154 @@
+{
+ "channels": [
+ {
+ "name": "/pi1/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi1",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi2",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi1",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi2"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi2",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi1",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi2"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.ServerStatistics",
+ "source_node": "pi1",
+ "frequency": 2
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.ServerStatistics",
+ "source_node": "pi2",
+ "frequency": 2
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.ClientStatistics",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.ClientStatistics",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/pi1/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos/remote_timestamps/pi1/pi2/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/test/aos-examples-Ping",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1"
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi1",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi2",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/test",
+ "type": "aos.examples.Ping",
+ "source_node": "pi1",
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi1"]
+ }
+ ],
+ "max_size": 20480
+ }
+ ],
+ "maps": [
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi1"
+ },
+ "rename": {
+ "name": "/pi1/aos"
+ }
+ },
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi2"
+ },
+ "rename": {
+ "name": "/pi2/aos"
+ }
+ }
+ ],
+ "nodes": [
+ {
+ "name": "pi1"
+ },
+ {
+ "name": "pi2"
+ }
+ ]
+}
diff --git a/aos/util/test_data/multinode_no_logged_timestamps_source.json b/aos/util/test_data/multinode_no_logged_timestamps_source.json
new file mode 100644
index 0000000..a956f73
--- /dev/null
+++ b/aos/util/test_data/multinode_no_logged_timestamps_source.json
@@ -0,0 +1,147 @@
+{
+ "channels": [
+ {
+ "name": "/pi1/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi1",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi2",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi1",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi1"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi2",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi1",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi2"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.ServerStatistics",
+ "source_node": "pi1",
+ "frequency": 2
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.ServerStatistics",
+ "source_node": "pi2",
+ "frequency": 2
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.ClientStatistics",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.ClientStatistics",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/pi1/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos/remote_timestamps/pi1/pi2/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi1",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi2",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/test",
+ "type": "aos.examples.Ping",
+ "source_node": "pi1",
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "NOT_LOGGED"
+ }
+ ],
+ "max_size": 20480
+ }
+ ],
+ "maps": [
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi1"
+ },
+ "rename": {
+ "name": "/pi1/aos"
+ }
+ },
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi2"
+ },
+ "rename": {
+ "name": "/pi2/aos"
+ }
+ }
+ ],
+ "nodes": [
+ {
+ "name": "pi1"
+ },
+ {
+ "name": "pi2"
+ }
+ ]
+}
diff --git a/aos/util/test_data/multinode_no_statistics_source.json b/aos/util/test_data/multinode_no_statistics_source.json
new file mode 100644
index 0000000..44fa5d8
--- /dev/null
+++ b/aos/util/test_data/multinode_no_statistics_source.json
@@ -0,0 +1,130 @@
+{
+ "channels": [
+ {
+ "name": "/pi1/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi1",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi2",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi1",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi1"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi2",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi1",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi2"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/pi1/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos/remote_timestamps/pi1/pi2/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/test/aos-examples-Ping",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1"
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi1",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi2",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/test",
+ "type": "aos.examples.Ping",
+ "source_node": "pi1",
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi1"]
+ }
+ ],
+ "max_size": 20480
+ }
+ ],
+ "maps": [
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi1"
+ },
+ "rename": {
+ "name": "/pi1/aos"
+ }
+ },
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi2"
+ },
+ "rename": {
+ "name": "/pi2/aos"
+ }
+ }
+ ],
+ "nodes": [
+ {
+ "name": "pi1"
+ },
+ {
+ "name": "pi2"
+ }
+ ]
+}
diff --git a/aos/util/test_data/multinode_timestamp_typo_source.json b/aos/util/test_data/multinode_timestamp_typo_source.json
new file mode 100644
index 0000000..afb4275
--- /dev/null
+++ b/aos/util/test_data/multinode_timestamp_typo_source.json
@@ -0,0 +1,154 @@
+{
+ "channels": [
+ {
+ "name": "/pi1/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi1",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi2",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi1",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi1"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi2",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi1",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi2"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.ServerStatistics",
+ "source_node": "pi1",
+ "frequency": 2
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.ServerStatistics",
+ "source_node": "pi2",
+ "frequency": 2
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.ClientStatistics",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.ClientStatistics",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/pi1/aos/aos-message_bridge-Timestam",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos/remote_timestamps/pi1/pi2/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/test/aos-examples-Ping",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1"
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi1",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi2",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/test",
+ "type": "aos.examples.Ping",
+ "source_node": "pi1",
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi1"]
+ }
+ ],
+ "max_size": 20480
+ }
+ ],
+ "maps": [
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi1"
+ },
+ "rename": {
+ "name": "/pi1/aos"
+ }
+ },
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi2"
+ },
+ "rename": {
+ "name": "/pi2/aos"
+ }
+ }
+ ],
+ "nodes": [
+ {
+ "name": "pi1"
+ },
+ {
+ "name": "pi2"
+ }
+ ]
+}
diff --git a/aos/util/test_data/valid_multinode_config_source.json b/aos/util/test_data/valid_multinode_config_source.json
new file mode 100644
index 0000000..0c35251
--- /dev/null
+++ b/aos/util/test_data/valid_multinode_config_source.json
@@ -0,0 +1,154 @@
+{
+ "channels": [
+ {
+ "name": "/pi1/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi1",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "source_node": "pi2",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi1",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi1"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.Timestamp",
+ "source_node": "pi2",
+ "frequency": 15,
+ "max_size": 200,
+ "destination_nodes": [
+ {
+ "name": "pi1",
+ "priority": 1,
+ "timestamp_logger": "LOCAL_AND_REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi2"],
+ "time_to_live": 5000000
+ }
+ ]
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.ServerStatistics",
+ "source_node": "pi1",
+ "frequency": 2
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.ServerStatistics",
+ "source_node": "pi2",
+ "frequency": 2
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.message_bridge.ClientStatistics",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.message_bridge.ClientStatistics",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/pi1/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1",
+ "frequency": 15
+ },
+ {
+ "name": "/pi2/aos/remote_timestamps/pi1/pi2/aos/aos-message_bridge-Timestamp",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi2",
+ "frequency": 15
+ },
+ {
+ "name": "/pi1/aos/remote_timestamps/pi2/test/aos-examples-Ping",
+ "type": "aos.message_bridge.RemoteMessage",
+ "logger": "NOT_LOGGED",
+ "source_node": "pi1"
+ },
+ {
+ "name": "/pi1/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi1",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/pi2/aos",
+ "type": "aos.timing.Report",
+ "source_node": "pi2",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/test",
+ "type": "aos.examples.Ping",
+ "source_node": "pi1",
+ "destination_nodes": [
+ {
+ "name": "pi2",
+ "priority": 1,
+ "timestamp_logger": "REMOTE_LOGGER",
+ "timestamp_logger_nodes": ["pi1"]
+ }
+ ],
+ "max_size": 20480
+ }
+ ],
+ "maps": [
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi1"
+ },
+ "rename": {
+ "name": "/pi1/aos"
+ }
+ },
+ {
+ "match": {
+ "name": "/aos*",
+ "source_node": "pi2"
+ },
+ "rename": {
+ "name": "/pi2/aos"
+ }
+ }
+ ],
+ "nodes": [
+ {
+ "name": "pi1"
+ },
+ {
+ "name": "pi2"
+ }
+ ]
+}
diff --git a/aos/util/test_data/valid_singlenode_config_source.json b/aos/util/test_data/valid_singlenode_config_source.json
new file mode 100644
index 0000000..736eace
--- /dev/null
+++ b/aos/util/test_data/valid_singlenode_config_source.json
@@ -0,0 +1,23 @@
+{
+ "channels": [
+ {
+ "name": "/aos",
+ "type": "aos.logging.LogMessageFbs",
+ "frequency": 200,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/aos",
+ "type": "aos.timing.Report",
+ "frequency": 50,
+ "num_senders": 20,
+ "max_size": 2048
+ },
+ {
+ "name": "/test",
+ "type": "aos.examples.Ping",
+ "max_size": 20480
+ }
+ ]
+}