SessionFilter filter;
std::stringstream ss;
filter.parse({"id=123"}, &ss);
- Session *a = new Session(nullptr);;
- Session *b = new Session(nullptr);;
+ auto a = ceph::make_ref<Session>(nullptr);;
+ auto b = ceph::make_ref<Session>(nullptr);;
a->info.inst.name.parse("client.123");
b->info.inst.name.parse("client.456");
ASSERT_TRUE(filter.match(*a, [](client_t c) -> bool {return false;}));
ASSERT_FALSE(filter.match(*b, [](client_t c) -> bool {return false;}));
- a->put();
- b->put();
}
TEST(MDSSessionFilter, StateEquality)
SessionFilter filter;
std::stringstream ss;
filter.parse({"state=closing"}, &ss);
- Session *a = new Session(nullptr);
+ auto a = ceph::make_ref<Session>(nullptr);
a->set_state(Session::STATE_CLOSING);
- Session *b = new Session(nullptr);
+ auto b = ceph::make_ref<Session>(nullptr);
b->set_state(Session::STATE_OPENING);
ASSERT_TRUE(filter.match(*a, [](client_t c) -> bool {return false;}));
ASSERT_FALSE(filter.match(*b, [](client_t c) -> bool {return false;}));
- a->put();
- b->put();
}
TEST(MDSSessionFilter, AuthEquality)
SessionFilter filter;
std::stringstream ss;
filter.parse({"auth_name=rhubarb"}, &ss);
- Session *a = new Session(nullptr);
+ auto a = ceph::make_ref<Session>(nullptr);
a->info.auth_name.set_id("rhubarb");
- Session *b = new Session(nullptr);
+ auto b = ceph::make_ref<Session>(nullptr);
b->info.auth_name.set_id("custard");
ASSERT_TRUE(filter.match(*a, [](client_t c) -> bool {return false;}));
ASSERT_FALSE(filter.match(*b, [](client_t c) -> bool {return false;}));
- a->put();
- b->put();
}
TEST(MDSSessionFilter, MetadataEquality)
int r = filter.parse({"client_metadata.root=/rhubarb"}, &ss);
ASSERT_EQ(r, 0);
client_metadata_t meta;
- Session *a = new Session(nullptr);
+ auto a = ceph::make_ref<Session>(nullptr);
meta.kv_map = {{"root", "/rhubarb"}};
a->set_client_metadata(meta);
- Session *b = new Session(nullptr);
+ auto b = ceph::make_ref<Session>(nullptr);
meta.kv_map = {{"root", "/custard"}};
b->set_client_metadata(meta);
ASSERT_TRUE(filter.match(*a, [](client_t c) -> bool {return false;}));
ASSERT_FALSE(filter.match(*b, [](client_t c) -> bool {return false;}));
- a->put();
- b->put();
}
TEST(MDSSessionFilter, ReconnectingEquality)
std::stringstream ss;
int r = filter.parse({"reconnecting=true"}, &ss);
ASSERT_EQ(r, 0);
- Session *a = new Session(nullptr);
+ auto a = ceph::make_ref<Session>(nullptr);
ASSERT_TRUE(filter.match(*a, [](client_t c) -> bool {return true;}));
ASSERT_FALSE(filter.match(*a, [](client_t c) -> bool {return false;}));
- a->put();
}