8
8
except ImportError :
9
9
from urllib .request import urlopen
10
10
11
- import osgtest .library .condor as condor
12
11
import osgtest .library .core as core
13
12
import osgtest .library .files as files
14
13
import osgtest .library .service as service
18
17
class TestCondorCE (osgunittest .OSGTestCase ):
19
18
20
19
def setUp (self ):
21
- # Enforce GSI auth for testing
22
- os .environ ['_condor_SEC_CLIENT_AUTHENTICATION_METHODS' ] = 'GSI'
20
+ # Enforce SciToken or GSI auth for testing
21
+ os .environ ['_condor_SEC_CLIENT_AUTHENTICATION_METHODS' ] = 'SCITOKENS, GSI'
22
+ core .skip_ok_unless_installed ('condor' , 'htcondor-ce' )
23
+ self .skip_bad_unless (service .is_running ('condor-ce' ), 'ce not running' )
24
+
25
+ self .command = []
26
+ if core .state ['token.condor_write_created' ]:
27
+ self .command = [f"_condor_SCITOKENS_FILE={ core .config ['token.condor_write' ]} " ]
23
28
24
29
def tearDown (self ):
25
30
os .environ .pop ('_condor_SEC_CLIENT_AUTHENTICATION_METHODS' )
26
31
32
+ def check_write_creds (self ):
33
+ """Check for credentials necessary for HTCondor-CE WRITE
34
+ """
35
+ self .skip_bad_unless (core .state ['proxy.valid' ] or core .state ['token.condor_write_created' ],
36
+ 'requires a scitoken or a proxy' )
37
+
38
+ def check_schedd_ready (self ):
39
+ """Check if the HTCondor-CE schedd is up as expected
40
+ """
41
+ self .skip_bad_unless (core .state ['condor-ce.schedd-ready' ], 'CE schedd not ready to accept jobs' )
42
+
27
43
def run_blahp_trace (self , lrms ):
28
44
"""Run condor_ce_trace() against a non-HTCondor backend and verify the cache"""
29
45
lrms_cache_prefix = {'pbs' : 'qstat' , 'slurm' : 'slurm' }
30
46
31
47
cwd = os .getcwd ()
32
48
os .chdir ('/tmp' )
33
- command = ('condor_ce_trace' , '-a osgTestBatchSystem = %s' % lrms .lower (), '--debug' , core .get_hostname ())
34
- trace_out , _ , _ = core .check_system (command , 'ce trace against %s' % lrms .lower (), user = True )
49
+ self .command += ['condor_ce_trace' ,
50
+ '-a osgTestBatchSystem = %s' % lrms .lower (),
51
+ '--debug' ,
52
+ core .get_hostname ()]
53
+ trace_out , _ , _ = core .check_system (self .command , 'ce trace against %s' % lrms .lower (), user = True )
35
54
36
55
try :
37
56
backend_jobid = re .search (r'%s_JOBID=(\d+)' % lrms .upper (), trace_out ).group (1 )
@@ -64,69 +83,55 @@ def run_blahp_trace(self, lrms):
64
83
# S'2'
65
84
# p6
66
85
# s."
67
- self .assert_ (re .search (r'BatchJobId[=\s"\'p1S]+%s' % backend_jobid , cache ),
68
- 'Job %s not found in %s blahp cache:\n %s' % (backend_jobid , lrms .upper (), cache ))
86
+ self .assertTrue (re .search (r'BatchJobId[=\s"\'p1S]+%s' % backend_jobid , cache ),
87
+ 'Job %s not found in %s blahp cache:\n %s' % (backend_jobid , lrms .upper (), cache ))
69
88
70
89
os .chdir (cwd )
71
90
72
- def general_requirements (self ):
73
- core .skip_ok_unless_installed ('condor' , 'htcondor-ce' , 'htcondor-ce-client' )
74
- self .skip_bad_unless (service .is_running ('condor-ce' ), 'ce not running' )
75
-
76
91
def test_01_status (self ):
77
- self .general_requirements ()
78
-
79
92
command = ('condor_ce_status' , '-any' )
80
93
core .check_system (command , 'ce status' , user = True )
81
94
82
95
def test_02_queue (self ):
83
- self .general_requirements ()
84
-
85
96
command = ('condor_ce_q' , '-verbose' )
86
97
core .check_system (command , 'ce queue' , user = True )
87
98
88
99
def test_03_ping (self ):
89
- self .general_requirements ()
90
- self .skip_bad_unless (core .state ['proxy.valid' ], 'requires a proxy cert' )
91
-
92
- command = ('condor_ce_ping' , 'WRITE' , '-verbose' )
93
- stdout , _ , _ = core .check_system (command , 'ping using GSI and gridmap' , user = True )
94
- self .assert_ (re .search (r'Authorized:\s*TRUE' , stdout ), 'could not authorize with GSI' )
100
+ self .check_write_creds ()
101
+ self .command += ['condor_ce_ping' , 'WRITE' , '-verbose' ]
102
+ stdout , _ , _ = core .check_system (self .command , 'ping using SCITOKENS or GSI' , user = True )
103
+ self .assertTrue (re .search (r'Authorized:\s*TRUE' , stdout ), 'could not authorize with SCITOKENS or GSI' )
95
104
96
105
def test_04_trace (self ):
97
- self .general_requirements ()
98
- self .skip_bad_unless (core .state ['condor-ce.schedd-ready' ], 'CE schedd not ready to accept jobs' )
99
- self .skip_bad_unless (core .state ['proxy.valid' ], 'requires a proxy cert' )
106
+ self .check_schedd_ready ()
107
+ self .check_write_creds ()
100
108
101
109
cwd = os .getcwd ()
102
110
os .chdir ('/tmp' )
103
111
104
- command = ( 'condor_ce_trace' , '--debug' , core .get_hostname ())
105
- core .check_system (command , 'ce trace' , user = True )
112
+ self . command += [ 'condor_ce_trace' , '--debug' , core .get_hostname ()]
113
+ core .check_system (self . command , 'ce trace' , user = True )
106
114
107
115
os .chdir (cwd )
108
116
109
117
def test_05_pbs_trace (self ):
110
- self .general_requirements ()
111
- self .skip_bad_unless (core .state ['condor-ce.schedd-ready' ], 'CE schedd not ready to accept jobs' )
112
118
core .skip_ok_unless_installed ('torque-mom' , 'torque-server' , 'torque-scheduler' , 'torque-client' , 'munge' ,
113
119
by_dependency = True )
114
120
self .skip_ok_unless (service .is_running ('pbs_server' ), 'pbs service not running' )
115
- self .skip_bad_unless (core .state ['proxy.valid' ], 'requires a proxy cert' )
121
+ self .check_schedd_ready ()
122
+ self .check_write_creds ()
116
123
self .run_blahp_trace ('pbs' )
117
124
118
125
def test_06_slurm_trace (self ):
119
- self .general_requirements ()
120
126
core .skip_ok_unless_installed (core .SLURM_PACKAGES )
121
- self .skip_bad_unless (service .is_running ('munge' ), 'slurm requires munge' )
122
127
self .skip_bad_unless (core .state ['condor-ce.schedd-ready' ], 'CE schedd not ready to accept jobs' )
123
128
self .skip_ok_unless (service .is_running (core .config ['slurm.service-name' ]), 'slurm service not running' )
124
- self .skip_bad_unless (core .state ['proxy.valid' ], 'requires a proxy cert' )
129
+ self .check_schedd_ready ()
130
+ self .check_write_creds ()
125
131
self .run_blahp_trace ('slurm' )
126
132
127
133
def test_07_ceview (self ):
128
134
core .config ['condor-ce.view-listening' ] = False
129
- self .general_requirements ()
130
135
core .skip_ok_unless_installed ('htcondor-ce-view' )
131
136
view_url = 'http://%s:%s' % (core .get_hostname (), int (core .config ['condor-ce.view-port' ]))
132
137
try :
@@ -141,6 +146,9 @@ def test_07_ceview(self):
141
146
debug_contents += 'Failed to read %s\n ' % debug_file
142
147
core .log_message (debug_contents )
143
148
self .fail ('Could not reach HTCondor-CE View at %s: %s' % (view_url , err ))
144
- self .assert_ (re .search (r'HTCondor-CE Overview' , src ), 'Failed to find expected CE View contents' )
149
+ self .assertTrue (re .search (r'HTCondor-CE Overview' , src ), 'Failed to find expected CE View contents' )
145
150
core .config ['condor-ce.view-listening' ] = True
146
151
152
+ def test_08_config_val (self ):
153
+ command = ('condor_ce_config_val' , '-dump' )
154
+ core .check_system (command , 'condor_ce_config_val as non-root' , user = True )
0 commit comments