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

Save progress, might be working.

This commit is contained in:
Lukas Ruzicka 2024-11-29 15:01:16 +01:00
parent d5bbba8120
commit 0d1268cd57
2 changed files with 16 additions and 17 deletions

View File

@ -20,11 +20,11 @@ sub run {
# We will fetch the version data from various locations.
# Download data from Bodhi for
assert_script_run("curl -o bodhi-$current.json https://bodhi.fedoraproject.org/releases/F$current");
assert_script_run("curl -o bodhi-$target.json https://bodhi.fedoraproject.org/releases/F$target");
# Download data from Fedora Schedule
assert_script_run("curl -o schedule-$current.json https://fedorapeople.org/groups/schedule/f-$current/f-$current-key.json");
assert_script_run("curl -o schedule-$target.json https://fedorapeople.org/groups/schedule/f-$target/f-$target-key.json");
# Install jq to modify the downloaded jsons and make sure, they will be correctly formed.
assert_script_run("dnf install -y jq", timeout => 60);
}
sub test_flags {

View File

@ -1,6 +1,6 @@
use base "installedtest";
use strict;
use JSON::PP;
use JSON;
use Time::Piece;
use testapi;
use utils;
@ -18,10 +18,10 @@ sub json_to_hash {
# This will convert a Json string into a valid
# Perl hash for further processing.
my $json = shift;
my $hash;
eval {
my $hash = JSON::PP->new->utf8->decode($json);
};
# The file is transferred via openQA methods and it basically
# is a string with \n symbols in it, which does not
# make it a valid json file. First, we need to remove these.
my $hash = decode_json($json);
die("Failed to parse JSON: $@") if ($@);
return $hash;
}
@ -50,7 +50,7 @@ sub get_bodhi_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 $json = script_output("cat ~/version_data/bodhi-$ver.json | jq -c");
my $bodhi = json_to_hash($json);
my $eol = $bodhi->{"eol"};
$eol = date_to_epoch($eol);
@ -63,22 +63,21 @@ sub get_schedule_eol {
# 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 $json = script_output("cat ~/version_data/schedule-$ver.json | jq -c");
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.
# FIXME parsing the tasks
my $tasks = $json->{tasks}[0]{tasks}[0]{tasks};
# The format of the json is quite complicated, so a lot of magic is necessary to come onto the EOL date inside, especially
# when some parts are placed in a list and Perl complains about incorrect HASH reference.
# However, I realized that it also has a field "end" just at the top structure which has the same value.
my $tasks = $schedule->{'tasks'}[0]{'tasks'}[0]{'tasks'};
my $eol;
foreach my $task (@$tasks) {
if ($task->{name} && $task->{name} =~ /End of Life/) {
$eol = $task->{end};
if ($task->{'name'} and $task->{'name'} =~ /End of Life/) {
$eol = $task->{'end'};
last;
}
}
# The EOL date is provided as an epoch, so just return it.
return $eol;
}