Skip to content

Commit 35254fe

Browse files
committed
review changes nr. 4
1 parent 7f8b62e commit 35254fe

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

indexing_utilities.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ namespace irods {
249249

250250

251251
class path_format_error: public std::runtime_error {
252-
public:
253-
path_format_error(const std::string & s) : std::runtime_error(s.c_str()) {}
252+
public:
253+
path_format_error(const std::string & s) : std::runtime_error(s.c_str()) {}
254254
};
255255

256256
template <typename T>

packaging/test_plugin_indexing.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ def test_coll_name():
788788
def test_indexing_permissions__81(self):
789789
with session.make_session_for_existing_admin() as admin_session,\
790790
indexing_plugin__installed(indexing_config = {'minimum_delay_time':'1', 'maximum_delay_time':'3'}):
791-
List_Active_Task_IDs = lambda : self.active_task_ids(admin_session,self)
791+
# - Define collections to be used for test.
792792
path_to_home = '/{0.zone_name}/home/{0.username}'.format(admin_session)
793793
test_path = path_to_home + "/" + self.test_coll_name()
794794
# STRUCTURE: (HOME)-->test_dir/
@@ -802,11 +802,15 @@ def test_indexing_permissions__81(self):
802802
data_1 = sub_path1 + "/data1"
803803
data_2 = sub_path2 + "/data2"
804804
data_3 = sub_path3 + "/data3"
805+
# - Define another index.
805806
INDEX_2 = DEFAULT_METADATA_INDEX+"_2"
806807
try:
808+
807809
# use two indices, to test that multiple index indicators are respected in recursive (-r) ichmod
808810
create_metadata_index(DEFAULT_METADATA_INDEX)
809811
create_metadata_index(INDEX_2)
812+
813+
# - Set up a test environment.
810814
objects = [
811815
('create', ['-C',{'path':test_path, 'delete_tree_when_done': True }]),
812816
('create', ['-C',{'path':sub_path1 }]), #--> for ichmod user0 without '-r', on data_1 object only
@@ -821,33 +825,43 @@ def test_indexing_permissions__81(self):
821825
('sleep_for', ['',{'seconds':5}]),
822826
('wait_for', [self.delay_queue_is_empty, {'num_iter':45,'interval':2.125,'threshold':2}]),
823827
]
828+
829+
# - Enact test environment.
824830
with self.logical_filesystem_for_indexing (objects,admin_session):
831+
832+
# - Convenience functions.
825833
expected_condition = lambda string: (operator.ge,1) if string != 'null' else (operator.eq,0)
826834
num_hits_multiplier = lambda string: 1 if string != 'null' else 0
827835

828-
for R_perm,W_perm in [('read','write'),('null','null')]: # Test once for setting ACLs and once for enulling them.
836+
# - On first pass, add ACLs; on the second, enull them. Index and test each time.
837+
838+
for R_perm,W_perm in [('read','write'),('null','null')]:
829839

830840
hits_ = ([],[],[])
831841

842+
# - Non-recursive ichmod and wait for results.
832843
admin_session.assert_icommand('ichmod {0} {1} {2}'.format(R_perm,self.user0.username,data_1))
833844
rep_result_0 = repeat_until(*expected_condition(R_perm), transform=make_number_of_hits_fcn(hits_[0])
834845
) (search_index_for_userPermissions_user_name) (DEFAULT_METADATA_INDEX,self.user0.username)
835846

847+
# - Recursive ichmod and wait for results.
836848
admin_session.assert_icommand('ichmod -r {0} {1} {2}'.format(W_perm,self.user1.username,sub_path2))
837849
rep_result_1 = repeat_until(*expected_condition(W_perm), transform=make_number_of_hits_fcn(hits_[1])
838850
) (search_index_for_userPermissions_user_name) (INDEX_2,self.user1.username)
839851
rep_result_2 = repeat_until(*expected_condition(W_perm), transform=make_number_of_hits_fcn(hits_[2])
840852
) (search_index_for_userPermissions_user_name) (DEFAULT_METADATA_INDEX,self.user1.username)
841853

842-
self.assertTrue(all([rep_result_0, rep_result_1, rep_result_2])) # Assert all conditions waited on were met.
854+
# - Assert all conditions waited on were met.
855+
self.assertTrue(all([rep_result_0, rep_result_1, rep_result_2]))
843856

857+
# - Assert the expected number of index hits.
844858
nhits = lambda array,user: len(list(filter((lambda _:any(e for e in _['_source']['userPermissions'] if e['user'] == user)),
845859
array[0]['hits']['hits'] )))
846-
847860
self.assertEqual( num_hits_multiplier(R_perm)*1, nhits(hits_[0], self.user0.username) )
848861
self.assertEqual( num_hits_multiplier(W_perm)*4, nhits(hits_[1], self.user1.username) )
849862
self.assertEqual( num_hits_multiplier(W_perm)*2, nhits(hits_[2], self.user1.username) )
850863
finally:
864+
# - Clean up
851865
delete_metadata_index(DEFAULT_METADATA_INDEX)
852866
delete_metadata_index(INDEX_2)
853867

0 commit comments

Comments
 (0)