Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#222] Set ADMIN_KW when user applying metadata is a rodsadmin (main) #225

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion irods_consortium_continuous_integration_build_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def add_cmake_to_front_of_path():

def install_building_dependencies(externals_directory):
externals_list = [
'irods-externals-boost1.78.0-0',
'irods-externals-boost1.81.0-0',
'irods-externals-clang-runtime13.0.0-0',
'irods-externals-clang13.0.0-0',
'irods-externals-cmake3.21.4-0',
Expand Down
5 changes: 5 additions & 0 deletions libirods_rule_engine_plugin-unified_storage_tiering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ namespace {
const_cast<char*>(ts.c_str()),
""};

if (_comm->clientUser.authInfo.authFlag >= LOCAL_PRIV_USER_AUTH) {
addKeyVal(&avuOp.condInput, ADMIN_KW, "");
}

auto status = rsModAVUMetadata(_comm, &avuOp);
if(status < 0) {
THROW(
Expand Down Expand Up @@ -248,6 +252,7 @@ namespace {
auto it = _args.begin();
std::advance(it, 2);
if(_args.end() == it) {
rodsLog(LOG_ERROR, "%s:%d: Invalid number of arguments [PEP=%s].", __func__, __LINE__, _rn.c_str());
THROW(
SYS_INVALID_INPUT_PARAM,
"invalid number of arguments");
Expand Down
49 changes: 49 additions & 0 deletions packaging/test_plugin_unified_storage_tiering.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,55 @@ def test_single_quote_data_name__127(self):
finally:
alice_session.assert_icommand('irm -f ' + cmd_filename)

def test_storage_tiering_sets_admin_keyword_when_updating_access_time_as_rodsadmin__222(self):
with storage_tiering_configured():
IrodsController().restart(test_mode=True)

with session.make_session_for_existing_admin() as admin_session:
zone_name = IrodsConfig().client_environment['irods_zone_name']

with session.make_session_for_existing_user('alice', 'apass', lib.get_hostname(), zone_name) as alice_session:
resc_name = 'storage_tiering_ufs_222'
filename = 'test_file_issue_222'

try:
lib.create_local_testfile(filename)
alice_session.assert_icommand(f'iput -R rnd0 {filename}')
alice_session.assert_icommand(f'imeta ls -d {filename}', 'STDOUT_SINGLELINE', filename)
alice_session.assert_icommand(f'ils -L {filename}', 'STDOUT_SINGLELINE', filename)
sleep(5)

# test stage to tier 1.
invoke_storage_tiering_rule()
delay_assert_icommand(alice_session, f'ils -L {filename}', 'STDOUT_SINGLELINE', 'rnd1')

# test stage to tier 2.
sleep(15)
invoke_storage_tiering_rule()
delay_assert_icommand(alice_session, f'ils -L {filename}', 'STDOUT_SINGLELINE', 'rnd2')

# capture the access time.
_, out, _ = admin_session.assert_icommand(
['iquest', '%s', f"select META_DATA_ATTR_VALUE where DATA_NAME = '{filename}' and META_DATA_ATTR_NAME = 'irods::access_time'"], 'STDOUT')
access_time = out.strip()
self.assertGreater(len(access_time), 0)

# show the access time is updated correctly.
lib.create_ufs_resource(admin_session, resc_name)
admin_session.assert_icommand(f'irepl -M -R {resc_name} {alice_session.home_collection}/{filename}')

_, out, _ = admin_session.assert_icommand(
['iquest', '%s', f"select META_DATA_ATTR_VALUE where DATA_NAME = '{filename}' and META_DATA_ATTR_NAME = 'irods::access_time'"], 'STDOUT')
new_access_time = out.strip()
self.assertGreater(len(new_access_time), 0)

# this assertion is the primary focus of the test.
self.assertGreater(int(new_access_time), int(access_time))

finally:
alice_session.assert_icommand(f'irm -f {filename}')
admin_session.assert_icommand(f'iadmin rmresc {resc_name}')

class TestStorageTieringPluginMultiGroup(ResourceBase, unittest.TestCase):
def setUp(self):
super(TestStorageTieringPluginMultiGroup, self).setUp()
Expand Down