Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 1 | #include "dbus_environment.hpp" |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 2 | #include "helpers.hpp" |
Szymon Dompke | b4ef22e | 2022-02-07 15:15:12 +0100 | [diff] [blame] | 3 | #include "interfaces/trigger_manager.hpp" |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 4 | #include "mocks/json_storage_mock.hpp" |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 5 | #include "mocks/report_factory_mock.hpp" |
Szymon Dompke | b4ef22e | 2022-02-07 15:15:12 +0100 | [diff] [blame] | 6 | #include "mocks/trigger_manager_mock.hpp" |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 7 | #include "params/report_params.hpp" |
| 8 | #include "report.hpp" |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 9 | #include "report_manager.hpp" |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 10 | #include "utils/conversion.hpp" |
Szymon Dompke | 32305f1 | 2022-07-05 15:37:21 +0200 | [diff] [blame] | 11 | #include "utils/dbus_path_utils.hpp" |
| 12 | #include "utils/string_utils.hpp" |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 13 | #include "utils/transform.hpp" |
Szymon Dompke | 32305f1 | 2022-07-05 15:37:21 +0200 | [diff] [blame] | 14 | #include "utils/tstring.hpp" |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 15 | |
| 16 | using namespace testing; |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 17 | using namespace std::string_literals; |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 18 | using namespace std::chrono_literals; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 19 | |
| 20 | class TestReportManager : public Test |
| 21 | { |
| 22 | public: |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 23 | ReportParams reportParams; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 24 | |
| 25 | std::unique_ptr<ReportFactoryMock> reportFactoryMockPtr = |
| 26 | std::make_unique<StrictMock<ReportFactoryMock>>(); |
| 27 | ReportFactoryMock& reportFactoryMock = *reportFactoryMockPtr; |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 28 | |
| 29 | std::unique_ptr<StorageMock> storageMockPtr = |
| 30 | std::make_unique<NiceMock<StorageMock>>(); |
| 31 | StorageMock& storageMock = *storageMockPtr; |
| 32 | |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 33 | std::unique_ptr<ReportMock> reportMockPtr = |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 34 | std::make_unique<NiceMock<ReportMock>>(reportParams.reportId()); |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 35 | ReportMock& reportMock = *reportMockPtr; |
| 36 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 37 | std::unique_ptr<ReportManager> sut; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 38 | |
| 39 | MockFunction<void(std::string)> checkPoint; |
| 40 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 41 | void SetUp() override |
| 42 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 43 | EXPECT_CALL(reportFactoryMock, convertMetricParams(_, _)) |
| 44 | .Times(AnyNumber()); |
| 45 | |
Krzysztof Grobelny | e6d4887 | 2022-02-08 13:41:30 +0100 | [diff] [blame] | 46 | sut = std::make_unique<ReportManager>(std::move(reportFactoryMockPtr), |
| 47 | std::move(storageMockPtr), |
| 48 | DbusEnvironment::getObjServer()); |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 49 | } |
| 50 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 51 | void TearDown() override |
| 52 | { |
| 53 | DbusEnvironment::synchronizeIoc(); |
| 54 | } |
| 55 | |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 56 | template <class... Args> |
| 57 | requires(sizeof...(Args) > 1) |
| 58 | std::pair<boost::system::error_code, std::string> addReport( |
| 59 | Args&&... args) |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 60 | { |
| 61 | std::promise<std::pair<boost::system::error_code, std::string>> |
| 62 | addReportPromise; |
| 63 | DbusEnvironment::getBus()->async_method_call( |
| 64 | [&addReportPromise](boost::system::error_code ec, |
| 65 | const std::string& path) { |
| 66 | addReportPromise.set_value({ec, path}); |
| 67 | }, |
| 68 | DbusEnvironment::serviceName(), ReportManager::reportManagerPath, |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 69 | ReportManager::reportManagerIfaceName, "AddReportFutureVersion", |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 70 | std::forward<Args>(args)...); |
Krzysztof Grobelny | f32f6fe | 2020-10-30 13:51:58 +0100 | [diff] [blame] | 71 | return DbusEnvironment::waitForFuture(addReportPromise.get_future()); |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 72 | } |
| 73 | |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 74 | auto addReport(const ReportParams& params) |
| 75 | { |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 76 | return addReport(params.reportId(), params.reportName(), |
| 77 | utils::enumToString(params.reportingType()), |
| 78 | utils::enumToString(params.reportUpdates()), |
| 79 | params.appendLimit(), |
| 80 | utils::transform(params.reportActions(), |
| 81 | [](const auto v) { |
| 82 | return utils::enumToString(v); |
| 83 | }), |
| 84 | params.interval().count(), |
| 85 | toReadingParameters(params.metricParameters())); |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 86 | } |
| 87 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 88 | template <class T> |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 89 | static T getProperty(const std::string& property) |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 90 | { |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 91 | return DbusEnvironment::getProperty<T>( |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 92 | ReportManager::reportManagerPath, |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 93 | ReportManager::reportManagerIfaceName, property); |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 94 | } |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | TEST_F(TestReportManager, minInterval) |
| 98 | { |
| 99 | EXPECT_THAT(getProperty<uint64_t>("MinInterval"), |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 100 | Eq(ReportManager::minInterval.count())); |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | TEST_F(TestReportManager, maxReports) |
| 104 | { |
Wludzik, Jozef | 503c158 | 2020-12-11 14:48:01 +0100 | [diff] [blame] | 105 | EXPECT_THAT(getProperty<size_t>("MaxReports"), |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 106 | Eq(ReportManager::maxReports)); |
| 107 | } |
| 108 | |
Krzysztof Grobelny | 60fee07 | 2022-01-13 16:25:04 +0100 | [diff] [blame] | 109 | TEST_F(TestReportManager, returnsPropertySupportedOperationTypes) |
| 110 | { |
| 111 | EXPECT_THAT( |
| 112 | getProperty<std::vector<std::string>>("SupportedOperationTypes"), |
| 113 | UnorderedElementsAre("Maximum", "Minimum", "Average", "Summation")); |
| 114 | } |
| 115 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 116 | TEST_F(TestReportManager, addReport) |
| 117 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 118 | EXPECT_CALL(reportFactoryMock, convertMetricParams(_, _)); |
| 119 | reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock)) |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 120 | .WillOnce(Return(ByMove(std::move(reportMockPtr)))); |
| 121 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 122 | auto [ec, path] = addReport(reportParams); |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 123 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::success)); |
| 124 | EXPECT_THAT(path, Eq(reportMock.getPath())); |
| 125 | } |
| 126 | |
Krzysztof Grobelny | f7ea299 | 2022-01-27 11:04:58 +0100 | [diff] [blame] | 127 | TEST_F(TestReportManager, addOnChangeReport) |
| 128 | { |
| 129 | EXPECT_CALL(reportFactoryMock, convertMetricParams(_, _)); |
| 130 | reportFactoryMock |
| 131 | .expectMake(reportParams.reportingType(ReportingType::onChange), |
| 132 | Ref(*sut), Ref(storageMock)) |
| 133 | .WillOnce(Return(ByMove(std::move(reportMockPtr)))); |
| 134 | |
| 135 | auto [ec, path] = addReport(reportParams); |
| 136 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::success)); |
| 137 | EXPECT_THAT(path, Eq(reportMock.getPath())); |
| 138 | } |
| 139 | |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 140 | TEST_F(TestReportManager, nameIsUsedToGenerateIdWhenIdIsEmptyInAddReport) |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 141 | { |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 142 | reportParams.reportId("ReportName"); |
| 143 | reportParams.reportName("ReportName"); |
| 144 | |
| 145 | reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock)); |
| 146 | |
| 147 | auto [ec, path] = addReport(reportParams.reportId("")); |
| 148 | |
| 149 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::success)); |
| 150 | EXPECT_THAT(path, Eq("/ReportName")); |
| 151 | } |
| 152 | |
| 153 | TEST_F(TestReportManager, nameIsUsedToGenerateIdWhenIdIsNamespace) |
| 154 | { |
| 155 | reportParams.reportId("Prefix/ReportName"); |
| 156 | reportParams.reportName("ReportName"); |
| 157 | |
| 158 | reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock)); |
| 159 | |
| 160 | auto [ec, path] = addReport(reportParams.reportId("Prefix/")); |
| 161 | |
| 162 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::success)); |
| 163 | EXPECT_THAT(path, Eq("/Prefix/ReportName")); |
| 164 | } |
| 165 | |
| 166 | TEST_F(TestReportManager, addReportWithMaxLengthId) |
| 167 | { |
Szymon Dompke | 32305f1 | 2022-07-05 15:37:21 +0200 | [diff] [blame] | 168 | std::string reportId = utils::string_utils::getMaxId(); |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 169 | reportParams.reportId(reportId); |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 170 | reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock)); |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 171 | |
| 172 | auto [ec, path] = addReport(reportParams); |
| 173 | |
| 174 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::success)); |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 175 | EXPECT_THAT(path, Eq("/"s + reportId)); |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 176 | } |
| 177 | |
Szymon Dompke | 32305f1 | 2022-07-05 15:37:21 +0200 | [diff] [blame] | 178 | TEST_F(TestReportManager, addReportWithMaxLengthPrefix) |
| 179 | { |
| 180 | std::string reportId = utils::string_utils::getMaxPrefix() + "/MyId"; |
| 181 | reportParams.reportId(reportId); |
| 182 | reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock)); |
| 183 | |
| 184 | auto [ec, path] = addReport(reportParams); |
| 185 | |
| 186 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::success)); |
| 187 | EXPECT_THAT(path, Eq("/"s + reportId)); |
| 188 | } |
| 189 | |
| 190 | TEST_F(TestReportManager, addReportWithMaxLengthName) |
| 191 | { |
| 192 | reportParams.reportName(utils::string_utils::getMaxName()); |
| 193 | reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock)); |
| 194 | |
| 195 | auto [ec, path] = addReport(reportParams); |
| 196 | |
| 197 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::success)); |
| 198 | EXPECT_THAT(path, Eq("/"s + reportParams.reportId())); |
| 199 | } |
| 200 | |
| 201 | TEST_F(TestReportManager, addReportWithMaxLengthMetricId) |
| 202 | { |
| 203 | namespace ts = utils::tstring; |
| 204 | std::vector<LabeledMetricParameters> newMetricParams{ |
| 205 | {LabeledMetricParameters{ |
| 206 | {LabeledSensorInfo{"Service", |
| 207 | "/xyz/openbmc_project/sensors/power/p1", |
| 208 | "metadata1"}}, |
| 209 | OperationType::avg, |
| 210 | utils::string_utils::getMaxId(), |
| 211 | CollectionTimeScope::point, |
| 212 | CollectionDuration(Milliseconds(0u))}}}; |
| 213 | |
| 214 | reportParams.metricParameters(newMetricParams); |
| 215 | reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock)); |
| 216 | |
| 217 | auto [ec, path] = addReport(reportParams); |
| 218 | |
| 219 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::success)); |
| 220 | EXPECT_THAT(path, Eq("/"s + reportParams.reportId())); |
| 221 | } |
| 222 | |
| 223 | TEST_F(TestReportManager, DISABLED_failToAddReportWithTooLongFullId) |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 224 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 225 | reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock)) |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 226 | .Times(0); |
| 227 | |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 228 | reportParams.reportId( |
Szymon Dompke | 32305f1 | 2022-07-05 15:37:21 +0200 | [diff] [blame] | 229 | std::string(utils::constants::maxReportFullIdLength + 1, 'z')); |
| 230 | |
| 231 | auto [ec, path] = addReport(reportParams); |
| 232 | |
| 233 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument)); |
| 234 | EXPECT_THAT(path, Eq(std::string())); |
| 235 | } |
| 236 | |
| 237 | TEST_F(TestReportManager, DISABLED_failToAddReportWithTooLongId) |
| 238 | { |
| 239 | reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock)) |
| 240 | .Times(0); |
| 241 | |
| 242 | reportParams.reportId(utils::string_utils::getTooLongId()); |
| 243 | |
| 244 | auto [ec, path] = addReport(reportParams); |
| 245 | |
| 246 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument)); |
| 247 | EXPECT_THAT(path, Eq(std::string())); |
| 248 | } |
| 249 | |
| 250 | TEST_F(TestReportManager, DISABLED_failToAddReportWithTooLongPrefix) |
| 251 | { |
| 252 | reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock)) |
| 253 | .Times(0); |
| 254 | |
| 255 | reportParams.reportId(utils::string_utils::getTooLongPrefix() + "/MyId"); |
| 256 | |
| 257 | auto [ec, path] = addReport(reportParams); |
| 258 | |
| 259 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument)); |
| 260 | EXPECT_THAT(path, Eq(std::string())); |
| 261 | } |
| 262 | |
| 263 | TEST_F(TestReportManager, DISABLED_failToAddReportWithTooManyPrefixes) |
| 264 | { |
| 265 | reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock)) |
| 266 | .Times(0); |
| 267 | |
| 268 | std::string reportId; |
| 269 | for (size_t i = 0; i < utils::constants::maxPrefixesInId + 1; i++) |
| 270 | { |
| 271 | reportId += "prefix/"; |
| 272 | } |
| 273 | reportId += "MyId"; |
| 274 | |
| 275 | reportParams.reportId(reportId); |
| 276 | |
| 277 | auto [ec, path] = addReport(reportParams); |
| 278 | |
| 279 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument)); |
| 280 | EXPECT_THAT(path, Eq(std::string())); |
| 281 | } |
| 282 | |
| 283 | TEST_F(TestReportManager, DISABLED_failToAddReportWithTooLongName) |
| 284 | { |
| 285 | reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock)) |
| 286 | .Times(0); |
| 287 | |
| 288 | reportParams.reportName(utils::string_utils::getTooLongName()); |
| 289 | |
| 290 | auto [ec, path] = addReport(reportParams); |
| 291 | |
| 292 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument)); |
| 293 | EXPECT_THAT(path, Eq(std::string())); |
| 294 | } |
| 295 | |
| 296 | TEST_F(TestReportManager, DISABLED_failToAddReportWithTooLongMetricId) |
| 297 | { |
| 298 | namespace ts = utils::tstring; |
| 299 | |
| 300 | std::vector<LabeledMetricParameters> newMetricParams{ |
| 301 | {LabeledMetricParameters{ |
| 302 | {LabeledSensorInfo{"Service", |
| 303 | "/xyz/openbmc_project/sensors/power/p1", |
| 304 | "metadata1"}}, |
| 305 | OperationType::avg, |
| 306 | utils::string_utils::getTooLongId(), |
| 307 | CollectionTimeScope::point, |
| 308 | CollectionDuration(Milliseconds(0u))}}}; |
| 309 | |
| 310 | reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock)) |
| 311 | .Times(0); |
| 312 | |
| 313 | reportParams.metricParameters(newMetricParams); |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 314 | |
| 315 | auto [ec, path] = addReport(reportParams); |
| 316 | |
| 317 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument)); |
| 318 | EXPECT_THAT(path, Eq(std::string())); |
| 319 | } |
| 320 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 321 | TEST_F(TestReportManager, DISABLED_failToAddReportTwice) |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 322 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 323 | reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock)) |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 324 | .WillOnce(Return(ByMove(std::move(reportMockPtr)))); |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 325 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 326 | addReport(reportParams); |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 327 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 328 | auto [ec, path] = addReport(reportParams); |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 329 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 330 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::file_exists)); |
| 331 | EXPECT_THAT(path, Eq(std::string())); |
| 332 | } |
| 333 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 334 | TEST_F(TestReportManager, DISABLED_failToAddReportWithInvalidInterval) |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 335 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 336 | reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock)) |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 337 | .Times(0); |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 338 | |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 339 | reportParams.reportingType(ReportingType::periodic); |
Krzysztof Grobelny | 973b4bb | 2022-04-25 17:07:27 +0200 | [diff] [blame] | 340 | reportParams.interval(ReportManager::minInterval - 1ms); |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 341 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 342 | auto [ec, path] = addReport(reportParams); |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 343 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 344 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument)); |
| 345 | EXPECT_THAT(path, Eq(std::string())); |
| 346 | } |
| 347 | |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 348 | TEST_F(TestReportManager, DISABLED_failToAddReportWithInvalidReportingType) |
| 349 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 350 | reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock)) |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 351 | .Times(0); |
| 352 | |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 353 | auto [ec, path] = addReport( |
| 354 | reportParams.reportName(), "InvalidReportingType", |
| 355 | utils::transform(reportParams.reportActions(), |
| 356 | [](const auto v) { return utils::enumToString(v); }), |
| 357 | reportParams.interval().count(), |
| 358 | toReadingParameters(reportParams.metricParameters())); |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 359 | |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 360 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument)); |
| 361 | EXPECT_THAT(path, Eq(std::string())); |
| 362 | } |
| 363 | |
Ankita Vilas Gawade | cd5b0b7 | 2022-01-20 20:55:04 +0000 | [diff] [blame] | 364 | TEST_F(TestReportManager, |
| 365 | DISABLED_failToAddReportWithMoreMetricPropertiesThanExpected) |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 366 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 367 | reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock)) |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 368 | .Times(0); |
| 369 | |
Ankita Vilas Gawade | cd5b0b7 | 2022-01-20 20:55:04 +0000 | [diff] [blame] | 370 | reportParams.metricParameters( |
| 371 | std::vector<LabeledMetricParameters>{{LabeledMetricParameters{ |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 372 | {LabeledSensorInfo{"Service", |
| 373 | "/xyz/openbmc_project/sensors/power/p1", |
| 374 | "Metadata1"}}, |
Krzysztof Grobelny | 60fee07 | 2022-01-13 16:25:04 +0100 | [diff] [blame] | 375 | OperationType::avg, |
Ankita Vilas Gawade | cd5b0b7 | 2022-01-20 20:55:04 +0000 | [diff] [blame] | 376 | "MetricId1", |
| 377 | CollectionTimeScope::point, |
| 378 | CollectionDuration(Milliseconds(0u))}}}); |
| 379 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 380 | auto metricParams = reportParams.metricParameters(); |
Ankita Vilas Gawade | cd5b0b7 | 2022-01-20 20:55:04 +0000 | [diff] [blame] | 381 | auto& metricParamsVec = |
| 382 | metricParams[0].at_label<utils::tstring::SensorPath>(); |
| 383 | |
| 384 | for (size_t i = 0; i < ReportManager::maxNumberMetrics; i++) |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 385 | { |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 386 | metricParamsVec.emplace_back(LabeledSensorInfo{ |
Ankita Vilas Gawade | cd5b0b7 | 2022-01-20 20:55:04 +0000 | [diff] [blame] | 387 | "Service", "/xyz/openbmc_project/sensors/power/p1", "Metadata1"}); |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 388 | } |
Ankita Vilas Gawade | cd5b0b7 | 2022-01-20 20:55:04 +0000 | [diff] [blame] | 389 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 390 | reportParams.metricParameters(std::move(metricParams)); |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 391 | |
| 392 | auto [ec, path] = addReport(reportParams); |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 393 | |
Wludzik, Jozef | bc766b4 | 2020-12-08 16:06:22 +0100 | [diff] [blame] | 394 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::argument_list_too_long)); |
| 395 | EXPECT_THAT(path, Eq(std::string())); |
| 396 | } |
| 397 | |
Ankita Vilas Gawade | cd5b0b7 | 2022-01-20 20:55:04 +0000 | [diff] [blame] | 398 | TEST_F(TestReportManager, DISABLED_failToAddReportWithMoreMetricsThanExpected) |
| 399 | { |
| 400 | reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock)) |
| 401 | .Times(0); |
| 402 | |
| 403 | auto metricParams = std::vector<LabeledMetricParameters>{}; |
| 404 | |
| 405 | for (size_t i = 0; i < ReportManager::maxNumberMetrics + 1; i++) |
| 406 | { |
| 407 | metricParams.emplace_back( |
| 408 | LabeledMetricParameters{{}, |
Krzysztof Grobelny | 60fee07 | 2022-01-13 16:25:04 +0100 | [diff] [blame] | 409 | OperationType::avg, |
Ankita Vilas Gawade | cd5b0b7 | 2022-01-20 20:55:04 +0000 | [diff] [blame] | 410 | "MetricId1", |
| 411 | CollectionTimeScope::point, |
| 412 | CollectionDuration(Milliseconds(0u))}); |
| 413 | } |
| 414 | |
| 415 | reportParams.metricParameters(std::move(metricParams)); |
| 416 | |
| 417 | auto [ec, path] = addReport(reportParams); |
| 418 | |
| 419 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::argument_list_too_long)); |
| 420 | EXPECT_THAT(path, Eq(std::string())); |
| 421 | } |
| 422 | |
| 423 | TEST_F(TestReportManager, DISABLED_failToAddReportWithAppendLimitGreaterThanMax) |
| 424 | { |
| 425 | reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock)) |
| 426 | .Times(0); |
| 427 | |
| 428 | reportParams.appendLimit(ReportManager::maxAppendLimit + 1); |
| 429 | |
| 430 | auto [ec, path] = addReport(reportParams); |
| 431 | |
| 432 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument)); |
| 433 | EXPECT_THAT(path, Eq(std::string())); |
| 434 | } |
| 435 | |
Krzysztof Grobelny | e6c417c | 2022-02-02 17:25:53 +0100 | [diff] [blame] | 436 | TEST_F(TestReportManager, addReportWithAppendLimitEqualToUint64MaxIsAllowed) |
| 437 | { |
| 438 | reportParams.appendLimit(std::numeric_limits<uint64_t>::max()); |
| 439 | |
| 440 | EXPECT_CALL(reportFactoryMock, convertMetricParams(_, _)); |
| 441 | reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock)) |
| 442 | .WillOnce(Return(ByMove(std::move(reportMockPtr)))); |
| 443 | |
| 444 | auto [ec, path] = addReport(reportParams); |
| 445 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::success)); |
| 446 | EXPECT_THAT(path, Eq(reportMock.getPath())); |
| 447 | } |
| 448 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 449 | TEST_F(TestReportManager, DISABLED_failToAddReportWhenMaxReportIsReached) |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 450 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 451 | reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock)) |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 452 | .Times(ReportManager::maxReports); |
| 453 | |
| 454 | for (size_t i = 0; i < ReportManager::maxReports; i++) |
| 455 | { |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 456 | reportParams.reportId(reportParams.reportName() + std::to_string(i)); |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 457 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 458 | auto [ec, path] = addReport(reportParams); |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 459 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::success)); |
| 460 | } |
| 461 | |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 462 | reportParams.reportId(reportParams.reportName() + |
| 463 | std::to_string(ReportManager::maxReports)); |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 464 | auto [ec, path] = addReport(reportParams); |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 465 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 466 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::too_many_files_open)); |
| 467 | EXPECT_THAT(path, Eq(std::string())); |
| 468 | } |
| 469 | |
| 470 | TEST_F(TestReportManager, removeReport) |
| 471 | { |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 472 | { |
| 473 | InSequence seq; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 474 | EXPECT_CALL(reportFactoryMock, convertMetricParams(_, _)); |
| 475 | reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock)) |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 476 | .WillOnce(Return(ByMove(std::move(reportMockPtr)))); |
| 477 | EXPECT_CALL(reportMock, Die()); |
| 478 | EXPECT_CALL(checkPoint, Call("end")); |
| 479 | } |
| 480 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 481 | addReport(reportParams); |
| 482 | sut->removeReport(&reportMock); |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 483 | checkPoint.Call("end"); |
| 484 | } |
| 485 | |
| 486 | TEST_F(TestReportManager, removingReportThatIsNotInContainerHasNoEffect) |
| 487 | { |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 488 | { |
| 489 | InSequence seq; |
| 490 | EXPECT_CALL(checkPoint, Call("end")); |
| 491 | EXPECT_CALL(reportMock, Die()); |
| 492 | } |
| 493 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 494 | sut->removeReport(&reportMock); |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 495 | checkPoint.Call("end"); |
| 496 | } |
| 497 | |
| 498 | TEST_F(TestReportManager, removingSameReportTwiceHasNoSideEffect) |
| 499 | { |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 500 | { |
| 501 | InSequence seq; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 502 | EXPECT_CALL(reportFactoryMock, convertMetricParams(_, _)); |
| 503 | reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock)) |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 504 | .WillOnce(Return(ByMove(std::move(reportMockPtr)))); |
| 505 | EXPECT_CALL(reportMock, Die()); |
| 506 | EXPECT_CALL(checkPoint, Call("end")); |
| 507 | } |
| 508 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 509 | addReport(reportParams); |
| 510 | sut->removeReport(&reportMock); |
| 511 | sut->removeReport(&reportMock); |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 512 | checkPoint.Call("end"); |
| 513 | } |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 514 | |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 515 | class TestReportManagerWithAggregationOperationType : |
| 516 | public TestReportManager, |
| 517 | public WithParamInterface<OperationType> |
| 518 | { |
| 519 | public: |
| 520 | OperationType operationType = GetParam(); |
| 521 | }; |
| 522 | |
| 523 | INSTANTIATE_TEST_SUITE_P(_, TestReportManagerWithAggregationOperationType, |
Krzysztof Grobelny | 60fee07 | 2022-01-13 16:25:04 +0100 | [diff] [blame] | 524 | Values(OperationType::max, OperationType::min, |
| 525 | OperationType::avg, OperationType::sum)); |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 526 | |
| 527 | TEST_P(TestReportManagerWithAggregationOperationType, |
| 528 | addReportWithDifferentOperationTypes) |
| 529 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 530 | reportParams.metricParameters( |
| 531 | std::vector<LabeledMetricParameters>{{LabeledMetricParameters{ |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 532 | {LabeledSensorInfo{"Service", |
| 533 | "/xyz/openbmc_project/sensors/power/p1", |
| 534 | "Metadata1"}}, |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 535 | operationType, |
| 536 | "MetricId1", |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 537 | CollectionTimeScope::point, |
| 538 | CollectionDuration(Milliseconds(0u))}}}); |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 539 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 540 | reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock)) |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 541 | .WillOnce(Return(ByMove(std::move(reportMockPtr)))); |
| 542 | |
| 543 | auto [ec, path] = addReport(reportParams); |
Karol Niczyj | 32859b6 | 2021-05-19 10:20:46 +0200 | [diff] [blame] | 544 | |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 545 | EXPECT_THAT(ec.value(), Eq(boost::system::errc::success)); |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 546 | EXPECT_THAT(path, Eq("/"s + reportParams.reportId())); |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 547 | } |
| 548 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 549 | class TestReportManagerStorage : public TestReportManager |
| 550 | { |
| 551 | public: |
| 552 | using FilePath = interfaces::JsonStorage::FilePath; |
| 553 | using DirectoryPath = interfaces::JsonStorage::DirectoryPath; |
| 554 | |
| 555 | void SetUp() override |
| 556 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 557 | EXPECT_CALL(reportFactoryMock, convertMetricParams(_, _)).Times(0); |
| 558 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 559 | ON_CALL(storageMock, list()) |
| 560 | .WillByDefault(Return(std::vector<FilePath>{FilePath("report1")})); |
| 561 | ON_CALL(storageMock, load(FilePath("report1"))) |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 562 | .WillByDefault(InvokeWithoutArgs([this] { return data; })); |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | void makeReportManager() |
| 566 | { |
Krzysztof Grobelny | e6d4887 | 2022-02-08 13:41:30 +0100 | [diff] [blame] | 567 | sut = std::make_unique<ReportManager>(std::move(reportFactoryMockPtr), |
| 568 | std::move(storageMockPtr), |
| 569 | DbusEnvironment::getObjServer()); |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | nlohmann::json data = nlohmann::json{ |
Lukasz Kazmierczak | 7e098e9 | 2021-09-16 15:59:56 +0200 | [diff] [blame] | 573 | {"Enabled", reportParams.enabled()}, |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 574 | {"Version", Report::reportVersion}, |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 575 | {"Id", reportParams.reportId()}, |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 576 | {"Name", reportParams.reportName()}, |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 577 | {"ReportingType", utils::toUnderlying(reportParams.reportingType())}, |
| 578 | {"ReportActions", reportParams.reportActions()}, |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 579 | {"Interval", reportParams.interval().count()}, |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 580 | {"ReportUpdates", utils::toUnderlying(reportParams.reportUpdates())}, |
Szymon Dompke | 3eb5686 | 2021-09-20 15:32:04 +0200 | [diff] [blame] | 581 | {"AppendLimit", reportParams.appendLimit()}, |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 582 | {"ReadingParameters", reportParams.metricParameters()}}; |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 583 | }; |
| 584 | |
| 585 | TEST_F(TestReportManagerStorage, reportManagerCtorAddReportFromStorage) |
| 586 | { |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 587 | reportFactoryMock.expectMake(reportParams, _, Ref(storageMock)); |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 588 | |
| 589 | makeReportManager(); |
| 590 | } |
| 591 | |
| 592 | TEST_F(TestReportManagerStorage, |
| 593 | reportManagerCtorRemoveFileIfVersionDoesNotMatch) |
| 594 | { |
| 595 | data["Version"] = Report::reportVersion - 1; |
| 596 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 597 | EXPECT_CALL(storageMock, remove(FilePath("report1"))); |
| 598 | |
| 599 | makeReportManager(); |
| 600 | } |
| 601 | |
| 602 | TEST_F(TestReportManagerStorage, |
| 603 | reportManagerCtorRemoveFileIfIntervalHasWrongType) |
| 604 | { |
| 605 | data["Interval"] = "1000"; |
| 606 | |
Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame] | 607 | EXPECT_CALL(storageMock, remove(FilePath("report1"))); |
| 608 | |
| 609 | makeReportManager(); |
| 610 | } |