lessless

lessless

Network Programming in Elixir and Erlang: Chat integration tests are failing at random

Title: Network Programming in Elixir and Erlang (p. 56)

Hi,
Thanks for the amazing book, first and foremost.

I found that Chat app integration tests, as they are provided on page 56, are randomly failing when I’m running them multiple times.

For example, all mix test runs were executed against the same codebase, with no modifications. Some runs succeeded, some failed and failed in different tests.

mix test
Compiling 1 file (.ex)
Generated chat app

16:48:32.613 [info] Started chat server on port 4101
Running ExUnit with seed: 621706, max_cases: 20

.........
Finished in 0.2 seconds (0.2s async, 0.00s sync)
1 doctest, 8 tests, 0 failures
mix test

16:48:34.200 [info] Started chat server on port 4101
Running ExUnit with seed: 208381, max_cases: 20

.........
Finished in 0.2 seconds (0.2s async, 0.00s sync)
1 doctest, 8 tests, 0 failures
mix test

16:48:35.467 [info] Started chat server on port 4101
Running ExUnit with seed: 474408, max_cases: 20

.........
Finished in 0.2 seconds (0.2s async, 0.00s sync)
1 doctest, 8 tests, 0 failures
mix test

16:48:36.701 [info] Started chat server on port 4101
Running ExUnit with seed: 709368, max_cases: 20

