Skip to content
Snippets Groups Projects
Commit 51f5e1c2 authored by Eric Cano's avatar Eric Cano
Browse files

Disabled the tests for objectstore middle tier which will not be updated for a...

Disabled the tests for objectstore middle tier which will not be updated for a while, pending the middle tier interface review.
Remove the now useless (following the move to generic test) printouts of the type in backend store tests.
Added tests for RootEntry's admin hosts and admin users interface.
parent 5b3877e0
Branches
Tags
No related merge requests found
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
namespace unitTests { namespace unitTests {
TEST_P(BackendAbstractTest, BasicReadWrite) { TEST_P(BackendAbstractTest, BasicReadWrite) {
std::cout << "Type=" << m_os->typeName() << std::endl; //std::cout << "Type=" << m_os->typeName() << std::endl;
const std::string testValue = "1234"; const std::string testValue = "1234";
const std::string testSecondValue = "1234"; const std::string testSecondValue = "1234";
const std::string testObjectName = "testObject"; const std::string testObjectName = "testObject";
...@@ -52,7 +52,7 @@ TEST_P(BackendAbstractTest, BasicReadWrite) { ...@@ -52,7 +52,7 @@ TEST_P(BackendAbstractTest, BasicReadWrite) {
} }
TEST_P(BackendAbstractTest, LockingInterface) { TEST_P(BackendAbstractTest, LockingInterface) {
std::cout << "Type=" << m_os->typeName() << std::endl; //std::cout << "Type=" << m_os->typeName() << std::endl;
const std::string testObjectName = "testObject"; const std::string testObjectName = "testObject";
m_os->create(testObjectName, ""); m_os->create(testObjectName, "");
{ {
...@@ -70,10 +70,10 @@ TEST_P(BackendAbstractTest, LockingInterface) { ...@@ -70,10 +70,10 @@ TEST_P(BackendAbstractTest, LockingInterface) {
} }
TEST_P(BackendAbstractTest, ParametersInterface) { TEST_P(BackendAbstractTest, ParametersInterface) {
std::cout << "Type=" << m_os->typeName() << std::endl; //std::cout << "Type=" << m_os->typeName() << std::endl;
std::unique_ptr<cta::objectstore::Backend::Parameters> params( std::unique_ptr<cta::objectstore::Backend::Parameters> params(
m_os->getParams()); m_os->getParams());
std::cout << params->toStr() << std::endl; //std::cout << params->toStr() << std::endl;
} }
cta::objectstore::BackendVFS osVFS; cta::objectstore::BackendVFS osVFS;
......
...@@ -38,7 +38,7 @@ TEST(RootEntry, BasicAccess) { ...@@ -38,7 +38,7 @@ TEST(RootEntry, BasicAccess) {
ASSERT_THROW(re.fetch(), cta::exception::Exception); ASSERT_THROW(re.fetch(), cta::exception::Exception);
cta::objectstore::ScopedSharedLock lock(re); cta::objectstore::ScopedSharedLock lock(re);
ASSERT_NO_THROW(re.fetch()); ASSERT_NO_THROW(re.fetch());
std::cout << re.dump(); re.dump();
} }
{ {
// Try to allocate the agent register // Try to allocate the agent register
...@@ -63,4 +63,126 @@ TEST(RootEntry, BasicAccess) { ...@@ -63,4 +63,126 @@ TEST(RootEntry, BasicAccess) {
ASSERT_EQ(false, re.exists()); ASSERT_EQ(false, re.exists());
} }
TEST(RootEntry, AdminHosts) {
cta::objectstore::BackendVFS be;
{
// Try to create the root entry
cta::objectstore::RootEntry re(be);
re.initialize();
re.insert();
}
{
// Add 2 admin hosts to the root entry
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedExclusiveLock lock(re);
ASSERT_NO_THROW(re.fetch());
cta::objectstore::CreationLog cl(99, "dummyUser", 99, "dummyGroup",
"unittesthost", time(NULL), "Creation of unit test agent register");
re.addAdminHost("adminHost1", cl);
re.addAdminHost("adminHost2", cl);
re.commit();
}
{
// Check that the admin hosts made it
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedSharedLock lock(re);
re.fetch();
ASSERT_TRUE(re.isAdminHost("adminHost1"));
ASSERT_TRUE(re.isAdminHost("adminHost2"));
ASSERT_FALSE(re.isAdminHost("adminHost3"));
}
{
// Check that we can remove existing and non-existing hosts
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedExclusiveLock lock(re);
re.fetch();
re.removeAdminHost("adminHost1");
re.removeAdminHost("noSuch");
re.commit();
}
{
// Check that we got the expected result
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedSharedLock lock(re);
re.fetch();
ASSERT_FALSE(re.isAdminHost("adminHost1"));
ASSERT_TRUE(re.isAdminHost("adminHost2"));
ASSERT_FALSE(re.isAdminHost("adminHost3"));
ASSERT_EQ(1, re.dumpAdminHosts().size());
ASSERT_EQ("adminHost2", re.dumpAdminHosts().front().hostname);
}
// Delete the root entry
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedExclusiveLock lock(re);
re.remove();
ASSERT_EQ(false, re.exists());
}
TEST(RootEntry, AdminUsers) {
cta::objectstore::BackendVFS be;
{
// Try to create the root entry
cta::objectstore::RootEntry re(be);
re.initialize();
re.insert();
}
cta::objectstore::UserIdentity user1(123, "user123", 456, "group456");
cta::objectstore::UserIdentity user1prime(123, "somethingelse", 789, "group789");
cta::objectstore::UserIdentity user2(234, "user234", 345, "group345");
cta::objectstore::UserIdentity user2prime(234, "somethingwrong", 567, "group567");
cta::objectstore::UserIdentity user3(345, "user234", 345, "group345");
{
// Add 2 admin users to the root entry
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedExclusiveLock lock(re);
ASSERT_NO_THROW(re.fetch());
cta::objectstore::CreationLog cl(99, "dummyUser", 99, "dummyGroup",
"unittesthost", time(NULL), "Creation of unit test agent register");
re.addAdminUser(user1, cl);
re.addAdminUser(user2, cl);
re.commit();
}
{
// Check that the admin hosts made it and that uid is the only meaningful
// criteria
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedSharedLock lock(re);
re.fetch();
ASSERT_TRUE(re.isAdminUser(user1));
ASSERT_TRUE(re.isAdminUser(user1prime));
ASSERT_TRUE(re.isAdminUser(user2));
ASSERT_TRUE(re.isAdminUser(user2prime));
ASSERT_FALSE(re.isAdminUser(user3));
}
{
// Check that we can remove existing and non-existing hosts
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedExclusiveLock lock(re);
re.fetch();
re.removeAdminUser(user1prime);
re.removeAdminUser(user3);
re.commit();
}
{
// Check that we got the expected result
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedSharedLock lock(re);
re.fetch();
ASSERT_FALSE(re.isAdminUser(user1));
ASSERT_FALSE(re.isAdminUser(user1prime));
ASSERT_TRUE(re.isAdminUser(user2));
ASSERT_TRUE(re.isAdminUser(user2prime));
ASSERT_FALSE(re.isAdminUser(user3));
ASSERT_EQ(1, re.dumpAdminUsers().size());
ASSERT_EQ(user2.uid, re.dumpAdminUsers().front().user.uid);
}
// Delete the root entry
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedExclusiveLock lock(re);
re.remove();
ASSERT_EQ(false, re.exists());
}
} }
...@@ -28,9 +28,8 @@ public: ...@@ -28,9 +28,8 @@ public:
UserIdentity (): uid(std::numeric_limits<decltype(uid)>::max()), UserIdentity (): uid(std::numeric_limits<decltype(uid)>::max()),
gid(std::numeric_limits<decltype(gid)>::max()) {} gid(std::numeric_limits<decltype(gid)>::max()) {}
UserIdentity (uint32_t ui, const std::string & un, UserIdentity (uint32_t ui, const std::string & un,
uint32_t gi, const std::string & gn, uint32_t gi, const std::string & gn):
const std::string & hn, uint64_t t, uid(ui), uname(un), gid(gi), gname(gn) {}
const std::string & c): uid(ui), uname(un), gid(gi), gname(gn) {}
uint32_t uid; uint32_t uid;
std::string uname; std::string uname;
uint32_t gid; uint32_t gid;
......
...@@ -15,7 +15,7 @@ target_link_libraries(unittests ...@@ -15,7 +15,7 @@ target_link_libraries(unittests
ctamiddletierunittests ctamiddletierunittests
ctamiddletiersqlite ctamiddletiersqlite
ctamiddletiersqliteunittests ctamiddletiersqliteunittests
ctamiddletierobjectstoreunittests #ctamiddletierobjectstoreunittests
ctamiddletierobjectstore ctamiddletierobjectstore
ctanameservertest ctanameservertest
ctaschedulertest ctaschedulertest
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment