Skip to content

Commit

Permalink
[?] Make python test suite restart server in test mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
korydraughn committed Oct 25, 2024
1 parent 80df3ee commit 9e17e30
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 69 deletions.
8 changes: 4 additions & 4 deletions scripts/irods/test/test_all_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def test_writeLine_config_last_3477(self):
irods_config.server_config['plugin_configuration']['rule_engines'] = orig
irods_config.commit(irods_config.server_config, irods_config.server_config_path, make_backup=True)

IrodsController().start()
IrodsController().start(test_mode=True)

@unittest.skip('Delete this line upon resolving #3957')
@unittest.skipIf(plugin_name == 'irods_rule_engine_plugin-irods_rule_language', 'only applicable for python REP')
Expand Down Expand Up @@ -460,7 +460,7 @@ def test_writeLine_config_first_3477(self):
irods_config.server_config['plugin_configuration']['rule_engines'] = orig
irods_config.commit(irods_config.server_config, irods_config.server_config_path, make_backup=True)

IrodsController().start()
IrodsController().start(test_mode=True)


@unittest.skipUnless(plugin_name == 'irods_rule_engine_plugin-irods_rule_language', 'only applicable for irods_rule_language REP')
Expand Down Expand Up @@ -1272,7 +1272,7 @@ def test_rename_local_zone__issue_5693(self):

# Restart the server. This is done so that the delay server does not fill
# the log with errors due having incorrect zone information.
IrodsController().restart()
IrodsController().restart(test_mode=True)

# Update the rods session with the new zone information so that icommands succeed.
with open(config.client_environment_path, 'r') as f:
Expand All @@ -1293,7 +1293,7 @@ def test_rename_local_zone__issue_5693(self):
finally:
# Restart the server. This is done so that the delay server does not fill
# the log file with errors due having incorrect zone information.
IrodsController().restart()
IrodsController().restart(test_mode=True)

# Update the rods session with the original zone information so that icommands succeed.
with open(config.client_environment_path, 'r') as f:
Expand Down
18 changes: 9 additions & 9 deletions scripts/irods/test/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_authentication_PAM_without_negotiation(self):
self.auth_session.environment_file_contents.update(client_update)

# server reboot to pick up new irodsEnv settings
IrodsController().start()
IrodsController().start(test_mode=True)

# do the reauth
self.auth_session.assert_icommand('iinit', 'STDOUT', 'Enter your current PAM password',
Expand All @@ -105,7 +105,7 @@ def test_authentication_PAM_without_negotiation(self):
os.unlink(filename)

# server reboot to pick up new irodsEnv and server settings
IrodsController().restart()
IrodsController().restart(test_mode=True)

@unittest.skipIf(test.settings.TOPOLOGY_FROM_RESOURCE_SERVER or test.settings.USE_SSL, 'Topo from resource or SSL')
def test_authentication_PAM_with_server_params(self):
Expand All @@ -118,7 +118,7 @@ def test_authentication_PAM_with_server_params(self):
lib.execute_command(['openssl', 'req', '-batch', '-new', '-x509', '-key', server_key_path, '-out', chain_pem_path, '-days', '365'])
lib.execute_command(['openssl', 'dhparam', '-2', '-out', dhparams_pem_path, str(numbits)])

IrodsController().stop()
IrodsController().stop(test_mode=True)

service_account_environment_file_path = os.path.join(os.path.expanduser('~'), '.irods', 'irods_environment.json')
auth_session_env_backup = copy.deepcopy(self.auth_session.environment_file_contents)
Expand Down Expand Up @@ -175,7 +175,7 @@ def acPreConnect(rule_args, callback, rei):
with temporary_core_file() as core:
core.add_rule(pep_map[self.plugin_name])

IrodsController().start()
IrodsController().start(test_mode=True)

# the test
print(f'running iinit for PAM user [{self.auth_session.username}] [{self.auth_session.password}]')
Expand All @@ -190,7 +190,7 @@ def acPreConnect(rule_args, callback, rei):
if os.path.exists(filename):
os.unlink(filename)

IrodsController().restart()
IrodsController().restart(test_mode=True)

def test_iinit_repaving_2646(self):
l = logging.getLogger(__name__)
Expand Down Expand Up @@ -224,10 +224,10 @@ def test_denylist(self):
}
lib.update_json_file_from_dict(paths.server_config_path(), server_config_update)

