22#include " FWCore/Catalog/interface/SiteLocalConfig.h"
33#include " FWCore/Utilities/interface/Exception.h"
44#include " FWCore/ServiceRegistry/interface/ServiceRegistry.h"
5- #include < filesystem>
65
6+ #include " TestSiteLocalConfig.h"
7+
8+ #include < filesystem>
79#include < string>
810
911#define CATCH_CONFIG_MAIN
1012#include " catch.hpp"
1113
12- namespace {
13- class TestSiteLocalConfig : public edm ::SiteLocalConfig {
14- public:
15- // constructor using trivial data catalogs
16- TestSiteLocalConfig (std::vector<std::string> catalogs) : m_trivialCatalogs(std::move(catalogs)) {}
17- // constructor using Rucio data catalogs
18- TestSiteLocalConfig (std::vector<edm::CatalogAttributes> catalogs) : m_catalogs(std::move(catalogs)) {}
19- std::vector<std::string> const & trivialDataCatalogs () const final { return m_trivialCatalogs; }
20- std::vector<edm::CatalogAttributes> const & dataCatalogs () const final { return m_catalogs; }
21- std::filesystem::path const storageDescriptionPath (const edm::CatalogAttributes& aDataCatalog) const final {
22- return std::filesystem::path ();
23- }
24-
25- std::string const lookupCalibConnect (std::string const & input) const final { return std::string (); }
26- std::string const rfioType (void ) const final { return std::string (); }
27-
28- std::string const * sourceCacheTempDir () const final { return nullptr ; }
29- double const * sourceCacheMinFree () const final { return nullptr ; }
30- std::string const * sourceCacheHint () const final { return nullptr ; }
31- std::string const * sourceCloneCacheHint () const final { return nullptr ; }
32- std::string const * sourceReadHint () const final { return nullptr ; }
33- unsigned int const * sourceTTreeCacheSize () const final { return nullptr ; }
34- unsigned int const * sourceTimeout () const final { return nullptr ; }
35- bool enablePrefetching () const final { return false ; }
36- unsigned int debugLevel () const final { return 0 ; }
37- std::vector<std::string> const * sourceNativeProtocols () const final { return nullptr ; }
38- struct addrinfo const * statisticsDestination () const final { return nullptr ; }
39- std::set<std::string> const * statisticsInfo () const final { return nullptr ; }
40- std::string const & siteName (void ) const final { return m_emptyString; }
41- std::string const & subSiteName (void ) const final { return m_emptyString; }
42- bool useLocalConnectString () const final { return false ; }
43- std::string const & localConnectPrefix () const final { return m_emptyString; }
44- std::string const & localConnectSuffix () const final { return m_emptyString; }
45-
46- private:
47- std::vector<std::string> m_trivialCatalogs;
48- std::vector<edm::CatalogAttributes> m_catalogs;
49- std::filesystem::path m_storageDescription_path;
50- std::string m_emptyString;
51- };
52- } // namespace
53-
54- TEST_CASE (" FileLocator with Rucio data catalog" , " [filelocatorRucioDataCatalog]" ) {
55- // catalog for testing "prefix"
56- edm::CatalogAttributes aCatalog;
57- aCatalog.site = " T1_US_FNAL" ;
58- aCatalog.subSite = " T1_US_FNAL" ;
59- aCatalog.storageSite = " T1_US_FNAL" ;
60- aCatalog.volume = " American_Federation" ;
61- aCatalog.protocol = " XRootD" ;
62- std::vector<edm::CatalogAttributes> tmp{aCatalog};
63- // catalog for testing "rules"
64- aCatalog.site = " T1_US_FNAL" ;
65- aCatalog.subSite = " T1_US_FNAL" ;
66- aCatalog.storageSite = " T1_US_FNAL" ;
67- aCatalog.volume = " FNAL_dCache_EOS" ;
68- aCatalog.protocol = " XRootD" ;
69- tmp.push_back (aCatalog);
70- // catalog for testing chained "rules"
71- aCatalog.site = " T1_US_FNAL" ;
72- aCatalog.subSite = " T1_US_FNAL" ;
73- aCatalog.storageSite = " T1_US_FNAL" ;
74- aCatalog.volume = " FNAL_dCache_EOS" ;
75- aCatalog.protocol = " root" ;
76- tmp.push_back (aCatalog);
77-
78- // create the services
79- edm::ServiceToken tempToken (
80- edm::ServiceRegistry::createContaining (std::unique_ptr<edm::SiteLocalConfig>(new TestSiteLocalConfig (tmp))));
81-
82- std::string CMSSW_BASE (std::getenv (" CMSSW_BASE" ));
83- std::string CMSSW_RELEASE_BASE (std::getenv (" CMSSW_RELEASE_BASE" ));
84- std::string file_name (" /src/FWCore/Catalog/test/storage.json" );
85- std::string full_file_name = std::filesystem::exists ((CMSSW_BASE + file_name).c_str ())
86- ? CMSSW_BASE + file_name
87- : CMSSW_RELEASE_BASE + file_name;
14+ TEST_CASE (" FileLocator with Rucio data catalog" , " [FWCore/Catalog]" ) {
15+ edm::ServiceToken tempToken = edmtest::catalog::makeTestSiteLocalConfigToken ();
8816
8917 SECTION (" prefix" ) {
9018 edm::ServiceRegistry::Operate operate (tempToken);
9119 // empty catalog
9220 edm::CatalogAttributes tmp_cat;
9321 // use the first catalog provided by site local config
94- edm::FileLocator fl (tmp_cat, 0 , full_file_name );
22+ edm::FileLocator fl (tmp_cat, 0 );
9523 CHECK (" root://cmsxrootd.fnal.gov/store/group/bha/bho" ==
9624 fl.pfn (" /store/group/bha/bho" , edm::CatalogType::RucioCatalog));
9725 }
@@ -100,7 +28,7 @@ TEST_CASE("FileLocator with Rucio data catalog", "[filelocatorRucioDataCatalog]"
10028 // empty catalog
10129 edm::CatalogAttributes tmp_cat;
10230 // use the second catalog provided by site local config
103- edm::FileLocator fl (tmp_cat, 1 , full_file_name );
31+ edm::FileLocator fl (tmp_cat, 1 );
10432 const std::array<const char *, 7 > lfn = {{" /bha/bho" ,
10533 " bha" ,
10634 " file:bha" ,
@@ -119,7 +47,7 @@ TEST_CASE("FileLocator with Rucio data catalog", "[filelocatorRucioDataCatalog]"
11947 // empty catalog
12048 edm::CatalogAttributes tmp_cat;
12149 // use the third catalog provided by site local config above
122- edm::FileLocator fl (tmp_cat, 2 , full_file_name );
50+ edm::FileLocator fl (tmp_cat, 2 );
12351 const std::array<const char *, 7 > lfn = {{" /bha/bho" ,
12452 " bha" ,
12553 " file:bha" ,
@@ -139,7 +67,7 @@ TEST_CASE("FileLocator with Rucio data catalog", "[filelocatorRucioDataCatalog]"
13967 }
14068}
14169
142- TEST_CASE (" FileLocator" , " [filelocator ]" ) {
70+ TEST_CASE (" FileLocator with TrivialFileCatalog " , " [FWCore/Catalog ]" ) {
14371 std::string CMSSW_BASE (std::getenv (" CMSSW_BASE" ));
14472 std::string CMSSW_RELEASE_BASE (std::getenv (" CMSSW_RELEASE_BASE" ));
14573 std::string file_name (" /src/FWCore/Catalog/test/simple_catalog.xml" );
@@ -149,8 +77,8 @@ TEST_CASE("FileLocator", "[filelocator]") {
14977
15078 // create the services
15179 std::vector<std::string> tmp{std::string (" trivialcatalog_file:" ) + full_file_name + " ?protocol=xrd" };
152- edm::ServiceToken tempToken (
153- edm::ServiceRegistry::createContaining ( std::unique_ptr<edm::SiteLocalConfig>(new TestSiteLocalConfig (tmp))));
80+ edm::ServiceToken tempToken (edm::ServiceRegistry::createContaining (
81+ std::unique_ptr<edm::SiteLocalConfig>(std::make_unique<edmtest::catalog:: TestSiteLocalConfig> (tmp))));
15482
15583 // make the services available
15684 SECTION (" standard" ) {
0 commit comments