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

[#429] Send correct <option> value for StartupPack #430

Merged
merged 7 commits into from
Dec 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ RUN sed --in-place --regexp-extended "s/(\/\/)(archive\.ubuntu)/\1nl.\2/" /etc/a
RUN apt-get update && \
apt-get install -y sudo wget less lsb-release apt-transport-https netcat gnupg2

ARG irods_package_version=4.3.1-0~focal
RUN wget -qO - https://packages.irods.org/irods-signing-key.asc | apt-key add -; \
echo "deb [arch=amd64] https://packages.irods.org/apt/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/renci-irods.list; \
apt-get update && \
apt-get install -y irods-runtime irods-icommands irods-server
apt-get install -y \
irods-runtime=${irods_package_version} \
irods-icommands=${irods_package_version} \
irods-server=${irods_package_version}

EXPOSE 1247 1248

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ RUN apt-get update && \
ADD db_commands.txt /
RUN service postgresql start && su - postgres -c 'psql -f /db_commands.txt'

ARG irods_package_version=4.3.1-0~focal
RUN wget -qO - https://packages.irods.org/irods-signing-key.asc | apt-key add -; \
echo "deb [arch=amd64] https://packages.irods.org/apt/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/renci-irods.list; \
apt-get update && \
apt-get install -y irods-runtime irods-icommands irods-server irods-database-plugin-postgres
apt-get install -y \
irods-runtime=${irods_package_version} \
irods-icommands=${irods_package_version} \
irods-server=${irods_package_version} \
irods-database-plugin-postgres=${irods_package_version}

EXPOSE 1247 1248

Expand All @@ -29,5 +34,3 @@ ADD testsetup-consortium.sh /
RUN chmod +x /testsetup-consortium.sh
RUN chmod u+x /start_provider.sh
ENTRYPOINT ["./start_provider.sh"]


Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ services:
build:
context: .
dockerfile: Dockerfile.provider
args:
irods_package_version: 4.3.1-0~focal
hostname: icat.example.org
networks:
irodsnet:
aliases:
- icat.example.org
ports:
- "1247:1247"
#ports:
#- "1247:1247"
#- "5432:5432"
#- "20000-21999"

Expand All @@ -34,6 +36,8 @@ services:
build:
context: .
dockerfile: Dockerfile.consumer
args:
irods_package_version: 4.3.1-0~focal
hostname: resource1.example.org
networks:
irodsnet:
Expand All @@ -45,8 +49,3 @@ services:
networks:
irodsnet:
driver: bridge





Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ public boolean isSupportsCaseInsensitiveQueries() {
}
return supports;
}

/**
* Handy method used to detect the exact version of the connected iRODS server.
*
* @param releaseVersion {@code String} in standard iRODS version format that
* will be checked against the currently-connected server.
* @return {@code boolean} that will be {@code true} if the iRODS server is
* {@code releaseVersion}
*/
public boolean isVersion(final String releaseVersion) {
if (releaseVersion == null || releaseVersion.isEmpty()) {
throw new IllegalArgumentException("null or empty releaseVersion");
}

return getIrodsVersion().compareTo(new IrodsVersion(releaseVersion)) == 0;
}

