Potential Race Condition in TestCli

Potential Race Condition in TestCli

by Yuchen Qian -
Number of replies: 2

There is a potential race condition inside TestCli: when the http server hasn't started with the async call, but the sendMsg tries to contact the server already. A quick ugly fix would be to wait a few milliseconds in the client, but a potential better fix would be to have some synchronization (like the ready channel). Should we take this race into consideration when we're implementing the sendMsg in cli/cli.go? 

Thanks for your time and have a nice day :)

In reply to Yuchen Qian

Re: Potential Race Condition in TestCli

by Cristina Basescu -

Thanks for reporting, you're totally right. I couldn't replicate the error, but we're aware that it could happen. In the client test (and just *that* test), it would be better if the test waited for a bit after starting the server in a separate go thread. Thus, if you fail the test and suspect that's the cause, (the server isn't ready to receive messages, so you get an error), please add a sleep immediately after the go routine.

In the interest of not changing the tests, we won't push a change. But we will take the issue into account when grading.

Did you observe this error when testing locally or on gitlab?


In reply to Cristina Basescu

Re: Potential Race Condition in TestCli

by Yuchen Qian -

Yes, I did observe this behaviour both locally and on gitlab... Thanks :)