Skip to content

Commit

Permalink
Closer to getting the cluster Storage::DBI test working, but not quit…
Browse files Browse the repository at this point in the history
…e (SQLite won't open the same DB twice..)
  • Loading branch information
dsnopek committed Jun 15, 2010
1 parent 3e60306 commit 9d9ceb6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/POE/Component/MessageQueue/Storage/Generic/DBI.pm
Expand Up @@ -137,7 +137,7 @@ sub _make_message {
}
# pull only the client ID out of the in_use_by field
my $mq_id = $self->mq_id;
if (defined $mq_id) {
if (defined $mq_id && defined $args{claimant}) {
$args{claimant} =~ s/^$mq_id://;
}
return POE::Component::MessageQueue::Message->new(%args);
Expand Down
32 changes: 29 additions & 3 deletions t/10_cluster_dbi.t
Expand Up @@ -4,12 +4,22 @@ use warnings;
use lib 't/lib';
use POE::Component::MessageQueue::Test::Stomp;
use POE::Component::MessageQueue::Test::MQ;
use POE::Component::MessageQueue::Test::EngineMaker;
use File::Path;
use Test::More tests => 4;
use Test::Exception;

# Make sure that there are no conflicts between in_use_by values when two
# seperate MQs are using Storage::DBI pointing at the same database.

END {
rmtree(DATA_DIR);
}

rmtree(DATA_DIR);
mkpath(DATA_DIR);
make_db();

my $pid1 = start_mq(
storage => 'DBI',
storage_args => { mq_id => 'mq1' },
Expand Down Expand Up @@ -43,9 +53,25 @@ ok($pid2, "MQ2 started");
# and make sure that the message isn't redelivered.
#

# TODO: subscribe to MQ1 and send a message, then claim the message (don't ACK)
# TODO: connect to MQ2, disconnect.
# TODO: make sure that the message isn't re-delivered!
my ($client1a, $client1b);
my $message;

ok($client1a = stomp_connect(), 'MQ1: client 1 connected');

lives_ok {
stomp_subscribe($client1a);
stomp_send($client1a);
} 'MQ1: client 1 subscribed and sent message';

ok($message = $client1a->receive_frame(), 'MQ1: client 1 claimed message');

# next, client 1 connects and disconnects to MQ2
ok($client1b = stomp_connect(8100), 'MQ2: client 1 connects');
lives_ok { $client1b->disconnect() } 'MQ2: client 1 disconnects';

# finally, client 2 connects and subscribes to MQ1 and makes sure that
# this first message isn't delivered
is(stomp_connect()->can_read({ timeout => 10 }), 0, 'message isn\'t re-delivered');

ok(stop_fork($pid1), 'MQ1 shut down.');
ok(stop_fork($pid2), 'MQ2 shut down.');
Expand Down

0 comments on commit 9d9ceb6

Please sign in to comment.