/**
* Handy method compares the iRODS release version of the target server, and
Expand Down Expand Up @@ -241,6 +257,24 @@ public boolean isAtLeastIrods420() {
return isTheIrodsServerAtLeastAtTheGivenReleaseVersion("rods4.2.0");
}

/**
* Is the server at least iRODS 4.3.0
*
* @return {@code boolean}
*/
public boolean isAtLeastIrods430() {
return isTheIrodsServerAtLeastAtTheGivenReleaseVersion("rods4.3.0");
korydraughn marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Is the server at least iRODS 4.3.1
*
* @return {@code boolean}
*/
public boolean isAtLeastIrods431() {
return isTheIrodsServerAtLeastAtTheGivenReleaseVersion("rods4.3.1");
}

public IrodsVersion getIrodsVersion() {
return irodsVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ public class StartupPack extends AbstractIRODSPackingInstruction {
private final IRODSAccount irodsAccount;
private int reconnFlag = 0;
private int connectCnt = 0;
private String option = "";
// "jargon" is the default name when reporting through sp_option/spOption; allows jargon
// applications to report with a name through ips
private static String option = "jargon";
private static String appName = "jargon";
public static final String NEGOTIATE_OPTION = "request_server_negotiation";

public static String getApplicationName() {
return option;
return appName;
}

public static void setApplicationName(String name) {
if (null == name || name.trim().isEmpty()) { // name can't contain only spaces
throw new IllegalArgumentException("null or empty name");
}

option = name;
appName = name;
}

public StartupPack(final IRODSAccount irodsAccount) {
Expand All @@ -44,6 +45,7 @@ public StartupPack(final IRODSAccount irodsAccount, final boolean reconnect, fin
if (option == null) {
throw new IllegalArgumentException("null option");
}
this.option = appName + option;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,38 @@ public static FilePermissionEnum enumValueFromSpecificQueryTextPermission(final
return OWN;
}

if (textPermission.equals("read")) {
if (textPermission.equals("read") || textPermission.equals("read object")
|| textPermission.equals("read_object")) {
return READ;
}

if (textPermission.equals("read object")) {
return READ;
if (textPermission.equals("write") || textPermission.equals("modify object")
|| textPermission.equals("modify_object")) {
return WRITE;
}

if (textPermission.equals("write")) {
return WRITE;
if (textPermission.equals("create_metadata")) {
return CREATE_METADATA;
}

if (textPermission.equals("modify object")) {
return WRITE;
if (textPermission.equals("modify_metadata")) {
return MODIFY_METADATA;
}

if (textPermission.equals("delete_metadata")) {
return DELETE_METADATA;
}

if (textPermission.equals("create_object")) {
return CREATE_OBJECT;
}

if (textPermission.equals("delete_object")) {
return DELETE_OBJECT;
}

if (textPermission.equals("null")) {
return NULL;
}

if (textPermission.equals("none")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.irods.jargon.testutils.filemanip.ScratchFileUtils;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
Expand Down Expand Up @@ -236,6 +237,10 @@ public void testCreateBundleZip() throws Exception {

IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);

// Skip if iRODS 4.3.0.
Assume.assumeFalse("Bug in iRODS 4.3.0 discovered post release", irodsFileSystem
.getIRODSAccessObjectFactory().getIRODSServerProperties(irodsAccount).isVersion("rods4.3.0"));

IRODSFile irodsFile = null;

String targetBunIrodsCollection = testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties(
Expand Down Expand Up @@ -358,6 +363,9 @@ public void testExtractBundleNoOverwriteNoBulk() throws Exception {
return;
}

// Skip if iRODS 4.3.0.
Assume.assumeFalse("Bug in iRODS 4.3.0 discovered post release", props.isVersion("rods4.3.0"));

IRODSFile irodsFile = null;

String targetBunIrodsCollection = testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties(
Expand Down Expand Up @@ -481,6 +489,9 @@ public void testExtractBundleWithOverwriteNoBulkWhenTargetCollectionAlreadyExist
return;
}

// Skip if iRODS 4.3.0.
Assume.assumeFalse("Bug in iRODS 4.3.0 discovered post release", props.isVersion("rods4.3.0"));

IRODSFile irodsFile = null;

String targetBunIrodsCollection = testingPropertiesHelper.buildIRODSCollectionAbsolutePathFromTestProperties(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.irods.jargon.core.connection.IRODSAccount;
import org.irods.jargon.core.connection.IRODSServerProperties;
import org.irods.jargon.core.exception.CatalogSQLException;
import org.irods.jargon.core.exception.DataNotFoundException;
import org.irods.jargon.core.exception.DuplicateDataException;
import org.irods.jargon.core.exception.FileNotFoundException;
Expand All @@ -30,6 +31,7 @@
import org.irods.jargon.testutils.filemanip.FileGenerator;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
Expand Down Expand Up @@ -680,6 +682,10 @@ public void testBulkAddAvuMetadataWithDuplicate() throws Exception {

IRODSAccessObjectFactory accessObjectFactory = irodsFileSystem.getIRODSAccessObjectFactory();

// Skip if iRODS 4.3.0.
Assume.assumeFalse("iRODS 4.3.0 does not report an error on duplicate AVUs",
accessObjectFactory.getIRODSServerProperties(irodsAccount).isVersion("rods4.3.0"));

IRODSFileFactory irodsFileFactory = irodsFileSystem.getIRODSFileFactory(irodsAccount);

IRODSFile dirFile = irodsFileFactory.instanceIRODSFile(targetIrodsCollection);
Expand All @@ -690,32 +696,36 @@ public void testBulkAddAvuMetadataWithDuplicate() throws Exception {
List<AvuData> listOfAvuData = new ArrayList<AvuData>();

listOfAvuData.add(AvuData.instance(expectedAttribName, expectedAttribValue, ""));

listOfAvuData.add(AvuData.instance(expectedAttribName, expectedAttribValue, ""));

List<BulkAVUOperationResponse> responses = collectionAO.addBulkAVUMetadataToCollection(targetIrodsCollection,
listOfAvuData);
if (accessObjectFactory.getIRODSServerProperties(irodsAccount).isAtLeastIrods431()) {
Assert.assertThrows(CatalogSQLException.class,
() -> collectionAO.addBulkAVUMetadataToCollection(targetIrodsCollection, listOfAvuData));
} else {
List<BulkAVUOperationResponse> responses = collectionAO
.addBulkAVUMetadataToCollection(targetIrodsCollection, listOfAvuData);

List<AVUQueryElement> queryElements = new ArrayList<AVUQueryElement>();
List<AVUQueryElement> queryElements = new ArrayList<AVUQueryElement>();

queryElements.add(AVUQueryElement.instanceForValueQuery(AVUQueryElement.AVUQueryPart.ATTRIBUTE,
QueryConditionOperators.EQUAL, expectedAttribName));
queryElements.add(AVUQueryElement.instanceForValueQuery(AVUQueryElement.AVUQueryPart.ATTRIBUTE,
QueryConditionOperators.EQUAL, expectedAttribName));

queryElements.add(AVUQueryElement.instanceForValueQuery(AVUQueryElement.AVUQueryPart.VALUE,
QueryConditionOperators.EQUAL, expectedAttribValue));
queryElements.add(AVUQueryElement.instanceForValueQuery(AVUQueryElement.AVUQueryPart.VALUE,
QueryConditionOperators.EQUAL, expectedAttribValue));

List<MetaDataAndDomainData> result = collectionAO.findMetadataValuesByMetadataQuery(queryElements);
Assert.assertFalse("no query result returned", result.isEmpty());
List<MetaDataAndDomainData> result = collectionAO.findMetadataValuesByMetadataQuery(queryElements);
Assert.assertFalse("no query result returned", result.isEmpty());

Assert.assertNotNull("no responses", responses);
Assert.assertFalse("no responses", responses.isEmpty());
Assert.assertEquals("should be 2 responses", 2, responses.size());
Assert.assertEquals("not success", BulkAVUOperationResponse.ResultStatus.OK,
responses.get(0).getResultStatus());
Assert.assertNotNull("no responses", responses);
Assert.assertFalse("no responses", responses.isEmpty());
Assert.assertEquals("should be 2 responses", 2, responses.size());
Assert.assertEquals("not success", BulkAVUOperationResponse.ResultStatus.OK,
responses.get(0).getResultStatus());

Assert.assertEquals("did not get the duplicate message", BulkAVUOperationResponse.ResultStatus.DUPLICATE_AVU,
responses.get(1).getResultStatus());
Assert.assertFalse("did not set a message for the duplicate", responses.get(1).getMessage().isEmpty());
Assert.assertEquals("did not get the duplicate message",
BulkAVUOperationResponse.ResultStatus.DUPLICATE_AVU, responses.get(1).getResultStatus());
Assert.assertFalse("did not set a message for the duplicate", responses.get(1).getMessage().isEmpty());
}
}

@Test
Expand Down Expand Up @@ -821,6 +831,10 @@ public void testAddDuplicateAvuMetadata() throws Exception {

IRODSAccessObjectFactory accessObjectFactory = irodsFileSystem.getIRODSAccessObjectFactory();

// Skip if iRODS 4.3.0.
Assume.assumeFalse("iRODS 4.3.0 does not report an error on duplicate AVUs",
accessObjectFactory.getIRODSServerProperties(irodsAccount).isVersion("rods4.3.0"));

IRODSFileFactory irodsFileFactory = irodsFileSystem.getIRODSFileFactory(irodsAccount);

IRODSFile dirFile = irodsFileFactory.instanceIRODSFile(targetIrodsCollection);
Expand All @@ -830,15 +844,17 @@ public void testAddDuplicateAvuMetadata() throws Exception {

AvuData dataToAdd = AvuData.instance(expectedAttribName, expectedAttribValue, "");
collectionAO.addAVUMetadata(targetIrodsCollection, dataToAdd);
try {
collectionAO.addAVUMetadata(targetIrodsCollection, dataToAdd);
} catch (DuplicateDataException dde) {
// expected post 3.1, not a great test anymore...

if (accessObjectFactory.getIRODSServerProperties(irodsAccount).isAtLeastIrods431()) {
Assert.assertThrows(CatalogSQLException.class,
() -> collectionAO.addAVUMetadata(targetIrodsCollection, dataToAdd));
} else {
Assert.assertThrows(DuplicateDataException.class,
() -> collectionAO.addAVUMetadata(targetIrodsCollection, dataToAdd));
}

}

@Test(expected = DuplicateDataException.class)
public void testAddDuplicateAvuMetadataWithUnits() throws Exception {
String testDirName = "testAddDuplicateAvuMetadata";
String expectedAttribName = "testattrib1";
Expand All @@ -860,7 +876,14 @@ public void testAddDuplicateAvuMetadataWithUnits() throws Exception {

AvuData dataToAdd = AvuData.instance(expectedAttribName, expectedAttribValue, expectedUnitsValue);
collectionAO.addAVUMetadata(targetIrodsCollection, dataToAdd);
collectionAO.addAVUMetadata(targetIrodsCollection, dataToAdd);

if (accessObjectFactory.getIRODSServerProperties(irodsAccount).isAtLeastIrods430()) {
Assert.assertThrows(CatalogSQLException.class,
() -> collectionAO.addAVUMetadata(targetIrodsCollection, dataToAdd));
} else {
Assert.assertThrows(DuplicateDataException.class,
() -> collectionAO.addAVUMetadata(targetIrodsCollection, dataToAdd));
}

}

Expand Down
Loading
Loading