ceylon-sdk icon indicating copy to clipboard operation
ceylon-sdk copied to clipboard

ceylon.net tests hang forever if server can't be started

Open quintesse opened this issue 9 years ago • 8 comments

I already had something running on port 8080 so the following happened when running the SDK tests:

.
.
.
[ceylon-test] running: test.ceylon.net::testPathMatcher
[ceylon-test] running: test.ceylon.net::testServer
[ceylon-test] Starting on 127.0.0.1:8080
[ceylon-test] Exception in thread "Thread-123" java.net.BindException: Address already in use
[ceylon-test]   at sun.nio.ch.Net.bind0(Native Method)
[ceylon-test]   at sun.nio.ch.Net.bind(Net.java:433)
[ceylon-test]   at sun.nio.ch.Net.bind(Net.java:425)
[ceylon-test]   at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
[ceylon-test]   at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
[ceylon-test]   at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:67)
[ceylon-test]   at org.xnio.nio.NioXnioWorker.createTcpConnectionServer(NioXnioWorker.java:182)
[ceylon-test]   at org.xnio.XnioWorker.createStreamConnectionServer(XnioWorker.java:243)
[ceylon-test]   at ceylon.net.http.server.internal.DefaultServer.start$canonical$(DefaultServer.ceylon:175)
[ceylon-test]   at ceylon.net.http.server.internal.DefaultServer.start(DefaultServer.ceylon:139)
[ceylon-test]   at ceylon.net.http.server.internal.DefaultServer$1httpd_.run(DefaultServer.ceylon:206)
[ceylon-test]   at java.lang.Thread.run(Thread.java:745)

And the process never stops, the tests never finish.

quintesse avatar Jan 20 '16 23:01 quintesse

@matejonnet is this something you can take a look at? Perhaps Status needs to be extended with an error? Or always signal stopped at least. Or perhaps skip waitTestToComplete() if the server is in an invalid state somehow. You probably know best :)

quintesse avatar Jan 20 '16 23:01 quintesse

Moving to 1.2.3

quintesse avatar Mar 07 '16 17:03 quintesse

@matejonnet any ideas you could give us? This issue continues to exist and is a bit nasty.

quintesse avatar Sep 08 '16 11:09 quintesse

This should solve the issue https://github.com/ceylon/ceylon-sdk/pull/619

matejonnet avatar Sep 09 '16 16:09 matejonnet

It does, thanks!

quintesse avatar Sep 09 '16 19:09 quintesse

So it seems this was only partly fixed, because on the CI server we still have the same problem:

.
.
.
[ceylon-test] running: test.ceylon.http.client::RequestLocalServerTest
[ceylon-test] running: test.ceylon.http.client::RequestLocalServerTest.defaultGet
[ceylon-test] Starting on 127.0.0.1:59746
[ceylon-test] Failed to start server.
[ceylon-test] Exception in thread "Thread-143" ceylon.http.server.ServerException "Failed to start server."
[ceylon-test]   at ceylon.http.server.internal.DefaultServer.start$canonical$(DefaultServer.ceylon:190)
[ceylon-test]   at ceylon.http.server.internal.DefaultServer.start(DefaultServer.ceylon:126)
[ceylon-test]   at ceylon.http.server.internal.DefaultServer$1anonymous_0_.run(DefaultServer.ceylon:215)
[ceylon-test] Caused by: java.net.SocketException: Permission denied
[ceylon-test]   at sun.nio.ch.Net.bind0(Native Method)
[ceylon-test]   at sun.nio.ch.Net.bind(Net.java:463)
[ceylon-test]   at sun.nio.ch.Net.bind(Net.java:455)
[ceylon-test]   at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
[ceylon-test]   at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
[ceylon-test]   at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:67)
[ceylon-test]   at org.xnio.nio.NioXnioWorker.createTcpConnectionServer(NioXnioWorker.java:182)
[ceylon-test]   at org.xnio.XnioWorker.createStreamConnectionServer(XnioWorker.java:243)
[ceylon-test]   at ceylon.http.server.internal.DefaultServer.start$canonical$(DefaultServer.ceylon:181)
[ceylon-test]   ... 2 more
Build was aborted
Aborted by Jenkins Admin
Finished: ABORTED

And after this error the test again hangs forever. So I'm reopening this.

(Btw, the part about "Aborted by Jenkins Admin" was me, like 2 hours after the tests had been started. So it obviously wasn't going to recover by itself)

quintesse avatar Nov 06 '16 12:11 quintesse

As an aside, I think this code related to the problem that @matejonnet improved the last time:

DefaultServer.ceylon:Line 187

} catch (IOException e) {
    print("Failed to start server.");
    notifyListeners(stopped);
    throw ServerException("Failed to start server.", e);
}

should perhaps be changed to catching any Exception, not just IOExceptions. Because if there's some other, runtime, problem then we'd want to listeners to get notified as well, right?

quintesse avatar Nov 06 '16 13:11 quintesse

Sounds right to catch all.

matejonnet avatar Nov 08 '16 10:11 matejonnet