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

Added compilation of object store middle tier. The unit test cannot compile...

Added compilation of object store middle tier. The unit test cannot compile yet (commented out) as the classes are not fully implemented.
parent fe598ccf
Branches
Tags
No related merge requests found
......@@ -59,13 +59,7 @@ set (MIDDLE_TIER_INTERFACE_SRC_FILES
add_library (ctamiddletier SHARED
${MIDDLE_TIER_INTERFACE_SRC_FILES})
#target_link_libraries (ctamiddletier ${SQLITE3_LIBRARY_RELEASE}
# CTAException)
set (MIDDLE_TIER_INTERFACE_UNIT_TESTS_LIB_SRC_FILES
# cta/SqliteMiddleTierAdminTest.cpp
# cta/SqliteMiddleTierUserTest.cpp
# cta/UtilsTest.cpp
interface/MockNameServerTest.cpp
sharedtest/MiddleTierAdminAbstractTest.cpp
sharedtest/MiddleTierUserAbstractTest.cpp)
......@@ -73,8 +67,6 @@ set (MIDDLE_TIER_INTERFACE_UNIT_TESTS_LIB_SRC_FILES
add_library (ctamiddletierunittests SHARED
${MIDDLE_TIER_INTERFACE_UNIT_TESTS_LIB_SRC_FILES})
#target_link_libraries (ctamiddletierunittests ${SQLITE3_LIBRARY_RELEASE})
add_library (ctamiddletiersqlite SHARED
SQLite/SqliteColumnNameToIndex.cpp
SQLite/SqliteDatabase.cpp
......@@ -85,3 +77,11 @@ target_link_libraries (ctamiddletiersqlite ${SQLITE3_LIBRARY_RELEASE})
add_library (ctamiddletiersqliteunittests SHARED
SQLite/SqliteMiddleTierTest.cpp)
include_directories(${CMAKE_BINARY_DIR})
add_library(ctamiddletiersqliteobjectstore
objectstore/ObjectStoreMiddleTierAdmin.cpp)
#add_library (ctamiddletiersqliteobjectstoreunittests SHARED
# objectstore/ObjectStoreMiddleTierTest.cpp)
cmake_minimum_required (VERSION 2.6)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../middletier)
include_directories(${CMAKE_BINARY_DIR})
add_library (CTAObjectStoreMiddleTier
ObjectStoreMiddleTierAdmin.cpp
)
set(MiddleTierUnitTests
MiddleTierAdminAbstractTest.cpp
MiddleTierUserAbstractTest.cpp
MiddleTierTest.cpp
)
add_executable(ObjectStoreMiddleTierUnitTests unit_tests.cpp ${MiddleTierUnitTests})
target_link_libraries(ObjectStoreMiddleTierUnitTests
CTAException CTAObjectStore CTAObjectStoreMiddleTier
protobuf rados gtest gmock ctamiddletier)
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "cta/Exception.hpp"
#include "ObjectStoreMiddleTier.hpp"
#include "objectstore/Backend.hpp"
#include "objectstore/RootEntry.hpp"
#include "objectstore/AdminUsersList.hpp"
namespace cta {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
OStoreMiddleTierAdmin::OStoreMiddleTierAdmin(objectstore::Backend& backend):
m_backend(backend) {
// check that we can at least access the root entry
objectstore::RootEntry re(m_backend);
objectstore::ScopedSharedLock reLock(re);
re.fetch();
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
OStoreMiddleTierAdmin::~OStoreMiddleTierAdmin() throw() {
}
//------------------------------------------------------------------------------
// createAdminUser
//------------------------------------------------------------------------------
void OStoreMiddleTierAdmin::createAdminUser(
const SecurityIdentity &requester,
const UserIdentity &user,
const std::string &comment) {
// TODO: authz is needed here!
// Find the admin users list from the root entry.
objectstore::RootEntry re(m_backend);
objectstore::ScopedSharedLock reLock(re);
re.fetch();
objectstore::AdminUsersList aul(re.getAdminUsersList(), m_backend);
reLock.release();
objectstore::ScopedExclusiveLock auLock(aul);
aul.fetch();
AdminUser au(user, requester.user, comment);
aul.add(au);
aul.commit();
}
}
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "cta/MiddleTierAdmin.hpp"
namespace cta {
namespace objectstore {
class Backend;
}
/**
* The administration API of the the middle-tier.
* ObjectStore based implementation
*/
class OStoreMiddleTierAdmin: public MiddleTierAdmin {
public:
/**
* Contructor
*/
OStoreMiddleTierAdmin(objectstore::Backend & backend);
/**
* Destructor
*/
virtual ~OStoreMiddleTierAdmin() throw();
/**
* Creates the specified administrator.
*
* @param requester The identity of the user requesting the creation of the
* administrator.
* @param user The identity of the administrator.
* @param comment The comment describing the sministrator.
*/
virtual void createAdminUser(
const SecurityIdentity &requester,
const UserIdentity &user,
const std::string &comment);
/**
* Deletes the specified administrator.
*
* @param requester The identity of the user requesting the deletion of the
* administrator.
* @param user The identity of the administrator.
*/
virtual void deleteAdminUser(
const SecurityIdentity &requester,
const UserIdentity &user);
/**
* Returns the current list of administrators in lexicographical order.
*
* @param requester The identity of the user requesting the list.
* @return The current list of administrators in lexicographical order.
*/
virtual std::list<AdminUser> getAdminUsers(const SecurityIdentity &requester)
const;
/**
* Creates the specified administration host.
*
* @param requester The identity of the user requesting the creation of the
* administration host.
* @param hostName The network name of the administration host.
* @param comment The comment describing the administration host.
*/
virtual void createAdminHost(
const SecurityIdentity &requester,
const std::string &hostName,
const std::string &comment);
/**
* Deletes the specified administration host.
*
* @param requester The identity of the user requesting the deletion of the
* administration host.
* @param hostName The network name of the administration host.
* @param comment The comment describing the administration host.
*/
virtual void deleteAdminHost(
const SecurityIdentity &requester,
const std::string &hostName);
/**
* Returns the current list of administration hosts in lexicographical order.
*
* @param requester The identity of the user requesting the list.
* @return The current list of administration hosts in lexicographical order.
*/
virtual std::list<AdminHost> getAdminHosts(const SecurityIdentity &requester)
const;
/**
* Creates the specified storage class.
*
* @param requester The identity of the user requesting the creation of the
* storage class.
* @param name The name of the storage class.
* @param nbCopies The number of copies a file associated with this storage
* class should have on tape.
* @param comment The comment describing the storage class.
*/
virtual void createStorageClass(
const SecurityIdentity &requester,
const std::string &name,
const uint8_t nbCopies,
const std::string &comment);
/**
* Deletes the specified storage class.
*
* @param requester The identity of the user requesting the deletion of the
* storage class.
* @param name The name of the storage class.
*/
virtual void deleteStorageClass(
const SecurityIdentity &requester,
const std::string &name);
/**
* Gets the current list of storage classes in lexicographical order.
*
* @param requester The identity of the user requesting the list.
* @return The current list of storage classes in lexicographical order.
*/
virtual std::list<StorageClass> getStorageClasses(
const SecurityIdentity &requester) const;
/**
* Creates a tape pool with the specifed name.
*
* @param requester The identity of the user requesting the creation of the
* tape pool.
* @param name The name of the tape pool.
* @param nbDrives The maximum number of drives that can be concurrently
* assigned to this pool independent of whether they are archiving or
* retrieving files.
* @param nbPartialTapes The maximum number of tapes that can be partially
* full at any moment in time.
* @param comment The comment describing the tape pool.
*/
virtual void createTapePool(
const SecurityIdentity &requester,
const std::string &name,
const uint16_t nbDrives,
const uint32_t nbPartialTapes,
const std::string &comment);
/**
* Delete the tape pool with the specifed name.
*
* @param requester The identity of the user requesting the deletion of the
* tape pool.
* @param name The name of the tape pool.
*/
virtual void deleteTapePool(
const SecurityIdentity &requester,
const std::string &name);
/**
* Gets the current list of tape pools in lexicographical order.
*
* @param requester The identity of the user requesting the list.
* @return The current list of tape pools in lexicographical order.
*/
virtual std::list<TapePool> getTapePools(
const SecurityIdentity &requester) const;
/**
* Creates the specified archive route.
*
* @param requester The identity of the user requesting the creation of the
* archive route.
* @param storageClassName The name of the storage class that identifies the
* source disk files.
* @param copyNb The tape copy number.
* @param tapePoolName The name of the destination tape pool.
* @param comment The comment describing the archive route.
*/
virtual void createArchivalRoute(
const SecurityIdentity &requester,
const std::string &storageClassName,
const uint8_t copyNb,
const std::string &tapePoolName,
const std::string &comment);
/**
* Deletes the specified archive route.
*
* @param requester The identity of the user requesting the deletion of the
* archive route.
* @param storageClassName The name of the storage class that identifies the
* source disk files.
* @param copyNb The tape copy number.
*/
virtual void deleteArchivalRoute(
const SecurityIdentity &requester,
const std::string &storageClassName,
const uint8_t copyNb);
/**
* Gets the current list of archive routes.
*
* @param requester The identity of the user requesting the list.
*/
virtual std::list<ArchivalRoute> getArchivalRoutes(
const SecurityIdentity &requester) const;
/**
* Creates a logical library with the specified name.
*
* @param requester The identity of the user requesting the creation of the
* logical library.
* @param name The name of the logical library.
* @param comment The comment describing the logical library.
*/
virtual void createLogicalLibrary(
const SecurityIdentity &requester,
const std::string &name,
const std::string &comment);
/**
* Deletes the logical library with the specified name.
*
* @param requester The identity of the user requesting the deletion of the
* logical library.
* @param name The name of the logical library.
*/
virtual void deleteLogicalLibrary(
const SecurityIdentity &requester,
const std::string &name);
/**
* Returns the current list of libraries in lexicographical order.
*
* @param requester The identity of the user requesting the list.
* @return The current list of libraries in lexicographical order.
*/
virtual std::list<LogicalLibrary> getLogicalLibraries(
const SecurityIdentity &requester) const;
/**
* Creates a tape.
*
* @param requester The identity of the user requesting the creation of the
* tape.
* @param vid The volume identifier of the tape.
* @param logicalLibrary The name of the logical library to which the tape
* belongs.
* @param tapePoolName The name of the tape pool to which the tape belongs.
* @param capacityInBytes The capacity of the tape.
* @param comment The comment describing the logical library.
*/
virtual void createTape(
const SecurityIdentity &requester,
const std::string &vid,
const std::string &logicalLibraryName,
const std::string &tapePoolName,
const uint64_t capacityInBytes,
const std::string &comment);
/**
* Deletes the tape with the specified volume identifier.
*
* @param requester The identity of the user requesting the deletion of the
* tape.
* @param vid The volume identifier of the tape.
*/
virtual void deleteTape(
const SecurityIdentity &requester,
const std::string &vid);
/**
* Returns the current list of tapes in the lexicographical order of their
* volume identifiers.
*
* @param requester The identity of the user requesting the list.
* @return The current list of tapes in the lexicographical order of their
* volume identifiers.
*/
virtual std::list<Tape> getTapes(
const SecurityIdentity &requester) const;
private:
/**
* Reference to the backend used for storing objects
*/
objectstore::Backend & m_backend;
};
}
......@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "cta/Exception.hpp"
#include "ObjectStoreMiddleTierAdmin.hpp"
#include "utils/exception/Exception.hpp"
#include "middletier/objectstore/ObjectStoreMiddleTierAdmin.hpp"
#include "objectstore/Backend.hpp"
#include "objectstore/RootEntry.hpp"
#include "objectstore/AdminUsersList.hpp"
......
......@@ -18,7 +18,7 @@
#pragma once
#include "cta/MiddleTierAdmin.hpp"
#include "middletier/interface/MiddleTierAdmin.hpp"
namespace cta {
......
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gtest/gtest.h>
#include <gmock/gmock.h>
int main(int argc, char** argv) {
// The following line must be executed to initialize Google Mock
// (and Google Test) before running the tests.
::testing::InitGoogleMock(&argc, argv);
int ret = RUN_ALL_TESTS();
// Close standard in, out and error so that valgrind can be used with the
// following command-line to track open file-descriptors:
//
// valgrind --track-fds=yes
close(0);
close(1);
close(2);
return ret;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment