def test_01_create_macaroons(self): core.config['xrootd.tpc.macaroon-1'] = None core.config['xrootd.tpc.macaroon-2'] = None core.skip_ok_unless_installed('x509-scitokens-issuer-client', by_dependency=True) self.skip_bad_unless(core.state['proxy.valid'], 'requires a proxy cert') uid = pwd.getpwnam(core.options.username)[2] usercert = '/tmp/x509up_u%d' % uid userkey = '/tmp/x509up_u%d' % uid core.config['xrootd.tpc.url-1'] = "https://" + core.get_hostname() + ":9001" + "/usr/share/osg-test/test_gridftp_data.txt".strip() command = ('macaroon-init', core.config['xrootd.tpc.url-1'], '20', 'ALL') status, stdout, stderr = core.system(command, user=True) fail = core.diagnose('Obtain Macaroon 1', command, status, stdout, stderr) self.assertEqual(status, 0, fail) core.config['xrootd.tpc.macaroon-1'] = stdout.strip() core.config['xrootd.tpc.url-2'] = "https://" + core.get_hostname() + ":9002" + "/tmp/test_gridftp_data_tpc.txt".strip() command = ('macaroon-init', core.config['xrootd.tpc.url-2'], '20', 'ALL') status, stdout, stderr = core.system(command, user=True) fail = core.diagnose('Obtain Macaroon 2', command, status, stdout, stderr) self.assertEqual(status, 0, fail) core.config['xrootd.tpc.macaroon-2'] = stdout.strip()
def test_03_xrdcp_server_to_local(self): core.skip_ok_unless_installed('xrootd', 'xrootd-client', by_dependency=True) if core.config['xrootd.gsi'] == "ON": core.skip_ok_unless_installed('globus-proxy-utils') self.skip_bad_unless(core.state['xrootd.started-server'] is True, 'Server not running') hostname = socket.getfqdn() temp_source_dir = tempfile.mkdtemp() temp_target_dir = tempfile.mkdtemp() os.chmod(temp_source_dir, 0o777) os.chmod(temp_target_dir, 0o777) f = open(temp_source_dir + "/copied_file.txt", "w") f.write("This is some test data for an xrootd test.") f.close() xrootd_url = 'root://%s:%d/%s/copied_file.txt' % (hostname, core.config['xrootd.port'], temp_source_dir) local_path = temp_target_dir + '/copied_file.txt' command = ('xrdcp', '--debug', '3', xrootd_url, local_path) status, stdout, stderr = core.system(command, user=True) fail = core.diagnose('Xrootd xrdcp copy, URL to local', command, status, stdout, stderr) file_copied = os.path.exists(local_path) shutil.rmtree(temp_source_dir) shutil.rmtree(temp_target_dir) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_04_copy_server_to_local_uberftp_parallel(self): if core.missing_rpm('globus-gridftp-server-progs', 'globus-ftp-client', 'globus-proxy-utils', 'globus-gass-copy-progs', 'uberftp'): return hostname = socket.getfqdn() temp_dir_source = tempfile.mkdtemp() temp_dir_dest = tempfile.mkdtemp() os.chmod(temp_dir_source, 0777) os.chmod(temp_dir_dest, 0777) filename = 'testfile_10MB' full_path = (os.path.join(temp_dir_source, filename)) command = ('dd', 'if=/dev/zero', 'of=' + full_path, 'bs=10485760', 'count=1') core.check_system(command, 'Create test file with dd', user=True) ftp_cmd = ('cd %s; lcd %s; get %s' % (temp_dir_source, temp_dir_dest, filename)) command = ('uberftp', '-parallel', '10', hostname, ftp_cmd) status, stdout, stderr = core.system(command, True) fail = core.diagnose('UberFTP copy, local to URL', status, stdout, stderr) file_copied = os.path.exists(os.path.join(temp_dir_dest, filename)) shutil.rmtree(temp_dir_source) shutil.rmtree(temp_dir_dest) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_04_copy_server_to_local_uberftp_parallel(self): core.skip_ok_unless_installed(*self.required_rpms) self.skip_bad_unless(core.state['gridftp.running-server'] is True, 'GridFTP not running') hostname = socket.getfqdn() temp_dir_source = tempfile.mkdtemp() temp_dir_dest = tempfile.mkdtemp() os.chmod(temp_dir_source, 0o777) os.chmod(temp_dir_dest, 0o777) filename = 'testfile_10MB' full_path = (os.path.join(temp_dir_source, filename)) command = ('dd', 'if=/dev/zero', 'of=' + full_path, 'bs=10485760', 'count=1') core.check_system(command, 'Create test file with dd', user=True) ftp_cmd = ('cd %s; lcd %s; get %s' % (temp_dir_source, temp_dir_dest, filename)) command = ('uberftp', '-parallel', '10', hostname, ftp_cmd) status, stdout, stderr = core.system(command, True) fail = core.diagnose('UberFTP copy, local to URL', command, status, stdout, stderr) file_copied = os.path.exists(os.path.join(temp_dir_dest, filename)) shutil.rmtree(temp_dir_source) shutil.rmtree(temp_dir_dest) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_14_execute_dcache_storage(self): # Malformed XML errors due to network issues (SOFTWARE-1748) core.state['gratia.dcache-whitelisted-error'] = False whitelisted_errors = ['The element type "metric" must be terminated by the matching end-tag "</metric>".', 'XML document structures must start and end within the same entity.'] core.skip_ok_unless_installed('gratia-probe-dcache-storage', 'gratia-service') core.state['gratia.dcache-storage-running'] = False self.skip_bad_if(core.state['gratia.dcache-logs-copied'] == False) if os.path.exists(core.config['gratia.log.file']): core.state['gratia.log.stat'] = os.stat(core.config['gratia.log.file']) core.log_message('stat.st_ino is: ' + str(core.state['gratia.log.stat'].st_ino)) core.log_message('stat.st_size is: ' + str(core.state['gratia.log.stat'].st_size)) command = ('/usr/share/gratia/dCache-storage/dCache-storage_meter.cron.sh',) status, stdout, stderr = core.system(command) if status != 0: for error in whitelisted_errors: if error in stdout: core.state['gratia.dcache-whitelisted-error'] = True break if not core.state['gratia.dcache-whitelisted-error']: self.fail(core.diagnose('Unable to execute dCache-storage.', command, status, stdout, stderr)) core.config['gratia.dcache-temp-dir'] = core.config['gratia.tmpdir.prefix'] + "subdir.dCache-storage" + \ core.config['gratia.tmpdir.postfix'] if core.state['gratia.database-installed'] == True: result = self.isProbeOutboxDirEmpty(core.config['gratia.dcache-temp-dir']) self.assert_(result, 'dCache-storage outbox check failed.') core.state['gratia.dcache-storage-running'] = True
def test_01_cvmfs_probe(self): default_local = '/etc/cvmfs/default.local' probe_repos = ",".join( ['atlas.cern.ch', 'cms.cern.ch', 'oasis.opensciencegrid.org']) # Test depends on oasis-config to access the oasis.opensciencegrid.org # repo. This is an external service, so the requirement should be # removed as part of SOFTWARE-1108. core.skip_ok_unless_installed('cvmfs') core.skip_ok_unless_installed('cvmfs-keys', 'oasis-config', by_dependency=True) command = ('cat', default_local) status, stdout, stderr = core.system(command, False) # Dave Dykstra suggested running cvmfs probe against a different # set of repositories than are currently set up, so we modify them # just for this test. (See SOFTWARE-1097) # In the future, this test might be removed since we do not want # to depend on external services, and it's redundant to probe the # repos that we have already mounted. files.replace(default_local, 'CVMFS_REPOSITORIES=cms.cern.ch', 'CVMFS_REPOSITORIES=' + probe_repos, owner='cvmfsprobe') try: command = ('cvmfs_config', 'probe') status, stdout, stderr = core.system(command, False) self.assertEqual( status, 0, core.diagnose('cvmfs probe', command, status, stdout, stderr)) finally: files.restore(default_local, 'cvmfsprobe')
def test_02_cvmfs(self): core.skip_ok_unless_installed('cvmfs') core.skip_ok_unless_installed('cvmfs-keys', by_dependency=True) core.state['cvmfs.mounted'] = False command = ('ls', '/cvmfs') status, stdout, stderr = core.system(command, False) file_exists = os.path.exists('/cvmfs') self.assert_(file_exists, 'Cvmfs mount point missing') core.state['cvmfs.mounted'] = True cern_repo = 'cms.cern.ch' command = ('ls', '/cvmfs/' + cern_repo) status, stdout, stderr = core.system(command, False) # If the previous command failed, output better debug info if status != 0: self.debug_cvmfs(cern_repo) command = ('ls', self.__check_path) status, stdout, stderr = core.system(command, False) self.assert_(file_exists, 'Test cvmfs file missing') command = ('bash', '-c', 'source ' + self.__check_path) status, stdout, stderr = core.system(command, False) fail = core.diagnose('cvmfs example source a file on fs', command, status, stdout, stderr) self.assertEqual(status, 0, fail)
def test_01_cvmfs_probe(self): default_local = '/etc/cvmfs/default.local' probe_repos = ",".join([ 'atlas.cern.ch', 'cms.cern.ch', 'oasis.opensciencegrid.org']) # Test depends on oasis-config to access the oasis.opensciencegrid.org # repo. This is an external service, so the requirement should be # removed as part of SOFTWARE-1108. core.skip_ok_unless_installed('cvmfs') core.skip_ok_unless_installed('cvmfs-keys', 'oasis-config', by_dependency=True) command = ('cat', default_local) status, stdout, stderr = core.system(command, False) # Dave Dykstra suggested running cvmfs probe against a different # set of repositories than are currently set up, so we modify them # just for this test. (See SOFTWARE-1097) # In the future, this test might be removed since we do not want # to depend on external services, and it's redundant to probe the # repos that we have already mounted. files.replace( default_local, 'CVMFS_REPOSITORIES=cms.cern.ch', 'CVMFS_REPOSITORIES=' + probe_repos, owner='cvmfsprobe') try: command = ('cvmfs_config', 'probe') status, stdout, stderr = core.system(command, False) self.assertEqual(status, 0, core.diagnose('cvmfs probe', command, status, stdout, stderr)) finally: files.restore(default_local, 'cvmfsprobe')
def test_01_xrdcp_local_to_server(self): core.skip_ok_unless_installed('xrootd', 'xrootd-client', by_dependency=True) if core.config['xrootd.gsi'] == "ON": core.skip_ok_unless_installed('globus-proxy-utils') self.skip_bad_unless(core.state['xrootd.started-server'] is True, 'Server not running') temp_dir = "/tmp/vdttest" hostname = socket.getfqdn() if core.config['xrootd.gsi'] == "ON": if not os.path.exists(temp_dir): os.mkdir(temp_dir) user = pwd.getpwnam(core.options.username) os.chown(temp_dir, user[2], user[3]) else: temp_dir = tempfile.mkdtemp() os.chmod(temp_dir, 0o777) xrootd_url = 'root://%s:%d/%s/copied_file.txt' % (hostname, core.config['xrootd.port'], temp_dir) command = ('xrdcp', '--debug', '3', TestXrootd.__data_path, xrootd_url) status, stdout, stderr = core.system(command, user=True) fail = core.diagnose('xrdcp copy, local to URL', command, status, stdout, stderr) file_copied = os.path.exists(os.path.join(temp_dir, 'copied_file.txt')) if core.config['xrootd.multiuser'] != "ON": shutil.rmtree(temp_dir) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def run_trace(self, *args): """Run condor_ce_trace along with any additional *args. If trace completes with a held job, also return output from 'condor_ce_q -held'. """ cwd = os.getcwd() os.chdir('/tmp') self.command += ['condor_ce_trace', '--debug' ] + list(args) + [core.get_hostname()] if core.osg_release() == "3.6" and \ core.PackageVersion('condor') >= '9.0.0' and \ core.PackageVersion('condor') < '9.0.8': with core.no_x509(core.options.username): trace_rc, trace_out, trace_err = core.system(self.command, user=True) else: trace_rc, trace_out, trace_err = core.system(self.command, user=True) os.chdir(cwd) if trace_rc: msg = 'condor_ce_trace failed' if trace_out.find(', was held'): msg = 'condor_ce_trace job held' _, hold_out, hold_err = core.system(('condor_ce_q', '-held')) self.fail( core.diagnose(msg, self.command, trace_rc, str(trace_out) + str(hold_out), str(trace_err) + str(hold_err))) return trace_out, trace_err
def test_04_copy_server_to_local_uberftp_parallel(self): core.skip_ok_unless_installed(*self.required_rpms) self.skip_bad_unless(core.state['gridftp.running-server'] is True, 'GridFTP not running') hostname = socket.getfqdn() temp_dir_source = tempfile.mkdtemp() temp_dir_dest = tempfile.mkdtemp() os.chmod(temp_dir_source, 0o777) os.chmod(temp_dir_dest, 0o777) filename = 'testfile_10MB' full_path = (os.path.join(temp_dir_source, filename)) command = ('dd', 'if=/dev/zero', 'of=' + full_path, 'bs=10485760', 'count=1') core.check_system(command, 'Create test file with dd', user=True) ftp_cmd = ('cd %s; lcd %s; get %s' % (temp_dir_source, temp_dir_dest, filename)) command = ('uberftp', '-parallel','10', hostname, ftp_cmd) status, stdout, stderr = core.system(command, True) fail = core.diagnose('UberFTP copy, local to URL', command, status, stdout, stderr) file_copied = os.path.exists(os.path.join(temp_dir_dest, filename)) shutil.rmtree(temp_dir_source) shutil.rmtree(temp_dir_dest) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_03_xrdcp_server_to_local(self): core.skip_ok_unless_installed('xrootd', 'xrootd-client', by_dependency=True) core.skip_ok_unless_installed('globus-proxy-utils') self.skip_bad_unless(core.state['xrootd.started-server'] is True, 'Server not running') hostname = socket.getfqdn() temp_source_dir = tempfile.mkdtemp() temp_target_dir = tempfile.mkdtemp() os.chmod(temp_source_dir, 0o777) os.chmod(temp_target_dir, 0o777) f = open(temp_source_dir + "/copied_file.txt", "w") f.write("This is some test data for an xrootd test.") f.close() xrootd_url = 'root://%s/%s/copied_file.txt' % (hostname, temp_source_dir) local_path = temp_target_dir + '/copied_file.txt' command = ('xrdcp', '--debug', '3', xrootd_url, local_path) status, stdout, stderr = core.system(command, user=True) fail = core.diagnose('Xrootd xrdcp copy, URL to local', command, status, stdout, stderr) file_copied = os.path.exists(local_path) shutil.rmtree(temp_source_dir) shutil.rmtree(temp_target_dir) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_01_xrdcp_local_to_server(self): core.state['xrootd.copied-to-server'] = False core.skip_ok_unless_installed('xrootd', 'xrootd-client', by_dependency=True) core.skip_ok_unless_installed('globus-proxy-utils') self.skip_bad_unless(core.state['xrootd.started-server'] is True, 'Server not running') temp_dir = tempfile.mkdtemp() core.config['xrootd.tmp-dir'] = temp_dir user = pwd.getpwnam(core.options.username) os.chown(temp_dir, user[2], user[3]) hostname = socket.getfqdn() os.chmod(temp_dir, 0o777) xrootd_url = 'root://%s/%s/copied_file.txt' % (hostname, temp_dir) command = ('xrdcp', '--debug', '3', TestXrootd.__data_path, xrootd_url) status, stdout, stderr = core.system(command, user=True) fail = core.diagnose('xrdcp copy, local to URL', command, status, stdout, stderr) file_copied = os.path.exists(os.path.join(temp_dir, 'copied_file.txt')) if file_copied: core.state['xrootd.copied-to-server'] = True self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_02_xrdcp_server_to_local(self): if core.missing_rpm('xrootd-server', 'xrootd-client'): return hostname = socket.getfqdn() temp_source_dir = tempfile.mkdtemp() temp_target_dir = tempfile.mkdtemp() os.chmod(temp_source_dir, 0777) os.chmod(temp_target_dir, 0777) f=open(temp_source_dir+"/copied_file.txt","w") f.write("This is some test data for an xrootd test.") f.close() xrootd_url = 'root://%s/%s/copied_file.txt' % (hostname, temp_source_dir) local_path = temp_target_dir + '/copied_file.txt' command = ('xrdcp', xrootd_url, local_path) status, stdout, stderr = core.system(command, True) fail = core.diagnose('Xrootd xrdcp copy, URL to local', status, stdout, stderr) file_copied = os.path.exists(local_path) shutil.rmtree(temp_source_dir) shutil.rmtree(temp_target_dir) if core.el_release() != 6: self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing') else: self.assertEqual(status, 1, fail) self.assert_(not file_copied, 'Copied file exists')
def test_01_xrdcp_local_to_server(self): if core.missing_rpm('xrootd-server', 'xrootd-client'): return hostname = socket.getfqdn() if core.config['xrootd.gsi'] == "ON": temp_dir="/tmp/vdttest" if not os.path.exists(temp_dir): os.mkdir(temp_dir) else: temp_dir = tempfile.mkdtemp() os.chmod(temp_dir, 0777) xrootd_url = 'root://%s/%s/copied_file.txt' % (hostname, temp_dir) command = ('xrdcp', TestXrootd.__data_path , xrootd_url) status, stdout, stderr = core.system(command, True) fail = core.diagnose('xrdcp copy, local to URL', status, stdout, stderr) file_copied = os.path.exists(os.path.join(temp_dir, 'copied_file.txt')) shutil.rmtree(temp_dir) if core.el_release() != 6: self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing') else: self.assertEqual(status, 1, fail) self.assert_(not file_copied, 'Copied file existed somehow')
def test_03_copy_server_to_local(self): command = ('srm-copy', self.get_srm_url(), 'file://' + TestBestman.__local_path, '-debug') status, stdout, stderr = core.system(command, True) fail = core.diagnose('Bestman copy, URL to local', command, status, stdout, stderr) file_copied = os.path.exists(TestBestman.__local_path) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing') files.remove(TestBestman.__local_path)
def test_04_remove_server_file(self): command = ('srm-rm', self.get_srm_url(), '-debug') status, stdout, stderr = core.system(command, True) fail = core.diagnose('Bestman remove, URL file', command, status, stdout, stderr) file_removed = not os.path.exists(TestBestman.__remote_path) self.assertEqual(status, 0, fail) self.assert_(file_removed, 'Copied file still exists') files.remove(TestBestman.__temp_dir)
def test_03_remove_server_file_lcg_util(self): command = ('lcg-del', '-v', '-b', '-l', '-D', 'srmv2', self.get_srm_url()) status, stdout, stderr = core.system(command, True) fail = core.diagnose('lcg-util remove, URL file', command, status, stdout, stderr) file_removed = not os.path.exists(TestLCGUtil.__remote_path) self.assertEqual(status, 0, fail) self.assert_(file_removed, 'Copied file still exists') files.remove(TestLCGUtil.__temp_dir)
def test_02_copy_server_to_local_lcg_util(self): command = ('lcg-cp', '-v', '-b', '-D', 'srmv2', self.get_srm_url(), 'file://' + TestLCGUtil.__local_path) status, stdout, stderr = core.system(command, True) fail = core.diagnose('lcg-util copy, URL to local', command, status, stdout, stderr) file_copied = os.path.exists(TestLCGUtil.__local_path) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing') files.remove(TestLCGUtil.__local_path)
def test_02_copy_local_to_server(self): self.setup_temp_paths() os.chmod(TestBestman.__temp_dir, 0777) command = ('srm-copy', 'file://' + TestBestman.__data_path, self.get_srm_url(), '-debug') status, stdout, stderr = core.system(command, True) fail = core.diagnose('Bestman copy, local to URL', command, status, stdout, stderr) file_copied = os.path.exists(TestBestman.__remote_path) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_01_copy_local_to_server_lcg_util(self): self.setup_temp_paths() os.chmod(TestLCGUtil.__temp_dir, 0777) command = ('lcg-cp', '-v', '-b', '-D', 'srmv2', 'file://' + TestLCGUtil.__data_path, self.get_srm_url()) status, stdout, stderr = core.system(command, True) fail = core.diagnose('lcg-util copy, local to URL', command, status, stdout, stderr) file_copied = os.path.exists(TestLCGUtil.__remote_path) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_03_remove_server_file_gfal2_util(self): core.skip_ok_unless_installed('bestman2-server', 'gfal2-plugin-srm', 'gums-service') self.skip_bad_unless(core.state['bestman.server-running'], 'bestman server not running') command = ('gfal-rm', '-v', self.get_srm_url()) status, stdout, stderr = core.system(command, True) fail = core.diagnose('gfal2-util remove, URL file', command, status, stdout, stderr) file_removed = not os.path.exists(TestGFAL2Util.__remote_path) self.assertEqual(status, 0, fail) self.assert_(file_removed, 'Copied file still exists') files.remove(TestGFAL2Util.__temp_dir)
def test_02_copy_server_to_local_gfal2_util(self): core.skip_ok_unless_installed('bestman2-server', 'gfal2-plugin-srm', 'gums-service') self.skip_bad_unless(core.state['bestman.server-running'], 'bestman server not running') command = ('gfal-copy', '-v', self.get_srm_url(), 'file://' + TestGFAL2Util.__local_path) status, stdout, stderr = core.system(command, True) fail = core.diagnose('gfal2-util copy, URL to local', command, status, stdout, stderr) file_copied = os.path.exists(TestGFAL2Util.__local_path) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing') files.remove(TestGFAL2Util.__local_path)
def test_01_copy_local_to_server_gfal2_util(self): core.skip_ok_unless_installed('bestman2-server', 'gfal2-plugin-srm', 'gums-service') self.skip_bad_unless(core.state['bestman.server-running'], 'bestman server not running') self.setup_temp_paths() os.chmod(TestGFAL2Util.__temp_dir, 0o777) command = ('gfal-copy', '-v', 'file://' + TestGFAL2Util.__data_path, self.get_srm_url()) status, stdout, stderr = core.system(command, True) fail = core.diagnose('gfal2-util copy, local to URL', command, status, stdout, stderr) file_copied = os.path.exists(TestGFAL2Util.__remote_path) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_01_ping(self): if core.missing_rpm('bestman2-server', 'bestman2-client', 'voms-clients'): return if not core.state['bestman.started-server']: core.skip('bestman server not started') return srm_url = 'srm://%s:' % (TestBestman.__hostname) command = ('srm-ping', srm_url + TestBestman.__port + '/' + TestBestman.__sfn ) status, stdout, stderr = core.system(command, True) fail = core.diagnose('Bestman Ping', status, stdout, stderr) self.assertEqual(status, 0, fail)
def test_01_create_macaroons(self): core.skip_ok_unless_installed('xrootd', 'xrootd-scitokens', 'x509-scitokens-issuer-client', by_dependency=True) self.skip_bad_unless(core.state['proxy.created'], 'Proxy creation failed') uid = pwd.getpwnam(core.options.username)[2] usercert = '/tmp/x509up_u%d' % uid userkey = '/tmp/x509up_u%d' % uid core.config['xrootd.tpc.url-1'] = "https://" + core.get_hostname() + ":9001" + "/usr/share/osg-test/test_gridftp_data.txt".strip() command = ('macaroon-init', core.config['xrootd.tpc.url-1'], '20', 'DOWNLOAD') status, stdout, stderr = core.system(command, user=True) fail = core.diagnose('Obtain Macaroon one', command, status, stdout, stderr) core.config['xrootd.tpc.macaroon-1'] = stdout.strip() core.config['xrootd.tpc.url-2'] = "https://" + core.get_hostname() + ":9002" + "/tmp/test_gridftp_data_tpc.txt".strip() command = ('macaroon-init', core.config['xrootd.tpc.url-2'], '20', 'UPLOAD') status, stdout, stderr = core.system(command, user=True) fail = core.diagnose('Obtain Macaroon number two', command, status, stdout, stderr) core.config['xrootd.tpc.macaroon-2'] = stdout.strip()
def test_01_copy_local_to_server_gfal2_util(self): core.skip_ok_unless_installed('bestman2-server', 'gfal2-plugin-srm', 'gums-service') self.skip_bad_unless(core.state['bestman.server-running'], 'bestman server not running') self.setup_temp_paths() os.chmod(TestGFAL2Util.__temp_dir, 0777) command = ('gfal-copy', '-v', 'file://' + TestGFAL2Util.__data_path, self.get_srm_url()) status, stdout, stderr = core.system(command, True) fail = core.diagnose('gfal2-util copy, local to URL', command, status, stdout, stderr) file_copied = os.path.exists(TestGFAL2Util.__remote_path) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_01_fetch_crl(self): core.skip_ok_unless_installed('fetch-crl') core.skip_ok_unless_installed('grid-certificates', by_dependency=True) if core.options.manualrun: command = ('fetch-crl', '-p', '20', '-T', '10') else: command = ['fetch-crl'] status, stdout, stderr = core.system(command) fail = core.diagnose('Run %s in /etc' % 'fetch-crl', command, status, stdout, stderr) if status == 1: self.assert_(output_is_acceptable(stdout), fail) else: self.assertEquals(status, 0, fail) count = len(glob.glob(os.path.join('/etc/grid-security/certificates', '*.r[0-9]'))) self.assert_(count > 3, True)
def test_04_remove_server_file(self): if core.missing_rpm('bestman2-server', 'bestman2-client', 'voms-clients'): return if not core.state['bestman.started-server']: core.skip('bestman server not started') return srm_url = 'srm://%s:%s/%s?SFN=%s' % (TestBestman.__hostname, TestBestman.__port, TestBestman.__sfn, TestBestman.__remote_path) command = ('srm-rm', srm_url) status, stdout, stderr = core.system(command, True) fail = core.diagnose('Bestman remove, URL file', status, stdout, stderr) file_removed = not os.path.exists(TestBestman.__remote_path) self.assertEqual(status, 0, fail) self.assert_(file_removed, 'Copied file still exists') files.remove(TestBestman.__temp_dir)
def test_01_fetch_crl(self): core.skip_ok_unless_installed('fetch-crl') core.skip_ok_unless_installed('grid-certificates', by_dependency=True) if core.options.manualrun: command = ('fetch-crl', '-p', '20', '-T', '10') else: command = ['fetch-crl'] status, stdout, stderr = core.system(command) fail = core.diagnose('Run %s in /etc' % 'fetch-crl', command, status, stdout, stderr) if status == 1: self.assert_(self.output_is_acceptable(stdout), fail) else: self.assertEquals(status, 0, fail) count = len(glob.glob(os.path.join('/etc/grid-security/certificates', '*.r[0-9]'))) self.assert_(count > 3, True)
def test_03_copy_server_to_local(self): if core.missing_rpm('bestman2-server', 'bestman2-client', 'voms-clients'): return if not core.state['bestman.started-server']: core.skip('bestman server not started') return srm_url = 'srm://%s:%s/%s?SFN=%s' % (TestBestman.__hostname, TestBestman.__port, TestBestman.__sfn, TestBestman.__remote_path) command = ('srm-copy', srm_url, 'file:///' + TestBestman.__local_path) status, stdout, stderr = core.system(command, True) fail = core.diagnose('Bestman copy, URL to local', status, stdout, stderr) file_copied = os.path.exists(TestBestman.__local_path) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing') files.remove(TestBestman.__local_path)
def test_02_initate_tpc(self): core.skip_ok_unless_installed('xrootd', 'xrootd-scitokens', 'x509-scitokens-issuer-client', by_dependency=True) headers = {} command = ('curl', '-A', 'Test', "-vk", "-X", "COPY", '-H', "Authorization: Bearer %s" % core.config['xrootd.tpc.macaroon-1'], '-H', "Source: %s" % core.config['xrootd.tpc.url-1'], '-H', 'Overwrite: T', '-H', 'Copy-Header: Authorization: Bearer %s'% core.config['xrootd.tpc.macaroon-2'], core.config['xrootd.tpc.url-2']) status, stdout, stderr = core.system(command, user=True) fail = core.diagnose('Initiate third party copy', command, status, stdout, stderr) file_copied = os.path.exists("/tmp/test_gridftp_data_tpc.txt") self.assert_(file_copied, 'Copied file missing') chechskum_match = files.checksum_files_match("/tmp/test_gridftp_data_tpc.txt", "/usr/share/osg-test/test_gridftp_data.txt") self.assert_(chechskum_match, 'Files have same contents')
def test_02_fetch_crl_dir(self): core.skip_ok_unless_installed('fetch-crl') core.skip_ok_unless_installed('grid-certificates', by_dependency=True) temp_crl_dir = tempfile.mkdtemp() if core.options.manualrun: command = ('fetch-crl', '-o', temp_crl_dir, '-p', '20', '-T', '10') else: command = ('fetch-crl', '-o', temp_crl_dir) status, stdout, stderr = core.system(command) fail = core.diagnose('Run fetch-crl in temp dir', command, status, stdout, stderr) if status == 1: self.assert_(output_is_acceptable(stdout), fail) else: self.assertEquals(status, 0, fail) count = len(glob.glob(os.path.join(temp_crl_dir, '*.r[0-9]'))) shutil.rmtree(temp_crl_dir) self.assert_(count > 3, True)
def test_02_fetch_crl_dir(self): core.skip_ok_unless_installed('fetch-crl') core.skip_ok_unless_installed('grid-certificates', by_dependency=True) temp_crl_dir = tempfile.mkdtemp() if core.options.manualrun: command = ('fetch-crl', '-o', temp_crl_dir, '-p', '20', '-T', '10') else: command = ('fetch-crl', '-o', temp_crl_dir) status, stdout, stderr = core.system(command) fail = core.diagnose('Run fetch-crl in temp dir', command, status, stdout, stderr) if status == 1: self.assert_(self.output_is_acceptable(stdout), fail) else: self.assertEquals(status, 0, fail) count = len(glob.glob(os.path.join(temp_crl_dir, '*.r[0-9]'))) shutil.rmtree(temp_crl_dir) self.assert_(count > 3, True)
def test_02_copy_server_to_local_uberftp(self): core.skip_ok_unless_installed(*self.required_rpms) hostname = socket.getfqdn() temp_dir = tempfile.mkdtemp() os.chmod(temp_dir, 0777) local_dir = '/usr/share/osg-test' local_path = 'test_gridftp_data.txt' ftp_cmd = 'cd %s; lcd %s; get %s' % (local_dir, temp_dir, local_path) command = ('uberftp', hostname, ftp_cmd) status, stdout, stderr = core.system(command, True) fail = core.diagnose('UberFTP copy, URL to local', command, status, stdout, stderr) file_copied = os.path.exists(os.path.join(temp_dir, local_path)) shutil.rmtree(temp_dir) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_02_initate_tpc(self): core.skip_ok_unless_installed('x509-scitokens-issuer-client', by_dependency=True) self.skip_bad_if(core.config['xrootd.tpc.macaroon-1'] is None, 'Macaroon 1 creation failed earlier') self.skip_bad_if(core.config['xrootd.tpc.macaroon-2'] is None, 'Macaroon 2 creation failed earlier') headers = {} command = ('curl', '-A', 'Test', "-vk", "-X", "COPY", '-H', "Authorization: Bearer %s" % core.config['xrootd.tpc.macaroon-1'], '-H', "Source: %s" % core.config['xrootd.tpc.url-1'], '-H', 'Overwrite: T', '-H', 'Copy-Header: Authorization: Bearer %s'% core.config['xrootd.tpc.macaroon-2'], core.config['xrootd.tpc.url-2']) status, stdout, stderr = core.system(command, user=True) fail = core.diagnose('Initiate third party copy', command, status, stdout, stderr) file_copied = os.path.exists("/tmp/test_gridftp_data_tpc.txt") self.assert_(file_copied, 'Copied file missing') chechskum_match = files.checksum_files_match("/tmp/test_gridftp_data_tpc.txt", "/usr/share/osg-test/test_gridftp_data.txt") self.assert_(chechskum_match, 'Files have same contents')
def retry_command(command, timeout_seconds=3600): """Run a Yum command repeatedly until success, hard failure, or timeout. Run the given Yum command. If it succeeds, return. If it fails for a whitelisted reason, keep trying, otherwise return a failure message. But, do not retry commands for longer than the timeout duration. """ deadline = time.time() + timeout_seconds fail_msg, status, stdout, stderr = '', '', '', '' # EPEL released xrootd-compat (2/17/2015), which requires xrootd >= 4.1, # which is not available in 3.1 if core.config['install.original-release-ver'] == '3.1': command.append('--exclude=xrootd-compat*') # Loop for retries while True: # Stop (re)trying if the deadline has passed if time.time() > deadline: fail_msg += "Retries terminated after timeout period" break clean_yum() status, stdout, stderr = core.system(command) # Deal with success if status == 0: break # Deal with failures that can be retried elif yum_failure_can_be_retried(stdout): time.sleep(30) core.log_message("Retrying command") continue # Otherwise, we do not expect a retry to succeed, ever, so fail this # package else: fail_msg = core.diagnose("Command failed", command, status, stdout, stderr) break return fail_msg, status, stdout, stderr
def test_02_copy_server_to_local(self): if core.missing_rpm('globus-gridftp-server-progs', 'globus-ftp-client', 'globus-proxy-utils', 'globus-gass-copy-progs'): return hostname = socket.getfqdn() temp_dir = tempfile.mkdtemp() os.chmod(temp_dir, 0777) gsiftp_url = 'gsiftp://' + hostname + TestGridFTP.__data_path local_path = temp_dir + '/copied_file.txt' command = ('globus-url-copy', gsiftp_url, 'file://' + local_path) status, stdout, stderr = core.system(command, True) fail = core.diagnose('GridFTP copy, URL to local', status, stdout, stderr) file_copied = os.path.exists(local_path) shutil.rmtree(temp_dir) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_02_copy_server_to_local(self): core.skip_ok_unless_installed('globus-gridftp-server-progs', 'globus-ftp-client', 'globus-proxy-utils', 'globus-gass-copy-progs') self.skip_bad_unless(core.state['gridftp.running-server'] is True, 'GridFTP not running') hostname = socket.getfqdn() temp_dir = tempfile.mkdtemp() os.chmod(temp_dir, 0o777) gsiftp_url = 'gsiftp://' + hostname + TestGridFTP.__data_path local_path = temp_dir + '/copied_file.txt' command = ('globus-url-copy', gsiftp_url, 'file://' + local_path) status, stdout, stderr = core.system(command, True) fail = core.diagnose('GridFTP copy, URL to local', command, status, stdout, stderr) file_copied = os.path.exists(local_path) shutil.rmtree(temp_dir) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_01_copy_local_to_server_uberftp(self): if core.missing_rpm('globus-gridftp-server-progs', 'globus-ftp-client', 'globus-proxy-utils', 'globus-gass-copy-progs', 'uberftp'): return hostname = socket.getfqdn() temp_dir = tempfile.mkdtemp() os.chmod(temp_dir, 0777) local_dir = '/usr/share/osg-test' local_path = 'test_gridftp_data.txt' ftp_cmd = 'cd %s; lcd %s; put %s' % (temp_dir, local_dir, local_path) command = ('uberftp', hostname, ftp_cmd) status, stdout, stderr = core.system(command, True) fail = core.diagnose('UberFTP copy, local to URL', status, stdout, stderr) file_copied = os.path.exists(os.path.join(temp_dir, local_path)) shutil.rmtree(temp_dir) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def test_02_copy_server_to_local_uberftp(self): core.skip_ok_unless_installed(*self.required_rpms) self.skip_bad_unless(core.state['gridftp.running-server'] is True, 'GridFTP not running') hostname = socket.getfqdn() temp_dir = tempfile.mkdtemp() os.chmod(temp_dir, 0o777) local_dir = '/usr/share/osg-test' local_path = 'test_gridftp_data.txt' ftp_cmd = 'cd %s; lcd %s; get %s' % (local_dir, temp_dir, local_path) command = ('uberftp', hostname, ftp_cmd) status, stdout, stderr = core.system(command, True) fail = core.diagnose('UberFTP copy, URL to local', command, status, stdout, stderr) file_copied = os.path.exists(os.path.join(temp_dir, local_path)) shutil.rmtree(temp_dir) self.assertEqual(status, 0, fail) self.assert_(file_copied, 'Copied file missing')
def retry_command(command, timeout_seconds=3600): """Run a Yum command repeatedly until success, hard failure, or timeout. Run the given Yum command. If it succeeds, return. If it fails for a whitelisted reason, keep trying, otherwise return a failure message. But, do not retry commands for longer than the timeout duration. """ deadline = time.time() + timeout_seconds fail_msg, status, stdout, stderr = '', '', '', '' # Loop for retries while True: # Stop (re)trying if the deadline has passed if time.time() > deadline: fail_msg += "Retries terminated after timeout period" break status, stdout, stderr = core.system(command) # Deal with success if status == 0: break # Deal with failures that can be retried elif yum_failure_can_be_retried(stdout): time.sleep(30) clean() core.log_message("Retrying command") continue # Otherwise, we do not expect a retry to succeed, ever, so fail this # package else: fail_msg = core.diagnose("Command failed", command, status, stdout, stderr) break return fail_msg, status, stdout, stderr
def run_trace(self, *args): """Run condor_ce_trace along with any additional *args. If trace completes with a held job, also return output from 'condor_ce_q -held'. """ cwd = os.getcwd() os.chdir('/tmp') self.command += ['condor_ce_trace', '--debug'] + list(args) + [core.get_hostname()] trace_rc, trace_out, trace_err = core.system(self.command, user=True) os.chdir(cwd) if trace_rc: msg = 'condor_ce_trace failed' if trace_out.find(', was held'): msg = 'condor_ce_trace job held' _, hold_out, hold_err = core.system(('condor_ce_q', '-held')) self.fail(core.diagnose(msg, self.command, trace_rc, str(trace_out) + str(hold_out), str(trace_err) + str(hold_err))) return trace_out, trace_err
def test_01_cvmfs(self): if core.missing_rpm('cvmfs', 'cvmfs-keys'): return #TESTING command = ('cat','/etc/cvmfs/default.local') status, stdout, stderr = core.system(command, False) # command = ('mkdir','-p', '/mnt/testcvmfs') # status, stdout, stderr = core.system(command, False) # command = ('mount','-t','cvmfs','cms.cern.ch','/mnt/testcvmfs') # status, stdout, stderr = core.system(command, False) # command = ('ls', '/mnt/testcvmfs') # status, stdout, stderr = core.system(command, False) command = ('service','cvmfs', 'probe') status, stdout, stderr = core.system(command, False) #END TESTING command = ('ls', '/cvmfs') status, stdout, stderr = core.system(command, False) file_exists = os.path.exists('/cvmfs') self.assert_(file_exists, 'Cvmfs mount point missing') command = ('ls', '/cvmfs/cms.cern.ch') status, stdout, stderr = core.system(command, False) file_exists = os.path.exists('/cvmfs/cms.cern.ch') self.assert_(file_exists, 'Cvmfs cern mount point missing') command = ('ls', self.__check_path) status, stdout, stderr = core.system(command, False) self.assert_(file_exists, 'Test cvmfs file missing') command = ('bash', '-c', 'source ' + self.__check_path) status, stdout, stderr = core.system(command, False) fail = core.diagnose('cvmfs example source a file on fs', status, stdout, stderr) self.assertEqual(status, 0, fail)
def test_01_ping(self): command = ('srm-ping', self.get_srm_url_base(), '-debug') status, stdout, stderr = core.system(command, True) fail = core.diagnose('Bestman Ping', command, status, stdout, stderr) self.assertEqual(status, 0, fail)