Skip to content

Commit 8f141d0

Browse files
author
Vasile Baluta
committed
change order of running tests
1 parent 910d4b0 commit 8f141d0

File tree

2 files changed

+11
-23
lines changed

2 files changed

+11
-23
lines changed

.travis.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ before_install:
1414
- chmod +x pom.xml
1515

1616
script:
17-
- mvn -DsomeModule.test.includes="**/UpStreamEventHandlerTest.java, **/TestExtractionHandler.java, **/ObjectHandlerTest.java, **/SubscriptionServiceTest.java" test
18-
#- mvn -DsomeModule.test.includes="**/SubscriptionServiceTest.java, **/ObjectHandlerTest.java" test
19-
#- mvn clean install
17+
# since we run parallel tests using embedded mongodb in fresh environment all tests run first in parallel
18+
# will try to download the embedded mongo to this travis instance but the late ones will fail to write.
19+
# We will therefore run one test using mongodb first that will download the mongo instance and
20+
# then the rest of the test that will no longer need to download the embedded mongo since it will exist
21+
- mvn -DsomeModule.test.includes="**/ObjectHandlerTest.java" test
22+
- mvn -DsomeModule.test.excludes="**/ObjectHandlerTest.java" test
23+

src/test/java/com/ericsson/ei/handlers/test/ObjectHandlerTest.java

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public class ObjectHandlerTest {
5757
private ObjectHandler objHandler = new ObjectHandler();
5858

5959
private MongodForTestsFactory testsFactory;
60-
private MongodExecutable mongodExecutable = null;
6160
private MongoClient mongoClient = null;
6261

6362
private MongoDBHandler mongoDBHandler = new MongoDBHandler();
@@ -79,21 +78,8 @@ public class ObjectHandlerTest {
7978

8079
public void setUpEmbeddedMongo() throws Exception {
8180
try {
82-
// testsFactory = MongodForTestsFactory.with(Version.V3_4_1);
83-
// mongoClient = testsFactory.newMongo();
84-
int port = SocketUtils.findAvailableTcpPort();
85-
86-
MongodStarter starter = MongodStarter.getDefaultInstance();
87-
88-
String bindIp = "localhost";
89-
90-
IMongodConfig mongodConfig = new MongodConfigBuilder().version(Version.Main.PRODUCTION)
91-
.net(new Net(bindIp, port, Network.localhostIsIPv6())).build();
92-
93-
mongodExecutable = starter.prepare(mongodConfig);
94-
MongodProcess mongod = mongodExecutable.start();
95-
mongoClient = new MongoClient("localhost", port);
96-
81+
testsFactory = MongodForTestsFactory.with(Version.V3_4_1);
82+
mongoClient = testsFactory.newMongo();
9783
} catch (Exception e) {
9884
log.error(e.getMessage(), e);
9985
e.printStackTrace();
@@ -138,10 +124,8 @@ public void dropCollection() {
138124
mongoDBHandler.dropDocument(dataBaseName, collectionName, condition);
139125
if (mongoClient != null)
140126
mongoClient.close();
141-
if (mongodExecutable != null)
142-
mongodExecutable.stop();
143-
// if (testsFactory != null)
144-
// testsFactory.shutdown();
127+
if (testsFactory != null)
128+
testsFactory.shutdown();
145129

146130
}
147131
}

0 commit comments

Comments
 (0)