Skip to content

Commit 27855cd

Browse files
committed
Attempt to fix more Mongo test failures
Similar idea to quarkusio#9524 This one attempts to get over an IOException that can occur when de.flapdoodle.embed.process.store.Downloader.downloadInputStream is called.
1 parent b6f3625 commit 27855cd

File tree

6 files changed

+114
-6
lines changed

6 files changed

+114
-6
lines changed

extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoTestBase.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void startMongoDatabase() throws IOException {
4747
.version(version)
4848
.net(new Net(port, Network.localhostIsIPv6()))
4949
.build();
50-
MONGO = MongodStarter.getDefaultInstance().prepare(config);
50+
MONGO = getMongodExecutable(config);
5151
try {
5252
MONGO.start();
5353
} catch (Exception e) {
@@ -65,6 +65,24 @@ public static void startMongoDatabase() throws IOException {
6565
}
6666
}
6767

68+
private static MongodExecutable getMongodExecutable(IMongodConfig config) {
69+
try {
70+
return doGetExecutable(config);
71+
} catch (Exception e) {
72+
// sometimes the download process can timeout so just sleep and try again
73+
try {
74+
Thread.sleep(1000);
75+
} catch (InterruptedException ignored) {
76+
77+
}
78+
return doGetExecutable(config);
79+
}
80+
}
81+
82+
private static MongodExecutable doGetExecutable(IMongodConfig config) {
83+
return MongodStarter.getDefaultInstance().prepare(config);
84+
}
85+
6886
@AfterAll
6987
public static void stopMongoDatabase() {
7088
if (MONGO != null) {

extensions/mongodb-client/deployment/src/test/java/io/quarkus/mongodb/MongoWithReplicasTestBase.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void startMongoDatabase() throws IOException {
4545
configs.add(buildMongodConfiguration("localhost", port, true));
4646
}
4747
configs.forEach(config -> {
48-
MongodExecutable exec = MongodStarter.getDefaultInstance().prepare(config);
48+
MongodExecutable exec = getMongodExecutable(config);
4949
MONGOS.add(exec);
5050
try {
5151
try {
@@ -70,6 +70,24 @@ public static void startMongoDatabase() throws IOException {
7070
}
7171
}
7272

73+
private static MongodExecutable getMongodExecutable(IMongodConfig config) {
74+
try {
75+
return doGetExecutable(config);
76+
} catch (Exception e) {
77+
// sometimes the download process can timeout so just sleep and try again
78+
try {
79+
Thread.sleep(1000);
80+
} catch (InterruptedException ignored) {
81+
82+
}
83+
return doGetExecutable(config);
84+
}
85+
}
86+
87+
private static MongodExecutable doGetExecutable(IMongodConfig config) {
88+
return MongodStarter.getDefaultInstance().prepare(config);
89+
}
90+
7391
@AfterAll
7492
public static void stopMongoDatabase() {
7593
MONGOS.forEach(mongod -> {

extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoTestBase.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static void startMongoDatabase() throws IOException {
6060
.version(version)
6161
.net(new Net(port, Network.localhostIsIPv6()))
6262
.build();
63-
MONGO = MongodStarter.getDefaultInstance().prepare(config);
63+
MONGO = getMongodExecutable(config);
6464
try {
6565
MONGO.start();
6666
} catch (Exception e) {
@@ -77,6 +77,24 @@ public static void startMongoDatabase() throws IOException {
7777
}
7878
}
7979

80+
private static MongodExecutable getMongodExecutable(IMongodConfig config) {
81+
try {
82+
return doGetExecutable(config);
83+
} catch (Exception e) {
84+
// sometimes the download process can timeout so just sleep and try again
85+
try {
86+
Thread.sleep(1000);
87+
} catch (InterruptedException ignored) {
88+
89+
}
90+
return doGetExecutable(config);
91+
}
92+
}
93+
94+
private static MongodExecutable doGetExecutable(IMongodConfig config) {
95+
return MongodStarter.getDefaultInstance().prepare(config);
96+
}
97+
8098
@AfterAll
8199
public static void stopMongoDatabase() {
82100
if (MONGO != null) {

extensions/mongodb-client/runtime/src/test/java/io/quarkus/mongodb/reactive/MongoWithReplicasTestBase.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void startMongoDatabase() throws IOException {
4545
configs.add(buildMongodConfiguration("localhost", port, true));
4646
}
4747
configs.forEach(config -> {
48-
MongodExecutable exec = MongodStarter.getDefaultInstance().prepare(config);
48+
MongodExecutable exec = getMongodExecutable(config);
4949
MONGOS.add(exec);
5050
try {
5151
try {
@@ -70,6 +70,24 @@ public static void startMongoDatabase() throws IOException {
7070
}
7171
}
7272

73+
private static MongodExecutable getMongodExecutable(IMongodConfig config) {
74+
try {
75+
return doGetExecutable(config);
76+
} catch (Exception e) {
77+
// sometimes the download process can timeout so just sleep and try again
78+
try {
79+
Thread.sleep(1000);
80+
} catch (InterruptedException ignored) {
81+
82+
}
83+
return doGetExecutable(config);
84+
}
85+
}
86+
87+
private static MongodExecutable doGetExecutable(IMongodConfig config) {
88+
return MongodStarter.getDefaultInstance().prepare(config);
89+
}
90+
7391
@AfterAll
7492
public static void stopMongoDatabase() {
7593
MONGOS.forEach(mongod -> {

integration-tests/mongodb-client/src/test/java/io/quarkus/it/mongodb/MongoTestResource.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public Map<String, String> start() {
3030
.version(version)
3131
.net(new Net(port, Network.localhostIsIPv6()))
3232
.build();
33-
MONGO = MongodStarter.getDefaultInstance().prepare(config);
33+
MONGO = getMongodExecutable(config);
3434
try {
3535
MONGO.start();
3636
} catch (Exception e) {
@@ -45,6 +45,24 @@ public Map<String, String> start() {
4545
return Collections.emptyMap();
4646
}
4747

48+
private MongodExecutable getMongodExecutable(IMongodConfig config) {
49+
try {
50+
return doGetExecutable(config);
51+
} catch (Exception e) {
52+
// sometimes the download process can timeout so just sleep and try again
53+
try {
54+
Thread.sleep(1000);
55+
} catch (InterruptedException ignored) {
56+
57+
}
58+
return doGetExecutable(config);
59+
}
60+
}
61+
62+
private MongodExecutable doGetExecutable(IMongodConfig config) {
63+
return MongodStarter.getDefaultInstance().prepare(config);
64+
}
65+
4866
@Override
4967
public void stop() {
5068
if (MONGO != null) {

integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/MongoTestResource.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public Map<String, String> start() {
2929
.version(version)
3030
.net(new Net(port, Network.localhostIsIPv6()))
3131
.build();
32-
MONGO = MongodStarter.getDefaultInstance().prepare(config);
32+
MONGO = getMongodExecutable(config);
3333
try {
3434
MONGO.start();
3535
} catch (Exception e) {
@@ -44,6 +44,24 @@ public Map<String, String> start() {
4444
}
4545
}
4646

47+
private MongodExecutable getMongodExecutable(IMongodConfig config) {
48+
try {
49+
return doGetExecutable(config);
50+
} catch (Exception e) {
51+
// sometimes the download process can timeout so just sleep and try again
52+
try {
53+
Thread.sleep(1000);
54+
} catch (InterruptedException ignored) {
55+
56+
}
57+
return doGetExecutable(config);
58+
}
59+
}
60+
61+
private MongodExecutable doGetExecutable(IMongodConfig config) {
62+
return MongodStarter.getDefaultInstance().prepare(config);
63+
}
64+
4765
@Override
4866
public void stop() {
4967
if (MONGO != null) {

0 commit comments

Comments
 (0)