1 |
|
2 |
import sets
|
3 |
import unittest
|
4 |
|
5 |
import common
|
6 |
import BlackWhiteListParser
|
7 |
|
8 |
cfg_params = {
|
9 |
'EDG.se_black_list': 'ccsrm.in2p3.fr, T1_*',
|
10 |
'EDG.se_white_list': 'T2_US, T2_UK, T2_KR_KNU',
|
11 |
'EDG.ce_black_list': 'lcg02.ciemat.es, bris.ac, *.fnal.gov',
|
12 |
'EDG.ce_white_list': 'T3',
|
13 |
}
|
14 |
|
15 |
class FakeLogger:
|
16 |
|
17 |
def debug(*args):
|
18 |
pass
|
19 |
|
20 |
def msg(*args):
|
21 |
pass
|
22 |
|
23 |
class TestBlackWhiteList(unittest.TestCase):
|
24 |
|
25 |
def setUp(self):
|
26 |
self.separser = BlackWhiteListParser.SEBlackWhiteListParser(cfg_params)
|
27 |
self.ceparser = BlackWhiteListParser.CEBlackWhiteListParser(cfg_params)
|
28 |
|
29 |
def test_se_black_list(self):
|
30 |
blacklist = ['ccsrm.in2p3.fr', 'cmssrm.fnal.gov']
|
31 |
other = ['t2-srm-02.lnl.infn.it', 'se-dcache.hepgrid.uerj.br']
|
32 |
results = self.separser.checkBlackList(other + blacklist)
|
33 |
results = sets.Set(results)
|
34 |
self.failUnless(results == sets.Set(other))
|
35 |
|
36 |
def test_se_white_list(self):
|
37 |
whitelist = ['srm.ihepa.ufl.edu', 'heplnx204.pp.rl.ac.uk',
|
38 |
'cluster142.knu.ac.kr']
|
39 |
other = ['f-dpm001.grid.sinica.edu.tw', 'cmsrm-se01.roma1.infn.it']
|
40 |
results = self.separser.checkWhiteList(other + whitelist)
|
41 |
results = sets.Set(results)
|
42 |
self.failUnless(results == sets.Set(whitelist))
|
43 |
|
44 |
def test_ce_black_list(self):
|
45 |
blacklist = ['lcg02.ciemat.es', 'lcgce01.phy.bris.ac.uk',
|
46 |
'lcgce02.phy.bris.ac.uk', 'cmsosgce4.fnal.gov']
|
47 |
other = ['osgce.hepgrid.uerj.br', 'egeece01.ifca.es',
|
48 |
'grid006.lca.uc.pt']
|
49 |
results = self.ceparser.checkBlackList(other + blacklist)
|
50 |
results = sets.Set(results)
|
51 |
self.failUnless(results == sets.Set(other))
|
52 |
|
53 |
def test_ce_white_list(self):
|
54 |
whitelist = ['vampire.accre.vanderbilt.edu',
|
55 |
'ic-kit-lcgce.rz.uni-karlsruhe.de']
|
56 |
other = ['gridce2.pi.infn.it', 'lcg02.ciemat.es']
|
57 |
results = self.ceparser.checkWhiteList(other + whitelist)
|
58 |
results = sets.Set(results)
|
59 |
self.failUnless(results == sets.Set(whitelist))
|
60 |
|
61 |
|
62 |
|
63 |
if __name__ == '__main__':
|
64 |
common.logger = FakeLogger()
|
65 |
unittest.main()
|
66 |
|