1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-12-28 05:03:09 +00:00

Test release date ahead in time.

This commit is contained in:
Lukas Ruzicka 2024-11-28 14:12:37 +01:00
parent 296d599541
commit 5335016adc
2 changed files with 31 additions and 20 deletions

View File

@ -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');

View File

@ -65,27 +65,39 @@ 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 as the epoch # This returns the current date in as the epoch
# which we need to see if the EOL is correctly set in the future. # which we need to see if the EOL is correctly set in the future.
my $time = localtime; my $time = localtime;
my $date = $time->strftime('%Y-%m-%d'); my %dates;
$date = date_to_epoch($date); $dates{'date'} = $time->strftime('%Y-%m-%d');
return $date; $dates{'epoch'} = date_to_epoch($date);
return \%dates;
} }
sub check_eol_in_year { sub check_eol_in_year {
# This will take the EOL date from the /etc/os-release # This will take the EOL date from the /etc/os-release
# file and it will check that it is at least a year in # file and it will check that it is at least a year in
# the future (when tested on Rawhide, Branched, or Beta) # the future (when tested on non published ISOs).
# or that it is at least a year in the future compared # Returns true if successful.
# to the previously released version (when tested on a released my $tested = shift;
# version) $tested = date_to_epoch($tested);
my $eol = shift; 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 run { sub run {
@ -207,8 +219,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;
@ -259,6 +269,13 @@ 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 $current->{epoch} which is at least a year ahead in time", $result == 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";