Merge pull request #37669 from lixiaoy1/fix_cache_state_ut_1015

rbd/cache: fix UTs related to image cache state

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
Reviewed-by: Mahati Chamarthy <mahati.chamarthy@intel.com>
This commit is contained in:
Jason Dillaman 2020-10-15 08:47:57 -04:00 committed by GitHub
commit 93eccc15f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,20 +65,13 @@ struct TestMockCacheReplicatedWriteLog : public TestMockFixture {
void validate_cache_state(librbd::ImageCtx *image_ctx,
MockImageCacheStateRWL &state,
bool present, bool empty, bool clean,
string host="", string path="",
uint64_t size=0) {
string host, string path,
uint64_t size) {
ConfigProxy &config = image_ctx->config;
ASSERT_EQ(present, state.present);
ASSERT_EQ(empty, state.empty);
ASSERT_EQ(clean, state.clean);
if (host.empty())
host = ceph_get_short_hostname();
if (path.empty())
path = config.get_val<string>("rbd_rwl_path");
if (!size)
size = config.get_val<uint64_t>("rbd_rwl_size");
ASSERT_EQ(host, state.host);
ASSERT_EQ(path, state.path);
ASSERT_EQ(size, state.size);
@ -122,7 +115,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, init_state_write) {
MockImageCtx mock_image_ctx(*ictx);
MockImageCacheStateRWL image_cache_state(&mock_image_ctx);
validate_cache_state(ictx, image_cache_state, true, true, true);
validate_cache_state(ictx, image_cache_state, false, true, true, "", "", 0);
image_cache_state.empty = false;
image_cache_state.clean = false;