Skip to content

Commit 64acb10

Browse files
committed
Add support for SciToken job submission (SOFTWARE-4221)
1 parent 1c71d47 commit 64acb10

File tree

5 files changed

+48
-26
lines changed

5 files changed

+48
-26
lines changed

osgtest/tests/test_190_condorce.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,28 @@ def test_02_reconfigure_condor(self):
3636
self.assertTrue(service.is_running('condor', timeout=10), 'Condor not running after reconfig')
3737

3838
def test_02_scitoken_mapping(self):
39+
core.state['condor-ce.wrote-mapfile'] = False
3940
core.skip_ok_unless_installed('condor', 'htcondor-ce')
40-
self.skip_ok_if(core.PackageVersion('condor') >= '8.9.4',
41+
self.skip_ok_if(core.PackageVersion('condor') <= '8.9.4',
4142
'HTCondor version does not support SciToken submission')
4243

43-
condorce_version = core.PackageVersion('condor')
44-
scitoken_mapping = f'SCITOKENS "https://demo.scitokens.org/" f{core.options.username}\n'
44+
condorce_version = core.PackageVersion('htcondor-ce')
45+
scitoken_mapping = f'SCITOKENS "https://demo.scitokens.org/" {core.options.username}\n'
4546

4647
# Write the mapfile to the admin mapfile directory
4748
# https://github.com/htcondor/htcondor-ce/pull/425
4849
if condorce_version >= '5.1.0':
4950
core.config['condor-ce.condorce_mapfile'] = '/etc/condor-ce/mapfiles.d/01-osg-test.conf'
5051
else:
5152
core.config['condor-ce.condorce_mapfile'] = '/etc/condor-ce/condor_mapfile'
52-
mapfile_contents = files.read(core.config['condor-ce.condorce_mapfile'])
53+
mapfile_contents = files.read(core.config['condor-ce.condorce_mapfile'], as_single_string=True)
5354
scitoken_mapping += mapfile_contents
5455

5556
files.write(core.config['condor-ce.condorce_mapfile'],
5657
scitoken_mapping,
5758
owner='condor-ce',
5859
chmod=0o644)
60+
core.state['condor-ce.wrote-mapfile'] = True
5961

6062
def test_03_configure_ce(self):
6163
core.skip_ok_unless_installed('condor', 'htcondor-ce', 'htcondor-ce-client')

osgtest/tests/test_401_scitokens.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def request_demo_scitoken(scope, audience='ANY'):
2424
'scope': scope,
2525
'exp': int(time.time() + 3600),
2626
'sub': 'osg-test'}
27-
payload = json.dumps({'payload': json.dumps({'payload': payload_dict}),
27+
payload = json.dumps({'payload': json.dumps(payload_dict),
2828
'algorithm': 'ES256'}).encode()
2929

3030
req = request.Request('https://demo.scitokens.org/issue',
@@ -41,7 +41,7 @@ def test_01_request_condor_write_scitoken(self):
4141
core.config['token.condor_write'] = '/tmp/condor_write.scitoken'
4242

4343
core.skip_ok_unless_installed('htcondor-ce', 'condor')
44-
self.skip_ok_if(core.PackageVersion('condor') >= '8.9.4',
44+
self.skip_ok_if(core.PackageVersion('condor') <= '8.9.4',
4545
'HTCondor version does not support SciToken submission')
4646
self.skip_ok_if(os.path.exists(core.config['token.condor_write']),
4747
'SciToken with HTCondor WRITE already exists')

osgtest/tests/test_410_jobs.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ def test_02_condor_ce_run_condor(self):
5858
self.skip_bad_unless(service.is_running('condor-ce'), 'ce not running')
5959
self.skip_bad_unless(service.is_running('condor'), 'condor not running')
6060
self.skip_bad_unless(core.state['jobs.env-set'], 'job environment not set')
61-
self.skip_bad_unless(core.state['proxy.valid'], 'requires a proxy cert')
61+
self.skip_bad_unless(core.state['proxy.valid'] or core.state['token.condor_write_created'],
62+
'requires a scitoken or a proxy')
6263

63-
command = ('condor_ce_run', '-r', '%s:9619' % core.get_hostname(), '/bin/env')
64+
command = ['condor_ce_run', '-r', '%s:9619' % core.get_hostname(), '/bin/env']
65+
if core.state['token.condor_write_created']:
66+
command.insert(0, f"_condor_SCITOKENS_FILE={core.config['token.condor_write']}")
6467
self.run_job_in_tmp_dir(command, 'condor_ce_run a Condor job')

osgtest/tests/test_550_condorce.py

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,40 @@
1717
class TestCondorCE(osgunittest.OSGTestCase):
1818

1919
def setUp(self):
20-
# Enforce GSI auth for testing
21-
os.environ['_condor_SEC_CLIENT_AUTHENTICATION_METHODS'] = 'GSI'
22-
core.skip_ok_unless_installed('condor', 'htcondor-ce', 'htcondor-ce-client')
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')
2323
self.skip_bad_unless(service.is_running('condor-ce'), 'ce not running')
2424

25+
self.command = []
26+
if core.state['token.condor_write_created']:
27+
self.command = [f"_condor_SCITOKENS_FILE={core.config['token.condor_write']}"]
28+
2529
def tearDown(self):
2630
os.environ.pop('_condor_SEC_CLIENT_AUTHENTICATION_METHODS')
2731

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+
2843
def run_blahp_trace(self, lrms):
2944
"""Run condor_ce_trace() against a non-HTCondor backend and verify the cache"""
3045
lrms_cache_prefix = {'pbs': 'qstat', 'slurm': 'slurm'}
3146

3247
cwd = os.getcwd()
3348
os.chdir('/tmp')
34-
command = ('condor_ce_trace', '-a osgTestBatchSystem = %s' % lrms.lower(), '--debug', core.get_hostname())
35-
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)
3654

3755
try:
3856
backend_jobid = re.search(r'%s_JOBID=(\d+)' % lrms.upper(), trace_out).group(1)
@@ -79,38 +97,37 @@ def test_02_queue(self):
7997
core.check_system(command, 'ce queue', user=True)
8098

8199
def test_03_ping(self):
82-
self.skip_bad_unless(core.state['proxy.valid'], 'requires a proxy cert')
83-
84-
command = ('condor_ce_ping', 'WRITE', '-verbose')
85-
stdout, _, _ = core.check_system(command, 'ping using GSI and gridmap', user=True)
100+
self.check_write_creds()
101+
self.command += ['condor_ce_ping', 'WRITE', '-verbose']
102+
stdout, _, _ = core.check_system(self.command, 'ping using GSI and gridmap', user=True)
86103
self.assertTrue(re.search(r'Authorized:\s*TRUE', stdout), 'could not authorize with GSI')
87104

88105
def test_04_trace(self):
89-
self.skip_bad_unless(core.state['condor-ce.schedd-ready'], 'CE schedd not ready to accept jobs')
90-
self.skip_bad_unless(core.state['proxy.valid'], 'requires a proxy cert')
106+
self.check_schedd_ready()
107+
self.check_write_creds()
91108

92109
cwd = os.getcwd()
93110
os.chdir('/tmp')
94111

95-
command = ('condor_ce_trace', '--debug', core.get_hostname())
96-
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)
97114

98115
os.chdir(cwd)
99116

100117
def test_05_pbs_trace(self):
101-
self.skip_bad_unless(core.state['condor-ce.schedd-ready'], 'CE schedd not ready to accept jobs')
102118
core.skip_ok_unless_installed('torque-mom', 'torque-server', 'torque-scheduler', 'torque-client', 'munge',
103119
by_dependency=True)
104120
self.skip_ok_unless(service.is_running('pbs_server'), 'pbs service not running')
105-
self.skip_bad_unless(core.state['proxy.valid'], 'requires a proxy cert')
121+
self.check_schedd_ready()
122+
self.check_write_creds()
106123
self.run_blahp_trace('pbs')
107124

108125
def test_06_slurm_trace(self):
109126
core.skip_ok_unless_installed(core.SLURM_PACKAGES)
110-
self.skip_bad_unless(service.is_running('munge'), 'slurm requires munge')
111127
self.skip_bad_unless(core.state['condor-ce.schedd-ready'], 'CE schedd not ready to accept jobs')
112128
self.skip_ok_unless(service.is_running(core.config['slurm.service-name']), 'slurm service not running')
113-
self.skip_bad_unless(core.state['proxy.valid'], 'requires a proxy cert')
129+
self.check_schedd_ready()
130+
self.check_write_creds()
114131
self.run_blahp_trace('slurm')
115132

116133
def test_07_ceview(self):

osgtest/tests/test_790_condorce.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ def test_02_restore_config(self):
1414

1515
files.restore(core.config['condor-ce.condor-cfg'], 'condor-ce')
1616
files.restore(core.config['condor-ce.condor-ce-cfg'], 'condor-ce')
17-
if core.options.hostcert:
17+
if core.state['condor-ce.wrote-mapfile']:
1818
files.restore(core.config['condor-ce.condorce_mapfile'], 'condor-ce')

0 commit comments

Comments
 (0)