Skip to content
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
2 changes: 1 addition & 1 deletion src/org/labkey/test/LabKeySiteWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ public void waitForPipelineJobsToComplete(final int finishedJobsExpected, final
* @param timeoutMilliseconds Maximum time to wait for pipeline jobs to finish (default 10 minutes)
*/
@LogMethod
public void waitForPipelineJobsToComplete(@LoggedParam final int finishedJobsExpected, @LoggedParam final String description, final boolean expectError, int timeoutMilliseconds)
public void waitForPipelineJobsToComplete(@LoggedParam final int finishedJobsExpected, @LoggedParam final String description, final boolean expectError, long timeoutMilliseconds)
{
final List<String> statusValues = waitForPipelineJobsToFinish(finishedJobsExpected, Duration.ofMillis(timeoutMilliseconds));

Expand Down
7 changes: 6 additions & 1 deletion src/org/labkey/test/TestCredentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ public static File getCredentialsFile()
{
if (null == credentialsFile)
{
setCredentialsFile(new File(System.getProperty("test.credentials.file", TestFileUtils.getTestRoot() + "/test.credentials.json")));
String credentialsFileLocation = System.getProperty("test.credentials.file");
if (credentialsFileLocation == null || credentialsFileLocation.isEmpty())
{
credentialsFileLocation = TestFileUtils.getTestRoot() + "/test.credentials.json";
}
setCredentialsFile(new File(credentialsFileLocation));
}
return credentialsFile;
}
Expand Down
85 changes: 31 additions & 54 deletions src/org/labkey/test/TestFileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.bouncycastle.openpgp.operator.jcajce.JcePBEDataDecryptorFactoryBuilder;
import org.bouncycastle.util.io.Streams;
import org.jetbrains.annotations.NotNull;
import org.labkey.api.util.FileUtil;
import org.jetbrains.annotations.Nullable;
import org.openqa.selenium.NotFoundException;

Expand Down Expand Up @@ -97,7 +98,7 @@ public abstract class TestFileUtils

public static String getFileContents(String rootRelativePath)
{
return getFileContents(Paths.get(getLabKeyRoot(), rootRelativePath));
return getFileContents(getLabKeyRoot().toPath().resolve(rootRelativePath));
}

public static String getFileContents(final File file)
Expand Down Expand Up @@ -137,7 +138,7 @@ public static String getStreamContentsAsString(InputStream is) throws IOExceptio
return StringUtils.join(IOUtils.readLines(is, Charset.defaultCharset()).toArray(), System.lineSeparator());
}

public static String getLabKeyRoot()
public static File getLabKeyRoot()
{
if (_labkeyRoot == null)
{
Expand All @@ -151,7 +152,7 @@ public static String getLabKeyRoot()
{
throw new IllegalStateException("Specified LabKey root does not exist [" + _labkeyRoot + "]. Configure this by passing VM arg labkey.root={yourroot}");
}
if (!new File(_labkeyRoot, "server").exists())
if (!FileUtil.appendName(_labkeyRoot, "server").exists())
{
throw new IllegalStateException("Specified LabKey root exists [" + _labkeyRoot + "] but isn't the root of a LabKey enlistment. Configure this by passing VM arg labkey.root={yourroot}");
}
Expand All @@ -167,25 +168,25 @@ public static String getLabKeyRoot()
_labkeyRoot = _labkeyRoot.getParentFile().getParentFile(); // Working directory is in '{labkey.root}/server'; otherwise is in enlistment root
else if (_labkeyRoot.getName().equals("server"))
_labkeyRoot = _labkeyRoot.getParentFile(); // Working directory is in '{labkey.root}/server'; otherwise is in enlistment root
else if (!new File(_labkeyRoot, "server").exists())
else if (!FileUtil.appendName(_labkeyRoot, "server").exists())
{
throw new IllegalStateException("Unable to locate enlistment. Working directory [" + _labkeyRoot + "] isn't a recognized location. Configure manually with passing VM arg labkey.root={yourroot}");
}
}
}
return _labkeyRoot.toString();
return _labkeyRoot;
}

public static File getServerLogDir()
{
return new File(getDefaultDeployDir(), "embedded/logs");
return FileUtil.appendName(FileUtil.appendName(getDefaultDeployDir(), "embedded"), "logs");
}

