diff --git a/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/simple-dataset-creation/plugin.properties b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/simple-dataset-creation/plugin.properties new file mode 100644 index 0000000000000000000000000000000000000000..da29aae62e9b7df1320644dbb44fc836e08469db --- /dev/null +++ b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/simple-dataset-creation/plugin.properties @@ -0,0 +1,6 @@ +incoming-dir = ${root-dir}/incoming-simple-dataset-test +incoming-dir-create = true +incoming-data-completeness-condition = auto-detection +top-level-data-set-handler = ch.systemsx.cisd.etlserver.registrator.api.v2.JythonTopLevelDataSetHandlerV2 +script-path = script.py +storage-processor = ch.systemsx.cisd.etlserver.DefaultStorageProcessor \ No newline at end of file diff --git a/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/simple-dataset-creation/script.py b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/simple-dataset-creation/script.py new file mode 100644 index 0000000000000000000000000000000000000000..beb015c2ead18681730fecbba56d940115692a49 --- /dev/null +++ b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/simple-dataset-creation/script.py @@ -0,0 +1,4 @@ +def process(transaction): + data = transaction.createNewDataSet("UNKNOWN", transaction.getIncoming().getName()) + data.setExperiment(transaction.getExperiment("/CISD/NEMO/EXP1")) + transaction.moveFile(transaction.getIncoming().getPath(), data) \ No newline at end of file diff --git a/datastore_server/sourceTest/java/ch/ethz/sis/openbis/generic/dss/systemtest/api/v3/SearchFileTest.java b/datastore_server/sourceTest/java/ch/ethz/sis/openbis/generic/dss/systemtest/api/v3/SearchFileTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2e615d74414ac4d09a6a8ecfdab7d6b63dbf33fe --- /dev/null +++ b/datastore_server/sourceTest/java/ch/ethz/sis/openbis/generic/dss/systemtest/api/v3/SearchFileTest.java @@ -0,0 +1,59 @@ +package ch.ethz.sis.openbis.generic.dss.systemtest.api.v3; + +import java.io.File; +import java.util.List; +import java.util.UUID; + +import org.testng.annotations.Test; + +import ch.ethz.sis.openbis.generic.dss.api.v3.IDataStoreServerApi; +import ch.ethz.sis.openbis.generic.dss.api.v3.dto.entity.datasetfile.DataSetFile; +import ch.ethz.sis.openbis.generic.dss.api.v3.dto.search.FileSearchCriterion; +import ch.systemsx.cisd.common.filesystem.FileUtilities; +import ch.systemsx.cisd.common.test.AssertionUtil; +import ch.systemsx.cisd.openbis.datastoreserver.systemtests.SystemTestCase; +import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; + +public class SearchFileTest extends SystemTestCase +{ + + @Override + protected File getIncomingDirectory() + { + return new File(rootDir, "incoming-simple-dataset-test"); + } + + @Override + protected int dataSetImportWaitDurationInSeconds() + { + return 280; + } + + @Test + public void allFilesOfGivenDatasetsAreReturned() throws Exception + { + IDataStoreServerApi dss = (IDataStoreServerApi) ServiceProvider.getDssServiceV3().getService(); + + String dataSetCode = UUID.randomUUID().toString().toUpperCase(); + + File dataSetDir = new File(workingDirectory, dataSetCode); + dataSetDir.mkdirs(); + FileUtilities.writeToFile(new File(dataSetDir, "file1.txt"), "hello world"); + FileUtilities.writeToFile(new File(dataSetDir, "file2.txt"), "hello world"); + moveFileToIncoming(dataSetDir); + waitUntilDataSetImported(); + waitUntilIndexUpdaterIsIdle(); + waitUntilDataSetPostRegistrationCompleted(dataSetCode); + + IGeneralInformationService generalInformationService = ServiceProvider.getGeneralInformationService(); + String sessionToken = generalInformationService.tryToAuthenticateForAllServices("test", "test"); + + FileSearchCriterion sc = new FileSearchCriterion(); + sc.withDataSet().withPermId().thatEquals(dataSetCode); + + List<DataSetFile> searchFiles = dss.searchFiles(sessionToken, sc); + AssertionUtil.assertSize(searchFiles, 1); + } + +} diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/SystemTestCase.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/SystemTestCase.java index 0194a4df49a3579a0f2f4948995000b2aa3916dc..75ad83ec4b183b7660568f8d4fb3ea9c25115d66 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/SystemTestCase.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/SystemTestCase.java @@ -34,7 +34,6 @@ import java.util.regex.Pattern; import org.apache.commons.io.FileUtils; import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Server; @@ -92,6 +91,8 @@ public abstract class SystemTestCase extends AssertJUnit private static final String DATA_SET_IMPORTED_LOG_MARKER = "Successfully registered data set"; + private static final String POST_REGISTRATION_COMPLETE_MARKER = "markSuccessfulPostRegistration"; + public static final ILogMonitoringStopCondition FINISHED_POST_REGISTRATION_CONDITION = new RegexCondition( ".*Post registration of (\\d*). of \\1 data sets: (.*)"); @@ -257,6 +258,26 @@ public abstract class SystemTestCase extends AssertJUnit return new File(workingDirectory, "log-registrations"); } + protected void waitUntilDataSetPostRegistrationCompleted(final String dataSetCode) throws Exception + { + waitUntilDataSetImported(new ILogMonitoringStopCondition() + { + @Override + public boolean stopConditionFulfilled(ParsedLogEntry logEntry) + { + String logMessage = logEntry.getLogMessage(); + return logMessage.contains(POST_REGISTRATION_COMPLETE_MARKER) && logMessage.contains(dataSetCode); + } + + @Override + public String toString() + { + return "Log message contains '" + POST_REGISTRATION_COMPLETE_MARKER + + "' and '" + dataSetCode + "'"; + } + }); + } + protected void waitUntilDataSetImported() throws Exception { waitUntilDataSetImported(new ILogMonitoringStopCondition() diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/dss/api/v3/dto/search/FileSearchCriterion.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/dss/api/v3/dto/search/FileSearchCriterion.java index aa0ecf3055cb4dfb967cadad695f21c0bf752dbc..8bffdd7572f2020fabe32b67899096135f7a9a06 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/dss/api/v3/dto/search/FileSearchCriterion.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/dss/api/v3/dto/search/FileSearchCriterion.java @@ -18,6 +18,7 @@ package ch.ethz.sis.openbis.generic.dss.api.v3.dto.search; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.search.AbstractCompositeSearchCriterion; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.search.DataSetSearchCriterion; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.search.SearchCriterionToStringBuilder; /** * @author jakubs @@ -30,4 +31,13 @@ public class FileSearchCriterion extends AbstractCompositeSearchCriterion { return with(new DataSetSearchCriterion()); } + + @Override + protected SearchCriterionToStringBuilder createBuilder() + { + SearchCriterionToStringBuilder builder = super.createBuilder(); + builder.setName("FILE"); + return builder; + } + }