Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Migrate some more YAML schedules using PoC for enhanced scheduler #14562

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ test-compile-changed: os-autoinst/

.PHONY: test-yaml-valid
test-yaml-valid:
$(eval YAMLS=$(shell sh -c "git ls-files schedule/ test_data/ | grep '\\.ya\?ml$$'"))
$(eval YAMLS=$(shell sh -c "git ls-files schedule/ test_data/ | grep -v '/defaults/' | grep '\\.ya\?ml$$'"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong in a first sight. It makes the CI obsolete and probe to give false positives

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is that the enhancement for the scheduler uses a new format for the default files which differs from the current schema used for YAML-Schedules. See my documentation on Confluence for details. So "schedule:" is no longer an array of type string, but rather a hash with sections that are arrays of string.
Therefore the YAML checking for the /defaults/ directory is omitted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but @b10n1k is right, in my initial PoC I just wrote that pass the CI, we will plan some ticket for it or I will improve it directly there, we need some specific path not so generic :) so no worries, was in my mind! CI/Documentation/Schema check that will come later, we are not going to merge anything with todos :)

if test -n "$(YAMLS)"; then \
export PERL5LIB=${PERL5LIB_} ; echo "$(YAMLS)" | xargs tools/test_yaml_valid ;\
else \
Expand Down
51 changes: 37 additions & 14 deletions lib/scheduler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ use testapi qw(get_var set_var diag);
use main_common 'loadtest';
use YAML::PP;
use YAML::PP::Schema::Include;
use Data::Dumper;
use YAML::PP::Common 'PRESERVE_ORDER';

our @EXPORT = qw(load_yaml_schedule get_test_suite_data);

my $test_suite_data;
my $root_project_dir = dirname(__FILE__) . '/../';
my $include = YAML::PP::Schema::Include->new(paths => ($root_project_dir));
my $ypp = YAML::PP->new(schema => ['Core', $include, 'Merge']);
my $ypp = YAML::PP->new(
schema => ['Core', $include, 'Merge'],
preserve => PRESERVE_ORDER
);
$include->yp($ypp);
$Data::Dumper::Terse = 1;

sub parse_vars {
my ($schedule) = shift;
Expand All @@ -32,18 +34,40 @@ sub parse_vars {
$value =~ s/%(.*?)%/get_var($1)/eg;
$vars{$var} = $value;
}
my $varlog = Dumper(\%vars);
diag("parse_vars (variables parsed from YAML schedule): " . $varlog);
diag('parse_vars (variables parsed from YAML schedule):');
diag($ypp->dump_string(\%vars));
return %vars;
}

sub parse_schedule {
my ($schedule) = shift;
my @scheduled;
for my $module (@{$schedule->{schedule}}) {
push(@scheduled, parse_schedule_module($schedule, $module));

# schedule contains keys overriding a default schedule
if (ref $schedule->{schedule} eq 'HASH') {
if (my $yaml_default_path = get_var('YAML_SCHEDULE_DEFAULT')) {
my $default_schedule = $ypp->load_file($root_project_dir . $yaml_default_path);
for my $k (keys %$default_schedule) {
if (exists $schedule->{schedule}{$k}) {
push @scheduled, $schedule->{schedule}{$k}->@* if $schedule->{schedule}{$k};
}
else {
push @scheduled, $default_schedule->{$k}->@* if $default_schedule->{$k};
}
}
}
else {
die "YAML_SCHEDULE_DEFAULT should be provided when using keys to be overriden " .
"instead of a list of test modules";
}
}
# schedule contains a list of test modules
else {
for my $module (@{$schedule->{schedule}}) {
push(@scheduled, parse_schedule_module($schedule, $module));
}
}
diag($ypp->dump_string(\@scheduled));
return @scheduled;
}

Expand Down Expand Up @@ -116,9 +140,8 @@ sub parse_test_suite_data {
$test_suite_data = {%$test_suite_data, %{$include_yaml}};
}
expand_test_data_vars($test_suite_data);
my $out = Dumper($test_suite_data);
chomp($out);
diag("parse_test_suite_data (data parsed from YAML test_data): $out");
diag('parse_test_suite_data (data parsed from YAML test_data):');
diag($ypp->dump_string($test_suite_data));
}

=head2 load_yaml_schedule
Expand All @@ -129,12 +152,12 @@ Parse variables and test modules from a yaml file representing a test suite to b

sub load_yaml_schedule {
if (my $yamlfile = get_var('YAML_SCHEDULE')) {
my $schedule = $ypp->load_file($root_project_dir . $yamlfile);
my %schedule_vars = parse_vars($schedule);
my $schedule_file = $ypp->load_file($root_project_dir . $yamlfile);
my %schedule_vars = parse_vars($schedule_file);
my $test_context_instance = undef;
while (my ($var, $value) = each %schedule_vars) { set_var($var, $value) }
my @schedule_modules = parse_schedule($schedule);
parse_test_suite_data($schedule);
my @schedule_modules = parse_schedule($schedule_file);
parse_test_suite_data($schedule_file);
$test_context_instance = get_var('TEST_CONTEXT')->new() if defined get_var('TEST_CONTEXT');
loadtest($_, run_args => $test_context_instance) for (@schedule_modules);
return 1;
Expand Down
43 changes: 0 additions & 43 deletions schedule/yast/btrfs/btrfs+warnings.yaml

This file was deleted.

44 changes: 0 additions & 44 deletions schedule/yast/btrfs/btrfs+warnings@pvm.yaml

This file was deleted.

47 changes: 0 additions & 47 deletions schedule/yast/btrfs/btrfs+warnings@s390x.yaml

This file was deleted.

95 changes: 0 additions & 95 deletions schedule/yast/btrfs/btrfs_sle_libstorage-ng.yaml

This file was deleted.

60 changes: 0 additions & 60 deletions schedule/yast/btrfs/btrfs_sle_libstorage-ng@ipmi.yaml

This file was deleted.