blob: ac93736b5e5e4e4968112ae598fc5b7527102764 [file] [log] [blame]
Tomáš Pecka55f64f82020-12-10 19:03:30 +01001#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
16using namespace std::chrono_literals;
17
18TEST_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át7efd6d52021-11-09 01:31:11 +010025 srSess.switchDatastore(sysrepo::Datastore::Operational);
Tomáš Pecka55f64f82020-12-10 19:03:30 +010026 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áš Pecka55f64f82020-12-10 19:03:30 +010031 {"/component[name='ne:edfa']", ""},
32 {"/component[name='ne:edfa']/name", "ne:edfa"},
33 {"/component[name='ne:edfa']/class", "iana-hardware:module"},
Tomáš Pecka55f64f82020-12-10 19:03:30 +010034 {"/component[name='ne:ctrl']", ""},
35 {"/component[name='ne:ctrl']/name", "ne:ctrl"},
36 {"/component[name='ne:ctrl']/class", "iana-hardware:module"},
Tomáš Pecka55f64f82020-12-10 19:03:30 +010037 });
Václav Kubernát7efd6d52021-11-09 01:31:11 +010038 srSess.switchDatastore(sysrepo::Datastore::Running);
Tomáš Pecka55f64f82020-12-10 19:03:30 +010039 }
40}