Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:08

0001 #include "FWCore/Catalog/interface/SiteLocalConfig.h"
0002 #include "FWCore/Services/src/SiteLocalConfigService.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/Utilities/interface/Exception.h"
0005 
0006 #define CATCH_CONFIG_MAIN
0007 #include "catch.hpp"
0008 
0009 TEST_CASE("Test SiteLocalConfigService", "[sitelocalconfig]") {
0010   std::string dirString;
0011   auto dir = std::getenv("LOCAL_TEST_DIR");
0012   if (dir) {
0013     dirString = dir;
0014   } else {
0015     auto base_dir = std::getenv("CMSSW_BASE");
0016     if (base_dir) {
0017       dirString = base_dir;
0018       dirString += "/src/FWCore/Services/test";
0019     }
0020   }
0021   REQUIRE(not dirString.empty());
0022   SECTION("sitelocalconfig/full/site-local-config.xml") {
0023     edm::ParameterSet pset;
0024     pset.addUntrackedParameter<std::string>("siteLocalConfigFileUrl",
0025                                             dirString + "/sitelocalconfig/full/site-local-config.xml");
0026 
0027     edm::service::SiteLocalConfigService slc(pset);
0028 
0029     CHECK(slc.trivialDataCatalogs()[0] == "trivialcatalog_file:/dummy/storage.xml?protocol=dcap");
0030     edm::CatalogAttributes tmp("DUMMY", "DUMMY_SUB_SITE", "DUMMY_CROSS_SITE", "CMSXrootdFederation", "XRootD");
0031     CHECK(slc.dataCatalogs()[0].site == tmp.site);
0032     CHECK(slc.dataCatalogs()[0].subSite == tmp.subSite);
0033     CHECK(slc.dataCatalogs()[0].storageSite == tmp.storageSite);
0034     CHECK(slc.dataCatalogs()[0].volume == tmp.volume);
0035     CHECK(slc.dataCatalogs()[0].protocol == tmp.protocol);
0036     REQUIRE(slc.sourceCacheTempDir() != nullptr);
0037     CHECK(*slc.sourceCacheTempDir() == "/a/b/c");
0038     CHECK(slc.sourceCacheMinFree() == nullptr);
0039     REQUIRE(slc.sourceCacheHint() != nullptr);
0040     CHECK(*slc.sourceCacheHint() == "application-only");
0041     REQUIRE(slc.sourceCloneCacheHint() == nullptr);
0042     REQUIRE(slc.sourceReadHint() != nullptr);
0043     CHECK(*slc.sourceReadHint() == "read-ahead-buffered");
0044     REQUIRE(slc.sourceTTreeCacheSize() != nullptr);
0045     CHECK(*slc.sourceTTreeCacheSize() == 10000);
0046     REQUIRE(slc.sourceTimeout() != nullptr);
0047     CHECK(*slc.sourceTimeout() == 7200);
0048     CHECK(slc.enablePrefetching());
0049     REQUIRE(slc.sourceNativeProtocols() != nullptr);
0050     REQUIRE(slc.sourceNativeProtocols()->size() == 2);
0051     CHECK((*slc.sourceNativeProtocols())[0] == "dcache");
0052     CHECK((*slc.sourceNativeProtocols())[1] == "file");
0053     REQUIRE(slc.statisticsDestination() != nullptr);
0054     REQUIRE(slc.statisticsInfo() != nullptr);
0055     CHECK(slc.statisticsInfo()->size() == 1);
0056     CHECK(slc.statisticsInfo()->find("dn") != slc.statisticsInfo()->end());
0057     CHECK(slc.siteName() == "DUMMY");
0058     CHECK(slc.subSiteName() == "DUMMY_SUB_SITE");
0059     REQUIRE(slc.useLocalConnectString() == true);
0060     REQUIRE(slc.localConnectPrefix() == "Test:Prefix");
0061     REQUIRE(slc.localConnectSuffix() == "Test.Suffix");
0062   }
0063 
0064   SECTION("overrides") {
0065     edm::ParameterSet pset;
0066     pset.addUntrackedParameter<std::string>("siteLocalConfigFileUrl",
0067                                             dirString + "/sitelocalconfig/full/site-local-config.xml");
0068 
0069     pset.addUntrackedParameter<std::string>("overrideSourceCacheTempDir", "/a/d");
0070     pset.addUntrackedParameter<double>("overrideSourceCacheMinFree", 10.);
0071     pset.addUntrackedParameter<std::string>("overrideSourceCacheHintDir", "dummy");
0072     pset.addUntrackedParameter<std::string>("overrideSourceCloneCacheHintDir", "foo");
0073     pset.addUntrackedParameter<std::string>("overrideSourceReadHint", "read-ahead-unbuffered");
0074     pset.addUntrackedParameter<std::vector<std::string> >("overrideSourceNativeProtocols", {{"http"}});
0075     pset.addUntrackedParameter<unsigned int>("overrideSourceTTreeCacheSize", 20000);
0076     pset.addUntrackedParameter<unsigned int>("overrideSourceTimeout", 0);
0077     pset.addUntrackedParameter<bool>("overridePrefetching", false);
0078     pset.addUntrackedParameter<std::string>("overrideStatisticsDestination", "");
0079     pset.addUntrackedParameter<std::vector<std::string> >("overrideStatisticsInfo", {{"nodn"}});
0080     pset.addUntrackedParameter<bool>("overrideUseLocalConnectString", false);
0081     pset.addUntrackedParameter<std::string>("overrideLocalConnectPrefix", "OverridePrefix");
0082     pset.addUntrackedParameter<std::string>("overrideLocalConnectSuffix", "OverrideSuffix");
0083 
0084     edm::service::SiteLocalConfigService slc(pset);
0085 
0086     CHECK(slc.trivialDataCatalogs()[0] == "trivialcatalog_file:/dummy/storage.xml?protocol=dcap");
0087     edm::CatalogAttributes tmp("DUMMY", "DUMMY_SUB_SITE", "DUMMY_CROSS_SITE", "CMSXrootdFederation", "XRootD");
0088     CHECK(slc.dataCatalogs()[0].site == tmp.site);
0089     CHECK(slc.dataCatalogs()[0].subSite == tmp.subSite);
0090     CHECK(slc.dataCatalogs()[0].storageSite == tmp.storageSite);
0091     CHECK(slc.dataCatalogs()[0].volume == tmp.volume);
0092     CHECK(slc.dataCatalogs()[0].protocol == tmp.protocol);
0093     REQUIRE(slc.sourceCacheTempDir() != nullptr);
0094     CHECK(*slc.sourceCacheTempDir() == "/a/d");
0095     REQUIRE(slc.sourceCacheMinFree() != nullptr);
0096     CHECK(*slc.sourceCacheMinFree() == 10.);
0097     REQUIRE(slc.sourceCacheHint() != nullptr);
0098     CHECK(*slc.sourceCacheHint() == "dummy");
0099     REQUIRE(slc.sourceCloneCacheHint() != nullptr);
0100     CHECK(*slc.sourceCloneCacheHint() == "foo");
0101     REQUIRE(slc.sourceReadHint() != nullptr);
0102     CHECK(*slc.sourceReadHint() == "read-ahead-unbuffered");
0103     REQUIRE(slc.sourceTTreeCacheSize() != nullptr);
0104     CHECK(*slc.sourceTTreeCacheSize() == 20000);
0105     REQUIRE(slc.sourceTimeout() != nullptr);
0106     CHECK(*slc.sourceTimeout() == 0);
0107     CHECK(not slc.enablePrefetching());
0108     REQUIRE(slc.sourceNativeProtocols() != nullptr);
0109     REQUIRE(slc.sourceNativeProtocols()->size() == 1);
0110     CHECK((*slc.sourceNativeProtocols())[0] == "http");
0111     REQUIRE(slc.statisticsDestination() == nullptr);
0112     REQUIRE(slc.statisticsInfo() != nullptr);
0113     CHECK(slc.statisticsInfo()->size() == 1);
0114     CHECK(slc.statisticsInfo()->find("nodn") != slc.statisticsInfo()->end());
0115     CHECK(slc.siteName() == "DUMMY");
0116     CHECK(slc.subSiteName() == "DUMMY_SUB_SITE");
0117     REQUIRE(slc.useLocalConnectString() == false);
0118     REQUIRE(slc.localConnectPrefix() == "OverridePrefix");
0119     REQUIRE(slc.localConnectSuffix() == "OverrideSuffix");
0120   }
0121 
0122   SECTION("sitelocalconfig/throw/site-local-config.xml") {
0123     edm::ParameterSet pset;
0124     pset.addUntrackedParameter<std::string>("siteLocalConfigFileUrl",
0125                                             dirString + "/sitelocalconfig/throw/site-local-config.xml");
0126 
0127     REQUIRE_THROWS_AS(edm::service::SiteLocalConfigService(pset), cms::Exception);
0128   }
0129 }