From 39e6ec4f3c3285482b401b1ce4f96b2cc352e0b0 Mon Sep 17 00:00:00 2001
From: Denis Pynkin <denis.pynkin@collabora.com>
Date: Wed, 20 Jan 2021 23:25:09 +0300
Subject: [PATCH] lava: add flexible options for unpack with tar

For AUM tests unpack of overlay with tests in verbose mode
produce too lot of almost useless information. This is the reason
why the job log exceeding 5MB limit and should be downloaded as
plain text which is hard to analyze.

Added common macros `tar_unpack_cmd()` which create dynamic unpack
string depending on variable `tar_additional_options` ('-v' by default).

Additional verbose option for `tar` was switched off for all AUM tests
to simplify log analysis in WEb interface.

It is possible to override default options with `lqa` command, for
example: `lqa -t tar_additional_options:""`.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
---
 lava/aum-tpl.yaml                | 7 +++++++
 lava/common-boot-macros.yaml     | 7 +++++++
 lava/common-boot-tpl-reboot.yaml | 2 +-
 lava/common-boot-tpl.yaml        | 2 +-
 lava/common-qemu-boot-tpl.yaml   | 2 +-
 lava/group-nfs-tpl.yaml          | 2 +-
 6 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/lava/aum-tpl.yaml b/lava/aum-tpl.yaml
index a7160f91..07a72433 100644
--- a/lava/aum-tpl.yaml
+++ b/lava/aum-tpl.yaml
@@ -1,4 +1,11 @@
 job_name: Ostree updater test {{aum_test}} on {{release_version}} {{pretty}} {{image_date}}
+
+{% import 'common-boot-macros.yaml' as boot with context -%}
+
+{% if tar_additional_options is not defined %}
+    {% set tar_additional_options = "" %}
+{% endif %}
+
 {% if device_type == 'qemu' %}
 {% include 'common-qemu-boot-tpl.yaml' %}
 {% else %}
diff --git a/lava/common-boot-macros.yaml b/lava/common-boot-macros.yaml
index aeb81f7d..7f5bd291 100644
--- a/lava/common-boot-macros.yaml
+++ b/lava/common-boot-macros.yaml
@@ -13,3 +13,10 @@
         {{baseurl}}/{{imgpath}}/{{image_date}}/{{arch}}/{{image_type}}/{{image_name}}.img.{{ext}}
     {%- endif %}
 {%- endmacro %}
+
+{% macro tar_unpack_cmd() -%}
+    {% if tar_additional_options is not defined -%}
+        {% set tar_additional_options = "-v" -%}
+    {% endif -%}
+    tar {{tar_additional_options}} -C / -z -x
+{%- endmacro %}
diff --git a/lava/common-boot-tpl-reboot.yaml b/lava/common-boot-tpl-reboot.yaml
index c929700f..d82e7505 100644
--- a/lava/common-boot-tpl-reboot.yaml
+++ b/lava/common-boot-tpl-reboot.yaml
@@ -5,7 +5,7 @@
       method: {{boot_method}}
       commands: {{boot_commands}}
       transfer_overlay:
-        download_command: sudo mount -o remount,rw / ; connmand-wait-online ; df -h; sh -c 'busybox wget $1 -O -| sudo tar -v -C / -z -x' --
+        download_command: sudo mount -o remount,rw / ; connmand-wait-online ; df -h; sh -c 'busybox wget $1 -O -| {{boot.tar_unpack_cmd()}}' --
         unpack_command: df -h; echo
       parameters:
         shutdown-message: "reboot: Restarting system"
diff --git a/lava/common-boot-tpl.yaml b/lava/common-boot-tpl.yaml
index 20af835f..5b79f9af 100644
--- a/lava/common-boot-tpl.yaml
+++ b/lava/common-boot-tpl.yaml
@@ -106,7 +106,7 @@ actions:
       method: {{boot_method}}
       commands: {{boot_commands}}
       transfer_overlay:
-        download_command: sudo mount -o remount,rw / ; connmand-wait-online ; df -h; sh -c 'busybox wget $1 -O -| sudo tar -v -C / -z -x' --
+        download_command: sudo mount -o remount,rw / ; connmand-wait-online ; df -h; sh -c 'busybox wget $1 -O -| sudo {{boot.tar_unpack_cmd()}}' --
         unpack_command: df -h; echo
       parameters:
         shutdown-message: "reboot: Restarting system"
diff --git a/lava/common-qemu-boot-tpl.yaml b/lava/common-qemu-boot-tpl.yaml
index 8d93a373..34b86296 100644
--- a/lava/common-qemu-boot-tpl.yaml
+++ b/lava/common-qemu-boot-tpl.yaml
@@ -61,7 +61,7 @@ actions:
       method: qemu
       media: tmpfs
       transfer_overlay:
-        download_command: sudo mount -o remount,rw / ; connmand-wait-online ; df -h; sh -c 'busybox wget $1 -O -| sudo tar -v -C / -z -x' --
+        download_command: sudo mount -o remount,rw / ; connmand-wait-online ; df -h; sh -c 'busybox wget $1 -O -| sudo {{boot.tar_unpack_cmd()}}' --
         unpack_command: df -h; echo
       parameters:
         shutdown-message: "reboot: Restarting system"
diff --git a/lava/group-nfs-tpl.yaml b/lava/group-nfs-tpl.yaml
index 04a97741..0ba15f17 100644
--- a/lava/group-nfs-tpl.yaml
+++ b/lava/group-nfs-tpl.yaml
@@ -69,7 +69,7 @@ actions:
       method: {{boot_method}}
       commands: nfs
       transfer_overlay:
-        download_command: sudo mount -o remount,rw / ; df -h; sh -c 'busybox wget $1 -O -| sudo tar -v -C / -z -x' --
+        download_command: sudo mount -o remount,rw / ; df -h; sh -c 'busybox wget $1 -O -| sudo {{boot.tar_unpack_cmd()}}' --
         unpack_command: df -h; echo
       auto_login:
         login_prompt: 'apertis login:'
-- 
GitLab