mirror of
https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git
synced 2024-12-28 05:03:09 +00:00
Compare commits
3 Commits
9c7fb06532
...
a0d026501f
Author | SHA1 | Date | |
---|---|---|---|
|
a0d026501f | ||
|
5335016adc | ||
|
296d599541 |
@ -6,14 +6,8 @@ use utils;
|
|||||||
sub run {
|
sub run {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
# Let's get the $target release version. Most of the time,
|
# Let's get the $target release version.
|
||||||
# the version will point to a future release. On Rawhide,
|
my $target = get_release_number();
|
||||||
# this will not be a number, so we need to convert it
|
|
||||||
# to a number.
|
|
||||||
my $target = get_var('VERSION');
|
|
||||||
if (get_var('VERSION') eq 'Rawhide') {
|
|
||||||
$target = get_var('RAWREL');
|
|
||||||
}
|
|
||||||
# The $current release version is the last stable release
|
# The $current release version is the last stable release
|
||||||
# around that we want to compare.
|
# around that we want to compare.
|
||||||
my $current = get_var('CURRREL');
|
my $current = get_var('CURRREL');
|
||||||
|
@ -15,11 +15,30 @@ sub strip_marks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub json_to_hash {
|
sub json_to_hash {
|
||||||
|
# This will convert a Json string into a valid
|
||||||
|
# Perl hash for further processing.
|
||||||
my $json = shift;
|
my $json = shift;
|
||||||
my $hash = JSON::PP->new->utf8->decode($json);
|
my $hash = JSON::PP->new->utf8->decode($json);
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub date_to_epoch {
|
||||||
|
# This takes the date in YYYY-MM-DD and converts it into
|
||||||
|
# the epoch integer.
|
||||||
|
my $dstring = shift;
|
||||||
|
my $date = Time::Piece->strptime($dstring, '%Y-%m-%d');
|
||||||
|
my $epoch = $date->epoch;
|
||||||
|
return $epoch;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub epoch_to_date {
|
||||||
|
# This will convert the epoch integer into YYYY-MM-DD.
|
||||||
|
my $epoch = shift;
|
||||||
|
my $time = localtime($epoch);
|
||||||
|
my $date = $time->strftime('%Y-%m-%d');
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
|
|
||||||
sub get_bodhi_eol {
|
sub get_bodhi_eol {
|
||||||
# This reads the Bodhi info file (downloaded in collect_web_data.pm),
|
# This reads the Bodhi info file (downloaded in collect_web_data.pm),
|
||||||
# parses it and returns the EOL date from that file.
|
# parses it and returns the EOL date from that file.
|
||||||
@ -30,6 +49,7 @@ sub get_bodhi_eol {
|
|||||||
my $json = script_output("cat ~/version_data/bodhi-$ver.json");
|
my $json = script_output("cat ~/version_data/bodhi-$ver.json");
|
||||||
my $bodhi = json_to_hash($json);
|
my $bodhi = json_to_hash($json);
|
||||||
my $eol = $bodhi->{"eol"};
|
my $eol = $bodhi->{"eol"};
|
||||||
|
$eol = date_to_epoch($eol);
|
||||||
return $eol;
|
return $eol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,21 +73,82 @@ sub get_schedule_eol {
|
|||||||
}
|
}
|
||||||
# The EOL date is provided as an epoch, so just return it.
|
# The EOL date is provided as an epoch, so just return it.
|
||||||
return $eol;
|
return $eol;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_current_date {
|
sub get_current_date {
|
||||||
# This returns the current date in the required form
|
# This returns the current date in as the epoch and YYYY-MM-DD.
|
||||||
# YYYY-MM-DD which we need to see if the EOL is
|
# which we need to see if the EOL is correctly set in the future.
|
||||||
# correctly set in the future.
|
|
||||||
my $time = localtime;
|
my $time = localtime;
|
||||||
$time = $time->strftime('%Y-%m-%d');
|
my $dates = {};
|
||||||
return $time;
|
$dates->{date} = $time->strftime('%Y-%m-%d');
|
||||||
|
$dates->{epoch} = date_to_epoch($dates{date});
|
||||||
|
return $dates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub check_eol_in_year {
|
||||||
|
# This will take the EOL date from the /etc/os-release
|
||||||
|
# file and it will check that it is at least a year in
|
||||||
|
# the future (when tested on non published ISOs).
|
||||||
|
# Returns true if successful.
|
||||||
|
my $tested = shift;
|
||||||
|
$tested = date_to_epoch($tested);
|
||||||
|
my $dates = get_current_date();
|
||||||
|
my $current = $dates->{epoch};
|
||||||
|
# The EOL in the os-release.pm must be at least a year
|
||||||
|
# in the future, so we calculate the epoch difference
|
||||||
|
# between $tested and $current.
|
||||||
|
# An epoch year should be
|
||||||
|
# 1 * 60 (min) *60 (hour) *24 (day) *365 (year)
|
||||||
|
my $year = 1*60*60*24*365;
|
||||||
|
my $delta = $tested - $current;
|
||||||
|
my $bool = 1;
|
||||||
|
if ($delta < $year) {
|
||||||
|
$bool = 0;
|
||||||
|
}
|
||||||
|
return $bool;
|
||||||
|
}
|
||||||
|
|
||||||
sub check_eol {
|
sub check_eols_match {
|
||||||
my $eol = shift;
|
# This will take the EOL dates from the /etc/os-release
|
||||||
|
# file and it will compare the value with those from
|
||||||
|
# Bodhi and Fedora Schedule and will succeed when they
|
||||||
|
# match each other.
|
||||||
|
my $tested = shift;
|
||||||
|
my $version = get_release_number();
|
||||||
|
my $bodhi = get_bodhi_eol($version);
|
||||||
|
$bodhi = epoch_to_date($bodhi);
|
||||||
|
my $schedule = get_schedule_eol($version);
|
||||||
|
$schedule = epoch_to_date($schedule);
|
||||||
|
# The resulting code will be 0 if the local SUPPORT_END cannot be validated
|
||||||
|
# against Bodhi or Schedule and os-release is the only source.
|
||||||
|
my $rcode = 0;
|
||||||
|
my $overall = 1;
|
||||||
|
# Change the exit code based on the resulting condition. We are only
|
||||||
|
# interested in the first condition really, but we want to know what
|
||||||
|
# the situation is exactly, so we will test all options.
|
||||||
|
if ($bodhi eq $schedule and $bodhi eq $tested) {
|
||||||
|
$rcode = 1;
|
||||||
|
}
|
||||||
|
elsif ($bodhi eq $schedule) {
|
||||||
|
$rcode = 2;
|
||||||
|
}
|
||||||
|
elsif ($tested eq $bodhi) {
|
||||||
|
$rcode = 3;
|
||||||
|
}
|
||||||
|
elsif ($tested eq $schedule) {
|
||||||
|
$rcode = 4;
|
||||||
|
}
|
||||||
|
$overall = 0 if ($rcode != 1);
|
||||||
|
my $return_codes = {
|
||||||
|
0 => "No EOL dates do match:\n\tos-release: $tested\n\tBodhi: $bodhi\n\tSchedule: $schedule",
|
||||||
|
2 => "The os-release doesn't match Bodhi or Schedule, but they match each other:\n\tos-release: $tested\n\tBodhi: $bodhi\n\tSchedule: $schedule"
|
||||||
|
3 => "The os-release file matches Bodhi but Schedule differs:\n\tos-release: $tested\n\tBodhi: $bodhi\n\tSchedule: $schedule",
|
||||||
|
4 => "The os-release file matches Schedule but Bodhi differs:\n\tos-release: $tested\n\tBodhi: $bodhi\n\tSchedule: $schedule",
|
||||||
|
1 => "All EOL dates match:\n\tos-release: $tested\n\tBodhi: $bodhi\n\tSchedule: $schedule"
|
||||||
|
};
|
||||||
|
|
||||||
|
my $result = [$overall, $return_codes->{$rcode}];
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
@ -189,8 +270,6 @@ sub run {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for the correct support day (a.k.a. EOL)
|
|
||||||
|
|
||||||
#Now. we can start testing the real values from the installed system.
|
#Now. we can start testing the real values from the installed system.
|
||||||
my @fails = ();
|
my @fails = ();
|
||||||
my $failref = \@fails;
|
my $failref = \@fails;
|
||||||
@ -241,6 +320,17 @@ sub run {
|
|||||||
print "VARIANT_ID was not tested because the compose is not Workstation or Server Edition.\n";
|
print "VARIANT_ID was not tested because the compose is not Workstation or Server Edition.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Test for EOL date in the distant future.
|
||||||
|
my $os_release_eol = $content{'SUPPORT_END'};
|
||||||
|
my $result = check_eol_in_year($os_release_eol);
|
||||||
|
my $current = get_current_date();
|
||||||
|
rec_log("The SUPPORT_END date is $os_release_eol which is at least a year ahead in time (now is $current->{date})", $result == 1, $failref);
|
||||||
|
|
||||||
|
# Test for EOL dates match each other.
|
||||||
|
$result = check_eols_match($os_release_eol);
|
||||||
|
rec_log($result->[1], $result->[0] == 1, $failref);
|
||||||
|
|
||||||
# Check for fails, count them, collect their messages and die if something was found.
|
# Check for fails, count them, collect their messages and die if something was found.
|
||||||
my $failcount = scalar @fails;
|
my $failcount = scalar @fails;
|
||||||
script_run "echo \"There were $failcount failures in total.\" >> /tmp/os-release.log";
|
script_run "echo \"There were $failcount failures in total.\" >> /tmp/os-release.log";
|
||||||
|
Loading…
Reference in New Issue
Block a user