def test_shutdown(self): # test shutdown lib.assert_command('irods-grid shutdown --all', 'STDOUT_SINGLELINE', 'shutting down') time.sleep(2) lib.assert_command('ils', 'STDERR_SINGLELINE', 'USER_SOCK_CONNECT_ERR') lib.start_irods_server()
def test_re_shm_cleanup(self): irodsctl_fullpath = os.path.join(lib.get_irods_top_level_dir(), 'iRODS', 'irodsctl') lib.assert_command([irodsctl_fullpath, 'stop'], 'STDOUT_SINGLELINE', 'Stopping iRODS server') assert not lib.re_shm_exists(), lib.re_shm_exists() lib.start_irods_server()
def test_shutdown(self): # test shutdown lib.assert_command('irods-grid shutdown --all', 'STDOUT_SINGLELINE', 'shutting down') time.sleep( 2 ) lib.assert_command('ils', 'STDERR_SINGLELINE', 'USER_SOCK_CONNECT_ERR') lib.start_irods_server()
def test_izonereport_and_validate(self): jsonschema_installed = True if lib.get_os_distribution() == 'Ubuntu' and lib.get_os_distribution_version_major() == '12': jsonschema_installed = False # bad URL self.admin.assert_icommand("izonereport > out.txt", use_unsafe_shell=True) if jsonschema_installed: lib.assert_command('python ../../iRODS/scripts/python/validate_json.py out.txt https://example.org/badurl', 'STDERR_MULTILINE', ['WARNING: Validation Failed', 'ValueError: No JSON object could be decoded'], desired_rc=0) else: lib.assert_command('python ../../iRODS/scripts/python/validate_json.py out.txt https://example.org/badurl', 'STDERR_SINGLELINE', 'jsonschema not installed', desired_rc=0) # good URL self.admin.assert_icommand("izonereport > out.txt", use_unsafe_shell=True) if jsonschema_installed: lib.assert_command('python ../../iRODS/scripts/python/validate_json.py out.txt https://schemas.irods.org/configuration/v2/zone_bundle.json', 'STDOUT_MULTILINE', ['Validating', '... Success'], desired_rc=0) else: lib.assert_command('python ../../iRODS/scripts/python/validate_json.py out.txt https://schemas.irods.org/configuration/v2/zone_bundle.json', 'STDERR_SINGLELINE', 'jsonschema not installed', desired_rc=0) # cleanup os.remove('out.txt')
def test_empty_files(self): # set up filename = "some_test_file.txt" filepath = lib.create_local_testfile(filename) emptyfile = "emptyfile.txt" lib.assert_command("touch "+emptyfile) # test it self.admin.assert_icommand("iput "+emptyfile) self.admin.assert_icommand("iput -f "+filepath+" "+emptyfile) self.admin.assert_icommand("ils -L "+" "+emptyfile,"STDOUT_MULTILINE",[" 0 demoResc;cacheResc 63 ", " 1 demoResc;archiveResc 63 "]) os.remove(filepath) os.remove(emptyfile)
def test_pause_and_resume(self): lib.assert_command('irods-grid pause --all', 'STDOUT_SINGLELINE', 'pausing') # need a time-out assert icommand for ils here lib.assert_command('irods-grid resume --all', 'STDOUT_SINGLELINE', 'resuming') # Make sure server is actually responding lib.assert_command('ils', 'STDOUT_SINGLELINE', lib.get_service_account_environment_file_contents()['irods_zone_name']) lib.assert_command('irods-grid status --all', 'STDOUT_SINGLELINE', 'hosts')
def test_pause_and_resume(self): # test pause lib.assert_command('irods-grid pause --all', 'STDOUT_SINGLELINE', 'pausing') # need a time-out assert icommand for ils here # resume the server lib.assert_command('irods-grid resume --all', 'STDOUT_SINGLELINE', 'resuming') # Make sure server is actually responding lib.assert_command('ils', 'STDOUT_SINGLELINE', lib.get_service_account_environment_file_contents()['irods_zone_name']) lib.assert_command('irods-grid status --all', 'STDOUT_SINGLELINE', 'hosts')
def test_configuration_schema_validation_from_file(self): schemas_git_dir = tempfile.mkdtemp(prefix='irods-test_configuration_schema_validation_from_file-git') with lib.directory_deleter(schemas_git_dir): schemas_repo = 'https://github.com/irods/irods_schema_configuration' lib.run_command(['git', 'clone', schemas_repo, schemas_git_dir]) schemas_branch = 'v3' lib.run_command(['git', 'checkout', schemas_branch], cwd=schemas_git_dir) schemas_deploy_dir = tempfile.mkdtemp(prefix='irods-test_configuration_schema_validation_from_file-schemas') with lib.directory_deleter(schemas_deploy_dir): lib.assert_command(['python', os.path.join(schemas_git_dir, 'deploy_schemas_locally.py'), '--output_directory_base', schemas_deploy_dir]) with lib.file_backed_up(os.path.join(lib.get_irods_config_dir(), 'server_config.json')) as server_config_filename: with open(server_config_filename) as f: server_config = json.load(f) server_config['schema_validation_base_uri'] = 'file://' + schemas_deploy_dir lib.update_json_file_from_dict(server_config_filename, server_config) irodsctl_fullpath = os.path.join(lib.get_irods_top_level_dir(), 'iRODS', 'irodsctl') if lib.is_jsonschema_installed(): expected_lines = ['Validating [{0}]... Success'.format(os.path.expanduser('~/.irods/irods_environment.json')), 'Validating [{0}/server_config.json]... Success'.format(lib.get_irods_config_dir()), 'Validating [{0}/VERSION.json]... Success'.format(lib.get_irods_top_level_dir()), 'Validating [{0}/hosts_config.json]... Success'.format(lib.get_irods_config_dir()), 'Validating [{0}/host_access_control_config.json]... Success'.format(lib.get_irods_config_dir())] if not configuration.TOPOLOGY_FROM_RESOURCE_SERVER: expected_lines.append('Validating [{0}/database_config.json]... Success'.format(lib.get_irods_config_dir())) lib.assert_command([irodsctl_fullpath, 'restart'], 'STDOUT_MULTILINE', expected_lines) else: lib.assert_command([irodsctl_fullpath, 'restart'], 'STDERR_SINGLELINE', 'jsonschema not installed', desired_rc=0)
def test_irsync_checksum_behavior(self): # set user0's checksum scheme to MD5 to mismatch with server scheme user0_env_backup = copy.deepcopy(self.user0.environment_file_contents) self.user0.environment_file_contents['irods_default_hash_scheme'] = 'MD5' self.user0.environment_file_contents['irods_match_hash_policy'] = 'compatible' # test settings depth = 1 files_per_level = 5 file_size = 1024*1024*40 # make local nested dirs base_name = 'test_irsync_checksum_behavior' local_dir = os.path.join(self.testing_tmp_dir, base_name) local_dirs = lib.make_deep_local_tmp_dir(local_dir, depth, files_per_level, file_size) # sync dir to coll self.user0.assert_icommand("irsync -r -K {local_dir} i:{base_name}".format(**locals()), "EMPTY") self.user0.assert_icommand("ils -L {base_name}".format(**locals()), "STDOUT_SINGLELINE", "ec8bb3b24d5b0f1b5bdf8c8f0f541ee6") self.user0.assert_icommand("ichksum -r -K {base_name}".format(**locals()), "STDOUT_SINGLELINE", "Total checksum performed = 5, Failed checksum = 0") self.user0.assert_icommand("irsync -v -r -K -l {local_dir} i:{base_name}".format(**locals()), "STDOUT_SINGLELINE", "junk0001 39.999 MB --- a match no sync required") self.user0.assert_icommand("irm -f {base_name}/junk0001".format(**locals()), "EMPTY") self.user0.assert_icommand_fail("ils -L {base_name}".format(**locals()), "STDOUT_SINGLELINE", "junk0001") self.user0.assert_icommand("irsync -v -r -K -l {local_dir} i:{base_name}".format(**locals()), "STDOUT_SINGLELINE", "junk0001 41943040 N") self.user0.assert_icommand("irsync -v -r -K {local_dir} i:{base_name}".format(**locals()), "STDOUT_SINGLELINE", "junk0001 39.999 MB ") self.user0.assert_icommand("irsync -v -r -K -l {local_dir} i:{base_name}".format(**locals()), "STDOUT_SINGLELINE", "junk0001 39.999 MB --- a match no sync required") lib.assert_command("rm -f {local_dir}/junk0001".format(**locals()), "EMPTY") self.user0.assert_icommand("irsync -v -r -K -l i:{base_name} {local_dir}".format(**locals()), "STDOUT_SINGLELINE", "junk0001 41943040 N") self.user0.assert_icommand("irsync -v -r -K i:{base_name} {local_dir}".format(**locals()), "STDOUT_SINGLELINE", "junk0001 39.999 MB ") self.user0.assert_icommand("irsync -v -r -K -l i:{base_name} {local_dir}".format(**locals()), "STDOUT_SINGLELINE", "junk0001 39.999 MB --- a match no sync required") self.user0.environment_file_contents = user0_env_backup
def test_configuration_schema_validation_from_file(self): schemas_git_dir = tempfile.mkdtemp( prefix='irods-test_configuration_schema_validation_from_file-git') with lib.directory_deleter(schemas_git_dir): schemas_repo = 'https://github.com/irods/irods_schema_configuration' lib.run_command(['git', 'clone', schemas_repo, schemas_git_dir]) schemas_branch = 'v3' lib.run_command(['git', 'checkout', schemas_branch], cwd=schemas_git_dir) schemas_deploy_dir = tempfile.mkdtemp( prefix= 'irods-test_configuration_schema_validation_from_file-schemas') with lib.directory_deleter(schemas_deploy_dir): lib.assert_command([ 'python', os.path.join(schemas_git_dir, 'deploy_schemas_locally.py'), '--output_directory_base', schemas_deploy_dir ]) with lib.file_backed_up( os.path.join( lib.get_irods_config_dir(), 'server_config.json')) as server_config_filename: with open(server_config_filename) as f: server_config = json.load(f) server_config[ 'schema_validation_base_uri'] = 'file://' + schemas_deploy_dir lib.update_json_file_from_dict(server_config_filename, server_config) irodsctl_fullpath = os.path.join( lib.get_irods_top_level_dir(), 'iRODS', 'irodsctl') if lib.is_jsonschema_installed(): expected_lines = [ 'Validating [/var/lib/irods/.irods/irods_environment.json]... Success', 'Validating [/etc/irods/server_config.json]... Success', 'Validating [/var/lib/irods/VERSION.json]... Success', 'Validating [/etc/irods/hosts_config.json]... Success', 'Validating [/etc/irods/host_access_control_config.json]... Success' ] if not configuration.TOPOLOGY_FROM_RESOURCE_SERVER: expected_lines.append( 'Validating [/etc/irods/database_config.json]... Success' ) lib.assert_command([irodsctl_fullpath, 'restart'], 'STDOUT_MULTILINE', expected_lines) else: lib.assert_command([irodsctl_fullpath, 'restart'], 'STDERR_SINGLELINE', 'jsonschema not installed', desired_rc=0)
def tearDown(self): lib.assert_command(['fusermount', '-uz', self.mount_point]) shutil.rmtree(self.mount_point) super(Test_Fuse, self).tearDown()
def test_re_shm_cleanup(self): irodsctl_fullpath = os.path.join(lib.get_irods_top_level_dir(), 'iRODS', 'irodsctl') lib.assert_command([irodsctl_fullpath, 'stop'], 'STDOUT_SINGLELINE', 'Stopping iRODS server') assert not lib.re_shm_exists(), lib.re_shm_exists() lib.start_irods_server()
def test_status(self): # test grid status lib.assert_command('irods-grid status --all', 'STDOUT_SINGLELINE', 'hosts')
def test_shutdown_local_server(self): initial_size_of_server_log = lib.get_log_size('server') lib.assert_command(['irods-grid', 'shutdown', '--hosts', lib.get_hostname()], 'STDOUT_SINGLELINE', 'shutting down') time.sleep(10) # server gives control plane the all-clear before printing done message assert 1 == lib.count_occurrences_of_string_in_log('server', 'iRODS Server is done', initial_size_of_server_log) lib.start_irods_server()
def test_hosts_separator(self): for s in [',', ', ']: hosts_string = s.join([lib.get_hostname()]*2) lib.assert_command(['irods-grid', 'status', '--hosts', hosts_string], 'STDOUT_SINGLELINE', lib.get_hostname())
def test_hosts_separator(self): for s in [',', ', ']: hosts_string = s.join([lib.get_hostname()] * 2) lib.assert_command( ['irods-grid', 'status', '--hosts', hosts_string], 'STDOUT_SINGLELINE', lib.get_hostname())
def tearDown(self): lib.assert_command(['fusermount', '-uz', self.mount_point]) shutil.rmtree(self.mount_point) super(Test_Fuse, self).tearDown()
def test_status(self): # test grid status lib.assert_command('irods-grid status --all', 'STDOUT_SINGLELINE', 'hosts')
def assert_icommand(self, *args, **kwargs): self._prepare_run_icommand(args[0], kwargs) lib.assert_command(*args, **kwargs)