| 1 | package PITA::Guest::Driver::Image::Test; | ||
| 2 | |||
| 3 | use 5.008; | ||
| 4 | use strict; | ||
| 5 | use File::Spec (); | ||
| 6 | use Probe::Perl (); | ||
| 7 | use PITA::Image 0.60 (); | ||
| 8 | use PITA::Guest::Driver::Image (); | ||
| 9 | |||
| 10 | our $VERSION = '0.60'; | ||
| 11 | our @ISA = 'PITA::Guest::Driver::Image'; | ||
| 12 | |||
| 13 | # The location of the support server | ||
| 14 | my $image_bin = File::Spec->rel2abs( | ||
| 15 | File::Spec->catfile( 't', 'bin', 'pita-imagetest' ) | ||
| 16 | ); | ||
| 17 | unless ( -f $image_bin ) { | ||
| 18 | Carp::croak("Failed to find the pita-imagetest script"); | ||
| 19 | } | ||
| 20 | |||
| 21 | # To allow for testing, whenever we return a support server we | ||
| 22 | # need to keep a reference to it. | ||
| 23 | use vars qw{$LAST_SUPPORT_SERVER}; | ||
| 24 | BEGIN { | ||
| 25 | $LAST_SUPPORT_SERVER = undef; | ||
| 26 | } | ||
| 27 | |||
| 28 | sub support_server_new { | ||
| 29 | my $self = shift; | ||
| 30 | my $server = PITA::Guest::Server::Process->new( | ||
| 31 | Program => [ | ||
| 32 | Probe::Perl->find_perl_interpreter, | ||
| 33 | $image_bin, | ||
| 34 | '--injector', | ||
| 35 | $self->injector_dir, | ||
| 36 | ], | ||
| 37 | Hostname => $self->support_server_addr, | ||
| 38 | Port => $self->support_server_port, | ||
| 39 | Mirrors => { }, | ||
| 40 | # http_result => $self->support_server_results, | ||
| 41 | # http_startup_timeout => 30, | ||
| 42 | # http_activity_timeout => 60, | ||
| 43 | # http_shutdown_timeout => 30, | ||
| 44 | ); | ||
| 45 | |||
| 46 | # Save the reference to the support server | ||
| 47 | $LAST_SUPPORT_SERVER = $server; | ||
| 48 | |||
| 49 | return $server; | ||
| 50 | } | ||
| 51 | |||
| 52 | 1; |