JUnit5 timeout error

132 views
Skip to first unread message

Ron Ariav

unread,
Apr 30, 2018, 12:01:19 PM4/30/18
to vert.x
Hello All, 

Our team recently started using Vert.x and we’re having some issues with testing.

We use JUnit5, and would love to stick to it, if possible (we say is possible given Vert.x’s JUnit5 integration is at a “Technical Preview” stage).

The main issue is that the test constantly times out and basically disregards the context.completeNow() call.

To try and isolate any potential mishaps on our side, we wrote some very simple code to better understand what we’re doing wrong, but we still haven’ figured it out.

Bellow please find the relevant code:

TestDao includes only 1 method:

//TestDao
public void foo(Handler<AsyncResult<Void>> handler) {
  vertx
.fileSystem().createFile(Paths.get("/", "tmp", "foo").toString(), handler);
}

ServiceVerticle class which extends AbstractVerticle and accepts TestDao in its constructor.

Our test is as follows:
//SampleTest
@Test
public void simpleTest(Vertx vertx, VertxTestContext context) {
   
final TestDao testDao = new TestDao();


    vertx
.deployVerticle(new ServiceVerticle(testDao), context.succeeding( id -> {


    test
.foo(
        context
.succeeding(
            result
-> {
              context
.verify(
                 
() -> {
                    assertThat
(Paths.get("/", "tmp", "foo").toFile().exists()).isTrue(); //We use Google's Truth Library


                    context
.completeNow();
                 
});
           
}));
     
}));
 
}
}

The error we get is `Closing the Vertx context timed out`
We also get the following warning `WARNING: You're already on a Vert.x context, are you sure you want to create a new Vertx instance?`

By plugging a few print statements before the assertion and after the #completeNow() we know that the block is being run, but we’re not sure what’s happening next.

Interestingly,  including vertx.close(), in either the deployment callback or the verify callback makes the test pass. But we’d assume that #completeNow() should suffice.

Any help would be greatly appreciated.

th3r...@gmail.com

unread,
May 1, 2018, 12:44:12 PM5/1/18
to vert.x
Hello,

I am experiencing the same issue where the test is failing to close vertx after the test execution

checkAndRemoveVertxInstance
is called and times out during the latch.await call.
latch.countDown should be called in the async handler of vertx.close but is apparently never reached.

Has anybody encounter this issue?

Best,
Ro

th3r...@gmail.com

unread,
May 1, 2018, 12:57:01 PM5/1/18
to vert.x
Found the issue,

I did override my verticle's stop method without completing the future, that is why vertx could not close properly.

Best,
Ro

Ron Ariav

unread,
May 2, 2018, 10:30:38 AM5/2/18
to vert.x
This is it!

Thanks!
Reply all
Reply to author
Forward
0 new messages