Skip to content
Snippets Groups Projects
Commit 780c9fb9 authored by anttil's avatar anttil
Browse files

SSDM-1813: First test for searching files

SVN: 34281
parent f384020f
No related branches found
No related tags found
No related merge requests found
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
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
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);
}
}
......@@ -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()
......
......@@ -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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment