-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.parallel.pl
executable file
·96 lines (71 loc) · 1.71 KB
/
run.parallel.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env perl
use strict;
use warnings;
use Rex -base;
use Rex::Commands::Cloud;
use Rex::Commands::SimpleCheck;
use Rex::Commands::SCM;
use Rex::Commands::Iptables;
use Test::More;
use Data::Dumper;
use YAML;
use Cwd 'getcwd';
$::QUIET = 1;
my $starttime;
my $phase;
our $branch = $ENV{REX_BRANCH} || "master";
our $git_repo = $ENV{GIT_REPO} || "git\@github.com:RexOps/Rex.git";
my $yaml =
eval { local ( @ARGV, $/ ) = ( $ENV{HOME} . "/.build_config" ); <>; };
$yaml .= "\n";
our $config = Load($yaml);
cloud_service "Jiffybox";
cloud_auth $config->{jiffybox}->{auth}->{access_key};
my @instances;
my @ips;
for my $i ( 1 .. $config->{parallelism} ) {
start_phase("Creating test instance: $i");
my $instance = cloud_instance create => {
image_id => "debian_squeeze_64bit",
name => "ptest$i",
plan_id => 29,
password => $config->{jiffybox}->{auth}->{password},
};
push @instances, $instance;
push @ips, $instance->{ip};
&end_phase;
}
our $user = "root";
our $pass = $config->{jiffybox}->{auth}->{password};
our $ip = join( " ", @ips );
$ENV{REX_USER} = $user;
$ENV{REX_PASS} = $pass;
parallelism 50;
our $RETVAL = 0;
eval {
do "run.tests.pl";
1;
} or do {
$RETVAL = 1;
};
my $i=1;
for my $inst ( @instances ) {
start_phase("Terminating test instance: $i");
cloud_instance terminate => $inst->{id};
$i++;
&end_phase;
}
my @running = grep { lc( $_->{state} ) eq "running" } cloud_instance_list;
if ( scalar @running >= 1 ) {
die "There are still some instances running...";
}
exit $RETVAL;
sub start_phase {
$phase = shift;
$starttime = time;
local $| = 1;
printf '%-50s', $phase;
}
sub end_phase {
printf "%4u s\n", scalar( time - $starttime );
}