public static File getTestRoot()
{
if (_testRoot == null)
{
_testRoot = new File(getLabKeyRoot(), "server/testAutomation");
_testRoot = FileUtil.appendName(FileUtil.appendName(getLabKeyRoot(), "server"), "testAutomation");
}
return _testRoot;
}
Expand All @@ -199,20 +200,20 @@ public static File getTestBuildDir()
{
if (_buildDir == null)
{
_buildDir = new File(getLabKeyRoot(), "build/modules/" + getTestProjectName()); // Gradle
_buildDir = FileUtil.appendPath(getLabKeyRoot(), org.labkey.api.util.Path.parse("build/modules/" + getTestProjectName())); // Gradle
}
return _buildDir;
}

public static File getBaseFileRoot()
{
// Files are a sibling of the modules directory
return new File(getModulesDir().getParentFile(), "files");
return FileUtil.appendName(getModulesDir().getParentFile(), "files");
}

public static File getGradleReportDir()
{
return new File(getTestBuildDir(), "test/logs/reports");
return FileUtil.appendPath(getTestBuildDir(), org.labkey.api.util.Path.parse("test/logs/reports"));
}

/**
Expand All @@ -221,35 +222,35 @@ public static File getGradleReportDir()
*/
static File getDefaultDeployDir()
{
return new File(getLabKeyRoot(), "build/deploy");
return FileUtil.appendPath(getLabKeyRoot(), org.labkey.api.util.Path.parse("build/deploy"));
}

public static File getModulesDir()
{
if (_modulesDir == null)
{
// Module root when deploying from embedded distribution
_modulesDir = new File(getDefaultDeployDir(), "embedded/modules");
_modulesDir = FileUtil.appendPath(getDefaultDeployDir(), org.labkey.api.util.Path.parse("embedded/modules"));
if (!_modulesDir.isDirectory())
{
_modulesDir = new File(getDefaultDeployDir(), "modules");
_modulesDir = FileUtil.appendName(getDefaultDeployDir(), "modules");
}
}
return _modulesDir;
}

public static File getDefaultFileRoot(String containerPath)
{
return new File(getBaseFileRoot(), containerPath + "/@files");
return FileUtil.appendPath(getBaseFileRoot(), org.labkey.api.util.Path.parse(containerPath + "/@files"));
}

public static String getDefaultWebAppRoot()
{
File path = new File(getModulesDir().getParentFile(), "labkeyWebapp");
File path = FileUtil.appendName(getModulesDir().getParentFile(), "labkeyWebapp");
if (!path.isDirectory())
{
// Casing is different when deployed from an embedded distribution
path = new File(getModulesDir().getParentFile(), "labkeywebapp");
path = FileUtil.appendName(getModulesDir().getParentFile(), "labkeywebapp");
}
return path.toString();
}
Expand Down Expand Up @@ -300,7 +301,7 @@ public static List<File> getSampleDatas(String relativePath)

