Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-30 22:38:53

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