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

Fixes for replica truncate tests #476

Merged
merged 2 commits into from
Aug 27, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,15 @@ public boolean isAtLeastIrods432() {
return isTheIrodsServerAtLeastAtTheGivenReleaseVersion("rods4.3.2");
}

/**
* Is the server at least iRODS 4.3.3
*
* @return {@code boolean}
*/
public boolean isAtLeastIrods433() {
return isTheIrodsServerAtLeastAtTheGivenReleaseVersion("rods4.3.3");
}

public IrodsVersion getIrodsVersion() {
return irodsVersion;
}
Expand Down
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
Loading