IrodsController().start()
IrodsController().start(test_mode=True)
self.user_sessions[0].assert_icommand( 'ils', 'STDERR_SINGLELINE', 'SYS_USER_NOT_ALLOWED_TO_CONN' )
self.user_sessions[1].assert_icommand( 'ils', 'STDOUT_SINGLELINE', '/home' )
IrodsController().restart()
IrodsController().restart(test_mode=True)

def test_allowlist(self):
IrodsController().stop()
Expand All @@ -247,10 +247,10 @@ def test_allowlist(self):
}
lib.update_json_file_from_dict(paths.server_config_path(), server_config_update)

IrodsController().start()
IrodsController().start(test_mode=True)
self.user_sessions[0].assert_icommand( 'ils', 'STDOUT_SINGLELINE', '/home' )
self.user_sessions[1].assert_icommand( 'ils', 'STDERR_SINGLELINE', 'SYS_USER_NOT_ALLOWED_TO_CONN' )
IrodsController().restart()
IrodsController().restart(test_mode=True)


class test_iinit(session.make_sessions_mixin([('otherrods', 'rods')], []), unittest.TestCase):
Expand Down
10 changes: 5 additions & 5 deletions scripts/irods/test/test_iadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ def acAclPolicy(rule_args, callback, rei):
core.add_rule(pep_map[self.plugin_name])

# restart the server to reread the new core.re
IrodsController().restart()
IrodsController().restart(test_mode=True)

self.admin.assert_icommand("ils", 'STDOUT_SINGLELINE', self.admin.zone_name)

Expand All @@ -1295,7 +1295,7 @@ def test_server_config_environment_variables(self):
irods_config.commit(server_config, irods_config.server_config_path)

# bounce the server to get the new env variable
IrodsController().restart()
IrodsController().restart(test_mode=True)

# look for the error "unable to read session variable $userNameClient."
cmd_directory = os.path.join(irods_config.irods_directory, 'msiExecCmd_bin')
Expand All @@ -1307,7 +1307,7 @@ def test_server_config_environment_variables(self):
'writeLine("stdout", "*out")\' null ruleExecOut'.format(os.path.basename(env_script.name)),
'STDOUT_SINGLELINE', the_value)
os.unlink(env_script.name)
IrodsController().restart()
IrodsController().restart(test_mode=True)

def test_set_resource_comment_to_emptystring_ticket_2434(self):
mycomment = "notemptystring"
Expand Down Expand Up @@ -1394,7 +1394,7 @@ def test_impostor_resource_debug_logging(self):
}
}
lib.update_json_file_from_dict(server_config_filename, server_config_update)
IrodsController().restart()
IrodsController().restart(test_mode=True)

name_of_bogus_resource = 'name_of_bogus_resource'
name_of_missing_plugin = 'name_of_missing_plugin'
Expand All @@ -1411,7 +1411,7 @@ def test_impostor_resource_debug_logging(self):
start_index=initial_size_of_server_log))

self.admin.assert_icommand(['iadmin', 'rmresc', name_of_bogus_resource])
IrodsController().restart()
IrodsController().restart(test_mode=True)

@unittest.skipIf(True, "Activate once fixed issue#3387")
def test_dlopen_failure_error_message(self):
Expand Down
8 changes: 4 additions & 4 deletions scripts/irods/test/test_icommands_file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def pep_resource_create_post(rule_args,callback,rei):
initial_size_of_server_log = lib.get_file_size_by_path(paths.server_log_path())
with temporary_core_file() as core:
core.add_rule(pep_map[self.plugin_name])
IrodsController().start()
IrodsController().start(test_mode=True)
with tempfile.NamedTemporaryFile(prefix='test_re_serialization__prep_13') as f:
lib.make_file(f.name, 80, contents='arbitrary')
self.admin.assert_icommand(['iput', f.name])
Expand Down Expand Up @@ -102,7 +102,7 @@ def pep_api_data_obj_put_post(rule_args,callback,rei):
initial_size_of_server_log = lib.get_file_size_by_path(paths.server_log_path())
with temporary_core_file() as core:
core.add_rule(pep_map[self.plugin_name])
IrodsController().start()
IrodsController().start(test_mode=True)
with tempfile.NamedTemporaryFile(prefix='test_re_serialization__prep_55') as f:
lib.make_file(f.name, 80, contents='arbitrary')
self.admin.assert_icommand(['iput', f.name])
Expand Down Expand Up @@ -253,7 +253,7 @@ def test_iput_r_with_kw(self):
start_index=initial_size_of_server_log))

finally:
IrodsController().restart()
IrodsController().restart(test_mode=True)

