Skip Menu |

This queue is for tickets about the Net-LDAP-Server-Test CPAN distribution.

Report information
The Basics
Id: 56987
Status: resolved
Priority: 0/
Queue: Net-LDAP-Server-Test

People
Owner: karman [...] cpan.org
Requestors: bo [...] startsiden.no
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.09
Fixed in: (no value)



Subject: Failes tests
Hi, I get the same errors as here: http://www.cpantesters.org/cpan/report/06914830-b19f-3f77-b713-d32bba55d77f Do you have any fix for this, or a pointer to what I am doing wrong? Seems like 0.07 worked ok for me. regards, Bjørn-Olav
I think maybe the problem is a missing dependency on Net::LDAP::Server. regards, Bjørn-Olav
I do not believe the issue is a missing dependency, since the dependency is present for 98% of the passing tests and it is listed in the Makefile.PL deps list. I've seen this issue very occasionally when there is a delay in the underlying socket connection being opened with fork(). There is an intentional mock sleep() call in lines 887-897 to account for this, but it seems to still miss in a small percentage of cases. You could try adjusting the $wait value up to: time() + 3; # or 4 or 5 and see if that allows it to pass all tests. You'll note that in the failing case you referenced, the t/01-ldap.t tests fail but the t/02-ad.t tests all pass, which suggests to me that this is a timing issue per-environment rather than something systemically wrong with the module code per se.
I also saw the tests fail when installing this, it certainly looks like a timing issue as the third time I tried it worked. However, I don't really like the idea of increasing the sleep time as it makes my tests go quite slow, I've been playing with a patch along the lines of the following: --- a/lib/Net/LDAP/Server/Test.pm +++ b/lib/Net/LDAP/Server/Test.pm @@ -828,6 +828,8 @@ sub new { "cannot handle both 'data' and 'auto_schema' features. Pick one."; } + pipe(my $r_fh, my $w_fh); + my $pid = fork(); if ( !defined $pid ) { @@ -835,15 +837,18 @@ sub new { } elsif ( $pid == 0 ) { + warn "creating new LDAP server on port $port ... \n"; + # the child (server) my $sock = IO::Socket::INET->new( Listen => 5, Proto => 'tcp', Reuse => 1, LocalPort => $port - ); + ) or die "Unable to listen: $!"; - warn "creating new LDAP server on port $port ... \n"; + syswrite $w_fh, "Ready\n"; + undef $w_fh; my $sel = IO::Select->new($sock); my %Handlers; @@ -884,16 +889,10 @@ sub new { } else { - # the parent (client). - # hesitate a little to account for slow fork()s since - # sleep() is not strictly portable. - #warn "starting nap at " . localtime() . "\n"; - my $wait = time() + 2; - while ( time() < $wait ) { - 1; - } - - #warn "awake at " . localtime() . "\n"; + # the parent (client), wait for the client to say it's ready + + return unless <$r_fh> =~ /Ready/; + return bless( \$pid, $class ); } i.e. use a pipe to tell the parent when it's ready, this also allows the client to signal a failure to the parent.
On Thu Jun 10 04:58:37 2010, DGL wrote: Show quoted text
> i.e. use a pipe to tell the parent when it's ready, this also allows the > client to signal a failure to the parent.
I forgot to close $w_fh in the parent, but after fixing that this seems to work nicely for me.
Thanks. Patch applied and 0.10 uploaded to PAUSE.