Helper to create a TmpFileMgr and initialise it with InitCustom(). Adds the mgr to 'obj_pool_' for automatic cleanup at the end of each test. Fails the test if InitCustom() fails.
| 113 | /// 'obj_pool_' for automatic cleanup at the end of each test. Fails the test if |
| 114 | /// InitCustom() fails. |
| 115 | TmpFileMgr* CreateTmpFileMgr(const string& tmp_dirs_spec, bool expect_ok = true, |
| 116 | HdfsFsCache::HdfsFsMap* hdfs_conn_map = nullptr) { |
| 117 | // Allocate a new metrics group for each TmpFileMgr so they don't get confused by |
| 118 | // the pre-existing metrics (TmpFileMgr assumes it's a singleton in product code). |
| 119 | MetricGroup* metrics = obj_pool_.Add(new MetricGroup("")); |
| 120 | TmpFileMgr* mgr = obj_pool_.Add(new TmpFileMgr()); |
| 121 | if (hdfs_conn_map != nullptr) mgr->hdfs_conns_ = *hdfs_conn_map; |
| 122 | Status status = mgr->InitCustom(tmp_dirs_spec, false, "", false, metrics); |
| 123 | if (expect_ok) { |
| 124 | EXPECT_TRUE(status.ok()); |
| 125 | } else { |
| 126 | EXPECT_FALSE(status.ok()); |
| 127 | } |
| 128 | return mgr; |
| 129 | } |
| 130 | |
| 131 | /// Check that metric values are consistent with TmpFileMgr state. |
| 132 | void CheckMetrics(TmpFileMgr* tmp_file_mgr) { |
nothing calls this directly
no test coverage detected