Agent-TCLI
view release on metacpan or search on metacpan
lib/Agent/TCLI/Transport/Test.pm view on Meta::CPAN
($another, $again) = $self->do_test($test, $response);
# allow tests to apply to more than one response by setting again
unless ( $again )
{
shift(@{$self->request_tests->{ $response->id } });
}
# adjust index only if again, otherwise we just shifted the array
$index += $again;
}
else
{
# There are not any more to do. :)
$another = 0;
$self->Verbose("PostResponse: response ".$response->id." received but no more tests");
}
next;
}
$self->responses_contiguous;
# if ( $response_prime->depth_test_array == 0 )
if ( scalar(@{$self->request_tests->{ $response->id } }) == 0 )
{
# TODO the way to do this is to have a test type that counts
# if ( defined( $response->get_responses_wanted) &&
# $response->get_responses_wanted == $response->response_count )
# {
# $self->builder->ok( 1, " Request ".$response->id." got wanted responses " );
# }
$requests_complete[$$self]++;
}
elsif ( scalar(@{$self->request_tests->{ $response->id } }) >= 0 )
{
my $complete = 1;
# if all we have left is are tests, then we can be complete.
foreach $test ( @{$self->request_tests->{ $response->id } } )
{
$complete = ($complete && $test->[0] =~ /^are/);
}
$requests_complete[$$self] += $complete;
}
}
=item SendChangeContext
B<SendChangeContext> is a POE event handler required for all Transports. Well,
all I<other> Transports, as this one still thinks it is special enough not to
need to do anything here.
=cut
sub SendChangeContext {
my ($kernel, $self, $control ) =
@_[KERNEL, OBJECT, ARG0 ];
# for jabber, we announce context with presence.
# for a terminal, it might be a prompt...
$self->Verbose($self->alias.":SendChangeContext: for control".$control->id());
}
=item SendRequest
B<SendRequest> is a POE event handler that is required for all Transports.
It takes a Agent::TCLI::Request as an argument
=cut
sub SendRequest {
my ($kernel, $self, $sender, $request) =
@_[KERNEL, OBJECT, SENDER, ARG0 ];
$self->Verbose($self->alias.":SendRequest: sender(".$sender->ID.") request(".$request->id.") \n");
$self->Verbose($self->alias.":SendRequest: request dump \n",3,$request);
# send request
# Need to think about sender stack...
# if there is nothing on the stack, it get's populated with
# test and posted to control.
# if another transport is on the stack, it puts itself on the bottom?
# Then sends it to the local transport for handling.
# The local transport will send it to the remote transport, putting
# itself (the local) on the stack as well. No, it needs to take off the remote when it sends it there.
# we're not via headers here. We just need to know where to go
# Transport should take themselves out and put in where they got the request
# so it can go back.
# Put time in request for tracking
$request->set_time(time());
if ( $request->sender->[0] eq $self->alias )
{
$self->Verbose($self->alias.":SendRequest: local request \n");
$self->Verbose($self->alias.":SendRequest: request dump ".$request->dump(1),3 );
# Get a Control for the test-master user loaded into peers.
my $control = $self->GetControl( $self->peers->[0]->id, $self->peers->[0] );
# Post to our Control
# Sometimes, control has not started, so we wiat if we have to.
if ( defined($control->start_time) )
{
$kernel->post( $control->id => 'Execute' => $request );
}
else
{
$kernel->delay('ControlExecute' => 1 => $control, $request );
}
}
else
{
$self->Verbose($self->alias.":SendRequest: punting the request \n");
# Take off Sender and postback and put us at the end.
# assuming here that wherever this is going, we don't have to
# worry about setting up the Control....
( run in 0.423 second using v1.01-cache-2.11-cpan-0b5f733616e )