Created
November 28, 2019 12:07
-
-
Save amaltaro/2c546c9a251d12b2f7bfa3d04eb56e34 to your computer and use it in GitHub Desktop.
Test MemoryCacheStruct for datatier validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
import time | |
from WMCore.Cache.GenericDataCache import GenericDataCache, MemoryCacheStruct | |
from WMCore.Services.DBS.DBS3Reader import DBS3Reader as DBSReader | |
def validateDatatier(datatier, dbsUrl, expiration=5): | |
cacheName = "dataTierList" | |
print("validateDatatier called with: %s" % dbsUrl) | |
if not GenericDataCache.cacheExists(cacheName): | |
print("Found no cache named: %s in GenericDataCache" % cacheName) | |
mc = MemoryCacheStruct(expiration, _listDatatiers, kwargs={'dbsUrl': dbsUrl}) | |
GenericDataCache.registerCache(cacheName, mc) | |
cacheData = GenericDataCache.getCacheData('dataTierList') | |
dbsTiers = cacheData.getData() | |
print("Found %d tiers" % len(dbsTiers)) | |
def _listDatatiers(dbsUrl): | |
dbsTiers = DBSReader.listDatatiers(dbsUrl) | |
return dbsTiers | |
print("Test 1") | |
#validateDatatier(["GEN"], "https://cmsweb-testbed.cern.ch/dbs/int/global/DBSReader") | |
validateDatatier(["GEN"], "https://cmsweb.cern.ch/dbs/prod/global/DBSReader") | |
print("Test 2") | |
validateDatatier(["GEN"], "https://cmsweb-testbed.cern.ch/dbs/int/global/DBSReader") | |
print("Test 3") | |
validateDatatier(["GEN"], "https://cmsweb.cern.ch/dbs/prod/global/DBSReader") | |
print("\nNow sleep for 10 seconds to let the cache expire....") | |
time.sleep(10) | |
print("Test 4") | |
validateDatatier(["GEN"], "https://cmsweb-testbed.cern.ch/dbs/int/global/DBSReader") | |
print("Test 5") | |
validateDatatier(["GEN"], "https://cmsweb.cern.ch/dbs/prod/global/DBSReader") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment