Mailing List Archive

r3800 - in trunk/perl: lib/KSx/Remote t
Author: creamyg
Date: 2008-08-29 22:07:11 -0700 (Fri, 29 Aug 2008)
New Revision: 3800

Modified:
trunk/perl/lib/KSx/Remote/SearchServer.pm
trunk/perl/t/510-remote_search.t
Log:
Skip remote tests if we can't get a socket.


Modified: trunk/perl/lib/KSx/Remote/SearchServer.pm
===================================================================
--- trunk/perl/lib/KSx/Remote/SearchServer.pm 2008-08-30 04:25:27 UTC (rev 3799)
+++ trunk/perl/lib/KSx/Remote/SearchServer.pm 2008-08-30 05:07:11 UTC (rev 3800)
@@ -73,8 +73,9 @@
my $client_sock = $main_sock->accept;

# Verify password.
- chomp( my $pass = <$client_sock> );
- if ( $pass eq $password{$$self} ) {
+ my $pass = <$client_sock>;
+ chomp($pass) if defined $pass;
+ if ( defined $pass && $pass eq $password{$$self} ) {
$read_set->add($client_sock);
print $client_sock "accepted\n";
}

Modified: trunk/perl/t/510-remote_search.t
===================================================================
--- trunk/perl/t/510-remote_search.t 2008-08-30 04:25:27 UTC (rev 3799)
+++ trunk/perl/t/510-remote_search.t 2008-08-30 05:07:11 UTC (rev 3800)
@@ -3,7 +3,9 @@

use Test::More;
use Time::HiRes qw( sleep );
+use IO::Socket::INET;

+my $PORT_NUM = 7890;
BEGIN {
if ( $^O =~ /mswin/i ) {
plan( 'skip_all', "fork on Windows not supported by KS" );
@@ -11,9 +13,6 @@
elsif ( $ENV{KINO_VALGRIND} ) {
plan( 'skip_all', "time outs cause probs under valgrind" );
}
- else {
- plan( tests => 10 );
- }
}

package SortSchema::UnAnalyzed;
@@ -63,7 +62,7 @@

my $searcher = KinoSearch::Searcher->new( invindex => $invindex, );
my $server = KSx::Remote::SearchServer->new(
- port => 7890,
+ port => $PORT_NUM,
searchable => $searcher,
password => 'foo',
);
@@ -71,9 +70,21 @@
exit(0);
}

+my $test_client_sock = IO::Socket::INET->new(
+ PeerAddr => "localhost:$PORT_NUM",
+ Proto => 'tcp',
+);
+if ($test_client_sock) {
+ plan( tests => 10 );
+ undef $test_client_sock;
+}
+else {
+ plan( 'skip_all', "Can't get a socket: $!" );
+}
+
my $searchclient = KSx::Remote::SearchClient->new(
schema => SortSchema->new,
- peer_address => 'localhost:7890',
+ peer_address => "localhost:$PORT_NUM",
password => 'foo',
);

@@ -159,3 +170,4 @@
$searchclient->terminate if defined $searchclient;
kill( TERM => $kid ) if $kid;
}
+


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits