Subject: | Race condition in tests |
http://matrix.cpantesters.org/?dist=LWP-Simple-REST%200.07 shows a random pattern of fail reports. It seems that most (all?) of these fail reports are caused by a race condition between start of the test http server, and connecting to this server. It happens if the server starts too slowly.
To simulate this race condition it's enough to monkeypatch the run() method, e.g. by adding the following to the HTTPTest package:
sub run {
my($self, @args) = @_;
sleep 1;
$self->SUPER::run(@args);
}
I'm not sure how to fix this reliably. One approach could be to check first if the connection is successful, and to sleep for a small period (sub-second) and retry again if not.