for (File sampledataDir : sampledataDirs)
{
File checkFile = new File(sampledataDir, relativePath);
File checkFile = FileUtil.appendPath(sampledataDir, org.labkey.api.util.Path.parse(relativePath));
if (checkFile.exists())
{
foundFiles.add(checkFile);
Expand All @@ -317,16 +318,16 @@ public static Set<File> getSampleDataDirs()
{
_sampledataDirs = new TreeSet<>();

File sampledataDirsFile = new File(getTestBuildDir(), "sampledata.dirs");
File sampledataDirsFile = FileUtil.appendName(getTestBuildDir(), "sampledata.dirs");
if (sampledataDirsFile.exists())
{
String path = getFileContents(sampledataDirsFile);
_sampledataDirs.addAll(Arrays.stream(path.split(";")).map(File::new).toList());
}
else
{
_sampledataDirs.add(new File(getTestRoot(), "data"));
Path modulesDir = new File(getLabKeyRoot(), "server/modules").toPath();
_sampledataDirs.add(FileUtil.appendName(getTestRoot(), "data"));
Path modulesDir = FileUtil.appendPath(getLabKeyRoot(), org.labkey.api.util.Path.parse("server/modules")).toPath();
try
{
// We know where the modules live; no reason to insist that sampledata.dirs exists.
Expand Down Expand Up @@ -363,8 +364,8 @@ public static Set<File> getSampleDataDirs()

public static File getTestTempDir()
{
File buildDir = new File(getLabKeyRoot(), "build");
return new File(buildDir, "testTemp");
File buildDir = FileUtil.appendName(getLabKeyRoot(), "build");
return FileUtil.appendName(buildDir, "testTemp");
}

/**
Expand All @@ -378,7 +379,7 @@ public static File ensureTestTempDir(String... children) throws IOException
File file = getTestTempDir();
for (String child : children)
{
file = new File(file, child);
file = FileUtil.appendName(file, child);
}

FileUtils.forceMkdir(file);
Expand All @@ -398,7 +399,7 @@ public static File ensureTestTempFile(String... children) throws IOException

for (String child : children)
{
file = new File(file, child);
file = FileUtil.appendName(file, child);
}

if (file.toString().length() == getTestTempDir().toString().length())
Expand Down Expand Up @@ -448,7 +449,7 @@ private static void checkFileLocation(File file)
{
try
{
if (!FileUtils.directoryContains(new File(getLabKeyRoot()), file))
if (!FileUtils.directoryContains(getLabKeyRoot(), file))
{
// TODO: Consider throwing IllegalArgumentException
LOG.info("DEBUG: Attempting to delete a file outside of test enlistment: " + getLabKeyRoot());
Expand All @@ -457,30 +458,6 @@ private static void checkFileLocation(File file)
catch (IOException ignore) { }
}

/**
*
* @param dir Location to create new file
* @param fileName Name of file to be created
* @param contents Text contents of file
* @return File object pointing to new file
* @deprecated Use {@link #writeFile(File, String)} or {@link #writeTempFile(String, String)}
*/
@Deprecated
public static File saveFile(File dir, String fileName, String contents)
{
File tsvFile = new File(dir, fileName);

try
{
return writeFile(tsvFile, contents);
}
catch (IOException e)
{
e.printStackTrace(System.err);
return null;
}
}

/**
* Write text to a file in the test temp directory. Temp directory will be created if it does not exist.
* @param name Name of the file to be created. An existing file will be overwritten
Expand All @@ -490,7 +467,7 @@ public static File saveFile(File dir, String fileName, String contents)
*/
public static File writeTempFile(String name, InputStream contents) throws IOException
{
File file = new File(getTestTempDir(), name);
File file = FileUtil.appendPath(getTestTempDir(), org.labkey.api.util.Path.parse(name));
FileUtils.forceMkdirParent(file);

FileUtils.copyInputStreamToFile(contents, file);
Expand All @@ -506,7 +483,7 @@ public static File writeTempFile(String name, InputStream contents) throws IOExc
*/
public static File writeTempFile(String name, String contents) throws IOException
{
File file = new File(getTestTempDir(), name);
File file = FileUtil.appendPath(getTestTempDir(), org.labkey.api.util.Path.parse(name));
FileUtils.forceMkdirParent(file);

return writeFile(file, contents);
Expand Down Expand Up @@ -587,7 +564,7 @@ public static List<File> unzipToDirectory(File sourceZip, File unzipDir) throws

while (null != (entry = zis.getNextEntry()))
{
File destFile = new File(unzipDir, entry.getName());
File destFile = FileUtil.appendName(unzipDir, entry.getName());

if (!destFile.getCanonicalPath().startsWith(unzipDir.getCanonicalPath() + File.separator)) {
throw new IOException("Zip entry is outside of the target dir: " + entry.getName());
Expand Down Expand Up @@ -641,7 +618,7 @@ private static List<File> unTar(final File inputFile, final File outputDir) thro

while ((entry = inputStream.getNextEntry()) != null)
{
final File outputFile = new File(outputDir, entry.getName());
final File outputFile = FileUtil.appendPath(outputDir, org.labkey.api.util.Path.parse(entry.getName()));

if (!outputFile.toPath().normalize().startsWith(normalizedOutputPath))
throw new IOException("Bad zip entry (" + entry.getName() + ") in " + inputFile.getAbsolutePath());
Expand Down Expand Up @@ -675,7 +652,7 @@ private static List<File> unTar(final File inputFile, final File outputDir) thro
*/
private static File unGzip(final File inputFile, final File outputDir) throws IOException
{
final File outputFile = new File(outputDir, inputFile.getName().substring(0, inputFile.getName().length() - 3));
final File outputFile = FileUtil.appendName(outputDir, inputFile.getName().substring(0, inputFile.getName().length() - 3));

try (GZIPInputStream in = new GZIPInputStream(new FileInputStream(inputFile));
FileOutputStream out = new FileOutputStream(outputFile))
Expand Down
3 changes: 2 additions & 1 deletion src/org/labkey/test/components/assay/AssayConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public class AssayConstants
public static final Locator COMMENTS_FIELD_LOCATOR = Locator.name("Comments");
public static final Locator TARGET_STUDY_FIELD_LOCATOR = Locator.name(TARGET_STUDY_FIELD_NAME);
public static final Locator TEXT_AREA_DATA_PROVIDER_LOCATOR = Locator.xpath("//input[@value='textAreaDataProvider']");
public static final Locator TEXT_AREA_DATA_COLLECTOR_LOCATOR = Locator.textarea("TextAreaDataCollector.textArea");
public static final String TEXT_AREA_DATA_COLLECTOR_TEXT_AREA_NAME = "TextAreaDataCollector.textArea";
public static final Locator TEXT_AREA_DATA_COLLECTOR_LOCATOR = Locator.textarea(TEXT_AREA_DATA_COLLECTOR_TEXT_AREA_NAME);
}
2 changes: 1 addition & 1 deletion src/org/labkey/test/teamcity/TeamCityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static void publishArtifact(File file, @Nullable String destination)
{
if (file != null && file.exists())
{
String labkeyRoot = new File(TestFileUtils.getLabKeyRoot()).getAbsolutePath();
String labkeyRoot = TestFileUtils.getLabKeyRoot().getAbsolutePath();
String filePath = file.getAbsoluteFile().toPath().normalize().toString();
if (filePath.startsWith(labkeyRoot))
{
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/testpicker/TestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class TestHelper
public static final String DEFAULT_PORT = WebTestHelper.getWebPort().toString();
public static final String DEFAULT_CONTEXT_PATH = WebTestHelper.getContextPath();
public static final String DEFAULT_SERVER = WebTestHelper.getTargetServer();
public static final String DEFAULT_ROOT = TestFileUtils.getLabKeyRoot();
public static final String DEFAULT_ROOT = TestFileUtils.getLabKeyRoot().toString();

private static Thread awtThread = null;
private static final String _saveFileName = "savedConfigs.idx";
Expand Down
4 changes: 2 additions & 2 deletions src/org/labkey/test/tests/FileBasedPipelineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void testRCopyInlinePipeline()
goToModule("FileContent");
_fileBrowserHelper.uploadFile(SAMPLE_FILE);

final String jobDescription = "@files/sample (InlineRCopy)";
final String jobDescription = "sample (InlineRCopy)";

pipelineAnalysis.runPipelineAnalysis(importAction, targetFiles, protocolProperties, "Duplicate File(s)", true);
pipelineAnalysis.verifyPipelineAnalysis(pipelineName, protocolName, jobDescription, null, fileRoot, outputFiles);
Expand Down Expand Up @@ -239,7 +239,7 @@ public void testWithOutputLocation()
goToModule("FileContent");
_fileBrowserHelper.uploadFile(SAMPLE_FILE);

final String jobDescription = "@files/sample (with_output_location)";
final String jobDescription = "sample (with_output_location)";

pipelineAnalysis.runPipelineAnalysis(importAction, targetFiles, protocolProperties);
pipelineAnalysis.verifyPipelineAnalysis(pipelineName, protocolName, null, jobDescription, fileRoot, outputFiles);
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/tests/RlabkeyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void testRlabkeyPipelineApi() throws Exception
// verify the expected pipeline jobs where run and completed
goToProjectHome();
PipelineStatusTable pipelineStatusTable = goToDataPipeline();
assertEquals("COMPLETE", pipelineStatusTable.getJobStatus("@files/sample (Rlabkey RCopy Test 1) (sample.txt)"));
assertEquals("COMPLETE", pipelineStatusTable.getJobStatus("sample (Rlabkey RCopy Test 1) (sample.txt)"));
assertEquals("COMPLETE", pipelineStatusTable.getJobStatus("test pipe desc"));
}

Expand Down
3 changes: 2 additions & 1 deletion src/org/labkey/test/tests/SampleTypeRemoteAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.labkey.test.TestTimeoutException;
import org.labkey.test.categories.Daily;
import org.labkey.test.components.CustomizeView;
import org.labkey.test.components.assay.AssayConstants;
import org.labkey.test.components.domain.DomainFormPanel;
import org.labkey.test.pages.ReactAssayDesignerPage;
import org.labkey.test.pages.assay.AssayImportPage;
Expand Down Expand Up @@ -766,7 +767,7 @@ private void insertAssayData(String assayName, List<TestDataGenerator> dataGener
for(TestDataGenerator dataGen : dataGenerators)
{
AssayImportPage page = new AssayImportPage(getDriver())
.setNamedTextAreaValue("TextAreaDataCollector.textArea",
.setNamedTextAreaValue(AssayConstants.TEXT_AREA_DATA_COLLECTOR_TEXT_AREA_NAME,
dataGen.getDataAsTsv());
imported++;

Expand Down
Loading