def test_06_remove_trustmanager(self): core.skip_ok_unless_installed(tomcat.pkgname(), 'emi-trustmanager-tomcat') # mv -f /etc/tomcat5/server.xml.old-trustmanager /etc/tomcat5/server.xml old_tm = os.path.join(tomcat.sysconfdir(), 'server.xml.old-trustmanager') new_tm = os.path.join(tomcat.sysconfdir(), 'server.xml') if os.path.exists(old_tm) and os.path.isdir(os.path.dirname(new_tm)): shutil.move(old_tm, new_tm) # rm -f /usr/share/tomcat5/server/lib/bcprov*.jar files.remove(os.path.join(tomcat.serverlibdir(), 'bcprov*.jar')) # rm -f /usr/share/tomcat5/server/lib/log4j*.jar files.remove(os.path.join(tomcat.serverlibdir(), 'log4j*.jar')) # rm -f /usr/share/tomcat5/server/lib/trustmanager-*.jar files.remove(os.path.join(tomcat.serverlibdir(), 'trustmanager-*.jar')) # rm -f /etc/tomcat5/log4j-trustmanager.properties files.remove(os.path.join(tomcat.sysconfdir(), 'log4j-trustmanager.properties')) # rm -f /var/lib/trustmanager-tomcat/server.xml files.remove('/var/lib/trustmanager-tomcat/server.xml') core.log_message('EMI trustmanager removed')
def test_04_xrootd_fuse(self): # This tests xrootd-fuse using a mount in /mnt core.skip_ok_unless_installed('xrootd', 'xrootd-client', 'xrootd-fuse') self.skip_ok_unless(os.path.exists("/mnt"), "/mnt did not exist") if not os.path.exists(TestXrootd.__fuse_path): os.mkdir(TestXrootd.__fuse_path) hostname = socket.getfqdn() # For some reason, sub process hangs on fuse processes, use os.system os.system( "mount -t fuse -o rdr=root://localhost//tmp,uid=xrootd xrootdfs %s" % TestXrootd.__fuse_path) # Copy a file in and see if it made it into the fuse mount xrootd_url = 'root://%s/%s/copied_file.txt' % (hostname, "/tmp") core.system( ['xrdcp', '--debug', '3', TestXrootd.__data_path, xrootd_url], user=True) self.assert_(os.path.isfile("/tmp/copied_file.txt"), "Test file not uploaded to FUSE mount") core.system(['umount', TestXrootd.__fuse_path]) os.rmdir(TestXrootd.__fuse_path) files.remove("/tmp/copied_file.txt")
def test_04_xrootd_fuse(self): # This tests xrootd-fuse using a mount in /mnt core.skip_ok_unless_installed('xrootd', 'xrootd-client', by_dependency=True) self.skip_ok_unless(os.path.exists("/mnt"), "/mnt did not exist") self.skip_ok_if(core.config['xrootd.gsi'] == "ON", 'fuse incompatible with GSI') if not os.path.exists(TestXrootd.__fuse_path): os.mkdir(TestXrootd.__fuse_path) hostname = socket.getfqdn() #command = ('xrootdfs',TestXrootd.__fuse_path,'-o','rdr=xroot://localhost:1094//tmp','-o','uid=xrootd') command = ('mount', '-t', 'fuse', '-o', 'rdr=xroot://localhost:1094//tmp,uid=xrootd', 'xrootdfs', TestXrootd.__fuse_path) command_str = ' '.join(command) #For some reason, sub process hangs on fuse processes, use os.system #status, stdout, stderr = core.system(command_str,shell=True) os.system(command_str) # Copy a file in and see if it made it into the fuse mount xrootd_url = 'root://%s/%s/copied_file.txt' % (hostname, "/tmp") command = ('xrdcp', '--debug', '3', TestXrootd.__data_path, xrootd_url) core.system(command, user=True) command = ('ls', "/tmp/copied_file.txt") core.check_system(command, "Checking file is copied to xrootd fuse mount correctly", user=True) command = ('umount', TestXrootd.__fuse_path) core.system(command) os.rmdir(TestXrootd.__fuse_path) files.remove("/tmp/copied_file.txt")
def test_01_stop_cvmfs(self): core.skip_ok_unless_installed('cvmfs') self.skip_ok_if(['cvmfs.started-server'] == False, 'did not start server') try: for temp_dir in core.config['cvmfs.debug-dirs']: command = ('umount', temp_dir) core.check_system(command, 'Manual cvmfs unmount failed') files.remove(temp_dir, force=True) except KeyError: pass # tempdir was never created if core.state['cvmfs.version'] < ('2', '1'): command = ('service', 'cvmfs', 'stop') else: command = ('cvmfs_config', 'umount') stdout, _, fail = core.check_system(command, 'Stop Cvmfs server') self.assert_(stdout.find('FAILED') == -1, fail) # Restart autofs to bring network filesystems back (specifically # homedirs on el5 fermicloud vms) if core.state['cvmfs.version'] >= ('2', '1'): stdout, _, fail = core.check_system(('service', 'autofs', 'restart'), 'Restart autofs') self.assert_(stdout.find('FAILED') == -1, fail) files.restore("/etc/fuse.conf","cvmfs") files.restore("/etc/auto.master","cvmfs") files.restore("/etc/cvmfs/default.local","cvmfs") files.restore("/etc/cvmfs/domain.d/cern.ch.local","cvmfs")
def test_03_xrootd_fuse(self): # This tests xrootd-fuse using a mount in /mnt core.skip_ok_unless_installed('xrootd', 'xrootd-client', by_dependency=True) self.skip_ok_unless(os.path.exists("/mnt"), "/mnt did not exist") self.skip_ok_if(core.config['xrootd.gsi'] == "ON", 'fuse incompatible with GSI') if not os.path.exists(TestXrootd.__fuse_path): os.mkdir(TestXrootd.__fuse_path) hostname = socket.getfqdn() #command = ('xrootdfs',TestXrootd.__fuse_path,'-o','rdr=xroot://localhost:1094//tmp','-o','uid=xrootd') command = ('mount', '-t', 'fuse', '-o', 'rdr=xroot://localhost:1094//tmp,uid=xrootd', 'xrootdfs', TestXrootd.__fuse_path) command_str = ' '.join(command) #For some reason, sub process hangs on fuse processes, use os.system #status, stdout, stderr = core.system(command_str,shell=True) os.system(command_str) # Copy a file in and see if it made it into the fuse mount xrootd_url = 'root://%s/%s/copied_file.txt' % (hostname, "/tmp") command = ('xrdcp', '--debug', '3', TestXrootd.__data_path, xrootd_url) core.system(command, user=True) command = ('ls', "/tmp/copied_file.txt") core.check_system(command, "Checking file is copied to xrootd fuse mount correctly", user=True) command = ('umount', TestXrootd.__fuse_path) core.system(command) os.rmdir(TestXrootd.__fuse_path) files.remove("/tmp/copied_file.txt")
def test_06_remove_trustmanager(self): core.skip_ok_unless_installed(tomcat.pkgname(), 'emi-trustmanager-tomcat') # mv -f /etc/tomcat5/server.xml.old-trustmanager /etc/tomcat5/server.xml old_tm = os.path.join(tomcat.sysconfdir(), 'server.xml.old-trustmanager') new_tm = os.path.join(tomcat.sysconfdir(), 'server.xml') if os.path.exists(old_tm) and os.path.isdir(os.path.dirname(new_tm)): shutil.move(old_tm, new_tm) # rm -f /usr/share/tomcat5/server/lib/bcprov*.jar files.remove(os.path.join(tomcat.serverlibdir(), 'bcprov*.jar')) # rm -f /usr/share/tomcat5/server/lib/log4j*.jar files.remove(os.path.join(tomcat.serverlibdir(), 'log4j*.jar')) # rm -f /usr/share/tomcat5/server/lib/trustmanager-*.jar files.remove(os.path.join(tomcat.serverlibdir(), 'trustmanager-*.jar')) # rm -f /etc/tomcat5/log4j-trustmanager.properties files.remove( os.path.join(tomcat.sysconfdir(), 'log4j-trustmanager.properties')) # rm -f /var/lib/trustmanager-tomcat/server.xml files.remove('/var/lib/trustmanager-tomcat/server.xml') core.log_message('EMI trustmanager removed')
def test_03_xrootd_fuse(self): """ This tests xrootd-fuse using a mount in /mnt """ if core.missing_rpm('xrootd-server', 'xrootd-client','xrootd-fuse'): return if not os.path.exists("/mnt"): core.log_message("/mnt did not exist, skipping xrootd fuse test") return if not os.path.exists(TestXrootd.__fuse_path): os.mkdir(TestXrootd.__fuse_path) if core.config['xrootd.gsi'] == "ON": core.log_message("fuse incompatible with GSI, skipping xrootd fuse") return hostname = socket.getfqdn() #command = ('xrootdfs',TestXrootd.__fuse_path,'-o','rdr=xroot://localhost:1094//tmp','-o','uid=xrootd') command = ('mount', '-t','fuse','-o','rdr=xroot://localhost:1094//tmp,uid=xrootd','xrootdfs',TestXrootd.__fuse_path) command_str= ' '.join(command) #For some reason, sub process hangs on fuse processes, use os.system #status, stdout, stderr = core.system(command_str,shell=True) os.system(command_str) # Copy a file in and see if it made it into the fuse mount xrootd_url = 'root://%s/%s/copied_file.txt' % (hostname, "/tmp") command = ('xrdcp', TestXrootd.__data_path , xrootd_url) status, stdout, stderr = core.system(command, True) command = ('ls', "/tmp/copied_file.txt") stdout, stderr, fail = core.check_system(command, "Checking file is copied to xrootd fuse mount correctly", user=True) command = ('umount',TestXrootd.__fuse_path) status, stdout, stderr = core.system(command) os.rmdir(TestXrootd.__fuse_path) files.remove("/tmp/copied_file.txt")
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_09_restore_varlibgratia(self): core.skip_ok_unless_installed('gratia-service') if 'gratia.varlibgratia-backedup' in core.state: files.remove('/var/lib/gratia', True) command = ("mv /var/lib/gratia_production /var/lib/gratia", ) core.check_system(command, 'Could not restore /var/lib/gratia', shell=True)
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_14_restore_etcgratia_collector_or_services(self): core.skip_ok_unless_installed('gratia-service') if 'gratia.etcgratia_collector_or_services-backedup' in core.state: gratia_directory_to_preserve = core.state['gratia.etcgratia_collector_or_services-backedup'] backup_path = gratia_directory_to_preserve + '_production' files.remove(gratia_directory_to_preserve, True) command = ("mv " + backup_path + " " + gratia_directory_to_preserve,) core.check_system(command, 'Could not restore ' + gratia_directory_to_preserve, shell=True)
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_03_clean_edg_mkgridmap(self): core.skip_ok_unless_installed('edg-mkgridmap', 'voms-server') for envvar in ('VO_LIST_FILE', 'UNDEFINED_ACCTS_FILE', 'EDG_MKGRIDMAP_LOG', 'USER_VO_MAP', 'GRIDMAP'): files.remove(os.environ[envvar]) del os.environ[envvar] files.restore(core.config['edg.conf'], 'edg')
def test_03_remove_server_file_gfal2_util_gftp(self): core.skip_ok_unless_installed('globus-gridftp-server-progs', 'gfal2-plugin-gridftp') self.skip_ok_unless(core.state['gridftp.running-server'], 'gridftp server not running') command = ('gfal-rm', '-v', self.get_gftp_url_base() + TestGFAL2Util.__remote_path) core.check_system(command, "gfal2-util remove, URL file", user='******') file_removed = not os.path.exists(TestGFAL2Util.__remote_path) self.assert_(file_removed, 'Copied file still exists') files.remove(TestGFAL2Util.__remote_path) files.remove(TestGFAL2Util.__local_path)
def test_06_remove_server_file_gfal2_util_gftp(self): core.skip_ok_unless_installed('globus-gridftp-server-progs', 'gfal2-plugin-gridftp') self.skip_ok_unless(core.state['gridftp.running-server'], 'gridftp server not running') command = ('gfal-rm', '-v', self.get_gftp_url_base() + TestGFAL2Util.__remote_path) core.check_system(command, "gfal2-util remove, URL file", user='******') file_removed = not os.path.exists(TestGFAL2Util.__remote_path) self.assert_(file_removed, 'Copied file still exists') files.remove(TestGFAL2Util.__remote_path) files.remove(TestGFAL2Util.__local_path)
def test_02_restore_backup(self): if not core.options.backupmysql: return core.skip_ok_unless_installed(mysql.server_rpm()) if core.config['mysql.backup']: files.remove(core.config['mysql.datadir'], force=True) shutil.move(core.config['mysql.backup'], core.config['mysql.datadir'])
def test_03_clean_edg_mkgridmap(self): if core.missing_rpm('edg-mkgridmap', 'voms-server'): return for envvar in ('VO_LIST_FILE', 'UNDEFINED_ACCTS_FILE', 'EDG_MKGRIDMAP_LOG', 'USER_VO_MAP', 'GRIDMAP'): files.remove(os.environ[envvar]) del os.environ[envvar] files.restore(core.config['edg.conf'], 'edg')
def test_03_clean_edg_mkgridmap(self): core.skip_ok_unless_installed('edg-mkgridmap', 'voms-admin-server') self.skip_bad_unless(core.state['voms-admin.read-members'], 'Cannot read VO member list') self.skip_bad_unless(core.state['tomcat.started'], 'Tomcat not started') for envvar in ('VO_LIST_FILE', 'UNDEFINED_ACCTS_FILE', 'EDG_MKGRIDMAP_LOG', 'USER_VO_MAP', 'GRIDMAP'): files.remove(os.environ[envvar]) del os.environ[envvar] files.restore(core.config['edg.conf'], 'edg')
def test_013_profiler(self): core.skip_ok_unless_installed('rsv') profiler_tarball = 'rsv-profiler.tar.gz' command = ('rsv-control', '--profile') stdout = core.check_system(command, 'rsv-control --profile')[0] self.assert_(re.search('Running the rsv-profiler', stdout) is not None) self.assert_(os.path.exists(profiler_tarball)) files.remove(profiler_tarball)
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_08_remove_scitokens(self): for key in core.config: if not key.startswith("token."): continue # token.foo is in core.config, but token.foo_created is in core.state if not core.state.get(key + "_created", None): # Skipping this token - we may not have created it continue token_file = core.config[key] if os.path.exists(token_file): files.remove(token_file)
def _test_download(self, remote_file, command, message): files.remove(TestXrootd.download_temp) try: core.check_system(command, message, user=True) self.assert_(os.path.isfile(TestXrootd.download_temp), "Downloaded file missing") self.assertEqualVerbose( files.read(TestXrootd.download_temp, as_single_string=True), files.read(remote_file, as_single_string=True), "Downloaded contents differ from expected") finally: files.remove(TestXrootd.download_temp)
def test_013_profiler(self): if core.missing_rpm('rsv'): return profiler_tarball = 'rsv-profiler.tar.gz' command = ('rsv-control', '--profile') stdout = core.check_system(command, 'rsv-control --profile')[0] self.assert_(re.search('Running the rsv-profiler', stdout) is not None) self.assert_(os.path.exists(profiler_tarball)) files.remove(profiler_tarball) return
def test_11_restore_etcgratia_collector_or_services(self): core.skip_ok_unless_installed('gratia-service') if 'gratia.etcgratia_collector_or_services-backedup' in core.state: gratia_directory_to_preserve = core.state[ 'gratia.etcgratia_collector_or_services-backedup'] backup_path = gratia_directory_to_preserve + '_production' files.remove(gratia_directory_to_preserve, True) command = ("mv " + backup_path + " " + gratia_directory_to_preserve, ) core.check_system(command, 'Could not restore ' + gratia_directory_to_preserve, shell=True)
def test_01_stop_xrootd(self): if core.state['xrootd.backups-exist']: if core.PackageVersion('xrootd') < '1:4.9.0': files.restore(core.config['xrootd.config'], "xrootd") else: files.restore(core.config['xrootd.config-extra'], "xrootd") files.restore('/etc/xrootd/auth_file', "xrootd") if not core.rpm_is_installed('xrootd-lcmaps'): files.restore('/etc/grid-security/xrd/xrdmapfile', "xrootd") core.skip_ok_unless_installed('xrootd', by_dependency=True) self.skip_ok_if(core.state['xrootd.started-server'], 'did not start server') service.check_stop(core.config['xrootd_service']) files.remove(core.config['xrootd.tmp-dir'], force=True)
def test_08_cleanup_sge(self): core.skip_ok_unless_installed('gratia-probe-sge', 'gratia-service') try: files.remove("/var/log/accounting", True) probeconfig = core.config['gratia.config.dir'] + "/sge/ProbeConfig" owner = os.path.basename(os.path.dirname(probeconfig)) files.restore(probeconfig, owner) except OSError as e: if e.errno == 2: # suppress "No such file or directory" error pass else: # reraise the exception, as it's an unexpected error raise
def test_11_cleanup_sge(self): core.skip_ok_unless_installed('gratia-probe-sge', 'gratia-service') try: files.remove("/var/log/accounting", True) probeconfig = core.config['gratia.config.dir'] + "/sge/ProbeConfig" owner = os.path.basename(os.path.dirname(probeconfig)) files.restore(probeconfig, owner) except OSError, e: if e.errno == 2: # suppress "No such file or directory" error pass else: # reraise the exception, as it's an unexpected error raise
def test_01_stop_xrootd(self): if core.state['xrootd.backups-exist']: files.restore(core.config['xrootd.config'], "xrootd") files.restore('/etc/xrootd/auth_file', "xrootd") if not core.rpm_is_installed('xrootd-lcmaps'): files.restore('/etc/grid-security/xrd/xrdmapfile', "xrootd") if core.el_release() < 7: files.restore(core.config['xrootd.service-defaults'], "xrootd") core.skip_ok_unless_installed('xrootd', 'globus-proxy-utils', by_dependency=True) self.skip_ok_if(core.state['xrootd.started-server'], 'did not start server') service.check_stop(core.config['xrootd_service']) files.remove(core.config['xrootd.tmp-dir'], force=True)
def test_04a_xrdcp_upload_gsi_authenticated_denied(self): self.skip_unless_security("GSI") try: command = ('xrdcp', '--debug', '2', TestXrootd.__data_path, xroot_url(TestXrootd.rootdir_copied_file)) with core.no_bearer_token(core.options.username): core.check_system( command, "xrdcp upload to dir w/o write access (should be denied)", exit=ERR_PERMISSION_DENIED, user=True) self.assertFalse(os.path.exists(TestXrootd.rootdir_copied_file), "Uploaded file wrongly present") finally: files.remove(TestXrootd.rootdir_copied_file)
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_02_uninstall_gratia_database(self): core.skip_ok_unless_installed('gratia-service') filename = "/tmp/gratia_admin_pass." + str(os.getpid()) + ".txt" contents="[client]\n" + "password=\n" files.write(filename, contents, backup=False) #Command to drop the gratia database is: #echo "drop database gratia;" | mysql --defaults-extra-file="/tmp/gratia_admin_pass.<pid>.txt" -B --unbuffered --user=root --port=3306 command = "echo \"drop database gratia_osgtest;\" | mysql --defaults-extra-file=\"" + filename + "\" -B --unbuffered --user=root --port=3306" core.check_system(command, 'Unable to drop Gratia Database.', shell=True) files.remove(filename) #At this time, remove the gratia reader password file also files.remove(core.config['gratia.sql.file'])
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_03_cleanup_gridftp(self): core.skip_ok_unless_installed('gratia-probe-gridftp-transfer', 'gratia-service') try: files.remove("/var/log/gridftp.log") files.remove("/var/log/gridftp-auth.log") probeconfig = core.config['gratia.config.dir'] + "/gridftp-transfer/ProbeConfig" owner = os.path.basename(os.path.dirname(probeconfig)) files.restore(probeconfig, owner) except OSError, e: if e.errno == 2: # suppress "No such file or directory" error pass else: # reraise the exception, as it's an unexpected error raise
def test_04_cleanup_glexec(self): core.skip_ok_unless_installed('gratia-probe-glexec', 'gratia-service') try: files.remove("/var/log/glexec.log") files.remove("/var/lib/gratia/data/glexec_plugin.chk") probeconfig = core.config['gratia.config.dir'] + "/glexec/ProbeConfig" owner = os.path.basename(os.path.dirname(probeconfig)) files.restore(probeconfig, owner) except OSError, e: if e.errno == 2: # suppress "No such file or directory" error pass else: # reraise the exception, as it's an unexpected error raise
def test_04_cleanup_glexec(self): core.skip_ok_unless_installed('gratia-probe-glexec', 'gratia-service') try: files.remove("/var/log/glexec.log") files.remove("/var/lib/gratia/data/glexec_plugin.chk") probeconfig = core.config[ 'gratia.config.dir'] + "/glexec/ProbeConfig" owner = os.path.basename(os.path.dirname(probeconfig)) files.restore(probeconfig, owner) except OSError as e: if e.errno == 2: # suppress "No such file or directory" error pass else: # reraise the exception, as it's an unexpected error raise
def test_04b_xrdcp_upload_scitoken_authenticated_denied(self): self.skip_unless_security("SCITOKENS") try: with core.no_x509(core.options.username), core.environ_context( {"BEARER_TOKEN_FILE": core.config['token.xrootd']}): xrootd_url = xroot_url(TestXrootd.rootdir_copied_file) command = ('xrdcp', '--debug', '2', TestXrootd.__data_path, xrootd_url) core.check_system( command, "Authenticated xrdcp upload to dir w/o write access (should be denied)", exit=ERR_PERMISSION_DENIED, user=True) self.assertFalse( os.path.exists(TestXrootd.rootdir_copied_file), "Uploaded file wrongly present") finally: files.remove(TestXrootd.rootdir_copied_file)
def test_03_cleanup_gridftp(self): core.skip_ok_unless_installed('gratia-probe-gridftp-transfer', 'gratia-service') try: files.remove("/var/log/gridftp.log") files.remove("/var/log/gridftp-auth.log") probeconfig = core.config[ 'gratia.config.dir'] + "/gridftp-transfer/ProbeConfig" owner = os.path.basename(os.path.dirname(probeconfig)) files.restore(probeconfig, owner) except OSError as e: if e.errno == 2: # suppress "No such file or directory" error pass else: # reraise the exception, as it's an unexpected error raise
def test_01_stop_cvmfs(self): core.skip_ok_unless_installed('cvmfs') self.skip_ok_if(['cvmfs.started-server'] == False, 'did not start server') try: for temp_dir in core.config['cvmfs.debug-dirs']: command = ('umount', temp_dir) core.check_system(command, 'Manual cvmfs unmount failed') files.remove(temp_dir, force=True) except KeyError: pass # tempdir was never created stdout, _, fail = core.check_system(('cvmfs_config', 'umount'), 'Stop Cvmfs server') self.assert_(stdout.find('FAILED') == -1, fail) files.restore("/etc/fuse.conf","cvmfs") files.restore("/etc/auto.master","cvmfs") files.restore("/etc/cvmfs/default.local","cvmfs") files.restore("/etc/cvmfs/domain.d/cern.ch.local","cvmfs")
def test_02_stop_xrootd(self): if core.state['xrootd.backups-exist']: files.restore(core.config['xrootd.config'], "xrootd") files.restore(core.config['xrootd.logging-config'], "xrootd") files.restore(core.config['xrootd.authfile'], "xrootd") files.restore(xrootd.logfile("standalone"), "xrootd", ignore_missing=True) if "SCITOKENS" in core.config['xrootd.security']: files.restore('/etc/xrootd/scitokens.conf', "xrootd") files.remove("/etc/xrootd/config.d/99-osgtest-ztn.cfg", force=True) if os.path.exists(xrootd.ROOTDIR): shutil.rmtree(xrootd.ROOTDIR) # Get xrootd service back to its original state self.skip_ok_unless(core.state['xrootd.is-configured'], "xrootd is not configured") xrootd_service = core.config['xrootd_service'] if service.is_running(xrootd_service): service.check_stop(xrootd_service, force=True) if core.state.get('xrootd.service-was-running', False): service.check_start(xrootd_service, force=True)
def test_02_uninstall_gratia_database(self): core.skip_ok_unless_installed('gratia-service') filename = "/tmp/gratia_admin_pass." + str(os.getpid()) + ".txt" contents = "[client]\n" + "password=\n" files.write(filename, contents, backup=False) # Command to drop the gratia database is: # echo "drop database gratia;" | mysql --defaults-extra-file="/tmp/gratia_admin_pass.<pid>.txt" -B --unbuffered # --user=root --port=3306 command = "echo \"drop database gratia_osgtest;\" | " + \ "mysql --defaults-extra-file=\"" + \ filename + \ "\" -B --unbuffered --user=root --port=3306" core.check_system(command, 'Unable to drop Gratia Database.', shell=True) files.remove(filename) #At this time, remove the gratia reader password file also files.remove(core.config['gratia.sql.file'])
def test_01_stop_cvmfs(self): core.skip_ok_unless_installed('cvmfs') self.skip_ok_unless(core.state['cvmfs.started-server'], 'did not start server') try: for temp_dir in core.config['cvmfs.debug-dirs']: command = ('umount', temp_dir) core.check_system(command, 'Manual cvmfs unmount failed') files.remove(temp_dir, force=True) except KeyError: pass # tempdir was never created stdout, _, fail = core.check_system(('cvmfs_config', 'umount'), 'Stop Cvmfs server') self.assert_(stdout.find('FAILED') == -1, fail) files.restore("/etc/fuse.conf", "cvmfs") files.restore("/etc/auto.master", "cvmfs") files.restore("/etc/cvmfs/default.local", "cvmfs") files.restore("/etc/sysconfig/autofs", "cvmfs")
def test_07_remove_test_user(self): if not core.state['general.user_added']: core.log_message('Did not add user') return username = core.options.username password_entry = pwd.getpwnam(username) globus_dir = os.path.join(password_entry.pw_dir, '.globus') # Remove certs in case userdel fails if core.state['general.user_cert_created']: files.remove(os.path.join(globus_dir, 'usercert.pem')) files.remove(os.path.join(globus_dir, 'userkey.pem')) # Get list of PIDs owned by the test user command = ('ps', '-U', username, '-u', username, '-o', 'pid=') _, output, _ = core.system(command) # Take no prisoners for pid in output.splitlines(): try: os.kill(int(pid), signal.SIGKILL) except OSError: continue command = ('userdel', username) core.check_system(command, "Remove user '%s'" % (username)) files.remove(os.path.join('/var/spool/mail', username)) shutil.rmtree(password_entry.pw_dir)
def test_04_xrootd_fuse(self): # This tests xrootd-fuse using a mount in /mnt core.skip_ok_unless_installed('xrootd', 'xrootd-client', 'xrootd-fuse') self.skip_ok_unless(os.path.exists("/mnt"), "/mnt did not exist") if not os.path.exists(TestXrootd.__fuse_path): os.mkdir(TestXrootd.__fuse_path) hostname = socket.getfqdn() #For some reason, sub process hangs on fuse processes, use os.system os.system("mount -t fuse -o rdr=root://localhost:%d//tmp,uid=xrootd xrootdfs %s" % (core.config['xrootd.port'], TestXrootd.__fuse_path)) # Copy a file in and see if it made it into the fuse mount xrootd_url = 'root://%s:%d/%s/copied_file.txt' % (hostname, core.config['xrootd.port'], "/tmp") core.system(['xrdcp', '--debug', '3', TestXrootd.__data_path, xrootd_url], user=True) self.assert_(os.path.isfile("/tmp/copied_file.txt"), "Test file not uploaded to FUSE mount") core.system(['umount', TestXrootd.__fuse_path]) os.rmdir(TestXrootd.__fuse_path) files.remove("/tmp/copied_file.txt")
def test_06_cleanup_test_certs(self): certs_dir = '/etc/grid-security/certificates' if core.state['certs.ca_created']: files.remove(os.path.join(certs_dir, 'OSG-Test-CA.*')) for link in os.listdir(certs_dir): abs_link_path = os.path.join(certs_dir, link) try: dest = os.readlink(abs_link_path) if re.match(r'OSG-Test-CA\.', dest): files.remove(abs_link_path) except OSError, e: if e.errno == errno.EINVAL: continue # Remove config files openssl_dir = '/etc/pki/' for ca_file in ['index.txt*', 'crlnumber*', 'serial*']: files.remove(os.path.join(openssl_dir, 'CA', ca_file)) for tls_file in ['osg-test-ca.conf', 'osg-test-extensions.conf']: files.remove(os.path.join(openssl_dir, 'tls', tls_file))
def test_07_cleanup_test_certs(self): certs_dir = '/etc/grid-security/certificates' if core.state['certs.ca_created']: files.remove(os.path.join(certs_dir, 'OSG-Test-CA.*')) for link in os.listdir(certs_dir): abs_link_path = os.path.join(certs_dir, link) try: dest = os.readlink(abs_link_path) if re.match(r'OSG-Test-CA\.', dest): files.remove(abs_link_path) except OSError, e: if e.errno == errno.EINVAL: continue # Remove config files openssl_dir = '/etc/pki/' for ca_file in ['index.txt*', 'crlnumber*', 'serial*']: files.remove(os.path.join(openssl_dir, 'CA', ca_file)) for tls_file in ['osg-test-ca.conf', 'osg-test-extensions.conf']: files.remove(os.path.join(openssl_dir, 'tls', tls_file))
def test_02_clean_test_files(self): files.remove("/tmp/test_gridftp_data_tpc.txt", force=True)
def test_13_restore_varlibgratiaservice(self): core.skip_ok_unless_installed('gratia-service') if 'gratia.varlibgratia-service-backedup' in core.state: files.remove('/var/lib/gratia-service', True) command = ("mv /var/lib/gratia-service_production /var/lib/gratia-service",) core.check_system(command, 'Could not restore /var/lib/gratia-service', shell=True)
def test_06_cleanup_test_certs(self): certs_dir = '/etc/grid-security/certificates' if core.state['certs.ca_created']: files.remove(os.path.join(certs_dir, 'OSG-Test-CA.*')) for link in os.listdir(certs_dir): abs_link_path = os.path.join(certs_dir, link) try: dest = os.readlink(abs_link_path) if re.match(r'OSG-Test-CA\.', dest): files.remove(abs_link_path) except OSError as e: if e.errno == errno.EINVAL: continue # Remove config files openssl_dir = '/etc/pki/' for ca_file in ['index.txt*', 'crlnumber*', 'serial*']: files.remove(os.path.join(openssl_dir, 'CA', ca_file)) for tls_file in ['osg-test-ca.conf', 'osg-test-extensions.conf']: files.remove(os.path.join(openssl_dir, 'tls', tls_file)) # Remove the entire certs dir if our test CA was the only resident if len(os.listdir(certs_dir)) == 0: files.remove(certs_dir, force=True) if core.state['certs.hostcert_created']: files.remove(core.config['certs.hostcert']) files.remove(core.config['certs.hostkey'])