Skip to content

Commit

Permalink
wip/test: GithubActionsIssues try with executor
Browse files Browse the repository at this point in the history
  • Loading branch information
bogovicj committed Oct 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent e35efc0 commit e196e41
Showing 1 changed file with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -5,6 +5,9 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.janelia.saalfeldlab.n5.DataType;
import org.janelia.saalfeldlab.n5.DatasetAttributes;
@@ -13,6 +16,7 @@
import org.janelia.saalfeldlab.n5.RawCompression;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

public class GithubActionsIssues {
@@ -38,8 +42,68 @@ public static void after() {
}

@Test
public void n5WriteReadWithExecutor() {

System.out.println("n5WriteReadWithExecutor");

final boolean cacheAttributes = false;
try (final N5FSWriter n5w = new N5FSWriter(baseDir.getAbsolutePath(), cacheAttributes)) {

for (int i = 0; i < 50; i++) {

final String dset = String.format("%04d", i);
ExecutorService exec = Executors.newFixedThreadPool(1);
exec.submit(() -> {
try (final N5FSReader n5r = new N5FSReader(baseDir.getAbsolutePath())) {
final DatasetAttributes attrs = n5r.getDatasetAttributes(dset);
assertNotNull("null attrs for dataset: " + dset, attrs);
n5r.close();
}
});
exec.shutdown();
try {
exec.awaitTermination(1000, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) { }

n5w.remove(dset);
}
n5w.remove();
n5w.close();
}
}

@Test
@Ignore
public void n5WriteReadSameInstance() {

System.out.println("n5WriteReadSameInstance");

final boolean cacheAttributes = false;
try (final N5FSWriter n5w = new N5FSWriter(baseDir.getAbsolutePath(), cacheAttributes)) {

for (int i = 0; i < 50; i++) {

final String dset = String.format("%04d", i);
n5w.createDataset(dset,
new DatasetAttributes(new long[]{6, 5, 4}, new int[]{6, 5, 4}, DataType.FLOAT32, new RawCompression()));

final DatasetAttributes attrs = n5w.getDatasetAttributes(dset);
assertNotNull("null attrs for dataset: " + dset , attrs);

n5w.remove(dset);
}
n5w.remove();
n5w.close();
}
}

@Test
@Ignore
public void n5WriteRead() {

System.out.println("n5WriteRead");

// seems to work
try (final N5FSWriter n5w = new N5FSWriter(baseDir.getAbsolutePath())) {

for (int i = 0; i < 50; i++) {
@@ -53,8 +117,8 @@ public void n5WriteRead() {
final DatasetAttributes attrs = n5r.getDatasetAttributes(dset);
assertNotNull("null attrs for dataset: " + dset , attrs);
n5r.close();
n5w.remove(dset);
}
n5w.remove(dset);
}
n5w.remove();
n5w.close();

0 comments on commit e196e41

Please sign in to comment.