line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tapper::Cmd::Scenario; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TAPPER'; |
3
|
|
|
|
|
|
|
$Tapper::Cmd::Scenario::VERSION = '5.0.11'; |
4
|
2
|
|
|
2
|
|
5640614
|
use warnings; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
135
|
|
5
|
2
|
|
|
2
|
|
17
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
60
|
|
6
|
2
|
|
|
2
|
|
85
|
use 5.010; |
|
2
|
|
|
|
|
10
|
|
7
|
2
|
|
|
2
|
|
553
|
use Moose; |
|
2
|
|
|
|
|
507241
|
|
|
2
|
|
|
|
|
38
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
17734
|
use YAML::XS; |
|
2
|
|
|
|
|
3183
|
|
|
2
|
|
|
|
|
135
|
|
10
|
2
|
|
|
2
|
|
471
|
use Tapper::Model 'model'; |
|
2
|
|
|
|
|
4015
|
|
|
2
|
|
|
|
|
108
|
|
11
|
2
|
|
|
2
|
|
15
|
use parent 'Tapper::Cmd'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
151
|
use Try::Tiny; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
119
|
|
14
|
2
|
|
|
2
|
|
559
|
use Tapper::Cmd::Testrun; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
1261
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub create { |
19
|
1
|
|
|
1
|
1
|
20
|
my ($self, $scenario, $instance) = @_; |
20
|
1
|
|
33
|
|
|
8
|
$scenario->{instance_id} ||= $instance; |
21
|
1
|
|
|
|
|
4
|
return $self->add([$scenario]); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub parse_interdep |
26
|
|
|
|
|
|
|
{ |
27
|
2
|
|
|
2
|
1
|
19
|
my ($self, $conf) = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# TODO |
30
|
|
|
|
|
|
|
# 2.) check whether more than 2 testruns are local and prevent sync in this case |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
5
|
my $i_scenario_id; |
33
|
2
|
|
|
|
|
11
|
my $or_schema = model('TestrunDB'); |
34
|
|
|
|
|
|
|
try { |
35
|
|
|
|
|
|
|
$or_schema->txn_do(sub { |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $scenario = $or_schema->resultset('Scenario')->new({ |
38
|
|
|
|
|
|
|
type => 'interdep', |
39
|
|
|
|
|
|
|
options => $conf->{scenario_options} || $conf->{options}, |
40
|
|
|
|
|
|
|
name => $conf->{scenario_name} || $conf->{name}, |
41
|
2
|
|
33
|
|
|
2667
|
}); |
|
|
|
33
|
|
|
|
|
42
|
2
|
|
|
|
|
1551
|
$scenario->insert; |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
7512
|
$i_scenario_id = $scenario->id; |
45
|
2
|
|
|
|
|
84
|
my $tr = Tapper::Cmd::Testrun->new({ schema => $or_schema }); |
46
|
|
|
|
|
|
|
|
47
|
2
|
100
|
|
|
|
1712
|
foreach my $plan (@{$conf->{scenario_description} || $conf->{description}}) { |
|
2
|
|
|
|
|
16
|
|
48
|
|
|
|
|
|
|
|
49
|
4
|
|
33
|
|
|
29
|
$plan->{scenario_id} ||= $i_scenario_id; |
50
|
4
|
|
|
|
|
10
|
$plan->{status} = 'schedule'; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# backwards compatibility for old interdep descriptions |
53
|
4
|
50
|
|
|
|
14
|
if ( $plan->{requested_hosts} ) { |
54
|
0
|
|
|
|
|
0
|
$plan->{requested_hosts_any} = delete $plan->{requested_hosts}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
4
|
|
|
|
|
23
|
$tr->create($plan, $conf->{instance_id}); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
2
|
|
|
2
|
|
131
|
}); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
catch { |
65
|
0
|
|
|
0
|
|
0
|
die $_; |
66
|
2
|
|
|
|
|
26
|
}; |
67
|
|
|
|
|
|
|
|
68
|
2
|
|
|
|
|
35461
|
return $i_scenario_id; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub add { |
74
|
3
|
|
|
3
|
1
|
23706
|
my ($self, $list_of_confs) = @_; |
75
|
|
|
|
|
|
|
|
76
|
3
|
|
|
|
|
9
|
my @ids; |
77
|
3
|
50
|
|
|
|
10
|
foreach my $conf (@{$list_of_confs || [] }) { |
|
3
|
|
|
|
|
17
|
|
78
|
3
|
100
|
|
|
|
20
|
if ( $conf->{scenario_type} eq 'interdep' ) { |
|
|
50
|
|
|
|
|
|
79
|
2
|
|
|
|
|
10
|
push @ids, $self->parse_interdep($conf); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
elsif ( $conf->{scenario_type} eq 'multitest' ) { |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $sc = $self->schema->resultset('Scenario')->new({ |
84
|
|
|
|
|
|
|
type => 'multitest', |
85
|
|
|
|
|
|
|
options => $conf->{scenario_options} || $conf->{options}, |
86
|
|
|
|
|
|
|
name => $conf->{scenario_name} || $conf->{name}, |
87
|
1
|
|
33
|
|
|
58
|
}); |
|
|
|
33
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
568
|
$sc->insert; |
90
|
|
|
|
|
|
|
|
91
|
1
|
|
33
|
|
|
13358
|
my $description = $conf->{scenario_description} || $conf->{description}; |
92
|
1
|
|
|
|
|
33
|
$description->{scenario_id} = $sc->id; |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
43
|
my $tr = Tapper::Cmd::Testrun->new( schema => $self->schema ); |
95
|
1
|
|
|
|
|
969
|
$tr->create($description); |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
37
|
push @ids, $sc->id; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
else { |
101
|
0
|
|
0
|
|
|
0
|
die "Unknown scenario type '" . ( $conf->{scenario_type} || q## ) . "'"; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
3
|
|
|
|
|
221
|
return @ids; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub del { |
113
|
1
|
|
|
1
|
1
|
4398
|
my ($self, $id) = @_; |
114
|
1
|
|
|
|
|
6
|
my $scenario = model('TestrunDB')->resultset('Scenario')->find($id); |
115
|
1
|
|
|
|
|
2840
|
$scenario->delete(); |
116
|
1
|
|
|
|
|
32967
|
return 0; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; # End of Tapper::Cmd::Testrun |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=pod |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=encoding UTF-8 |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 NAME |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Tapper::Cmd::Scenario |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SYNOPSIS |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This project offers backend functions for all projects for manipulation the |
134
|
|
|
|
|
|
|
database on a higher level than that offered by Tapper::Schema. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
use Tapper::Cmd::Scenario; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
my $bar = Tapper::Cmd::Scenario->new(); |
139
|
|
|
|
|
|
|
$bar->add($scenario); |
140
|
|
|
|
|
|
|
... |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 NAME |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Tapper::Cmd::Scenario - Backend functions for manipulation of scenario in the database |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 FUNCTIONS |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 create |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Create a new scenario from one element of a test plan (actually a test |
151
|
|
|
|
|
|
|
plan instance). If the new scenario belong to a test plan instance the |
152
|
|
|
|
|
|
|
function expects the id of this instance as second parameter. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
@param hash ref - test plan element |
155
|
|
|
|
|
|
|
@param instance - test plan instance id |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
@return success - array - scenario ids |
158
|
|
|
|
|
|
|
@return error - die |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 parse_interdep |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Parse an interdep scenario and do everything needed to put it into the |
163
|
|
|
|
|
|
|
database. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
@param hash ref - config containing all relevant information |
166
|
|
|
|
|
|
|
@param hash ref - options |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
@return success - int - scenario_id |
169
|
|
|
|
|
|
|
@return error - die with error text |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 add |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Add a new scenario to database. Add with testplan instance id if given. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
@param hash ref - options for new scenario |
176
|
|
|
|
|
|
|
@param instance - test plan instance id |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
@return success - array - scenario id |
179
|
|
|
|
|
|
|
@return error - die |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 del |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Delete a testrun with given id. Its named del instead of delete to |
184
|
|
|
|
|
|
|
prevent confusion with the buildin delete function. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
@param int - testrun id |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
@return success - 0 |
189
|
|
|
|
|
|
|
@return error - error string |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 AUTHORS |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=over 4 |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item * |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item * |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Tapper Team <tapper-ops@amazon.com> |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=back |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Advanced Micro Devices, Inc.. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
This is free software, licensed under: |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=cut |