diff --git a/test/python/Utils_t/Patterns_t.py b/test/python/Utils_t/Patterns_t.py index 27320cb36a..f5a42eaa74 100644 --- a/test/python/Utils_t/Patterns_t.py +++ b/test/python/Utils_t/Patterns_t.py @@ -2,18 +2,17 @@ Patterns_t module provide unit tests for Patterns module Unittests for Utilities functions """ - - import time import unittest -from Utils.Patterns import Singleton +from Utils.Patterns import Singleton, getDomainName -class Test(object, metaclass=Singleton):#Test(with_metaclass(Singleton, object)): +class Test(object, metaclass=Singleton): "Example of Singleton class" def __init__(self): self.time = time.time() + class PatternsTests(unittest.TestCase): """ unittest for Patterns functions @@ -27,5 +26,19 @@ def testSingleton(self): self.assertEqual(obj1.time, obj2.time) self.assertEqual(id(obj1), id(obj2)) + + def testGetDomainName(self): + "Test the getDomainName function" + # test with http protocol + self.assertEqual(getDomainName("http://cmsweb.cern.ch/blah/two"), "cmsweb") + # test with https protocol + self.assertEqual(getDomainName("https://cmsweb.cern.ch/blah/two"), "cmsweb") + self.assertEqual(getDomainName("https://cmsweb-testbed.cern.ch"), "cmsweb-testbed") + self.assertEqual(getDomainName("https://cmsweb-preprod.cern.ch"), "cmsweb-preprod") + self.assertEqual(getDomainName("https://cmsweb-test3.cern.ch"), "cmsweb-test3") + # test with unexpected/wrong URL + self.assertEqual(getDomainName("https://cmsweb.blah.ch"), "") + + if __name__ == '__main__': unittest.main() diff --git a/test/python/WMCore_t/WMSpec_t/Steps_t/Fetchers_t/PileupFetcher_t.py b/test/python/WMCore_t/WMSpec_t/Steps_t/Fetchers_t/PileupFetcher_t.py index dde68f3bae..5a25d68809 100644 --- a/test/python/WMCore_t/WMSpec_t/Steps_t/Fetchers_t/PileupFetcher_t.py +++ b/test/python/WMCore_t/WMSpec_t/Steps_t/Fetchers_t/PileupFetcher_t.py @@ -96,15 +96,17 @@ def _queryAndCompareWithDBS(self, pileupDict, pileupConfig, dbsUrl): for dataset in datasets: dbsBlocks = reader.listFileBlocks(dataset=dataset) - rucioBlocksLocation = rucioObj.getPileupLockedAndAvailable(dataset, - account=self.rucioAcct) + rucioBlocks = rucioObj.getBlocksInContainer(container=dataset) + print(f"DBS knows {len(dbsBlocks)} while Rucio knows {len(rucioBlocks)} blocks for {dataset}") + # now pileup data location comes from MSPileup (from MockMSPileupAPI) + rucioBlocksLocation = ["T2_XX_SiteA", "T2_XX_SiteB", "T2_XX_SiteC"] # first, validate the number of blocks and their names self.assertItemsEqual(list(blockDict), dbsBlocks) - self.assertItemsEqual(list(blockDict), list(rucioBlocksLocation)) + self.assertItemsEqual(list(blockDict), rucioBlocks) # now validate the block location between Rucio and PileupFetcher for block, blockLocation in viewitems(blockDict): - self.assertItemsEqual(blockLocation['PhEDExNodeNames'], rucioBlocksLocation[block]) + self.assertItemsEqual(blockLocation['PhEDExNodeNames'], rucioBlocksLocation) # finally, validate the files fileList = []