line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::Component::SmokeBox; |
2
|
|
|
|
|
|
|
$POE::Component::SmokeBox::VERSION = '0.56'; |
3
|
|
|
|
|
|
|
#ABSTRACT: POE enabled CPAN smoke testing with added value. |
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
9326
|
use strict; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
325
|
|
6
|
11
|
|
|
11
|
|
159
|
use warnings; |
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
328
|
|
7
|
11
|
|
|
11
|
|
987
|
use POE qw(Component::SmokeBox::Backend Component::SmokeBox::JobQueue); |
|
11
|
|
|
|
|
60454
|
|
|
11
|
|
|
|
|
94
|
|
8
|
11
|
|
|
11
|
|
683
|
use POE::Component::SmokeBox::Smoker; |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
249
|
|
9
|
11
|
|
|
11
|
|
58
|
use POE::Component::SmokeBox::Job; |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
226
|
|
10
|
11
|
|
|
11
|
|
58
|
use POE::Component::SmokeBox::Result; |
|
11
|
|
|
|
|
26
|
|
|
11
|
|
|
|
|
15570
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub spawn { |
13
|
9
|
|
|
9
|
1
|
2506
|
my $package = shift; |
14
|
9
|
|
|
|
|
40
|
my %params = @_; |
15
|
9
|
|
|
|
|
58
|
$params{lc $_} = delete $params{$_} for keys %params; |
16
|
9
|
|
|
|
|
25
|
my $options = delete $params{'options'}; |
17
|
9
|
100
|
|
|
|
175
|
$params{'delay'} = 0 unless exists $params{'delay'}; |
18
|
9
|
|
|
|
|
26
|
my $self = bless \%params, $package; |
19
|
9
|
100
|
|
|
|
122
|
$self->{session_id} = POE::Session->create( |
20
|
|
|
|
|
|
|
object_states => [ |
21
|
|
|
|
|
|
|
$self => { |
22
|
|
|
|
|
|
|
shutdown => '_shutdown', |
23
|
|
|
|
|
|
|
add_smoker => '_add_smoker', |
24
|
|
|
|
|
|
|
del_smoker => '_del_smoker', |
25
|
|
|
|
|
|
|
submit => '_submit', |
26
|
|
|
|
|
|
|
register_ui => '_reg_ui', |
27
|
|
|
|
|
|
|
unregister_ui => '_unreg_ui', |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
$self => [qw(_start)], |
30
|
|
|
|
|
|
|
], |
31
|
|
|
|
|
|
|
heap => $self, |
32
|
|
|
|
|
|
|
( ref($options) eq 'HASH' ? ( options => $options ) : () ), |
33
|
|
|
|
|
|
|
)->ID(); |
34
|
9
|
|
|
|
|
1569
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub session_id { |
38
|
45
|
|
|
45
|
1
|
1622
|
return $_[0]->{session_id}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub multiplicity { |
42
|
2
|
|
|
2
|
1
|
1100
|
return $_[0]->{multiplicity}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub delay { |
46
|
3
|
50
|
|
3
|
1
|
441
|
if ( defined $_[1] ) { |
47
|
|
|
|
|
|
|
# verify it's an int |
48
|
0
|
0
|
|
|
|
0
|
if ( $_[1] !~ /^\d+$/ ) { |
49
|
0
|
|
|
|
|
0
|
return; |
50
|
|
|
|
|
|
|
} else { |
51
|
0
|
|
|
|
|
0
|
$_[0]->{delay} = $_[1]; |
52
|
0
|
|
|
|
|
0
|
return $_[1]; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} else { |
55
|
3
|
|
|
|
|
14
|
return $_[0]->{delay}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub queues { |
60
|
20
|
|
|
20
|
1
|
3364
|
return map { $_->{queue} } @{ $_[0]->{queues} }; |
|
33
|
|
|
|
|
172
|
|
|
20
|
|
|
|
|
88
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub shutdown { |
64
|
9
|
|
|
9
|
1
|
4890
|
my $self = shift; |
65
|
9
|
|
|
|
|
82
|
$poe_kernel->call( $self->session_id() => 'shutdown' => @_ ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _start { |
69
|
9
|
|
|
9
|
|
3410
|
my ($kernel,$self) = @_[KERNEL,OBJECT]; |
70
|
9
|
|
|
|
|
41
|
$self->{session_id} = $_[SESSION]->ID(); |
71
|
9
|
50
|
|
|
|
69
|
if ( $self->{alias} ) { |
72
|
0
|
|
|
|
|
0
|
$kernel->alias_set( $self->{alias} ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else { |
75
|
9
|
|
|
|
|
59
|
$kernel->refcount_increment( $self->{session_id} => __PACKAGE__ ); |
76
|
|
|
|
|
|
|
} |
77
|
9
|
|
|
|
|
444
|
$self->{queues} = [ ]; |
78
|
9
|
|
|
|
|
25
|
my $smokers = delete $self->{smokers}; |
79
|
9
|
50
|
66
|
|
|
77
|
return unless $smokers and ref $smokers eq 'ARRAY' and scalar @{ $smokers }; |
|
6
|
|
100
|
|
|
36
|
|
80
|
6
|
|
|
|
|
14
|
$self->add_smoker( $_ ) for @{ $smokers }; |
|
6
|
|
|
|
|
25
|
|
81
|
6
|
|
|
|
|
53
|
return; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _shutdown { |
85
|
9
|
|
|
9
|
|
766
|
my ($kernel,$self) = @_[KERNEL,OBJECT]; |
86
|
9
|
50
|
|
|
|
76
|
if ( $self->{alias} ) { |
87
|
0
|
|
|
|
|
0
|
$kernel->alias_remove($_) for $kernel->alias_list(); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else { |
90
|
9
|
|
|
|
|
69
|
$kernel->refcount_decrement( $self->{session_id} => __PACKAGE__ ); |
91
|
|
|
|
|
|
|
} |
92
|
9
|
|
|
|
|
485
|
$_->{queue}->shutdown() for @{ $self->{queues} }; |
|
9
|
|
|
|
|
120
|
|
93
|
9
|
|
|
|
|
194
|
return; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub add_smoker { |
97
|
31
|
|
|
31
|
1
|
186
|
my $self = shift; |
98
|
31
|
|
|
|
|
251
|
$poe_kernel->call( $self->{session_id}, 'add_smoker', @_ ); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub del_smoker { |
102
|
11
|
|
|
11
|
1
|
106223
|
my $self = shift; |
103
|
11
|
|
|
|
|
113
|
$poe_kernel->call( $self->{session_id}, 'del_smoker', @_ ); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub _add_smoker { |
107
|
31
|
|
|
31
|
|
1873
|
my ($kernel,$self,$state,$sender,$smoker) = @_[KERNEL,OBJECT,STATE,SENDER,ARG0]; |
108
|
31
|
50
|
33
|
|
|
268
|
unless ( $smoker and $smoker->isa('POE::Component::SmokeBox::Smoker') ) { |
109
|
0
|
|
|
|
|
0
|
warn "ARG0 must be a 'POE::Component::SmokeBox::Smoker' object\n"; |
110
|
0
|
|
|
|
|
0
|
return; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
# If no jobqueues start a job queue. |
113
|
|
|
|
|
|
|
# If multiplicity start a job queue for each smoker object. |
114
|
31
|
100
|
100
|
|
|
93
|
if ( $self->{multiplicity} or scalar @{ $self->{queues} } == 0 ) { |
|
21
|
|
|
|
|
67
|
|
115
|
17
|
|
|
|
|
37
|
my $queue = { }; |
116
|
|
|
|
|
|
|
$queue->{queue} = POE::Component::SmokeBox::JobQueue->spawn( |
117
|
|
|
|
|
|
|
'delay' => $self->{delay}, |
118
|
17
|
|
|
|
|
67
|
); |
119
|
17
|
|
|
|
|
32
|
push @{ $queue->{smokers} }, $smoker; |
|
17
|
|
|
|
|
45
|
|
120
|
17
|
|
|
|
|
28
|
push @{ $self->{queues} }, $queue; |
|
17
|
|
|
|
|
32
|
|
121
|
17
|
|
|
|
|
54
|
return; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
# Otherwise we just add the smoker to our existing queue |
124
|
14
|
|
|
|
|
24
|
push @{ $self->{queues}->[0]->{smokers} }, $smoker; |
|
14
|
|
|
|
|
35
|
|
125
|
14
|
|
|
|
|
35
|
return; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub _del_smoker { |
129
|
11
|
|
|
11
|
|
4472
|
my ($kernel,$self,$state,$sender,$smoker) = @_[KERNEL,OBJECT,STATE,SENDER,ARG0]; |
130
|
11
|
50
|
33
|
|
|
204
|
unless ( $smoker and $smoker->isa('POE::Component::SmokeBox::Smoker') ) { |
131
|
0
|
|
|
|
|
0
|
warn "ARG0 must be a 'POE::Component::SmokeBox::Smoker' object\n"; |
132
|
0
|
|
|
|
|
0
|
return; |
133
|
|
|
|
|
|
|
} |
134
|
11
|
|
|
|
|
35
|
my $x = 0; |
135
|
11
|
|
|
|
|
38
|
foreach my $queue ( @{ $self->{queues} } ) { |
|
11
|
|
|
|
|
78
|
|
136
|
17
|
|
|
|
|
52
|
my $i = 0; |
137
|
17
|
|
|
|
|
52
|
for ( @{ $queue->{smokers} } ) { |
|
17
|
|
|
|
|
66
|
|
138
|
29
|
100
|
|
|
|
107
|
splice(@{ $queue->{smokers} }, $i, 1) if $_ == $smoker; |
|
8
|
|
|
|
|
43
|
|
139
|
29
|
|
|
|
|
82
|
++$i; |
140
|
|
|
|
|
|
|
} |
141
|
17
|
100
|
|
|
|
42
|
unless ( scalar @{ $queue->{smokers} } ) { |
|
17
|
|
|
|
|
72
|
|
142
|
3
|
|
|
|
|
8
|
splice(@{ $self->{queues} }, $x, 1); |
|
3
|
|
|
|
|
8
|
|
143
|
3
|
|
|
|
|
22
|
$queue->{queue}->shutdown(); |
144
|
|
|
|
|
|
|
} |
145
|
17
|
|
|
|
|
111
|
++$x; |
146
|
|
|
|
|
|
|
} |
147
|
11
|
|
|
|
|
60
|
return; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub submit { |
151
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
152
|
0
|
|
|
|
|
0
|
$poe_kernel->call( $self->{session_id}, 'submit', @_ ); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub _submit { |
156
|
36
|
|
|
36
|
|
5662
|
my ($kernel,$self,$state,$sender) = @_[KERNEL,OBJECT,STATE,SENDER]; |
157
|
36
|
50
|
|
|
|
133
|
return if $self->{_shutdown}; |
158
|
36
|
|
|
|
|
78
|
my $args; |
159
|
36
|
50
|
|
|
|
89
|
if ( ref( $_[ARG0] ) eq 'HASH' ) { |
160
|
0
|
|
|
|
|
0
|
$args = { %{ $_[ARG0] } }; |
|
0
|
|
|
|
|
0
|
|
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
else { |
163
|
36
|
|
|
|
|
143
|
$args = { @_[ARG0..$#_] }; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
36
|
|
|
|
|
73
|
$args->{lc $_} = delete $args->{$_} for grep { $_ !~ /^_/ } keys %{ $args }; |
|
72
|
|
|
|
|
340
|
|
|
36
|
|
|
|
|
117
|
|
167
|
|
|
|
|
|
|
|
168
|
36
|
50
|
|
|
|
130
|
unless ( $args->{event} ) { |
169
|
0
|
|
|
|
|
0
|
warn "No 'event' specified for $state\n"; |
170
|
0
|
|
|
|
|
0
|
return; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
36
|
50
|
33
|
|
|
259
|
unless ( $args->{job} and $args->{job}->isa('POE::Component::SmokeBox::Job') ) { |
174
|
0
|
|
|
|
|
0
|
warn "No 'job' specified for $state or it was not a valid 'POE::Component::SmokeBox::Job' object\n"; |
175
|
0
|
|
|
|
|
0
|
return; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
36
|
50
|
33
|
|
|
131
|
if ( $args->{session} and my $ref = $kernel->alias_resolve( $args->{session} ) ) { |
179
|
0
|
|
|
|
|
0
|
$args->{session} = $ref->ID(); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
else { |
182
|
36
|
|
|
|
|
104
|
$args->{session} = $sender->ID(); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
36
|
50
|
|
|
|
217
|
warn "No smokers have been defined yet!!!!!\n" unless scalar @{ $self->{queues} }; |
|
36
|
|
|
|
|
99
|
|
186
|
|
|
|
|
|
|
|
187
|
36
|
|
|
|
|
57
|
foreach my $q ( @{ $self->{queues} } ) { |
|
36
|
|
|
|
|
83
|
|
188
|
44
|
|
|
|
|
225
|
$args->{smokers} = [ @{ $q->{smokers} } ]; |
|
44
|
|
|
|
|
127
|
|
189
|
44
|
|
|
|
|
146
|
$q->{queue}->submit( $args ); |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
36
|
|
|
|
|
821
|
return; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
0
|
|
|
sub _reg_ui { |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
0
|
|
|
sub _unreg_ui { |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
"We've Got a Fuzzbox and We're Gonna Use It"; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
__END__ |