Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
msbarry committed Nov 15, 2024
1 parent 3f31d96 commit 9646958
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static PlanetilerConfig from(Arguments arguments) {
int renderMaxzoom =
arguments.getInteger("render_maxzoom", "maximum rendering zoom level up to " + MAX_MAXZOOM,
Math.max(maxzoom, DEFAULT_MAXZOOM));
Path tmpDir = arguments.file("tmpdir", "temp directory", Path.of("data", "tmp"));
Path tmpDir = arguments.file("tmpdir|tmp", "temp directory", Path.of("data", "tmp"));

return new PlanetilerConfig(
arguments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

class AppendStoreTest {
abstract class AppendStoreTest {

static abstract class IntsTest {
abstract static class IntsTest {

protected AppendStore.Ints store;

@ParameterizedTest
@ValueSource(ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
public void writeThenRead(int num) {
void writeThenRead(int num) {
for (int i = 0; i < num; i++) {
store.appendInt(i + 1);
}
Expand All @@ -30,7 +30,7 @@ public void writeThenRead(int num) {
}

@Test
public void readBig() {
void readBig() {
store.appendInt(Integer.MAX_VALUE);
store.appendInt(Integer.MAX_VALUE - 1);
store.appendInt(Integer.MAX_VALUE - 2);
Expand All @@ -40,13 +40,13 @@ public void readBig() {
}
}

static abstract class LongsTest {
abstract static class LongsTest {

protected AppendStore.Longs store;

@ParameterizedTest
@ValueSource(ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
public void writeThenRead(int num) {
void writeThenRead(int num) {
for (int i = 0; i < num; i++) {
store.appendLong(i + 1);
}
Expand All @@ -61,82 +61,82 @@ public void writeThenRead(int num) {

@ParameterizedTest
@ValueSource(longs = {maxInt - 1, maxInt, maxInt + 1, 2 * maxInt - 1, 2 * maxInt, 5 * maxInt - 1, 5 * maxInt + 1})
public void readBig(long value) {
void readBig(long value) {
store.appendLong(value);
assertEquals(value, store.getLong(0));
}

}

static class RamInt extends IntsTest {
static class RamIntTest extends IntsTest {

@BeforeEach
public void setup() {
void setup() {
this.store = new AppendStoreRam.Ints(false, 4 << 2);
}
}

static class MMapInt extends IntsTest {
static class MMapIntTest extends IntsTest {

@BeforeEach
public void setup(@TempDir Path path) {
void setup(@TempDir Path path) {
this.store = new AppendStoreMmap.Ints(path.resolve("ints"), 4 << 2, true);
}
}

static class DirectInt extends IntsTest {
static class DirectIntTest extends IntsTest {

@BeforeEach
public void setup() {
void setup() {
this.store = new AppendStoreRam.Ints(true, 4 << 2);
}
}

static class RamLong extends LongsTest {
static class RamLongTest extends LongsTest {

@BeforeEach
public void setup() {
void setup() {
this.store = new AppendStoreRam.Longs(false, 4 << 2);
}
}

static class MMapLong extends LongsTest {
static class MMapLongTest extends LongsTest {

@BeforeEach
public void setup(@TempDir Path path) {
void setup(@TempDir Path path) {
this.store = new AppendStoreMmap.Longs(path.resolve("longs"), 4 << 2, true);
}
}

static class DirectLong extends LongsTest {
static class DirectLongTest extends LongsTest {

@BeforeEach
public void setup() {
void setup() {
this.store = new AppendStoreRam.Longs(true, 4 << 2);
}
}

static class MMapSmallLong extends LongsTest {
static class MMapSmallLongTest extends LongsTest {

@BeforeEach
public void setup(@TempDir Path path) {
void setup(@TempDir Path path) {
this.store = new AppendStore.SmallLongs(
(i) -> new AppendStoreMmap.Ints(path.resolve("smalllongs" + i), 4 << 2, true));
}
}

static class RamSmallLong extends LongsTest {
static class RamSmallLongTest extends LongsTest {

@BeforeEach
public void setup() {
void setup() {
this.store = new AppendStore.SmallLongs((i) -> new AppendStoreRam.Ints(false, 4 << 2));
}
}

static class DirectSmallLong extends LongsTest {
static class DirectSmallLongTest extends LongsTest {

@BeforeEach
public void setup() {
void setup() {
this.store = new AppendStore.SmallLongs((i) -> new AppendStoreRam.Ints(true, 4 << 2));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public abstract class LongLongMultimapTest {
abstract class LongLongMultimapTest {

protected LongLongMultimap map;
protected boolean retainInputOrder = false;

@Test
public void missingValue() {
void missingValue() {
assertTrue(map.get(0).isEmpty());
}

@Test
public void oneValue() {
void oneValue() {
put(1, 1);
assertResultLists(LongArrayList.from(), map.get(0));
assertResultLists(LongArrayList.from(1), map.get(1));
Expand Down Expand Up @@ -50,7 +50,7 @@ private void putAll(long k, LongArrayList vs) {
}

@Test
public void twoConsecutiveValues() {
void twoConsecutiveValues() {
put(1, 1);
put(2, 2);
assertResultLists(LongArrayList.from(), map.get(0));
Expand All @@ -60,7 +60,7 @@ public void twoConsecutiveValues() {
}

@Test
public void twoNonconsecutiveValues() {
void twoNonconsecutiveValues() {
put(1, 1);
put(3, 3);
assertResultLists(LongArrayList.from(), map.get(0));
Expand All @@ -71,7 +71,7 @@ public void twoNonconsecutiveValues() {
}

@Test
public void returnToFirstKey() {
void returnToFirstKey() {
if (retainInputOrder) {
return;
}
Expand All @@ -91,7 +91,7 @@ public void returnToFirstKey() {
}

@Test
public void manyInsertsOrdered() {
void manyInsertsOrdered() {
long[] toInsert = new long[10];
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 10; j++) {
Expand Down Expand Up @@ -128,7 +128,7 @@ private void assertResultLists(LongArrayList expected, LongArrayList actual) {
}

@Test
public void manyInsertsUnordered() {
void manyInsertsUnordered() {
for (long i = 99; i >= 0; i--) {
putAll(i, LongArrayList.from(
i * 10 + 10,
Expand Down Expand Up @@ -160,43 +160,43 @@ public void manyInsertsUnordered() {
}

@Test
public void multiInsert() {
void multiInsert() {
putAll(1, LongArrayList.from(1, 2, 3));
put(0, 3);
assertResultLists(LongArrayList.from(3), map.get(0));
assertResultLists(LongArrayList.from(1, 2, 3), map.get(1));
assertResultLists(LongArrayList.from(), map.get(2));
}

public static class SparseUnorderedTest extends LongLongMultimapTest {
static class SparseUnorderedTest extends LongLongMultimapTest {

@BeforeEach
public void setup() {
void setup() {
this.map = LongLongMultimap.newAppendableMultimap();
}
}

public static class DenseOrderedTest extends LongLongMultimapTest {
static class DenseOrderedTest extends LongLongMultimapTest {

@BeforeEach
public void setup() {
void setup() {
retainInputOrder = true;
this.map =
LongLongMultimap.newInMemoryReplaceableMultimap();
}
}

public static class DenseOrderedMmapTest extends LongLongMultimapTest {
static class DenseOrderedMmapTest extends LongLongMultimapTest {

@BeforeEach
public void setup(@TempDir Path dir) {
void setup(@TempDir Path dir) {
retainInputOrder = true;
this.map =
LongLongMultimap.newReplaceableMultimap(Storage.MMAP, new Storage.Params(dir.resolve("multimap"), true));
}

@AfterEach
public void teardown() {
void teardown() {
this.map.close();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void integrationTest(@TempDir Path tmpDir) throws Exception {
// Override input source locations
"osm_path", TestUtils.pathToResource("monaco-latest.osm.pbf"),
// Override temp dir location
"tmp", tmpDir.toString(),
"tmpdir", tmpDir.toString(),
// Override output location
"output", dbPath.toString()
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void integrationTest(@TempDir Path tmpDir) throws Exception {
// Override input source locations
"osm_path", TestUtils.pathToResource("monaco-latest.osm.pbf"),
// Override temp dir location
"tmp", tmpDir.toString(),
"tmpdir", tmpDir.toString(),
// Override output location
"output", dbPath.toString()
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void integrationTest(@TempDir Path tmpDir) throws Exception {
// Override input source locations
"osm_path", TestUtils.pathToResource("monaco-latest.osm.pbf"),
// Override temp dir location
"tmp", tmpDir.toString(),
"tmpdir", tmpDir.toString(),
// Override output location
"output", dbPath.toString()
));
Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,15 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<!-- by default surefire excludes tests on nested classes https://github.com/junit-team/junit5/issues/1377 -->
<configuration>
<!-- by default surefire excludes tests on nested classes https://github.com/junit-team/junit5/issues/1377 -->
<excludes>
<exclude/>
</excludes>
<!-- by default surefire only includes tests matching Test*.java *Test.java or *TestCase.java -->
<includes>
<include>**/*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -451,6 +455,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>!slow</groups>
<forkCount>1C</forkCount>
</configuration>
</plugin>
</plugins>
Expand Down
2 changes: 1 addition & 1 deletion scripts/fasttests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -o errexit
set -o pipefail
set -o nounset

./mvnw -Pfast clean test
./mvnw -T 1C -Pfast clean test

0 comments on commit 9646958

Please sign in to comment.