Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 1 | #include "trompeloeil_doctest.h" |
| 2 | #include <iterator> |
| 3 | #include "ietf-hardware/IETFHardware.h" |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 4 | #include "ietf-hardware/sysrepo/Sysrepo.h" |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 5 | #include "mock/ietf_hardware.h" |
| 6 | #include "pretty_printers.h" |
| 7 | #include "test_log_setup.h" |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 8 | #include "test_sysrepo_helpers.h" |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 9 | #include "tests/configure.cmake.h" |
| 10 | |
| 11 | using namespace std::literals; |
| 12 | |
| 13 | TEST_CASE("HardwareState") |
| 14 | { |
| 15 | TEST_INIT_LOGS; |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 16 | static const auto modulePrefix = "/ietf-hardware:hardware"s; |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 17 | |
| 18 | trompeloeil::sequence seq1; |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 19 | auto ietfHardware = std::make_shared<velia::ietf_hardware::IETFHardware>(); |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 20 | |
| 21 | auto fans = std::make_shared<FakeHWMon>(); |
| 22 | auto sysfsTempCpu = std::make_shared<FakeHWMon>(); |
| 23 | auto sysfsTempFront = std::make_shared<FakeHWMon>(); |
| 24 | auto sysfsTempMII0 = std::make_shared<FakeHWMon>(); |
| 25 | auto sysfsTempMII1 = std::make_shared<FakeHWMon>(); |
| 26 | auto emmc = std::make_shared<FakeEMMC>(); |
| 27 | |
| 28 | std::map<std::string, std::string> attributesEMMC; |
| 29 | std::map<std::string, int64_t> attributesHWMon; |
| 30 | |
| 31 | // initialize all mocks |
| 32 | attributesEMMC = { |
| 33 | // FIXME passing initializer_list to macro is hell |
| 34 | {"date"s, "02/2017"s}, |
| 35 | {"serial"s, "0x00a8808d"s}, |
| 36 | {"name"s, "8GME4R"s}, |
| 37 | }; |
| 38 | FAKE_EMMC(emmc, attributesEMMC); |
| 39 | |
| 40 | attributesHWMon = { |
| 41 | {"fan1_input"s, 253}, |
| 42 | {"fan2_input"s, 0}, |
| 43 | {"fan3_input"s, 1280}, |
| 44 | {"fan4_input"s, 666}, |
| 45 | }; |
| 46 | FAKE_HWMON(fans, attributesHWMon); |
| 47 | |
| 48 | attributesHWMon = {{"temp1_input", 30800}}; |
| 49 | FAKE_HWMON(sysfsTempFront, attributesHWMon); |
| 50 | attributesHWMon = {{"temp1_input", 41800}}; |
| 51 | FAKE_HWMON(sysfsTempCpu, attributesHWMon); |
| 52 | attributesHWMon = {{"temp1_input", 39000}}; |
| 53 | FAKE_HWMON(sysfsTempMII0, attributesHWMon); |
| 54 | attributesHWMon = {{"temp1_input", 36000}}; |
| 55 | FAKE_HWMON(sysfsTempMII1, attributesHWMon); |
| 56 | |
| 57 | attributesEMMC = {{"life_time"s, "40"s}}; |
| 58 | FAKE_EMMC(emmc, attributesEMMC); |
| 59 | |
| 60 | // register components into hw state |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 61 | ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::StaticData("ne", std::nullopt, {{"class", "iana-hardware:chassis"}, {"mfg-name", "CESNET"s}})); |
| 62 | ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::StaticData("ne:ctrl", "ne", {{"class", "iana-hardware:module"}})); |
| 63 | ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::Fans("ne:fans", "ne", fans, 4)); |
| 64 | ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::SysfsTemperature("ne:ctrl:temperature-front", "ne:ctrl", sysfsTempFront, 1)); |
| 65 | ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::SysfsTemperature("ne:ctrl:temperature-cpu", "ne:ctrl", sysfsTempCpu, 1)); |
| 66 | ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::SysfsTemperature("ne:ctrl:temperature-internal-0", "ne:ctrl", sysfsTempMII0, 1)); |
| 67 | ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::SysfsTemperature("ne:ctrl:temperature-internal-1", "ne:ctrl", sysfsTempMII1, 1)); |
| 68 | ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::EMMC("ne:ctrl:emmc", "ne:ctrl", emmc)); |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 69 | |
| 70 | SECTION("Test HardwareState without sysrepo") |
| 71 | { |
| 72 | std::map<std::string, std::string> expected = { |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 73 | {"/ietf-hardware:hardware/component[name='ne']/class", "iana-hardware:chassis"}, |
| 74 | {"/ietf-hardware:hardware/component[name='ne']/mfg-name", "CESNET"}, |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 75 | |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 76 | {"/ietf-hardware:hardware/component[name='ne:fans']/class", "iana-hardware:module"}, |
| 77 | {"/ietf-hardware:hardware/component[name='ne:fans']/parent", "ne"}, |
| 78 | {"/ietf-hardware:hardware/component[name='ne:fans:fan1']/class", "iana-hardware:fan"}, |
| 79 | {"/ietf-hardware:hardware/component[name='ne:fans:fan1']/parent", "ne:fans"}, |
| 80 | {"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/class", "iana-hardware:sensor"}, |
| 81 | {"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/parent", "ne:fans:fan1"}, |
| 82 | {"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/sensor-data/oper-status", "ok"}, |
| 83 | {"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/sensor-data/value", "253"}, |
| 84 | {"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/sensor-data/value-precision", "0"}, |
| 85 | {"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/sensor-data/value-scale", "units"}, |
| 86 | {"/ietf-hardware:hardware/component[name='ne:fans:fan1:rpm']/sensor-data/value-type", "rpm"}, |
| 87 | {"/ietf-hardware:hardware/component[name='ne:fans:fan2']/class", "iana-hardware:fan"}, |
| 88 | {"/ietf-hardware:hardware/component[name='ne:fans:fan2']/parent", "ne:fans"}, |
| 89 | {"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/class", "iana-hardware:sensor"}, |
| 90 | {"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/parent", "ne:fans:fan2"}, |
| 91 | {"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/sensor-data/oper-status", "ok"}, |
| 92 | {"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/sensor-data/value", "0"}, |
| 93 | {"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/sensor-data/value-precision", "0"}, |
| 94 | {"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/sensor-data/value-scale", "units"}, |
| 95 | {"/ietf-hardware:hardware/component[name='ne:fans:fan2:rpm']/sensor-data/value-type", "rpm"}, |
| 96 | {"/ietf-hardware:hardware/component[name='ne:fans:fan3']/class", "iana-hardware:fan"}, |
| 97 | {"/ietf-hardware:hardware/component[name='ne:fans:fan3']/parent", "ne:fans"}, |
| 98 | {"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/class", "iana-hardware:sensor"}, |
| 99 | {"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/parent", "ne:fans:fan3"}, |
| 100 | {"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/sensor-data/oper-status", "ok"}, |
| 101 | {"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/sensor-data/value", "1280"}, |
| 102 | {"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/sensor-data/value-precision", "0"}, |
| 103 | {"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/sensor-data/value-scale", "units"}, |
| 104 | {"/ietf-hardware:hardware/component[name='ne:fans:fan3:rpm']/sensor-data/value-type", "rpm"}, |
| 105 | {"/ietf-hardware:hardware/component[name='ne:fans:fan4']/class", "iana-hardware:fan"}, |
| 106 | {"/ietf-hardware:hardware/component[name='ne:fans:fan4']/parent", "ne:fans"}, |
| 107 | {"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/class", "iana-hardware:sensor"}, |
| 108 | {"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/parent", "ne:fans:fan4"}, |
| 109 | {"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/sensor-data/oper-status", "ok"}, |
| 110 | {"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/sensor-data/value", "666"}, |
| 111 | {"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/sensor-data/value-precision", "0"}, |
| 112 | {"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/sensor-data/value-scale", "units"}, |
| 113 | {"/ietf-hardware:hardware/component[name='ne:fans:fan4:rpm']/sensor-data/value-type", "rpm"}, |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 114 | |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 115 | {"/ietf-hardware:hardware/component[name='ne:ctrl']/parent", "ne"}, |
| 116 | {"/ietf-hardware:hardware/component[name='ne:ctrl']/class", "iana-hardware:module"}, |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 117 | |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 118 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/class", "iana-hardware:sensor"}, |
| 119 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/parent", "ne:ctrl"}, |
| 120 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/sensor-data/oper-status", "ok"}, |
| 121 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/sensor-data/value", "41800"}, |
| 122 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/sensor-data/value-precision", "0"}, |
| 123 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/sensor-data/value-scale", "milli"}, |
| 124 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-cpu']/sensor-data/value-type", "celsius"}, |
| 125 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-front']/class", "iana-hardware:sensor"}, |
| 126 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-front']/parent", "ne:ctrl"}, |
| 127 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-front']/sensor-data/oper-status", "ok"}, |
| 128 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-front']/sensor-data/value", "30800"}, |
| 129 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-front']/sensor-data/value-precision", "0"}, |
| 130 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-front']/sensor-data/value-scale", "milli"}, |
| 131 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-front']/sensor-data/value-type", "celsius"}, |
| 132 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-0']/class", "iana-hardware:sensor"}, |
| 133 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-0']/parent", "ne:ctrl"}, |
| 134 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-0']/sensor-data/oper-status", "ok"}, |
| 135 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-0']/sensor-data/value", "39000"}, |
| 136 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-0']/sensor-data/value-precision", "0"}, |
| 137 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-0']/sensor-data/value-scale", "milli"}, |
| 138 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-0']/sensor-data/value-type", "celsius"}, |
| 139 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-1']/class", "iana-hardware:sensor"}, |
| 140 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-1']/parent", "ne:ctrl"}, |
| 141 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-1']/sensor-data/oper-status", "ok"}, |
| 142 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-1']/sensor-data/value", "36000"}, |
| 143 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-1']/sensor-data/value-precision", "0"}, |
| 144 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-1']/sensor-data/value-scale", "milli"}, |
| 145 | {"/ietf-hardware:hardware/component[name='ne:ctrl:temperature-internal-1']/sensor-data/value-type", "celsius"}, |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 146 | |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 147 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc']/parent", "ne:ctrl"}, |
| 148 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc']/class", "iana-hardware:module"}, |
| 149 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc']/serial-num", "0x00a8808d"}, |
| 150 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc']/mfg-date", "2017-02-01T00:00:00Z"}, |
| 151 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc']/model-name", "8GME4R"}, |
| 152 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/class", "iana-hardware:sensor"}, |
| 153 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/parent", "ne:ctrl:emmc"}, |
| 154 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/sensor-data/oper-status", "ok"}, |
| 155 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/sensor-data/value", "40"}, |
| 156 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/sensor-data/value-precision", "0"}, |
| 157 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/sensor-data/value-scale", "units"}, |
| 158 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/sensor-data/value-type", "other"}, |
| 159 | {"/ietf-hardware:hardware/component[name='ne:ctrl:emmc:lifetime']/sensor-data/units-display", "percent"}, |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 160 | }; |
| 161 | |
| 162 | // exclude last-change node |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 163 | auto result = ietfHardware->process(); |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 164 | result.erase(modulePrefix + "/last-change"); |
| 165 | REQUIRE(result == expected); |
| 166 | } |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 167 | |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 168 | SECTION("Test IETF Hardware from sysrepo's view") |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 169 | { |
| 170 | TEST_SYSREPO_INIT_LOGS; |
Tomáš Pecka | 749af2e | 2021-01-14 09:52:09 +0100 | [diff] [blame] | 171 | TEST_SYSREPO_INIT; |
| 172 | TEST_SYSREPO_INIT_CLIENT; |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 173 | |
Tomáš Pecka | 83b62e1 | 2020-12-16 14:50:49 +0100 | [diff] [blame] | 174 | auto ietfHardwareSysrepo = std::make_shared<velia::ietf_hardware::sysrepo::Sysrepo>(srSubs, ietfHardware); |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 175 | |
| 176 | SECTION("test last-change") |
| 177 | { |
| 178 | // at least check that there is some timestamp |
Tomáš Pecka | 749af2e | 2021-01-14 09:52:09 +0100 | [diff] [blame] | 179 | REQUIRE(dataFromSysrepo(client, modulePrefix, SR_DS_OPERATIONAL).count("/last-change") > 0); |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | SECTION("test components") |
| 183 | { |
| 184 | std::map<std::string, std::string> expected = { |
| 185 | {"[name='ne']/name", "ne"}, |
| 186 | {"[name='ne']/class", "iana-hardware:chassis"}, |
| 187 | {"[name='ne']/mfg-name", "CESNET"}, |
| 188 | {"[name='ne']/sensor-data", ""}, |
| 189 | |
| 190 | {"[name='ne:fans']/class", "iana-hardware:module"}, |
| 191 | {"[name='ne:fans']/name", "ne:fans"}, |
| 192 | {"[name='ne:fans']/parent", "ne"}, |
| 193 | {"[name='ne:fans']/sensor-data", ""}, |
| 194 | {"[name='ne:fans:fan1']/class", "iana-hardware:fan"}, |
| 195 | {"[name='ne:fans:fan1']/name", "ne:fans:fan1"}, |
| 196 | {"[name='ne:fans:fan1']/parent", "ne:fans"}, |
| 197 | {"[name='ne:fans:fan1']/sensor-data", ""}, |
| 198 | {"[name='ne:fans:fan1:rpm']/class", "iana-hardware:sensor"}, |
| 199 | {"[name='ne:fans:fan1:rpm']/name", "ne:fans:fan1:rpm"}, |
| 200 | {"[name='ne:fans:fan1:rpm']/parent", "ne:fans:fan1"}, |
| 201 | {"[name='ne:fans:fan1:rpm']/sensor-data", ""}, |
| 202 | {"[name='ne:fans:fan1:rpm']/sensor-data/oper-status", "ok"}, |
| 203 | {"[name='ne:fans:fan1:rpm']/sensor-data/value", "253"}, |
| 204 | {"[name='ne:fans:fan1:rpm']/sensor-data/value-precision", "0"}, |
| 205 | {"[name='ne:fans:fan1:rpm']/sensor-data/value-scale", "units"}, |
| 206 | {"[name='ne:fans:fan1:rpm']/sensor-data/value-type", "rpm"}, |
| 207 | {"[name='ne:fans:fan2']/class", "iana-hardware:fan"}, |
| 208 | {"[name='ne:fans:fan2']/name", "ne:fans:fan2"}, |
| 209 | {"[name='ne:fans:fan2']/parent", "ne:fans"}, |
| 210 | {"[name='ne:fans:fan2']/sensor-data", ""}, |
| 211 | {"[name='ne:fans:fan2:rpm']/class", "iana-hardware:sensor"}, |
| 212 | {"[name='ne:fans:fan2:rpm']/name", "ne:fans:fan2:rpm"}, |
| 213 | {"[name='ne:fans:fan2:rpm']/parent", "ne:fans:fan2"}, |
| 214 | {"[name='ne:fans:fan2:rpm']/sensor-data", ""}, |
| 215 | {"[name='ne:fans:fan2:rpm']/sensor-data/oper-status", "ok"}, |
| 216 | {"[name='ne:fans:fan2:rpm']/sensor-data/value", "0"}, |
| 217 | {"[name='ne:fans:fan2:rpm']/sensor-data/value-precision", "0"}, |
| 218 | {"[name='ne:fans:fan2:rpm']/sensor-data/value-scale", "units"}, |
| 219 | {"[name='ne:fans:fan2:rpm']/sensor-data/value-type", "rpm"}, |
| 220 | {"[name='ne:fans:fan3']/class", "iana-hardware:fan"}, |
| 221 | {"[name='ne:fans:fan3']/name", "ne:fans:fan3"}, |
| 222 | {"[name='ne:fans:fan3']/parent", "ne:fans"}, |
| 223 | {"[name='ne:fans:fan3']/sensor-data", ""}, |
| 224 | {"[name='ne:fans:fan3:rpm']/class", "iana-hardware:sensor"}, |
| 225 | {"[name='ne:fans:fan3:rpm']/name", "ne:fans:fan3:rpm"}, |
| 226 | {"[name='ne:fans:fan3:rpm']/parent", "ne:fans:fan3"}, |
| 227 | {"[name='ne:fans:fan3:rpm']/sensor-data", ""}, |
| 228 | {"[name='ne:fans:fan3:rpm']/sensor-data/oper-status", "ok"}, |
| 229 | {"[name='ne:fans:fan3:rpm']/sensor-data/value", "1280"}, |
| 230 | {"[name='ne:fans:fan3:rpm']/sensor-data/value-precision", "0"}, |
| 231 | {"[name='ne:fans:fan3:rpm']/sensor-data/value-scale", "units"}, |
| 232 | {"[name='ne:fans:fan3:rpm']/sensor-data/value-type", "rpm"}, |
| 233 | {"[name='ne:fans:fan4']/class", "iana-hardware:fan"}, |
| 234 | {"[name='ne:fans:fan4']/name", "ne:fans:fan4"}, |
| 235 | {"[name='ne:fans:fan4']/parent", "ne:fans"}, |
| 236 | {"[name='ne:fans:fan4']/sensor-data", ""}, |
| 237 | {"[name='ne:fans:fan4:rpm']/class", "iana-hardware:sensor"}, |
| 238 | {"[name='ne:fans:fan4:rpm']/name", "ne:fans:fan4:rpm"}, |
| 239 | {"[name='ne:fans:fan4:rpm']/parent", "ne:fans:fan4"}, |
| 240 | {"[name='ne:fans:fan4:rpm']/sensor-data", ""}, |
| 241 | {"[name='ne:fans:fan4:rpm']/sensor-data/oper-status", "ok"}, |
| 242 | {"[name='ne:fans:fan4:rpm']/sensor-data/value", "666"}, |
| 243 | {"[name='ne:fans:fan4:rpm']/sensor-data/value-precision", "0"}, |
| 244 | {"[name='ne:fans:fan4:rpm']/sensor-data/value-scale", "units"}, |
| 245 | {"[name='ne:fans:fan4:rpm']/sensor-data/value-type", "rpm"}, |
| 246 | |
| 247 | {"[name='ne:ctrl']/name", "ne:ctrl"}, |
| 248 | {"[name='ne:ctrl']/parent", "ne"}, |
| 249 | {"[name='ne:ctrl']/class", "iana-hardware:module"}, |
| 250 | {"[name='ne:ctrl']/sensor-data", ""}, |
| 251 | |
| 252 | {"[name='ne:ctrl:temperature-cpu']/name", "ne:ctrl:temperature-cpu"}, |
| 253 | {"[name='ne:ctrl:temperature-cpu']/class", "iana-hardware:sensor"}, |
| 254 | {"[name='ne:ctrl:temperature-cpu']/parent", "ne:ctrl"}, |
| 255 | {"[name='ne:ctrl:temperature-cpu']/sensor-data", ""}, |
| 256 | {"[name='ne:ctrl:temperature-cpu']/sensor-data/oper-status", "ok"}, |
| 257 | {"[name='ne:ctrl:temperature-cpu']/sensor-data/value", "41800"}, |
| 258 | {"[name='ne:ctrl:temperature-cpu']/sensor-data/value-precision", "0"}, |
| 259 | {"[name='ne:ctrl:temperature-cpu']/sensor-data/value-scale", "milli"}, |
| 260 | {"[name='ne:ctrl:temperature-cpu']/sensor-data/value-type", "celsius"}, |
| 261 | {"[name='ne:ctrl:temperature-front']/name", "ne:ctrl:temperature-front"}, |
| 262 | {"[name='ne:ctrl:temperature-front']/class", "iana-hardware:sensor"}, |
| 263 | {"[name='ne:ctrl:temperature-front']/parent", "ne:ctrl"}, |
| 264 | {"[name='ne:ctrl:temperature-front']/sensor-data", ""}, |
| 265 | {"[name='ne:ctrl:temperature-front']/sensor-data/oper-status", "ok"}, |
| 266 | {"[name='ne:ctrl:temperature-front']/sensor-data/value", "30800"}, |
| 267 | {"[name='ne:ctrl:temperature-front']/sensor-data/value-precision", "0"}, |
| 268 | {"[name='ne:ctrl:temperature-front']/sensor-data/value-scale", "milli"}, |
| 269 | {"[name='ne:ctrl:temperature-front']/sensor-data/value-type", "celsius"}, |
| 270 | {"[name='ne:ctrl:temperature-internal-0']/name", "ne:ctrl:temperature-internal-0"}, |
| 271 | {"[name='ne:ctrl:temperature-internal-0']/class", "iana-hardware:sensor"}, |
| 272 | {"[name='ne:ctrl:temperature-internal-0']/parent", "ne:ctrl"}, |
| 273 | {"[name='ne:ctrl:temperature-internal-0']/sensor-data", ""}, |
| 274 | {"[name='ne:ctrl:temperature-internal-0']/sensor-data/oper-status", "ok"}, |
| 275 | {"[name='ne:ctrl:temperature-internal-0']/sensor-data/value", "39000"}, |
| 276 | {"[name='ne:ctrl:temperature-internal-0']/sensor-data/value-precision", "0"}, |
| 277 | {"[name='ne:ctrl:temperature-internal-0']/sensor-data/value-scale", "milli"}, |
| 278 | {"[name='ne:ctrl:temperature-internal-0']/sensor-data/value-type", "celsius"}, |
| 279 | {"[name='ne:ctrl:temperature-internal-1']/name", "ne:ctrl:temperature-internal-1"}, |
| 280 | {"[name='ne:ctrl:temperature-internal-1']/class", "iana-hardware:sensor"}, |
| 281 | {"[name='ne:ctrl:temperature-internal-1']/parent", "ne:ctrl"}, |
| 282 | {"[name='ne:ctrl:temperature-internal-1']/sensor-data", ""}, |
| 283 | {"[name='ne:ctrl:temperature-internal-1']/sensor-data/oper-status", "ok"}, |
| 284 | {"[name='ne:ctrl:temperature-internal-1']/sensor-data/value", "36000"}, |
| 285 | {"[name='ne:ctrl:temperature-internal-1']/sensor-data/value-precision", "0"}, |
| 286 | {"[name='ne:ctrl:temperature-internal-1']/sensor-data/value-scale", "milli"}, |
| 287 | {"[name='ne:ctrl:temperature-internal-1']/sensor-data/value-type", "celsius"}, |
| 288 | |
| 289 | {"[name='ne:ctrl:emmc']/name", "ne:ctrl:emmc"}, |
| 290 | {"[name='ne:ctrl:emmc']/parent", "ne:ctrl"}, |
| 291 | {"[name='ne:ctrl:emmc']/class", "iana-hardware:module"}, |
| 292 | {"[name='ne:ctrl:emmc']/serial-num", "0x00a8808d"}, |
| 293 | {"[name='ne:ctrl:emmc']/mfg-date", "2017-02-01T00:00:00Z"}, |
| 294 | {"[name='ne:ctrl:emmc']/model-name", "8GME4R"}, |
| 295 | {"[name='ne:ctrl:emmc']/sensor-data", ""}, |
| 296 | {"[name='ne:ctrl:emmc:lifetime']/name", "ne:ctrl:emmc:lifetime"}, |
| 297 | {"[name='ne:ctrl:emmc:lifetime']/class", "iana-hardware:sensor"}, |
| 298 | {"[name='ne:ctrl:emmc:lifetime']/parent", "ne:ctrl:emmc"}, |
| 299 | {"[name='ne:ctrl:emmc:lifetime']/sensor-data", ""}, |
| 300 | {"[name='ne:ctrl:emmc:lifetime']/sensor-data/oper-status", "ok"}, |
| 301 | {"[name='ne:ctrl:emmc:lifetime']/sensor-data/value", "40"}, |
| 302 | {"[name='ne:ctrl:emmc:lifetime']/sensor-data/value-precision", "0"}, |
| 303 | {"[name='ne:ctrl:emmc:lifetime']/sensor-data/value-scale", "units"}, |
| 304 | {"[name='ne:ctrl:emmc:lifetime']/sensor-data/value-type", "other"}, |
| 305 | {"[name='ne:ctrl:emmc:lifetime']/sensor-data/units-display", "percent"}, |
| 306 | }; |
| 307 | |
Tomáš Pecka | 749af2e | 2021-01-14 09:52:09 +0100 | [diff] [blame] | 308 | REQUIRE(dataFromSysrepo(client, modulePrefix + "/component", SR_DS_OPERATIONAL) == expected); |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | SECTION("test leafnode query") |
| 312 | { |
| 313 | const auto xpath = modulePrefix + "/component[name='ne:ctrl:emmc:lifetime']/class"; |
Tomáš Pecka | 749af2e | 2021-01-14 09:52:09 +0100 | [diff] [blame] | 314 | client->session_switch_ds(SR_DS_OPERATIONAL); |
| 315 | auto val = client->get_item(xpath.c_str()); |
| 316 | client->session_switch_ds(SR_DS_RUNNING); |
Tomáš Pecka | 98ad18d | 2020-11-13 15:39:55 +0100 | [diff] [blame] | 317 | REQUIRE(!!val); |
| 318 | REQUIRE(val->data()->get_identityref() == "iana-hardware:sensor"s); |
| 319 | } |
| 320 | } |
Tomáš Pecka | 339bc67 | 2020-11-11 15:59:03 +0100 | [diff] [blame] | 321 | } |