Skip to contentSkip to conversation

tests: Add 'fetch-acceptance' rule

PATCH In review Philippe Mathieu-Daudé 3 participants 6 messages Jul 24, 2020

lore
Share & tools
lore
#0 lore raw

cover tests: Add 'fetch-acceptance' rule

Add a rule to fetch acceptance test assets.

This is particularly useful in a CI context, when a single job can fetch and save the cache so other jobs reuse it directly.

It is also useful to measure the time spent downloading the assets versus the time spent running the tests.

For now we have to exclude the 'boot_linux.py' which triggers an exception.

Philippe Mathieu-Daudé (2):
tests: Add 'fetch-acceptance' rule
tests: Exclude 'boot_linux.py' from fetch-acceptance rule

 tests/Makefile.include | 9 +++++++++
 1 file changed, 9 insertions(+)
Signature · 1 line
2.21.3
#1 lore raw

PATCH 1/2 tests: Add 'fetch-acceptance' rule

Add a rule to fetch acceptance test assets.

This is particularly useful in a CI context, when a single job can fetch and save the cache so other jobs reuse it directly.

It is also useful to measure the time spent downloading the assets versus the time spent running the tests.

---
 tests/Makefile.include | 9 +++++++++
 1 file changed, 9 insertions(+)
tests/Makefile.include +9 -0
index c7e4646ded..238974d8da 100644
@@ -944,6 +944,15 @@ get-vm-image-fedora-31-%: check-venv
 # download all vm images, according to defined targets
 get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOWNLOAD))
 