@unittest.skipIf(test.settings.TOPOLOGY_FROM_RESOURCE_SERVER, "Skip for topology testing from resource server")
class Test_ICommands_File_Operations_2(resource_suite.ResourceBase, shared_functions, unittest.TestCase):
Expand Down Expand Up @@ -679,7 +679,7 @@ def irods_server_stopped():
try:
yield
finally:
control.start()
control.start(test_mode=True)
with irods_server_stopped():
self.admin.assert_icommand(['ils'], 'STDERR_SINGLELINE', 'Connection refused')

Expand Down
2 changes: 1 addition & 1 deletion scripts/irods/test/test_iphymv.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def test_exit_code_when_connection_fails(self):
self.assertEqual(2, rc)

finally:
IrodsController().start()
IrodsController().start(test_mode=True)

@unittest.skipIf(test.settings.TOPOLOGY_FROM_RESOURCE_SERVER, 'Delete on resolution of #5690')
def test_exit_code_for_authentication_failure(self):
Expand Down
4 changes: 2 additions & 2 deletions scripts/irods/test/test_irodsctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_re_shm_cleanup(self):
irodsctl_fullpath = os.path.join(IrodsConfig().irods_directory, 'irodsctl')
assert_command([irodsctl_fullpath, 'stop', '-v'], 'STDOUT_SINGLELINE', 'Stopping iRODS server')
assert not lib.re_shm_exists(), lib.re_shm_exists()
IrodsController().start()
IrodsController().start(test_mode=True)

def test_configuration_schema_validation_from_file(self):
with lib.file_backed_up(IrodsConfig().server_config_path) as server_config_filename:
Expand Down Expand Up @@ -115,7 +115,7 @@ def test_agents_kept_alive_by_connected_clients_are_cleaned_up_after_failed_grac

finally:
# Restart the server.
IrodsController().restart()
IrodsController().restart(test_mode=True)

