-
Notifications
You must be signed in to change notification settings - Fork 73
[#746] establish default order for replicas listed by an iRODSDataObject
#815
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
base: main
Are you sure you want to change the base?
Changes from all commits
b5bdf84
93dae32
ff2c8df
d229216
06c70d2
4f9e624
a9c4e99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1253,8 +1253,7 @@ | |
|
|
||
| # assertions on replicas | ||
| self.assertEqual(len(obj.replicas), number_of_replicas) | ||
| for i, replica in enumerate(obj.replicas): | ||
| self.assertEqual(replica.number, i) | ||
| self.assertEqual({repl.number for repl in obj.replicas}, {*range(len(obj.replicas))}) | ||
|
|
||
| # now trim odd-numbered replicas | ||
| # note (see irods/irods#4861): COPIES_KW might disappear in the future | ||
|
|
@@ -1267,10 +1266,7 @@ | |
| obj = session.data_objects.get(obj_path) | ||
|
|
||
| # check remaining replica numbers | ||
| replica_numbers = [] | ||
| for replica in obj.replicas: | ||
| replica_numbers.append(replica.number) | ||
| self.assertEqual(replica_numbers, [0, 2, 4, 6]) | ||
| self.assertEqual({r.number for r in obj.replicas}, {0, 2, 4, 6}) | ||
|
|
||
| # remove object | ||
| obj.unlink(force=True) | ||
|
|
@@ -1728,11 +1724,12 @@ | |
| self.assertIsNotNone(obj.replicas[1].__getattribute__(i)) | ||
|
|
||
| # ensure replica info is sensible | ||
| replicas = sorted(obj.replicas, key=lambda repl: repl.number) | ||
| for i in range(2): | ||
| self.assertEqual(obj.replicas[i].number, i) | ||
| self.assertEqual(obj.replicas[i].status, "1") | ||
| self.assertEqual(obj.replicas[i].path.split("/")[-1], filename) | ||
| self.assertEqual(obj.replicas[i].resc_hier.split(";")[-1], ufs_resources[i].name) | ||
| self.assertEqual(replicas[i].number, i) | ||
| self.assertEqual(replicas[i].status, "1") | ||
| self.assertEqual(replicas[i].path.split("/")[-1], filename) | ||
| self.assertEqual(replicas[i].resc_hier.split(";")[-1], ufs_resources[i].name) | ||
|
|
||
| self.assertEqual(obj.replicas[0].resource_name, ufs_resources[0].name) | ||
| if self.sess.server_version < (4, 2, 0): | ||
|
|
@@ -2992,6 +2989,36 @@ | |
|
|
||
| test_put__issue_722(self) | ||
|
|
||
| @unittest.skipIf(irods.version.version_as_tuple() < (4,), 'too soon for this test.') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider changing the message to something like the following. |
||
| def test_modified_default_sorting_of_replicas__issue_647(self): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like we need another test for the sorter option? Alternatively, you can change the behavior of the test such that it covers PRC 3 and PRC 4. For example: if irods.version.version_as_tuple() < (4,):
data = self.sess.data_objects.get(data.path, sorter=<fn>)
else:
data = self.sess.data_objects.get(data.path)Doing that implies the name of the test would need to change as well. |
||
| basename = unique_name(my_function_name(), datetime.now()) + '_dataobj_647' | ||
| with self.create_simple_resc() as newResc1, self.create_simple_resc() as newResc2: | ||
| data = helpers.make_object(self.sess, f'{helpers.home_collection(self.sess)}/{basename}') | ||
|
|
||
| # Precondition for an eventual total of 3 replicas: initial data replica is not on either of the new resources. | ||
| self.assertFalse({repl.resource_name for repl in data.replicas} & {newResc1, newResc2}) | ||
| try: | ||
| data.replicate(resource=newResc1) | ||
|
|
||
| # Ensure that one of the replicas is stale, to test proper sorting. | ||
| with data.open('a', **{kw.RESC_NAME_KW: newResc1}) as f: | ||
| f.write(b'.') | ||
| time.sleep(2) | ||
|
|
||
| # Voting should ensure exactly two good replicas of the three. | ||
| data.replicate(resource=newResc2) | ||
|
Comment on lines
+3003
to
+3009
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add an assertion which proves a replica is stale. |
||
|
|
||
| # refresh replicas | ||
| data = self.sess.data_objects.get(data.path) | ||
|
|
||
| # Test replica sorting. | ||
| self.assertEqual(data.replicas[0].status, '1') | ||
| self.assertEqual(data.replicas[0].modify_time, data.modify_time) | ||
| self.assertGreater(data.replicas[0].modify_time, data.replicas[1].modify_time) | ||
| finally: | ||
| if data: | ||
| data.unlink(force=True) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # let the tests find the parent irods lib | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only way to support this in a minor release is to provide an opt-in which changes the default behavior.