+# fetch acceptance test assets
+fetch-acceptance: check-venv
+	$(call quiet-command, \
+            $(TESTS_VENV_DIR)/bin/python -m avocado \
+            $(if $(V),--show=$(AVOCADO_SHOW)) \
+            assets fetch \
+            $(wildcard tests/acceptance/*.py), \
+            "AVOCADO", "tests/acceptance")
+
 check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images
 	$(call quiet-command, \
             $(TESTS_VENV_DIR)/bin/python -m avocado \
Signature · 1 line
2.21.3
#2 lore raw

Hello,

Quoted 18 lines · Philippe Mathieu-Daudé

Add a rule to fetch acceptance test assets.

This is particularly useful in a CI context, when a single job can fetch and save the cache so other jobs reuse it directly.

It is also useful to measure the time spent downloading the assets versus the time spent running the tests.

---
  tests/Makefile.include | 9 +++++++++
  1 file changed, 9 insertions(+)
tests/Makefile.include +0 -0
index c7e4646ded..238974d8da 100644

tests/Makefile.include get-vm-image-fedora-31-%: check-venv · line 948

Quoted 5 lines
tests/Makefile.include +2 -0
@@ -944,6 +944,15 @@ get-vm-image-fedora-31-%: check-venv
  # download all vm images, according to defined targets
  get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOWNLOAD))
 
+# fetch acceptance test assets
+fetch-acceptance: check-venv

This new target misses an entry on check-help.

tests/Makefile.include get-vm-image-fedora-31-%: check-venv · line 952

Quoted 4 lines
tests/Makefile.include +4 -0
+	$(call quiet-command, \
+            $(TESTS_VENV_DIR)/bin/python -m avocado \
+            $(if $(V),--show=$(AVOCADO_SHOW)) \
+            assets fetch \

Perhaps pass '--ignore-errors' so that intermittent network failurse won't disturb the execution (the test will have a second chance to download the asset later when it executes).

tests/Makefile.include get-vm-image-fedora-31-%: check-venv · line 954

Quoted 2 lines
tests/Makefile.include +2 -0
+            $(wildcard tests/acceptance/*.py), \
+            "AVOCADO", "tests/acceptance")

nit: print "Downloading acceptance tests assets" (similar to get-vm-image-fedora-32-% target).

Talking about get-vm-images...that target is pre-req of check-acceptance, which makes me think that fetch-acceptance should be either (for the sake of consistency.) The downside is that - as a developer running it on my machine - avocado assets fetch will attempt to download artifacts even for those tests which I'm not going to run anyway. Any opinion?

Regards,

Wainer

Quoted 4 lines
tests/Makefile.include +1 -0
+
  check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images
  	$(call quiet-command, \
              $(TESTS_VENV_DIR)/bin/python -m avocado \
#3 lore raw

PATCH 2/2 tests: Exclude 'boot_linux.py' from fetch-acceptance rule

In reply to Philippe Mathieu-Daudé

The boot_linux.py file triggers an exception:

  $ make fetch-acceptance
  AVOCADO tests/acceptance
  Fetching assets from tests/acceptance/empty_cpu_model.py.
  Fetching assets from tests/acceptance/vnc.py.
  Fetching assets from tests/acceptance/boot_linux_console.py.
  Fetching assets from tests/acceptance/boot_linux.py.
  Traceback (most recent call last):
    File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/__main__.py", line 11, in <module>
      sys.exit(main.run())
    File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/core/app.py", line 91, in run
      return method(self.parser.config)
    File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 291, in run
      success, fail = fetch_assets(test_file)
    File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 200, in fetch_assets
      handler = FetchAssetHandler(test_file, klass, method)
    File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 65, in __init__
      self.visit(self.tree)
    File "/usr/lib64/python3.7/ast.py", line 271, in visit
      return visitor(node)
    File "/usr/lib64/python3.7/ast.py", line 279, in generic_visit
      self.visit(item)
    File "/usr/lib64/python3.7/ast.py", line 271, in visit
      return visitor(node)
    File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 139, in visit_ClassDef
      self.generic_visit(node)
    File "/usr/lib64/python3.7/ast.py", line 279, in generic_visit
      self.visit(item)
    File "/usr/lib64/python3.7/ast.py", line 271, in visit
      return visitor(node)
    File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 171, in visit_Assign
      self.asgmts[cur_klass][cur_method][name] = node.value.s
  KeyError: 'launch_and_wait'
  make: *** [tests/Makefile.include:949: fetch-acceptance] Error 1

Exclude it for now. We will revert this commit once the script is fixed.

---
 tests/Makefile.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/Makefile.include +1 -1
index 238974d8da..7c9cf7a818 100644
@@ -950,7 +950,7 @@ fetch-acceptance: check-venv
             $(TESTS_VENV_DIR)/bin/python -m avocado \
             $(if $(V),--show=$(AVOCADO_SHOW)) \
             assets fetch \
-            $(wildcard tests/acceptance/*.py), \
+            $(filter-out tests/acceptance/boot_linux.py,$(wildcard tests/acceptance/*.py)), \
             "AVOCADO", "tests/acceptance")
 
 check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images
Signature · 1 line
2.21.3
#4 lore raw

Re: [PATCH 2/2] tests: Exclude 'boot_linux.py' from fetch-acceptance rule

Hi Philippe,

Quoted 27 lines · Philippe Mathieu-Daudé

The boot_linux.py file triggers an exception:

   $ make fetch-acceptance
   AVOCADO tests/acceptance
   Fetching assets from tests/acceptance/empty_cpu_model.py.
   Fetching assets from tests/acceptance/vnc.py.
   Fetching assets from tests/acceptance/boot_linux_console.py.
   Fetching assets from tests/acceptance/boot_linux.py.
   Traceback (most recent call last):
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/__main__.py", line 11, in <module>
       sys.exit(main.run())
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/core/app.py", line 91, in run
       return method(self.parser.config)
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 291, in run
       success, fail = fetch_assets(test_file)
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 200, in fetch_assets
       handler = FetchAssetHandler(test_file, klass, method)
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 65, in __init__
       self.visit(self.tree)
     File "/usr/lib64/python3.7/ast.py", line 271, in visit
       return visitor(node)
     File "/usr/lib64/python3.7/ast.py", line 279, in generic_visit
       self.visit(item)
     File "/usr/lib64/python3.7/ast.py", line 271, in visit
       return visitor(node)
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 139, in visit_ClassDef
       self.generic_visit(node)
Quoted 8 lines
     File "/usr/lib64/python3.7/ast.py", line 279, in generic_visit
       self.visit(item)
     File "/usr/lib64/python3.7/ast.py", line 271, in visit
       return visitor(node)
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 171, in visit_Assign
       self.asgmts[cur_klass][cur_method][name] = node.value.s
   KeyError: 'launch_and_wait'
   make: *** [tests/Makefile.include:949: fetch-acceptance] Error 1

Currently the acceptance tests use Avocado 7.6. I bumped to 80.0 (latest released) here and that error is gone. Could you double check?

Regards,

Wainer

Quoted 22 lines

Exclude it for now. We will revert this commit once the script is fixed.

---
  tests/Makefile.include | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tests/Makefile.include +1 -1
index 238974d8da..7c9cf7a818 100644
@@ -950,7 +950,7 @@ fetch-acceptance: check-venv
              $(TESTS_VENV_DIR)/bin/python -m avocado \
              $(if $(V),--show=$(AVOCADO_SHOW)) \
              assets fetch \
-            $(wildcard tests/acceptance/*.py), \
+            $(filter-out tests/acceptance/boot_linux.py,$(wildcard tests/acceptance/*.py)), \
              "AVOCADO", "tests/acceptance")
 
  check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images
#5 lore raw

Re: [PATCH 2/2] tests: Exclude 'boot_linux.py' from fetch-acceptance rule

Quoted 40 lines · Wainer dos Santos Moschetta

Hi Philippe,

Quoted 27 lines · Philippe Mathieu-Daudé

The boot_linux.py file triggers an exception:

   $ make fetch-acceptance
   AVOCADO tests/acceptance
   Fetching assets from tests/acceptance/empty_cpu_model.py.
   Fetching assets from tests/acceptance/vnc.py.
   Fetching assets from tests/acceptance/boot_linux_console.py.
   Fetching assets from tests/acceptance/boot_linux.py.
   Traceback (most recent call last):
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/__main__.py", line 11, in <module>
       sys.exit(main.run())
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/core/app.py", line 91, in run
       return method(self.parser.config)
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 291, in run
       success, fail = fetch_assets(test_file)
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 200, in fetch_assets
       handler = FetchAssetHandler(test_file, klass, method)
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 65, in __init__
       self.visit(self.tree)
     File "/usr/lib64/python3.7/ast.py", line 271, in visit
       return visitor(node)
     File "/usr/lib64/python3.7/ast.py", line 279, in generic_visit
       self.visit(item)
     File "/usr/lib64/python3.7/ast.py", line 271, in visit
       return visitor(node)
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 139, in visit_ClassDef
       self.generic_visit(node)
Quoted 8 lines
     File "/usr/lib64/python3.7/ast.py", line 279, in generic_visit
       self.visit(item)
     File "/usr/lib64/python3.7/ast.py", line 271, in visit
       return visitor(node)
     File "/var/tmp/qemu-builddir/tests/venv/lib64/python3.7/site-packages/avocado/plugins/assets.py", line 171, in visit_Assign
       self.asgmts[cur_klass][cur_method][name] = node.value.s
   KeyError: 'launch_and_wait'
   make: *** [tests/Makefile.include:949: fetch-acceptance] Error 1
Quoted 6 lines

Currently the acceptance tests use Avocado 7.6. I bumped to 80.0 (latest released) here and that error is gone. Could you double check?

Regards,

Wainer

Hi Wainer, thanks for looking at this problem.

This bug was fixed here
https://github.com/avocado-framework/avocado/pull/3665, on release 78 of Avocado. It was reported by Philippe at that time. I think we forgot to bump the Avocado version here.

Quoted 24 lines
Quoted 23 lines

Exclude it for now. We will revert this commit once the script is fixed.

---
  tests/Makefile.include | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tests/Makefile.include +1 -1
index 238974d8da..7c9cf7a818 100644
@@ -950,7 +950,7 @@ fetch-acceptance: check-venv
              $(TESTS_VENV_DIR)/bin/python -m avocado \
              $(if $(V),--show=$(AVOCADO_SHOW)) \
              assets fetch \
-            $(wildcard tests/acceptance/*.py), \
+            $(filter-out tests/acceptance/boot_linux.py,$(wildcard tests/acceptance/*.py)), \
              "AVOCADO", "tests/acceptance")
 
  check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images