| 258 | |
| 259 | |
| 260 | void FetcherCacheTest::verifyCacheMetrics() |
| 261 | { |
| 262 | JSON::Object metrics = Metrics(); |
| 263 | |
| 264 | ASSERT_EQ( |
| 265 | 1u, |
| 266 | metrics.values.count("containerizer/fetcher/cache_size_total_bytes")); |
| 267 | |
| 268 | // The total size is always given by the corresponding agent flag. |
| 269 | EXPECT_SOME_EQ( |
| 270 | flags.fetcher_cache_size.bytes(), |
| 271 | metrics.at<JSON::Number>("containerizer/fetcher/cache_size_total_bytes")); |
| 272 | |
| 273 | Try<std::list<Path>> files = fetcherProcess->cacheFiles(); |
| 274 | ASSERT_SOME(files); |
| 275 | |
| 276 | Bytes used; |
| 277 | |
| 278 | foreach (const auto& file, files.get()) { |
| 279 | Try<Bytes> size = os::stat::size(file); |
| 280 | ASSERT_SOME(size); |
| 281 | |
| 282 | used += size.get(); |
| 283 | } |
| 284 | |
| 285 | ASSERT_EQ( |
| 286 | 1u, |
| 287 | metrics.values.count("containerizer/fetcher/cache_size_used_bytes")); |
| 288 | |
| 289 | // Verify that the used amount of cache is the total of the size of |
| 290 | // all the files in the cache. |
| 291 | EXPECT_SOME_EQ( |
| 292 | used.bytes(), |
| 293 | metrics.at<JSON::Number>("containerizer/fetcher/cache_size_used_bytes")); |
| 294 | } |
| 295 | |
| 296 | |
| 297 | void FetcherCacheTest::TearDown() |
nothing calls this directly
no test coverage detected