Skip to content

Commit e51d0fa

Browse files
korydraughnalanking
authored andcommitted
[#171] Adjust test for iRODS 5
This commit fixes a failing test in the following way: - Guarantees server config is reloaded on test completion - Reloads server config after modification - Checks the log for messages from an earlier starting point
1 parent c7a0ae6 commit e51d0fa

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

indexing/packaging/test_plugin_indexing.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def indexing_plugin__installed(indexing_config=(), server_env_options={}):
204204
]
205205
irods_config.commit(irods_config.server_config, irods_config.server_config_path)
206206
irods_config = IrodsConfig(**server_env_options)
207-
IrodsController(irods_config).restart()
207+
IrodsController(irods_config).reload_configuration()
208208
try:
209209
yield
210210
finally:
@@ -991,30 +991,34 @@ def test_load_parameters_as_int_or_string__91(self):
991991
cli_env['irods_log_level'] = 7
992992
new_client_env = json.dumps(cli_env, sort_keys=True, indent=4, separators=(',', ': '))
993993

994-
server_config_filename = paths.server_config_path()
995-
with open(server_config_filename) as f:
996-
svr_cfg = json.load(f)
997-
svr_cfg['log_level']['legacy'] = 'debug'
998-
new_server_config = json.dumps(svr_cfg, sort_keys=True, indent=4, separators=(',', ': '))
999-
1000-
with lib.file_backed_up(server_config_filename), lib.file_backed_up(env_filename):
1001-
with open(server_config_filename, 'w') as f:
1002-
f.write(new_server_config)
1003-
with open(env_filename, 'w') as f_env:
1004-
f_env.write(new_client_env)
1005-
config_0 = { 'minimum_delay_time': 20, 'maximum_delay_time': 25, 'job_limit_per_collection_indexing_operation': 2001 }
1006-
for test_config in [ config_0, # try once with integers ...
1007-
{k:str(v) for k,v in config_0.items()} ]: # and once with strings
1008-
with session.make_session_for_existing_admin() as ses:
1009-
with indexing_plugin__installed(indexing_config = test_config):
994+
try:
995+
server_config_filename = paths.server_config_path()
996+
with open(server_config_filename) as f:
997+
svr_cfg = json.load(f)
998+
svr_cfg['log_level']['legacy'] = 'debug'
999+
new_server_config = json.dumps(svr_cfg, sort_keys=True, indent=4, separators=(',', ': '))
1000+
1001+
with lib.file_backed_up(server_config_filename), lib.file_backed_up(env_filename):
1002+
with open(server_config_filename, 'w') as f:
1003+
f.write(new_server_config)
1004+
with open(env_filename, 'w') as f_env:
1005+
f_env.write(new_client_env)
1006+
config_0 = { 'minimum_delay_time': 20, 'maximum_delay_time': 25, 'job_limit_per_collection_indexing_operation': 2001 }
1007+
for test_config in [ config_0, # try once with integers ...
1008+
{k:str(v) for k,v in config_0.items()} ]: # and once with strings
1009+
with session.make_session_for_existing_admin() as ses:
10101010
log_offset = lib.get_file_size_by_path(paths.server_log_path())
1011-
ses.assert_icommand ('ils' , 'STDOUT');
1012-
lib.delayAssert(lambda : all(
1013-
1 <= lib.count_occurrences_of_string_in_log( log_path = paths.server_log_path(),
1014-
string = "value of {name}: {value}".format(**locals()),
1015-
start_index = log_offset)
1016-
for name, value in test_config.items()
1017-
))
1011+
with indexing_plugin__installed(indexing_config = test_config):
1012+
ses.assert_icommand ('ils' , 'STDOUT');
1013+
lib.delayAssert(lambda : all(
1014+
1 <= lib.count_occurrences_of_string_in_log( log_path = paths.server_log_path(),
1015+
string = "value of {name}: {value}".format(**locals()),
1016+
start_index = log_offset)
1017+
for name, value in test_config.items()
1018+
))
1019+
1020+
finally:
1021+
IrodsController().reload_configuration()
10181022

10191023
if __name__ == '__main__':
10201024
unittest.main()

0 commit comments

Comments
 (0)