......
16:48:36.961 [error] GenServer #PID<0.180.0> terminating
** (FunctionClauseError) no function clause matching in Chat.Connection.handle_info/2
    (chat 0.1.0) lib/chat/connection.ex:19: Chat.Connection.handle_info({:tcp_closed, #Port<0.11>}, %Chat.Connection{socket: #Port<0.11>, username: "amy", buffer: ""})
    (stdlib 6.2.2.2) gen_server.erl:2345: :gen_server.try_handle_info/3
    (stdlib 6.2.2.2) gen_server.erl:2433: :gen_server.handle_msg/6
    (stdlib 6.2.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: {:tcp_closed, #Port<0.11>}
State: %Chat.Connection{socket: #Port<0.11>, username: "amy", buffer: ""}

16:48:36.961 [error] GenServer #PID<0.181.0> terminating
** (FunctionClauseError) no function clause matching in Chat.Connection.handle_info/2
    (chat 0.1.0) lib/chat/connection.ex:19: Chat.Connection.handle_info({:tcp_closed, #Port<0.12>}, %Chat.Connection{socket: #Port<0.12>, username: "bern", buffer: ""})
    (stdlib 6.2.2.2) gen_server.erl:2345: :gen_server.try_handle_info/3
    (stdlib 6.2.2.2) gen_server.erl:2433: :gen_server.handle_msg/6
    (stdlib 6.2.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: {:tcp_closed, #Port<0.12>}
State: %Chat.Connection{socket: #Port<0.12>, username: "bern", buffer: ""}

16:48:36.961 [error] GenServer #PID<0.179.0> terminating
** (FunctionClauseError) no function clause matching in Chat.Connection.handle_info/2
    (chat 0.1.0) lib/chat/connection.ex:19: Chat.Connection.handle_info({:tcp_closed, #Port<0.8>}, %Chat.Connection{socket: #Port<0.8>, username: "jd", buffer: ""})
    (stdlib 6.2.2.2) gen_server.erl:2345: :gen_server.try_handle_info/3
    (stdlib 6.2.2.2) gen_server.erl:2433: :gen_server.handle_msg/6
    (stdlib 6.2.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: {:tcp_closed, #Port<0.8>}
State: %Chat.Connection{socket: #Port<0.8>, username: "jd", buffer: ""}


  1) test server closes connection ficlient sends register message twice (Chat.IntegrationTest)
     test/chat/integration_test.exs:9
     Assertion with =~ failed
     code:  assert log =~ "Invalid Register message"
     left:  ""
     right: "Invalid Register message"
     stacktrace:
       test/chat/integration_test.exs:21: (test)

..
Finished in 0.2 seconds (0.2s async, 0.00s sync)
1 doctest, 8 tests, 1 failure
mix test

16:48:55.294 [info] Started chat server on port 4101
Running ExUnit with seed: 303579, max_cases: 20

......

  1) test server closes connection ficlient sends register message twice (Chat.IntegrationTest)
     test/chat/integration_test.exs:9
     Assertion with =~ failed
     code:  assert log =~ "Invalid Register message"
     left:  ""
     right: "Invalid Register message"
     stacktrace:
       test/chat/integration_test.exs:21: (test)

..
Finished in 0.2 seconds (0.2s async, 0.00s sync)
1 doctest, 8 tests, 1 failure
mix test

16:48:57.808 [info] Started chat server on port 4101
Running ExUnit with seed: 817244, max_cases: 20

......

  1) test server closes connection ficlient sends register message twice (Chat.IntegrationTest)
     test/chat/integration_test.exs:9
     Assertion with =~ failed
     code:  assert log =~ "Invalid Register message"
     left:  ""
     right: "Invalid Register message"
     stacktrace:
       test/chat/integration_test.exs:21: (test)

..
Finished in 0.2 seconds (0.2s async, 0.00s sync)
1 doctest, 8 tests, 1 failure
mix test

16:48:59.453 [info] Started chat server on port 4101
Running ExUnit with seed: 461426, max_cases: 20

......

  1) test server closes connection ficlient sends register message twice (Chat.IntegrationTest)
     test/chat/integration_test.exs:9
     Assertion with =~ failed
     code:  assert log =~ "Invalid Register message"
     left:  ""
     right: "Invalid Register message"
     stacktrace:
       test/chat/integration_test.exs:21: (test)

..
Finished in 0.2 seconds (0.2s async, 0.00s sync)
1 doctest, 8 tests, 1 failure
mix test

16:49:00.937 [info] Started chat server on port 4101
Running ExUnit with seed: 944586, max_cases: 20

......
16:49:01.205 [error] GenServer #PID<0.180.0> terminating
** (FunctionClauseError) no function clause matching in Chat.Connection.handle_info/2
    (chat 0.1.0) lib/chat/connection.ex:19: Chat.Connection.handle_info({:tcp_closed, #Port<0.10>}, %Chat.Connection{socket: #Port<0.10>, username: "amy", buffer: ""})
    (stdlib 6.2.2.2) gen_server.erl:2345: :gen_server.try_handle_info/3
    (stdlib 6.2.2.2) gen_server.erl:2433: :gen_server.handle_msg/6
    (stdlib 6.2.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: {:tcp_closed, #Port<0.10>}
State: %Chat.Connection{socket: #Port<0.10>, username: "amy", buffer: ""}

16:49:01.205 [error] GenServer #PID<0.181.0> terminating
** (FunctionClauseError) no function clause matching in Chat.Connection.handle_info/2
    (chat 0.1.0) lib/chat/connection.ex:19: Chat.Connection.handle_info({:tcp_closed, #Port<0.12>}, %Chat.Connection{socket: #Port<0.12>, username: "bern", buffer: ""})
    (stdlib 6.2.2.2) gen_server.erl:2345: :gen_server.try_handle_info/3
    (stdlib 6.2.2.2) gen_server.erl:2433: :gen_server.handle_msg/6
    (stdlib 6.2.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: {:tcp_closed, #Port<0.12>}
State: %Chat.Connection{socket: #Port<0.12>, username: "bern", buffer: ""}

16:49:01.205 [error] GenServer #PID<0.179.0> terminating
** (FunctionClauseError) no function clause matching in Chat.Connection.handle_info/2
    (chat 0.1.0) lib/chat/connection.ex:19: Chat.Connection.handle_info({:tcp_closed, #Port<0.8>}, %Chat.Connection{socket: #Port<0.8>, username: "jd", buffer: ""})
    (stdlib 6.2.2.2) gen_server.erl:2345: :gen_server.try_handle_info/3
    (stdlib 6.2.2.2) gen_server.erl:2433: :gen_server.handle_msg/6
    (stdlib 6.2.2.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: {:tcp_closed, #Port<0.8>}
State: %Chat.Connection{socket: #Port<0.8>, username: "jd", buffer: ""}


  1) test server closes connection ficlient sends register message twice (Chat.IntegrationTest)
     test/chat/integration_test.exs:9
     Assertion with =~ failed
     code:  assert log =~ "Invalid Register message"
     left:  ""
     right: "Invalid Register message"
     stacktrace:
       test/chat/integration_test.exs:21: (test)

..
Finished in 0.2 seconds (0.2s async, 0.00s sync)
1 doctest, 8 tests, 1 failure
mix test

16:49:02.370 [info] Started chat server on port 4101
Running ExUnit with seed: 378187, max_cases: 20

......

  1) test server closes connection ficlient sends register message twice (Chat.IntegrationTest)
     test/chat/integration_test.exs:9
     Assertion with =~ failed
     code:  assert log =~ "Invalid Register message"
     left:  ""
     right: "Invalid Register message"
     stacktrace:
       test/chat/integration_test.exs:21: (test)

..
Finished in 0.2 seconds (0.2s async, 0.00s sync)
1 doctest, 8 tests, 1 failure
mix test

16:49:04.997 [info] Started chat server on port 4101
Running ExUnit with seed: 5948, max_cases: 20

......

  1) test server closes connection ficlient sends register message twice (Chat.IntegrationTest)
     test/chat/integration_test.exs:9
     Assertion with =~ failed
     code:  assert log =~ "Invalid Register message"
     left:  ""
     right: "Invalid Register message"
     stacktrace:
       test/chat/integration_test.exs:21: (test)

..
Finished in 0.2 seconds (0.2s async, 0.00s sync)
1 doctest, 8 tests, 1 failure
mix test

16:49:08.565 [info] Started chat server on port 4101
Running ExUnit with seed: 573340, max_cases: 20

......

  1) test server closes connection ficlient sends register message twice (Chat.IntegrationTest)
     test/chat/integration_test.exs:9
     Assertion with =~ failed
     code:  assert log =~ "Invalid Register message"
     left:  ""
     right: "Invalid Register message"
     stacktrace:
       test/chat/integration_test.exs:21: (test)

..
Finished in 0.2 seconds (0.2s async, 0.00s sync)
1 doctest, 8 tests, 1 failure
mix test

16:49:16.089 [info] Started chat server on port 4101
Running ExUnit with seed: 98240, max_cases: 20

.........
Finished in 0.2 seconds (0.2s async, 0.00s sync)
1 doctest, 8 tests, 0 failures

The repo to reproduce the issue is available at GitHub - lessless/chat: Errata for

Where Next?

Popular Pragmatic Bookshelf topics Top

jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
New
mikecargal
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display) It looks like ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
raul
Page 28: It implements io.ReaderAt on the store type. Sorry if it’s a dumb question but was the io.ReaderAt supposed to be io.ReadAt? ...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
hazardco
On page 78 the following code appears: &lt;%= link_to ‘Destroy’, product, class: ‘hover:underline’, method: :delete, data: { confirm...
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New
mcpierce
@mfazio23 I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
New

Other popular topics Top

DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
AstonJ
Or looking forward to? :nerd_face:
485 12328 258
New
Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
NewsBot
Node.js v22.14.0 has been released. Link: Release 2025-02-11, Version 22.14.0 'Jod' (LTS), @aduh95 · nodejs/node · GitHub
New

Sub Categories: