-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More fix spring auth #277
More fix spring auth #277
Conversation
This seems to be an alternative way, that's what's autogenerated on a brand new phoenix project.
When disconnecting, there's a bunch of additional logic run, like storing some statistic and publishing events. This is racy against the teardown of the SQL sandbox, leading to the confusing "cannot find ownership process" message. By manually disconnecting we avoid this problem.
Turn out, the server doesn't send the ignore list to the client when it modifies anything. This seems to be conform to the spec at: https://springrts.com/dl/LobbyProtocol/ProtocolDescription.html#IGNORELIST:server The test needs to manually send the message to get the ignore list.
Otherwise login will fail and won't be broadcasted to other players.
Assuming the server does the correct thing, after all, this is what's currently running live and that the tests drifted away.
BAR is custom commands for this, that have been added after the initial tests. Updated the tests to reflect these changes and make them pass.
af60475
to
627af28
Compare
@L-e-x-o-n if you have some time to have a look. |
lib/teiserver/libs/test_lib.ex
Outdated
@@ -92,6 +92,12 @@ defmodule Teiserver.TeiserverTestLib do | |||
|
|||
@spec auth_setup(nil | Map.t()) :: %{socket: port(), user: Map.t(), pid: pid()} | |||
def auth_setup(user \\ nil) do | |||
# Remember to call Teiserver.Client.disconnect(user.id) at the end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is just a workaround to issue where teiserver instance is shared across all tests. I do not think it is wise to share a teiserver instance and with every tests figureout how to correctly clean it up. We should instead ensure teiserver boots and shuts down on each test that requires connections to teiserver.
I am getting
but there is probably something broken with my local build because GH action test workflow only gets 1 auth test error: 132) test RENAMEACCOUNT (Teiserver.SpringAuthTest)
Error: test/teiserver/protocols/spring/spring_auth_test.exs:450
Assertion with == failed
code: assert reply == "SERVERMSG Invalid characters in name (only a-z, A-Z, 0-9, [, ] allowed)\n"
left: "SERVERMSG Invalid characters in name (only a-z, A-Z, 0-9, [, ] allowed)\nSAIDPRIVATE Coordinator Invalid characters in name (only a-z, A-Z, 0-9, [, ] allowed)\n"
right: "SERVERMSG Invalid characters in name (only a-z, A-Z, 0-9, [, ] allowed)\n"
stacktrace:
test/teiserver/protocols/spring/spring_auth_test.exs:467: (test) |
Have you tried dropping the test db? There may be some more flakiness around though, as shown from the github action, but I'd rather focus on running tests for just this file for now, or at least for the "fixed" files.
That seems very excessive, and not the default for phoenix tests. Ensuring disconnection is really to prevent stdout being inundated by errors irrelevant to the tests themselves. |
I agree that shutting the whole server down is excessive, however those error logs are prove that there is some code still executing after the test finishes. I would just like to have some way how to sand box the whole test so know nothing else is running, i guess this is a topic on its own. All the tests do pass fine on my machine otherwise. |
Yeah, the teardown code is running after the tests because there are a few
When starting, teiserver does a bunch of DB query, I think it seeds the DB with some data if not there, and warm a bunch of caches as well. I suspect this may be problematic with many tests indeed. |
As far as i understand the sandboxing in terms of ecto, it just records the transactions made agains the DB and then reverses them. I did not find any other layer of sandboxing. I think what is happening is that we completely escape the context of the test via the TCP connections that are made to the running teiserver. Since most of these test dont only test how the messages are handled but as well the L4 TCP. These test are on level of rancher so no phoenix is include here afaik. Overall i think we should either remove the |
Good point, used |
627af28
to
a96004a
Compare
I amended the commit 627af28 |
Is there anything anymore to this PR? I'd like to get it merged soon-ish if possible. |
A few fixes for some old tests.
mix test test/teiserver/protocols/spring/spring_auth_test.exs
now returns 16 tests passed out of 16 vs 7 failures out of 16 tests on master.Although there are still some async errors regarding tests teardown, it doesn't actually fail any tests. More info in af60475