# Set the replica to stale (it will be in the intermediate status - this is not a bug) and remove.
admin_session.run_icommand(
Expand Down
6 changes: 3 additions & 3 deletions scripts/irods/test/test_log_levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_log_sql__issue_3865(self):
initial_log_size = lib.get_file_size_by_path(IrodsConfig().server_log_path)

# Restart with spLogSql not set in the environment
IrodsController().restart()
IrodsController().restart(test_mode=True)

# There should be no LOG_SQL lines in the log at this point. None.
lib.delayAssert(
Expand All @@ -46,10 +46,10 @@ def test_log_sql__issue_3865(self):
env['spLogSql'] = '1'

# Restart with spLogSql set in the environment
IrodsController(IrodsConfig(injected_environment=env)).restart()
IrodsController(IrodsConfig(injected_environment=env)).restart(test_mode=True)

# Restart with spLogSql not set in the environment
IrodsController().restart()
IrodsController().restart(test_mode=True)

# There should be more than 20 LOG_SQL lines in the log at this point.
lib.delayAssert(
Expand Down
4 changes: 2 additions & 2 deletions scripts/irods/test/test_native_rule_engine_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,13 @@ def pep_network_agent_start_post(rule_args, callback, rei):
f.write(new_server_config)

# Bounce server to apply setting
irodsctl.restart()
irodsctl.restart(test_mode=True)

# Actually run the test
self.helper_test_pep(pep_map[self.plugin_name], "iput -f --metadata ATTR;VALUE;UNIT "+self.testfile)

# Bounce server to get back original settings
irodsctl.restart()
irodsctl.restart(test_mode=True)

def test_auth_pep(self):
pep_map = {
Expand Down
26 changes: 13 additions & 13 deletions scripts/irods/test/test_pam_password_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def do_test_invalid_password_time_configurations(self, _option_name):
with temporary_core_file() as core:
core.add_rule(test_configurations.get_pep_for_ssl(self.plugin_name))

IrodsController().start()
IrodsController().start(test_mode=True)

# Make sure the settings applied correctly...
self.admin.assert_icommand(
Expand All @@ -154,7 +154,7 @@ def do_test_invalid_password_time_configurations(self, _option_name):
self.auth_session.environment_file_contents = auth_session_env_backup
self.admin.environment_file_contents = admin_session_env_backup

IrodsController().restart()
IrodsController().restart(test_mode=True)

self.admin.assert_icommand(
['iadmin', 'set_grid_configuration', self.configuration_namespace, _option_name, original_config])
Expand Down Expand Up @@ -197,7 +197,7 @@ def test_password_max_time_less_than_password_min_time_makes_ttl_constraints_uns
with temporary_core_file() as core:
core.add_rule(test_configurations.get_pep_for_ssl(self.plugin_name))

IrodsController().start()
IrodsController().start(test_mode=True)

# Make sure the settings applied correctly...
self.admin.assert_icommand(
Expand Down Expand Up @@ -253,14 +253,14 @@ def test_password_max_time_less_than_password_min_time_makes_ttl_constraints_uns
self.auth_session.environment_file_contents = auth_session_env_backup
self.admin.environment_file_contents = admin_session_env_backup

IrodsController().restart()
IrodsController().restart(test_mode=True)

self.admin.assert_icommand(
['iadmin', 'set_grid_configuration', self.configuration_namespace, max_time_option_name, original_max_time])
self.admin.assert_icommand(
['iadmin', 'set_grid_configuration', self.configuration_namespace, min_time_option_name, original_min_time])

IrodsController().restart()
IrodsController().restart(test_mode=True)

def test_password_expires_appropriately_based_on_grid_configuration_value(self):
import time
Expand Down Expand Up @@ -296,7 +296,7 @@ def test_password_expires_appropriately_based_on_grid_configuration_value(self):
with temporary_core_file() as core:
core.add_rule(test_configurations.get_pep_for_ssl(self.plugin_name))

IrodsController().start()
IrodsController().start(test_mode=True)

# Make sure the settings applied correctly...
self.admin.assert_icommand(
Expand Down Expand Up @@ -341,7 +341,7 @@ def test_password_expires_appropriately_based_on_grid_configuration_value(self):
self.auth_session.environment_file_contents = auth_session_env_backup
self.admin.environment_file_contents = admin_session_env_backup

IrodsController().restart()
IrodsController().restart(test_mode=True)

self.admin.assert_icommand(
['iadmin', 'set_grid_configuration', self.configuration_namespace, max_time_option_name, original_max_time])
Expand Down Expand Up @@ -400,7 +400,7 @@ def test_password_extend_lifetime_set_to_true_extends_other_authentications_past
with temporary_core_file() as core:
core.add_rule(test_configurations.get_pep_for_ssl(self.plugin_name))

IrodsController().start()
IrodsController().start(test_mode=True)

# Make sure the settings applied correctly...
self.admin.assert_icommand(
Expand Down Expand Up @@ -460,7 +460,7 @@ def test_password_extend_lifetime_set_to_true_extends_other_authentications_past
self.auth_session.environment_file_contents = auth_session_env_backup
self.admin.environment_file_contents = admin_session_env_backup

IrodsController().restart()
IrodsController().restart(test_mode=True)

self.admin.assert_icommand(
['iadmin', 'set_grid_configuration', self.configuration_namespace, extend_lifetime_option_name, original_extend_lifetime])
Expand Down Expand Up @@ -519,7 +519,7 @@ def test_password_extend_lifetime_set_to_false_invalidates_other_authentications
with temporary_core_file() as core:
core.add_rule(test_configurations.get_pep_for_ssl(self.plugin_name))

IrodsController().start()
IrodsController().start(test_mode=True)

# Make sure the settings applied correctly...
self.admin.assert_icommand(
Expand Down Expand Up @@ -582,7 +582,7 @@ def test_password_extend_lifetime_set_to_false_invalidates_other_authentications
self.auth_session.environment_file_contents = auth_session_env_backup
self.admin.environment_file_contents = admin_session_env_backup

IrodsController().restart()
IrodsController().restart(test_mode=True)

self.admin.assert_icommand(
['iadmin', 'set_grid_configuration', self.configuration_namespace, extend_lifetime_option_name, original_extend_lifetime])
Expand Down Expand Up @@ -624,7 +624,7 @@ def test_password_max_time_can_exceed_1209600__issue_3742_5096(self):
with temporary_core_file() as core:
core.add_rule(test_configurations.get_pep_for_ssl(self.plugin_name))

IrodsController().start()
IrodsController().start(test_mode=True)

# The test value is 2 hours more than the default in order to try a TTL value 1 greater and 1 less
# than the configured password_max_time while still remaining above 1209600 to show that there is
Expand Down Expand Up @@ -663,7 +663,7 @@ def test_password_max_time_can_exceed_1209600__issue_3742_5096(self):
self.auth_session.environment_file_contents = auth_session_env_backup
self.admin.environment_file_contents = admin_session_env_backup

IrodsController().restart()
IrodsController().restart(test_mode=True)

self.admin.assert_icommand(
['iadmin', 'set_grid_configuration', self.configuration_namespace, max_time_option_name, original_max_time])
Loading

0 comments on commit 9e17e30

Please sign in to comment.