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
sdmoralesma
Title: Web Development with Clojure, Third Edition - migrations/create not working: p159 When I execute the command: user=&gt; (create-...
New
mikecargal
Title: Hands-on Rust: question about get_component (page 295) (feel free to respond. “You dug you’re own hole… good luck”) I have somet...
New
JohnS
I can’t setup the Rails source code. This happens in a working directory containing multiple (postgres) Rails apps. With: ruby-3.0.0 s...
New
New
jskubick
I’m running Android Studio “Arctic Fox” 2020.3.1 Patch 2, and I’m embarrassed to admit that I only made it to page 8 before running into ...
New
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
New
brunogirin
When running tox for the first time, I got the following error: ERROR: InterpreterNotFound: python3.10 I realised that I was running ...
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
New
dachristenson
@mfazio23 Android Studio will not accept anything I do when trying to use the Transformations class, as described on pp. 140-141. Googl...
New

Other popular topics Top

PragmaticBookshelf
Brace yourself for a fun challenge: build a photorealistic 3D renderer from scratch! In just a couple of weeks, build a ray tracer that r...
New
PragmaticBookshelf
Ruby, Io, Prolog, Scala, Erlang, Clojure, Haskell. With Seven Languages in Seven Weeks, by Bruce A. Tate, you’ll go beyond the syntax—and...
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
PragmaticBookshelf
Tailwind CSS is an exciting new CSS framework that allows you to design your site by composing simple utility classes to create complex e...
New
PragmaticBookshelf
Use WebRTC to build web applications that stream media and data in real time directly from one user to another, all in the browser. ...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
hilfordjames
There appears to have been an update that has changed the terminology for what has previously been known as the Taskbar Overflow - this h...
New
New

Sub Categories: