From ff962cb16de6e0c472d38aee5d5dfb8ffefba397 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Nov 01 2019 20:07:23 +0000 Subject: Backport PR #2456 to fix a needle URL issue affecting needle diff --- diff --git a/0001-Fix-URLs-for-needles-in-subdirectories-POO-58959.patch b/0001-Fix-URLs-for-needles-in-subdirectories-POO-58959.patch new file mode 100644 index 0000000..0f016e1 --- /dev/null +++ b/0001-Fix-URLs-for-needles-in-subdirectories-POO-58959.patch @@ -0,0 +1,54 @@ +From 96188d8067a365b2f4a4ffbdb327b2ec8214c19c Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Fri, 1 Nov 2019 12:03:35 -0700 +Subject: [PATCH] Fix URLs for needles in subdirectories (POO #58959) + +As discussed in the POO, this was broken by PR #2410 commit +36aa974 - it assumes you can always find a needle simply by +sticking the needle filename on the end of a `needledir` call, +but you can't, needles are allowed to be in subdirectories of +needledir. This should hopefully fix that without breaking +the custom run case by using the *whole* of the JSON file path - +we just figure out the subdirectory component from it. This works +for me in the 'needle is in a subdirectory of the normal needle +dir' case, but I didn't test it in the custom run case. + +Signed-off-by: Adam Williamson +--- + lib/OpenQA/WebAPI/Controller/File.pm | 20 +++++++++++++++++++- + 1 file changed, 19 insertions(+), 1 deletion(-) + +diff --git a/lib/OpenQA/WebAPI/Controller/File.pm b/lib/OpenQA/WebAPI/Controller/File.pm +index ad1b004f..ed73f9be 100644 +--- a/lib/OpenQA/WebAPI/Controller/File.pm ++++ b/lib/OpenQA/WebAPI/Controller/File.pm +@@ -43,7 +43,25 @@ sub needle { + } + + # locate the needle in the needle directory for the given distri and version +- push(@{($self->{static} = Mojolicious::Static->new)->paths}, needledir($distri, $version)); ++ my $needledir = needledir($distri, $version); ++ # we need to handle the needle being in a subdirectory - we cannot ++ # assume it is always just '$needledir/$name.$format'. figure out ++ # subdirectory elements from the JSON file path ++ my ($dummy1, $path, $dummy2) = fileparse($jsonfile); ++ # drop the trailing / from $path ++ $path = substr($path, 0, -1); ++ if (index($path, '/needles') != -1) { ++ # we got something like /var/lib/openqa/share/tests/distri/needles/(subdir)/needle.json ++ my @elems = split('/needles', $path, 2); ++ if (defined $elems[1]) { ++ $needledir .= $elems[1]; ++ } ++ } ++ elsif ($path ne '.') { ++ # we got something like subdir/needle.json, $path will be "subdir" ++ $needledir .= "/$path"; ++ } ++ push(@{($self->{static} = Mojolicious::Static->new)->paths}, $needledir); + + # name is an URL parameter and can't contain slashes, so it should be safe + return $self->serve_static_($name . $format); +-- +2.24.0.rc1 + diff --git a/openqa.spec b/openqa.spec index fa5858e..a3417ec 100644 --- a/openqa.spec +++ b/openqa.spec @@ -60,7 +60,7 @@ Name: openqa Version: %{github_version} -Release: 34%{?github_date:.%{github_date}git%{shortcommit}}%{?dist} +Release: 35%{?github_date:.%{github_date}git%{shortcommit}}%{?dist} Summary: OS-level automated testing framework License: GPLv2+ Url: http://os-autoinst.github.io/openQA/ @@ -85,6 +85,9 @@ Source4: 23-fedora-messaging.t # https://github.com/os-autoinst/openQA/pull/2453 # Drop fedmsg plugin Patch0: 0001-Remove-fedmsg-plugin.patch +# https://github.com/os-autoinst/openQA/pull/2456 +# Fix a needle URL issue which broke needlediff for needles in subdirs +Patch1: 0001-Fix-URLs-for-needles-in-subdirectories-POO-58959.patch BuildRequires: %{python_scripts_requires} BuildRequires: perl-generators @@ -533,6 +536,9 @@ fi %{_datadir}/openqa/lib/OpenQA/WebAPI/Plugin/FedoraUpdateRestart.pm %changelog +* Fri Nov 01 2019 Adam Williamson - 4.6-35.20191031git127fcf3 +- Backport PR #2456 to fix a needle URL issue affecting needle diff + * Thu Oct 31 2019 Adam Williamson - 4.6-34.20191031git127fcf3 - Update to latest upstream git - Resync spec with upstream