Homework 0 forum

Tests and concurrency

 
Picture of Yoan Yvan Hubert Martin
Tests and concurrency
by Yoan Yvan Hubert Martin - Tuesday, 22 September 2020, 10:46
 

Hello all, 

I manage to write my code such that each test works individually. However, when I run all the tests together, I face the error "address already in use". I suspect that tests are executed concurrently. Hence, many peers can be initialized with the same address returning this error. 

I don't know how to correct this, do you think it comes from the tests files? Can there be something wrong regarding my concurrency management? 

Thank you for your reply :)

Picture of Huan-Cheng Chang
Re: Tests and concurrency
by Huan-Cheng Chang - Tuesday, 22 September 2020, 10:58
 
If you want to run your tests locally, do this:

go test ./... -p 1

This is because some test cases use the same port. Go runs your test suites in parallel by default, depending on how many available CPUs you have in your machine, so when they try to open the same port, the error you saw is thrown.
Picture of Cristina Basescu
Re: Tests and concurrency
by Cristina Basescu - Tuesday, 22 September 2020, 11:14
 

Hi Yoan,

Huan-Cheng is right (and thanks to him for previously reporting the issue to us). When running tests locally, please use "-p". When running the tests on gitlab, you shouldn't experience this problem - could you confirm this?

We'll fix the issue for future assignments by using random ports. However, for this assignment we'll keep the test ports as they are.

Cristina

Picture of Yoan Yvan Hubert Martin
Re: Tests and concurrency
by Yoan Yvan Hubert Martin - Tuesday, 22 September 2020, 11:31
 

Thank you both for your quick reply! Running tests using "-p" solves my problem locally. However, I still experience the issue on Gitlab

Picture of Aaron Joos Lippeveldts
Re: Tests and concurrency
by Aaron Joos Lippeveldts - Tuesday, 22 September 2020, 11:50
 

I added -p 1 to the .gitlab-ci.yml file in the root of the project, that fixed it for me on GitLab.

Picture of Cristina Basescu
Re: Tests and concurrency
by Cristina Basescu - Tuesday, 22 September 2020, 11:57
 

That's indeed the way to do it.

Thanks all,

Cristina

Picture of Elie Daou
Re: Tests and concurrency
by Elie Daou - Monday, 28 September 2020, 03:31
 

Hello, are the CI machines shared between students? while running the tests on GitLab with -p 1 added I encountered this error which made the tests fail:

> E : cli.go:36 (cli.sendMsg) - Post "http://127.0.0.1:2001/message": dial tcp 127.0.0.1:2001: connect: connection refused

After two retries with the same error the pipeline passed on the third try. Could it be an unavailable port or should I look for a problem elsewhere?
Picture of Cristina Basescu
Re: Tests and concurrency
by Cristina Basescu - Monday, 28 September 2020, 08:09
 

Hi,

Sharing doesn't cause this problem. The machine is indeed shared, but the environment not: every student's tests run in a docker container.

Have you taken a look at this thread? [1] Might solve your problem.

Cristina

[1] https://moodle.epfl.ch/mod/forum/discuss.php?d=42548