Skip to content

Commit

Permalink
create integration tests instead of unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Nov 11, 2024
1 parent bf20909 commit 37ada2f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
Empty file.
29 changes: 29 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,33 @@ Universidad Carlos III de Madrid.</license.copyrightOwners>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>integration-tests</id>
<activation>
<property>
<name>env.CI</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
Expand All @@ -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<String> 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");
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
}
}

}

0 comments on commit 37ada2f

Please sign in to comment.