Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 1 | #include "trompeloeil_doctest.h" |
| 2 | #include "pretty_printers.h" |
| 3 | #include "test_log_setup.h" |
| 4 | #include "test_sysrepo_helpers.h" |
| 5 | |
| 6 | /* This is a generic test for the following use-case in the ietf-hardware model |
| 7 | * - Process #1 starts and uses sr_set_item to set some data in the "/ietf-hardware:hardware/component" subtree |
| 8 | * - Process #2 starts and implements sr_oper_get_items_subscribe for the data in the same subtree |
| 9 | * - Process #3 should see all of the data. |
| 10 | * |
| 11 | * Processes #1 and #2 are started (and stopped) by ctest wrapper script (sysrepo_test_merge_fixture.sh) and their code can be found in sysrepo_test_merge_daemon.cpp |
| 12 | * The wrapper script ŕeturns *after* both processes report that sysrepo is initialised (ie., callback is added in #2, items are set in #1). |
| 13 | * This is implemented simply via some checks whether file exists (see the sh file). |
| 14 | */ |
| 15 | |
| 16 | using namespace std::chrono_literals; |
| 17 | |
| 18 | TEST_CASE("HardwareState with two daemons") |
| 19 | { |
| 20 | TEST_SYSREPO_INIT; |
| 21 | TEST_SYSREPO_INIT_LOGS; |
| 22 | |
| 23 | SECTION("Test when both processes are running") |
| 24 | { |
Václav Kubernát | 7efd6d5 | 2021-11-09 01:31:11 +0100 | [diff] [blame] | 25 | srSess.switchDatastore(sysrepo::Datastore::Operational); |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 26 | REQUIRE(dataFromSysrepo(srSess, "/ietf-hardware:hardware") == std::map<std::string, std::string> { |
| 27 | {"/component[name='ne']", ""}, |
| 28 | {"/component[name='ne']/name", "ne"}, |
| 29 | {"/component[name='ne']/class", "iana-hardware:module"}, |
| 30 | {"/component[name='ne']/description", "This data was brought to you by process 2 (subscr)."}, |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 31 | {"/component[name='ne:edfa']", ""}, |
| 32 | {"/component[name='ne:edfa']/name", "ne:edfa"}, |
| 33 | {"/component[name='ne:edfa']/class", "iana-hardware:module"}, |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 34 | {"/component[name='ne:ctrl']", ""}, |
| 35 | {"/component[name='ne:ctrl']/name", "ne:ctrl"}, |
| 36 | {"/component[name='ne:ctrl']/class", "iana-hardware:module"}, |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 37 | }); |
Václav Kubernát | 7efd6d5 | 2021-11-09 01:31:11 +0100 | [diff] [blame] | 38 | srSess.switchDatastore(sysrepo::Datastore::Running); |
Tomáš Pecka | 55f64f8 | 2020-12-10 19:03:30 +0100 | [diff] [blame] | 39 | } |
| 40 | } |