@@ -35,7 +35,7 @@ use Text::Diff;
35
35
use OpenQA::File;
36
36
use OpenQA::Parser ' parser' ;
37
37
use OpenQA::WebSockets::Client;
38
- use List::Util qw( any) ;
38
+ use List::Util qw( any all ) ;
39
39
use Scalar::Util qw( looks_like_number) ;
40
40
# The state and results constants are duplicated in the Python client:
41
41
# if you change them or add any, please also update const.py.
@@ -1056,7 +1056,7 @@ sub calculate_result ($self) {
1056
1056
}
1057
1057
1058
1058
sub save_screenshot ($self , $screen ) {
1059
- return unless length ($screen -> {name });
1059
+ return unless ref $screen eq ' HASH ' && length ($screen -> {name });
1060
1060
1061
1061
my $tmpdir = $self -> worker-> get_property(' WORKER_TMPDIR' );
1062
1062
return unless -d $tmpdir ; # we can't help
@@ -1083,10 +1083,6 @@ sub append_log ($self, $log, $file_name) {
1083
1083
}
1084
1084
}
1085
1085
1086
- sub update_backend ($self , $backend_info ) {
1087
- $self -> update({backend => $backend_info -> {backend }});
1088
- }
1089
-
1090
1086
sub update_result ($self , $result , $state = undef ) {
1091
1087
my %values = (result => $result );
1092
1088
$values {state } = $state if defined $state ;
@@ -1096,6 +1092,9 @@ sub update_result ($self, $result, $state = undef) {
1096
1092
}
1097
1093
1098
1094
sub insert_module ($self , $tm , $skip_jobs_update = undef ) {
1095
+ my @required_fields = ($tm -> {name }, $tm -> {category }, $tm -> {script });
1096
+ return 0 unless all { defined $_ } @required_fields ;
1097
+
1099
1098
# prepare query to insert job module
1100
1099
my $insert_sth = $self -> {_insert_job_module_sth };
1101
1100
$insert_sth = $self -> {_insert_job_module_sth } = $self -> result_source-> schema-> storage-> dbh-> prepare(
@@ -1112,7 +1111,7 @@ sub insert_module ($self, $tm, $skip_jobs_update = undef) {
1112
1111
# note: We have 'important' in the DB but 'ignore_failure' in the flags for historical reasons (see #1266).
1113
1112
my $flags = $tm -> {flags };
1114
1113
$insert_sth -> execute(
1115
- $self -> id, $tm -> { name }, $tm -> { category }, $tm -> { script } ,
1114
+ $self -> id, @required_fields ,
1116
1115
$flags -> {milestone } ? 1 : 0,
1117
1116
$flags -> {ignore_failure } ? 0 : 1,
1118
1117
$flags -> {fatal } ? 1 : 0,
@@ -1126,7 +1125,7 @@ sub insert_module ($self, $tm, $skip_jobs_update = undef) {
1126
1125
}
1127
1126
1128
1127
sub insert_test_modules ($self , $testmodules ) {
1129
- return undef unless scalar @$testmodules ;
1128
+ return undef unless ref $testmodules eq ' ARRAY ' && scalar @$testmodules ;
1130
1129
1131
1130
# insert all test modules and update job module statistics uxing txn to avoid inconsistent job module
1132
1131
# statistics in the error case
@@ -1333,11 +1332,11 @@ sub parse_extra_tests ($self, $asset, $type, $script = undef) {
1333
1332
1334
1333
$parser -> load($tmp_extra_test )-> results-> each (
1335
1334
sub {
1336
- return if ! $_ -> test;
1337
- $_ -> test -> script( $script ) if $script ;
1338
- my $t_info = $_ -> test-> to_openqa ;
1339
- $self -> insert_module($t_info );
1340
- $self -> update_module($_ -> test -> name , $_ -> to_openqa);
1335
+ return unless my $test = $_ -> test;
1336
+ return unless my $test_name = $test -> name ;
1337
+ $ test-> script( $script ) if $script ;
1338
+ $self -> insert_module($test -> to_openqa );
1339
+ $self -> update_module($test_name , $_ -> to_openqa);
1341
1340
});
1342
1341
1343
1342
$self -> account_result_size(" $type results" , $parser -> write_output($self -> result_dir));
@@ -1481,10 +1480,8 @@ sub update_status ($self, $status) {
1481
1480
$self -> append_log($status -> {serial_terminal }, ' serial-terminal-live.txt' );
1482
1481
$self -> append_log($status -> {serial_terminal_user }, ' serial-terminal-live.txt' );
1483
1482
# delete from the hash so it becomes dumpable for debugging
1484
- my $screen = delete $status -> {screen };
1485
- $self -> save_screenshot($screen ) if $screen ;
1486
- $self -> update_backend($status -> {backend }) if $status -> {backend };
1487
- $self -> insert_test_modules($status -> {test_order }) if $status -> {test_order };
1483
+ $self -> save_screenshot(delete $status -> {screen });
1484
+ $self -> insert_test_modules($status -> {test_order });
1488
1485
my %known_image ;
1489
1486
my %known_files ;
1490
1487
my @failed_modules ;
0 commit comments