Skip to content

Commit

Permalink
[DICE-UNC#472] Fix replica truncate tests for iRODS 4.3.3.
Browse files Browse the repository at this point in the history
iRODS 4.3.2's implementation of rx_replica_truncate contained a bug that
caused it not return JSON as often as it should. The details of the
issue can be found here:

    irods/irods#7918

This commit adjusts the tests so that they work with iRODS 4.3.2 and
iRODS 4.3.3.
  • Loading branch information
korydraughn committed Aug 27, 2024
1 parent 448f63a commit 0f6e86b
Showing 1 changed file with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5076,14 +5076,23 @@ public void testReplicaTruncateNoTargetReplica() throws Exception {
// Truncate the data object to "hello".
String truncatedContent = content.substring(0, 5);
String json = dao.truncateReplica(logicalPath, truncatedContent.length());
Assert.assertNull(json);
final String expectedJson = "{\"message\":\"\",\"replica_number\":0,\"resource_hierarchy\":\"test1-resc\"}";
if (aof.getIRODSServerProperties(irodsAccount).isAtLeastIrods433()) {
Assert.assertTrue(expectedJson.equals(json));
} else {
Assert.assertNull(json);
}
stat = dao.getObjectStatForAbsolutePath(logicalPath);
Assert.assertEquals(stat.getObjSize(), truncatedContent.length());

// Truncate the data object to a size of 50 bytes.
final long newDataSize = 50;
json = dao.truncateReplica(logicalPath, newDataSize);
Assert.assertNull(json);
if (aof.getIRODSServerProperties(irodsAccount).isAtLeastIrods433()) {
Assert.assertTrue(expectedJson.equals(json));
} else {
Assert.assertNull(json);
}
stat = dao.getObjectStatForAbsolutePath(logicalPath);
Assert.assertEquals(stat.getObjSize(), newDataSize);
}
Expand Down Expand Up @@ -5132,14 +5141,23 @@ public void testReplicaTruncateUsingReplicaNumber() throws Exception {
String truncatedContent = content.substring(0, 5);
final int replicaNumber = 1;
String json = dao.truncateReplicaByReplicaNumber(logicalPath, replicaNumber, truncatedContent.length());
Assert.assertNull(json);
final String expectedJson = "{\"message\":\"\",\"replica_number\":1,\"resource_hierarchy\":\"testReplicaTruncateUsingReplicaNumber\"}";
if (aof.getIRODSServerProperties(irodsAccount).isAtLeastIrods433()) {
Assert.assertTrue(expectedJson.equals(json));
} else {
Assert.assertNull(json);
}
stat = dao.getObjectStatForAbsolutePath(logicalPath);
Assert.assertEquals(stat.getObjSize(), truncatedContent.length());

// Truncate the data object to a size of 50 bytes.
final long newDataSize = 50;
json = dao.truncateReplicaByReplicaNumber(logicalPath, replicaNumber, newDataSize);
Assert.assertNull(json);
if (aof.getIRODSServerProperties(irodsAccount).isAtLeastIrods433()) {
Assert.assertTrue(expectedJson.equals(json));
} else {
Assert.assertNull(json);
}
stat = dao.getObjectStatForAbsolutePath(logicalPath);
Assert.assertEquals(stat.getObjSize(), newDataSize);
}
Expand Down Expand Up @@ -5195,14 +5213,23 @@ public void testReplicaTruncateUsingResourceName() throws Exception {
// Truncate the data object to "hello".
String truncatedContent = content.substring(0, 5);
String json = dao.truncateReplicaByResource(logicalPath, resc.getName(), truncatedContent.length());
Assert.assertNull(json);
final String expectedJson = "{\"message\":\"\",\"replica_number\":1,\"resource_hierarchy\":\"testReplicaTruncateUsingResourceName\"}";
if (aof.getIRODSServerProperties(irodsAccount).isAtLeastIrods433()) {
Assert.assertTrue(expectedJson.equals(json));
} else {
Assert.assertNull(json);
}
stat = dao.getObjectStatForAbsolutePath(logicalPath);
Assert.assertEquals(stat.getObjSize(), truncatedContent.length());

// Truncate the data object to a size of 50 bytes.
final long newDataSize = 50;
json = dao.truncateReplicaByResource(logicalPath, resc.getName(), newDataSize);
Assert.assertNull(json);
if (aof.getIRODSServerProperties(irodsAccount).isAtLeastIrods433()) {
Assert.assertTrue(expectedJson.equals(json));
} else {
Assert.assertNull(json);
}
stat = dao.getObjectStatForAbsolutePath(logicalPath);
Assert.assertEquals(stat.getObjSize(), newDataSize);
}
Expand Down

0 comments on commit 0f6e86b

Please sign in to comment.