forked from opentable/otj-pg-embedded
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't allow multiple initdb processes on OSX.
Fixes: [initdb:pid(95804)] INFO i.z.t.d.p.embedded.EmbeddedPostgres - 2020-09-17 12:59:51.996 MDT [95916] DETAIL: Failed system call was shmget(key=5432002, size=56, 03600).
- Loading branch information
1 parent
b1e0444
commit bee4fcf
Showing
2 changed files
with
183 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/test/java/io/zonky/test/db/postgres/embedded/InitdbShmgetTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.zonky.test.db.postgres.embedded; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.*; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class InitdbShmgetTest { | ||
|
||
@Test | ||
public void testEmbeddedPg() throws InterruptedException, ExecutionException { | ||
ExecutorService executor = Executors.newCachedThreadPool(); | ||
List<InitdbThread> futureList = new ArrayList<>(); | ||
for (int i = 0; i < 100; i++) { | ||
futureList.add(new InitdbThread()); | ||
} | ||
try{ | ||
List<Future<Void>> futures = executor.invokeAll(futureList); | ||
for(Future<Void> future : futures){ | ||
future.get(); | ||
assertTrue(future.isDone()); | ||
} | ||
} finally { | ||
executor.shutdown(); | ||
executor.awaitTermination(5, TimeUnit.SECONDS); | ||
} | ||
} | ||
|
||
class InitdbThread implements Callable<Void> { | ||
|
||
public Void call() throws IOException, InterruptedException { | ||
EmbeddedPostgres.Builder databaseBuilder = EmbeddedPostgres.builder(); | ||
EmbeddedPostgres pg = databaseBuilder.start(); | ||
Thread.sleep(5000); | ||
pg.close(); | ||
return null; | ||
} | ||
} | ||
} |