1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-12-26 20:23:09 +00:00

Add functionality to parse files.

This commit is contained in:
Lukas Ruzicka 2024-11-27 13:04:01 +01:00
parent a3fbe7fcc9
commit 9c7fb06532

View File

@ -1,9 +1,9 @@
use base "installedtest";
use strict;
use JSON::PP;
use Time::Piece;
use testapi;
use utils;
use IO::Socket::INET;
use JSON;
# This test checks that the descriptions in /etc/os-release file are correct and that they
# match the current version.
@ -14,10 +14,58 @@ sub strip_marks {
return $string;
}
sub get_fedora_schedule_version {
sleep(10);
sub json_to_hash {
my $json = shift;
my $hash = JSON::PP->new->utf8->decode($json);
return $hash;
}
sub get_bodhi_eol {
# This reads the Bodhi info file (downloaded in collect_web_data.pm),
# parses it and returns the EOL date from that file.
# As argument it takes the version number from which the EOL
# date should be returned.
my $ver = shift;
# The content of the downloaded file is a JSON string.
my $json = script_output("cat ~/version_data/bodhi-$ver.json");
my $bodhi = json_to_hash($json);
my $eol = $bodhi->{"eol"};
return $eol;
}
sub get_schedule_eol {
# This reads the Fedora Schedule info file (downloaded
# previously in collect_web_data.pm), parses it and returns
# the EOL date from that file. As argument, it takes the version
# number from which the EOL date should be returned.
my $ver = shift;
my $json = script_output("cat ~/version_data/schedule-$ver.json");
my $schedule = json_to_hash($json);
my $eol;
# The format of the json is quite complicated, so we need to do
# quite a lot of magic to arrive at the correct date, so let's
# hope the format stays the same in the future.
foreach my $task (@{$json->{tasks}->[0]->{tasks}->[0]->{tasks}}) {
if ($task->{name} && $task->{name} =~ /End of Life/) {
$eol = $task->{end};
last;
}
}
# The EOL date is provided as an epoch, so just return it.
return $eol;
}
sub get_current_date {
# This returns the current date in the required form
# YYYY-MM-DD which we need to see if the EOL is
# correctly set in the future.
my $time = localtime;
$time = $time->strftime('%Y-%m-%d');
return $time;
}
sub check_eol {
my $eol = shift;
}