diff --git a/.github/workflows/integration_test.yaml b/.github/workflows/integration_test.yaml new file mode 100644 index 00000000..e69de29b diff --git a/pom.xml b/pom.xml index 38e4ca0f..1f8e2c5d 100644 --- a/pom.xml +++ b/pom.xml @@ -176,4 +176,33 @@ Universidad Carlos III de Madrid. + + + integration-tests + + + env.CI + true + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + integration-test + + integration-test + verify + + + + + + + + + diff --git a/src/test/java/TestRunEveryFramework.java b/src/integration-test/java/TestRunEveryFramework.java similarity index 74% rename from src/test/java/TestRunEveryFramework.java rename to src/integration-test/java/TestRunEveryFramework.java index e51f883c..f05e5e26 100644 --- a/src/test/java/TestRunEveryFramework.java +++ b/src/integration-test/java/TestRunEveryFramework.java @@ -1,4 +1,5 @@ import java.io.File; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.net.HttpURLConnection; @@ -16,17 +17,30 @@ import org.junit.Test; import io.bioimage.modelrunner.bioimageio.BioimageioRepo; +import io.bioimage.modelrunner.bioimageio.description.ModelDescriptor; +import io.bioimage.modelrunner.bioimageio.description.ModelDescriptorFactory; +import io.bioimage.modelrunner.bioimageio.description.exceptions.ModelSpecsException; import io.bioimage.modelrunner.bioimageio.download.DownloadModel; import io.bioimage.modelrunner.engine.installation.EngineInstall; import io.bioimage.modelrunner.engine.installation.FileDownloader; import io.bioimage.modelrunner.system.PlatformDetection; import io.bioimage.modelrunner.utils.CommonUtils; +import io.bioimage.modelrunner.utils.Constants; import io.bioimage.modelrunner.utils.ZipUtils; public class TestRunEveryFramework { private List modelPaths; + private static final String MACRO_FORMAT = "" + + "run(\"DeepImageJ Run\", " + + "\"" + + "modelPath=%s " + + "inputPath=%s " + + "outputFolder=%s " + + "displayOutput=null" + + "\")"; + private static final File FIJI_DIR = new File("fiji"); private static final File ENGINES_DIR = new File(FIJI_DIR.getAbsolutePath(), "engines"); private static final File MODELS_DIR = new File(FIJI_DIR.getAbsolutePath(), "models"); @@ -49,12 +63,17 @@ public class TestRunEveryFramework { FIJI_URL.put(PlatformDetection.OS_OSX, "https://downloads.imagej.net/fiji/latest/fiji-macosx.zip"); } - @Test - public void testRun() throws InterruptedException, IOException { + @BeforeAll + public void setUp() throws InterruptedException, IOException, ModelSpecsException { downloadAndTrackFiji(); installEngines(); installModels(); - //runModels(); + compileAndCopyToPlugins(); + runModels(); + } + + private void compileAndCopyToPlugins() { + // TODO method that executes mvn build in subprocess and copies jar to fiji plugins folder } private static void downloadAndTrackFiji() throws InterruptedException, IOException { @@ -111,7 +130,17 @@ private void installModels() throws IOException, InterruptedException { String path = br.downloadModelByID(mm, MODELS_DIR.getAbsolutePath()); modelPaths.add(path); } - + } + + private void runModels() throws FileNotFoundException, ModelSpecsException, IOException { + for (String mm : modelPaths) { + ModelDescriptor model = ModelDescriptorFactory.readFromLocalFile(mm + File.separator + Constants.RDF_FNAME); + String modelPath = model.getModelPath(); + String samplePath = modelPath + File.separator + model.getInputTensors().get(0).getSampleTensorName(); + String macro = String.format(MACRO_FORMAT, modelPath, samplePath, modelPath); + String runModelCommand = "command that runs macros in headless mode"; + new ProcessBuilder().command(runModelCommand).start(); + } } }