Skip to content

Commit

Permalink
squash. More updates to tests for iRODS 5 changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
korydraughn committed Oct 29, 2024
1 parent c8776af commit 9332a70
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 28 deletions.
52 changes: 31 additions & 21 deletions scripts/irods/test/test_native_rule_engine_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,17 @@ def test_failing_on_code_5043 (self):
''')
}

with temporary_core_file() as core:
core.add_rule(pep_map[self.plugin_name])
with tempfile.NamedTemporaryFile(mode='w+t', suffix='.r') as rule_file:
print(rule_map[self.plugin_name], file = rule_file)
rule_file.flush()
self.admin.assert_icommand(['irule','-r', self.plugin_name + '-instance','-F',rule_file.name],
'STDOUT_SINGLELINE', ["true"])
try:
with temporary_core_file() as core:
core.add_rule(pep_map[self.plugin_name])
IrodsController().reload_configuration()
with tempfile.NamedTemporaryFile(mode='w+t', suffix='.r') as rule_file:
print(rule_map[self.plugin_name], file = rule_file)
rule_file.flush()
self.admin.assert_icommand(['irule','-r', self.plugin_name + '-instance','-F',rule_file.name],
'STDOUT_SINGLELINE', ["true"])
finally:
IrodsController().reload_configuration()


@unittest.skipIf(plugin_name == 'irods_rule_engine_plugin-python' or test.settings.TOPOLOGY_FROM_RESOURCE_SERVER, 'Native only test when not in a topology')
Expand Down Expand Up @@ -194,14 +198,17 @@ def test_error_smsi_5043 (self):
''')
}

with temporary_core_file() as core:
core.add_rule(pep_map[self.plugin_name])
try:
with temporary_core_file() as core:
core.add_rule(pep_map[self.plugin_name])
IrodsController().reload_configuration()
with tempfile.NamedTemporaryFile(mode='w+t', suffix='.r') as rule_file:
print(rule_map[self.plugin_name], file = rule_file)
rule_file.flush()
self.admin.assert_icommand(['irule','-F',rule_file.name], 'STDOUT_MULTILINE', ['SYS_INTERNAL_ERR = -154000',
'RULE_ENGINE_CONTINUE = 5000000'])
finally:
IrodsController().reload_configuration()
with tempfile.NamedTemporaryFile(mode='w+t', suffix='.r') as rule_file:
print(rule_map[self.plugin_name], file = rule_file)
rule_file.flush()
self.admin.assert_icommand(['irule','-F',rule_file.name], 'STDOUT_MULTILINE', ['SYS_INTERNAL_ERR = -154000',
'RULE_ENGINE_CONTINUE = 5000000'])

@unittest.skipIf(plugin_name == 'irods_rule_engine_plugin-python', 'Native only test when not in a topology')
@unittest.skipIf(test.settings.TOPOLOGY_FROM_RESOURCE_SERVER, 'Do not run in topology on resource server')
Expand Down Expand Up @@ -509,7 +516,6 @@ def pep_network_agent_start_post(rule_args, callback, rei):
''')
}

irodsctl = IrodsController()
server_config_filename = paths.server_config_path()

# load server_config.json to inject a new rule base
Expand All @@ -523,13 +529,17 @@ def pep_network_agent_start_post(rule_args, callback, rei):
# dump to a string to repave the existing server_config.json
new_server_config = json.dumps(svr_cfg, sort_keys=True, indent=4, separators=(',', ': '))

with lib.file_backed_up(server_config_filename):
# repave the existing server_config.json
with open(server_config_filename, 'w') as f:
f.write(new_server_config)
try:
with lib.file_backed_up(server_config_filename):
# repave the existing server_config.json
with open(server_config_filename, 'w') as f:
f.write(new_server_config)

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

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

def test_auth_pep(self):
pep_map = {
Expand Down
2 changes: 1 addition & 1 deletion scripts/irods/test/test_pam_password_authentication.py
Original file line number Diff line number Diff line change
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().reload_configuration()
IrodsController().start(test_mode=True)

# Make sure the settings applied correctly...
self.admin.assert_icommand(
Expand Down
6 changes: 3 additions & 3 deletions scripts/irods/test/test_resource_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ def test_detached_mode_host_not_in_host_list__issue_4421(self):
lib.make_file(file1, 100)

# put small file
self.admin.assert_icommand("iput -R %s %s" % (resource_name, file1), 'STDERR', 'USER_SOCK_CONNECT_ERR') # iput
self.admin.assert_icommand("iput -R %s %s" % (resource_name, file1), 'STDERR', 'USER_SOCK_CONNECT_TIMEDOUT') # iput
self.admin.assert_icommand("ils -L %s" % file1, 'STDERR_SINGLELINE', "does not exist") # should not be listed
finally:
if os.path.exists(file1):
Expand All @@ -812,7 +812,7 @@ def test_attached_mode_default_setting_invalid_host__issue_4421(self):
lib.make_file(file1, 100)

# put small file
self.admin.assert_icommand("iput -R %s %s" % (resource_name, file1), 'STDERR', 'USER_SOCK_CONNECT_ERR') # iput
self.admin.assert_icommand("iput -R %s %s" % (resource_name, file1), 'STDERR', 'USER_SOCK_CONNECT_TIMEDOUT') # iput
self.admin.assert_icommand("ils -L %s" % file1, 'STDERR_SINGLELINE', "does not exist") # should not be listed
finally:
if os.path.exists(file1):
Expand All @@ -836,7 +836,7 @@ def test_attached_mode_explicit_setting_invalid_host__issue_4421(self):
lib.make_file(file1, 100)

# put small file
self.admin.assert_icommand("iput -R %s %s" % (resource_name, file1), 'STDERR', 'USER_SOCK_CONNECT_ERR') # iput
self.admin.assert_icommand("iput -R %s %s" % (resource_name, file1), 'STDERR', 'USER_SOCK_CONNECT_TIMEDOUT') # iput
self.admin.assert_icommand("ils -L %s" % file1, 'STDERR_SINGLELINE', "does not exist") # should not be listed
finally:
if os.path.exists(file1):
Expand Down
7 changes: 4 additions & 3 deletions scripts/irods/test/test_rulebase.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,22 +305,23 @@ def test_rulebase_update__2585(self):
# repave the existing server_config.json
with open(server_config_filename, 'w') as f:
f.write(new_server_config)

IrodsController().reload_configuration()

# checkpoint log to know where to look for the string
initial_log_size = lib.get_file_size_by_path(paths.server_log_path())
self.admin.assert_icommand('irule -F ' + rule_file)
self.admin.assert_icommand('irule -r irods_rule_engine_plugin-irods_rule_language-instance -F ' + rule_file)

lib.delayAssert(lambda: lib.count_occurrences_of_string_in_log(paths.server_log_path(), 'TEST_STRING_TO_FIND_1_2585', start_index=initial_log_size))

# repave rule with new string
os.unlink(test_re)
with open(test_re, 'wt') as f:
print(rules[2], file=f, end='')
IrodsController().reload_configuration()

# checkpoint log to know where to look for the string
initial_log_size = lib.get_file_size_by_path(paths.server_log_path())
self.admin.assert_icommand('irule -F ' + rule_file)
self.admin.assert_icommand('irule -r irods_rule_engine_plugin-irods_rule_language-instance -F ' + rule_file)
lib.delayAssert(lambda: lib.count_occurrences_of_string_in_log(paths.server_log_path(), 'TEST_STRING_TO_FIND_2_2585', start_index=initial_log_size))

finally:
Expand Down

0 comments on commit 9332a70

Please sign in to comment.