Commit 6bd91f41 authored by M. Huang's avatar M. Huang
Browse files

move mqtt test to test9

parent ae73de09
......@@ -147,10 +147,10 @@ test: test1 test2 test5
testpns: test4
testhttp: test6 test7 test8
testhttp: test6 test7 test8 test9
test1:
$(PYTEST) tests/test_dataset.py --cov=fdi/dataset $(OPT) $(T)
$(PYTEST) tests/test_dataset.py -k 'not _mqtt' --cov=fdi/dataset $(OPT) $(T)
test2:
$(PYTEST) tests/test_pal.py -k 'not _http' $(T) --cov=fdi/pal $(OPT)
......@@ -173,6 +173,9 @@ test7:
test8:
$(PYTEST) $(OPT) $(T) tests/test_pal.py -k '_http'
test9:
$(PYTEST) tests/test_dataset.py -k '_mqtt' $(T)
FORCE:
......
......@@ -19,7 +19,7 @@ pc = getConfig()
DEFAULT_MEM_POOL = 'defaultmem'
# localpool
DEFAULT_POOL = 'pool_' + getpass.getuser()
DEFAULT_POOL = 'fdi_pool_' + __name__ + getpass.getuser()
def remoteRegister(p, poolurl):
......
......@@ -50,7 +50,7 @@ pnsconfig['server_poolpath'] = '/var/www/httppool_server/data' # For server
# logging level for server
pnsconfig['logginglevel'] = logging.DEBUG
# for HttpPool
pnsconfig['defaultpool'] = 'pool_default'
pnsconfig['defaultpool'] = 'default'
# message queue config
pnsconfig['mqtt'] = dict(
......
......@@ -511,8 +511,8 @@ A :class:`ProductStorage` with pools attached can be queried with tags, properti
""")
# clean possible data left from previous runs
defaultpoolpath = '/tmp/pool_' + getpass.getuser()
newpoolname = 'newpool_' + getpass.getuser()
defaultpoolpath = '/tmp/fdi_pool_' + __name__ + getpass.getuser()
newpoolname = 'fdi_newpool_' + __name__ + getpass.getuser()
newpoolpath = '/tmp/' + newpoolname
os.system('rm -rf ' + defaultpoolpath)
os.system('rm -rf ' + newpoolpath)
......
......@@ -36,7 +36,7 @@ logger.setLevel(logging.INFO)
logger.debug('logging level %d' % (logger.getEffectiveLevel()))
test_poolid = 'client_test_pool'
test_poolid = 'fdi_'+__name__
@pytest.fixture(scope="module")
......@@ -49,63 +49,63 @@ def test_gen_url(setup):
"""
aburl, headers = setup
samplepoolname = 'defaultpool'
samplepoolname = 'fdi_default_'+__name__
samplepoolurl = aburl + '/' + samplepoolname
sampleurn = 'urn:' + samplepoolname + ':fdi.dataset.product.Product:10'
logger.info('Test GET HK')
got_hk_url = urn2fdiurl(
urn=sampleurn, poolurl=samplepoolurl, contents='housekeeping', method='GET')
hk_url = aburl + '/' + 'defaultpool/hk'
hk_url = aburl + '/' + samplepoolname + '/hk'
assert got_hk_url == hk_url, 'Housekeeping url error: ' + got_hk_url + ':' + hk_url
logger.info('Test GET classes, urns, tags, webapi url')
got_classes_url = urn2fdiurl(
urn=sampleurn, poolurl=samplepoolurl, contents='classes', method='GET')
classes_url = aburl + '/' + 'defaultpool/hk/classes'
classes_url = aburl + '/' + samplepoolname + '/hk/classes'
assert got_classes_url == classes_url, 'Classes url error: ' + got_classes_url
got_urns_url = urn2fdiurl(
urn=sampleurn, poolurl=samplepoolurl, contents='urns', method='GET')
urns_url = aburl + '/' + 'defaultpool/hk/urns'
urns_url = aburl + '/' + samplepoolname + '/hk/urns'
assert got_urns_url == urns_url, 'Urns url error: ' + got_urns_url
got_tags_url = urn2fdiurl(
urn=sampleurn, poolurl=samplepoolurl, contents='tags', method='GET')
tags_url = aburl + '/' + 'defaultpool/hk/tags'
tags_url = aburl + '/' + samplepoolname + '/hk/tags'
assert got_tags_url == tags_url, 'Housekeeping url error: ' + got_tags_url
logger.info('Get product url')
got_product_url = urn2fdiurl(
urn=sampleurn, poolurl=samplepoolurl, contents='product', method='GET')
product_url = aburl + '/'+'defaultpool/fdi.dataset.product.Product/10'
product_url = aburl + '/'+samplepoolname + '/fdi.dataset.product.Product/10'
assert got_product_url == product_url, 'Get product url error: ' + got_product_url
logger.info('GET WebAPI url')
call = 'tagExists/foo'
got_webapi_url = urn2fdiurl(
urn=sampleurn, poolurl=samplepoolurl, contents=call, method='GET')
webapi_url = aburl + '/' + 'defaultpool/' + 'api/' + call
webapi_url = aburl + '/' + samplepoolname + '/' + 'api/' + call
assert got_webapi_url == webapi_url, 'Get WebAPI url error: ' + got_webapi_url
logger.info('Post product url')
got_post_product_url = urn2fdiurl(
urn=sampleurn, poolurl=samplepoolurl, contents='product', method='POST')
post_product_url = aburl + '/'+'defaultpool/fdi.dataset.product.Product/10'
post_product_url = aburl + '/'+samplepoolname + '/fdi.dataset.product.Product/10'
assert got_post_product_url == post_product_url, 'Post product url error: ' + \
got_post_product_url
logger.info('Delete product url')
got_del_product_url = urn2fdiurl(
urn=sampleurn, poolurl=samplepoolurl, contents='product', method='DELETE')
del_product_url = aburl + '/' + 'defaultpool/fdi.dataset.product.Product/10'
del_product_url = aburl + '/' + samplepoolname + '/fdi.dataset.product.Product/10'
assert got_del_product_url == del_product_url, 'Delete product url error: ' + \
got_del_product_url
logger.info('Delete pool url')
got_del_pool_url = urn2fdiurl(
urn=sampleurn, poolurl=samplepoolurl, contents='pool', method='DELETE')
del_pool_url = aburl + '/' + 'defaultpool'
del_pool_url = aburl + '/' + samplepoolname
assert got_del_pool_url == del_pool_url, 'Delete product url error: ' + got_del_pool_url
logger.info('Test corrupt request url')
......
......@@ -69,7 +69,7 @@ if 0:
lupd = 0
test_poolid = 'test'
test_poolid = 'fdi_'+__name__
prodt = 'fdi.dataset.product.Product'
......
......@@ -387,7 +387,11 @@ def test_EventType():
assert EventTypeOf['CHANGED']['UNKNOWN_ATTRIBUTE'] == 'UNKNOWN_ATTRIBUTE_CHANGED'
def test_EventSender():
test123 = 0
@pytest.fixture()
def mocksndrlsnr():
global test123
class MockFileWatcher(EventSender):
......@@ -427,6 +431,13 @@ def test_EventSender():
l2 = MockListener()
l2.targetChanged = log_file_change2
return MockFileWatcher, MockFileWatcher2, l1, l2
def test_EventSender(mocksndrlsnr):
global test123
MockFileWatcher, MockFileWatcher2, l1, l2 = mocksndrlsnr
watcher = MockFileWatcher()
watcher.addListener(l2)
watcher.addListener(l1)
......@@ -443,6 +454,12 @@ def test_EventSender():
assert test123 == "'foo' changed."
# __import__('pdb').set_trace()
def test_MqttRelay_mqtt(mocksndrlsnr):
global test123
MockFileWatcher, MockFileWatcher2, l1, l2 = mocksndrlsnr
# MQ Relay
v = MqttRelayListener(topics="test.mq.bounce2", host=None,
port=None, username=None, passwd=None,
......
......@@ -92,15 +92,15 @@ def test_UrnUtils():
prd = Product(description='pal test')
a1 = 'file' # scheme
a2 = '/e:' # place
b1, b2 = '/tmp/foo', 'pool/name'
a3 = b1 + '/' + b2 # /tmp/foo/pool/name
b1, b2 = '/tmp/foo', 'name'
a3 = b1 + '/' + b2 # /tmp/foo/name
a4 = fullname(prd) # fdi.dataset.Product
a5 = 43
s = a1 + '://' + a2 # file:///e:
poolurl = s + a3 # file:///e:/tmp/foo/pool/name
poolurl = s + a3 # file:///e:/tmp/foo/name
r = a4 + ':' + str(a5) # fdi.dataset.Product:43
rp = a4 + '_' + str(a5) # fdi.dataset.Product_43
urn = 'urn:' + b2 + ':' + r # urn:pool/name:fdi.dataset.Product:43
urn = 'urn:' + b2 + ':' + r # urn:name:fdi.dataset.Product:43
urn1 = 'urn:' + b2 + ':' + a4+':'+str(a5-1)
# utils
assert parseUrn(urn) == (b2, a4, a5)
......@@ -152,15 +152,15 @@ def test_Urn():
prd = Product(description='pal test')
a1 = 'file' # scheme
a2 = '/e:' # place
b1, b2 = '/tmp/foo', 'pool/name'
a3 = b1 + '/' + b2 # /tmp/foo/pool/name
b1, b2 = '/tmp/foo', 'name'
a3 = b1 + '/' + b2 # /tmp/foo/name
a4 = fullname(prd) # fdi.dataset.Product
a5 = 43
s = a1 + '://' + a2 # file:///e:
poolurl = s + a3 # file:///e:/tmp/foo/pool/name
poolurl = s + a3 # file:///e:/tmp/foo/name
r = a4 + ':' + str(a5) # fdi.dataset.Product:43
rp = a4 + '_' + str(a5) # fdi.dataset.Product_43
urn = 'urn:' + b2 + ':' + r # urn:pool/name:fdi.dataset.Product:43
urn = 'urn:' + b2 + ':' + r # urn:name:fdi.dataset.Product:43
urn1 = 'urn:' + b2 + ':' + a4+':'+str(a5-1)
# constructor
# urn only
......@@ -278,7 +278,7 @@ def cleanup(poolurl=None, poolname=None):
def test_PoolManager():
defaultpoolName = 'pool_' + getpass.getuser()
defaultpoolName = 'fdi_pool_' + __name__ + getpass.getuser()
defaultpoolPath = '/tmp'
defaultpoolUrl = 'file://' + defaultpoolPath + '/' + defaultpoolName
cleanup(defaultpoolUrl, defaultpoolName)
......@@ -383,7 +383,7 @@ def checkdbcount(expected_cnt, poolurl, prodname, currentSN, usrpsw, *args):
def test_ProductRef():
defaultpoolName = 'pool_' + getpass.getuser()
defaultpoolName = 'fdi_pool_' + __name__ + getpass.getuser()
defaultpoolPath = '/tmp'
defaultpoolUrl = 'file://' + defaultpoolPath + '/' + defaultpoolName
cleanup(defaultpoolUrl, defaultpoolName)
......@@ -457,11 +457,11 @@ def test_ProductRef():
def test_ProductStorage_init():
defaultpoolname = 'pool_' + getpass.getuser()
defaultpoolname = 'fdi_pool_' + __name__ + getpass.getuser()
poolpath = '/tmp'
defaultpoolurl = 'file://' + poolpath + '/' + defaultpoolname
cleanup(defaultpoolurl, defaultpoolname)
newpoolname = 'newpool_' + getpass.getuser()
newpoolname = 'fdi_newpool_' + __name__ + getpass.getuser()
newpoolurl = 'file://' + poolpath + '/' + newpoolname
cleanup(newpoolurl, newpoolname)
......@@ -579,7 +579,7 @@ def check_ps_func_for_pool(thepoolname, thepoolurl, *args):
def test_ProdStorage_func_local_mem():
# local pool
thepoolname = 'pool_' + getpass.getuser()
thepoolname = 'fdi_pool_' + __name__ + getpass.getuser()
thepoolpath = '/tmp'
thepoolurl = 'file://' + thepoolpath + '/' + thepoolname
cleanup(thepoolurl, thepoolname)
......@@ -598,7 +598,7 @@ def test_ProdStorage_func_http(setup, userpass):
aburl, hdr = setup
# httpclientpool
thepoolname = 'testhttppool'
thepoolname = 'fdi_'+__name__
thepoolurl = aburl + '/' + thepoolname
cleanup(thepoolurl, thepoolname)
......@@ -619,7 +619,7 @@ def test_ProdStorage_func_http(setup, userpass):
def test_ProdStorage_func_server(local_pools_dir):
# httppool , the http server-side pool
thepoolname = 'testserverpool'
thepoolname = 'fdi_server'+__name__
thepoolurl = 'server://' + local_pools_dir + '/' + thepoolname
cleanup(thepoolurl, thepoolname)
......@@ -627,7 +627,7 @@ def test_ProdStorage_func_server(local_pools_dir):
def test_LocalPool():
thepoolname = 'pool_' + getpass.getuser()
thepoolname = 'fdi_localpool_' + __name__ + getpass.getuser()
thepoolpath = '/tmp'
thepoolurl = 'file://' + thepoolpath + '/' + thepoolname
......@@ -700,12 +700,12 @@ def doquery(poolpath, newpoolpath):
assert q.retrieveAllVersions() == a4
# make a productStorage
thepoolname = 'pool_' + getpass.getuser()
thepoolname = 'fdi_pool_' + __name__ + getpass.getuser()
thepoolurl = poolpath + '/' + thepoolname
thepool, pstore = mkStorage(thepoolname, thepoolurl)
# make another
newpoolname = 'newpool_' + getpass.getuser()
newpoolname = 'fdi_newpool_' + __name__ + getpass.getuser()
newpoolurl = newpoolpath + '/' + newpoolname
newpool, pstore2 = mkStorage(newpoolname, newpoolurl)
......@@ -979,7 +979,7 @@ def test_MapContext():
assert c4['refs']['x'].product.description == 'hi'
# stored prod
thepoolname = 'pool_' + getpass.getuser()
thepoolname = 'fdi_pool_' + __name__ + getpass.getuser()
thepoolpath = '/tmp'
thepoolurl = 'file://' + thepoolpath + '/'+thepoolname
# create a prooduct
......@@ -1059,7 +1059,7 @@ def test_MapContext():
def test_realistic():
poolname = 'pool_' + getpass.getuser()
poolname = 'fdi_pool_' + __name__ + getpass.getuser()
poolpath = '/tmp'
poolurl = 'file://' + poolpath + '/' + poolname
# remove existing pools in memory
......@@ -1127,7 +1127,7 @@ def speed():
p['array'] = a
PoolManager().removeAll()
# create a product store
pool = 'file:///tmp/perf_' + getpass.getuser()
pool = 'file:///tmp/fdi_perf_' + __name__ + getpass.getuser()
pstore = ProductStorage(pool)
# clean up possible garbage of previous runs
pstore.wipePool()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment