Skip to content

Commit

Permalink
Fix more tests that launch ClusterStartup (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-jeckels authored Feb 15, 2024
1 parent 187b6f0 commit 4d522e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 33 deletions.
19 changes: 18 additions & 1 deletion SequenceAnalysis/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.labkey.gradle.plugin.TeamCity
import org.labkey.gradle.plugin.extension.ServerDeployExtension
import org.labkey.gradle.plugin.extension.TeamCityExtension
import org.labkey.gradle.task.DoThenSetup
import org.labkey.gradle.util.BuildUtils
import org.labkey.gradle.util.GroupNames
import org.labkey.gradle.util.PropertiesUtils
Expand Down Expand Up @@ -174,6 +175,7 @@ dependencies {
if (project.findProject(BuildUtils.getTestProjectPath(project.gradle)) != null && project.hasProperty("teamcity"))
{
project.evaluationDependsOn(BuildUtils.getTestProjectPath(project.gradle))
def configDir = "${ServerDeployExtension.getServerDeployDirectory(project)}/config"
def testProject = project.findProject(BuildUtils.getTestProjectPath(project.gradle))
def createPipelineConfigTask = project.tasks.register("createPipelineConfig", Copy) {
Copy task ->
Expand All @@ -193,10 +195,25 @@ if (project.findProject(BuildUtils.getTestProjectPath(project.gradle)) != null &
return newLine

})
task.destinationDir = new File("${ServerDeployExtension.getServerDeployDirectory(project)}/config")
task.destinationDir = new File(configDir)

if (BuildUtils.useEmbeddedTomcat(project)) {
task.doFirst {
new File(new File(BuildUtils.getEmbeddedConfigPath(project)), "application.properties") << "\n${configDir}"
}

rootProject.allprojects {
task.mustRunAfter tasks.withType(DoThenSetup)
}
}
}
testProject.tasks.named("startTomcat").configure {
dependsOn(createPipelineConfigTask)
if (BuildUtils.useEmbeddedTomcat(project)) {
it.doFirst {
new File(new File(BuildUtils.getEmbeddedConfigPath(project)), "application.properties") << "\ncontext.pipelineConfig=${configDir}"
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.jetbrains.annotations.Nullable;
import org.json.JSONObject;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.labkey.api.module.ModuleLoader;
import org.labkey.api.pipeline.PipelineJob;
import org.labkey.api.pipeline.PipelineJobService;
import org.labkey.api.pipeline.PipelineService;
import org.labkey.api.pipeline.TaskId;
import org.labkey.api.pipeline.WorkDirectory;
import org.labkey.api.reader.Readers;
Expand All @@ -25,7 +24,6 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import static org.labkey.api.sequenceanalysis.pipeline.SequencePipelineService.SEQUENCE_TOOLS_PARAM;
Expand Down Expand Up @@ -202,35 +200,7 @@ public void RunBwaRemote() throws Exception

protected void executeJobRemote(File workDir, @Nullable File jobJson) throws IOException
{
List<String> args = new ArrayList<>();
args.add(System.getProperty("java.home") + "/bin/java" + (SystemUtils.IS_OS_WINDOWS ? ".exe" : ""));

File labkeyBootstrap = new File(System.getProperty("catalina.home"), "lib/labkeyBootstrap.jar");
if (!labkeyBootstrap.exists())
{
throw new IOException("Unable to find labkeyBootstrap.jar, expected: " + labkeyBootstrap.getPath());
}

args.add("-cp");
args.add(labkeyBootstrap.getPath());
args.add("org.labkey.bootstrap.ClusterBootstrap");

File webappDir = new File(ModuleLoader.getServletContext().getRealPath(""));
if (!webappDir.exists())
{
throw new IOException("Unable to find webappdir, expected: " + webappDir.getPath());
}

for (String sysProp : new String[]{"labkey.externalModulesDir", "labkey.modulesDir", "cpas.modulesDir"})
{
String sysPropValue = StringUtils.trimToNull(System.getProperty(sysProp));
if (sysPropValue != null)
{
args.add("-D" + sysProp +"=" + sysPropValue);
}
}

args.add("-webappdir=" + webappDir.getPath());
List<String> args = PipelineService.get().getClusterStartupArguments();

File configDir = setupConfigDir(workDir);
args.add("-configdir=" + configDir.getPath());
Expand Down

0 comments on commit 4d522e6

Please sign in to comment.