-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration test for Mongo Service Binding
- Loading branch information
Showing
8 changed files
with
160 additions
and
0 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
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
84 changes: 84 additions & 0 deletions
84
...data-panache/src/test/java/io/quarkus/it/mongodb/rest/data/panache/MongoTestResource.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,84 @@ | ||
package io.quarkus.it.mongodb.rest.data.panache; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
import de.flapdoodle.embed.mongo.MongodExecutable; | ||
import de.flapdoodle.embed.mongo.MongodStarter; | ||
import de.flapdoodle.embed.mongo.config.IMongodConfig; | ||
import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; | ||
import de.flapdoodle.embed.mongo.config.Net; | ||
import de.flapdoodle.embed.mongo.distribution.Version; | ||
import de.flapdoodle.embed.process.runtime.Network; | ||
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; | ||
|
||
public class MongoTestResource implements QuarkusTestResourceLifecycleManager { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(MongoTestResource.class); | ||
private static MongodExecutable MONGO; | ||
|
||
@Override | ||
public Map<String, String> start() { | ||
try { | ||
//JDK bug workaround | ||
//https://github.com/quarkusio/quarkus/issues/14424 | ||
//force class init to prevent possible deadlock when done by mongo threads | ||
Class.forName("sun.net.ext.ExtendedSocketOptions", true, ClassLoader.getSystemClassLoader()); | ||
} catch (ClassNotFoundException e) { | ||
} | ||
try { | ||
Version.Main version = Version.Main.V4_0; | ||
int port = 37017; | ||
LOGGER.infof("Starting Mongo %s on port %s", version, port); | ||
IMongodConfig config = new MongodConfigBuilder() | ||
.version(version) | ||
.net(new Net(port, Network.localhostIsIPv6())) | ||
.build(); | ||
MONGO = getMongodExecutable(config); | ||
try { | ||
MONGO.start(); | ||
} catch (Exception e) { | ||
//every so often mongo fails to start on CI runs | ||
//see if this helps | ||
Thread.sleep(1000); | ||
MONGO.start(); | ||
} | ||
|
||
// don't return any properties, since we want Service Binding to configure Quarkus | ||
return Collections.emptyMap(); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
private MongodExecutable getMongodExecutable(IMongodConfig config) { | ||
try { | ||
return doGetExecutable(config); | ||
} catch (Exception e) { | ||
// sometimes the download process can timeout so just sleep and try again | ||
try { | ||
Thread.sleep(1000); | ||
} catch (InterruptedException ignored) { | ||
|
||
} | ||
return doGetExecutable(config); | ||
} | ||
} | ||
|
||
private MongodExecutable doGetExecutable(IMongodConfig config) { | ||
return MongodStarter.getDefaultInstance().prepare(config); | ||
} | ||
|
||
private void initData() { | ||
|
||
} | ||
|
||
@Override | ||
public void stop() { | ||
if (MONGO != null) { | ||
MONGO.stop(); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
integration-tests/mongodb-rest-data-panache/src/test/resources/k8s-sb/mongo/database
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 @@ | ||
test |
1 change: 1 addition & 0 deletions
1
integration-tests/mongodb-rest-data-panache/src/test/resources/k8s-sb/mongo/host
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 @@ | ||
localhost |
1 change: 1 addition & 0 deletions
1
integration-tests/mongodb-rest-data-panache/src/test/resources/k8s-sb/mongo/port
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 @@ | ||
37017 |
1 change: 1 addition & 0 deletions
1
integration-tests/mongodb-rest-data-panache/src/test/resources/k8s-sb/mongo/provider
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 @@ | ||
atlas |
1 change: 1 addition & 0 deletions
1
integration-tests/mongodb-rest-data-panache/src/test/resources/k8s-sb/mongo/type
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 @@ | ||
mongodb |