Project

General

Profile

Actions

action #132656

closed

Runs only the last Python test in os-autoinst size:M

Added by NoF3X 10 months ago. Updated 10 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Feature requests
Target version:
Start date:
2023-07-13
Due date:
2023-08-01
% Done:

0%

Estimated time:

Description

Observation

When running Python tests, openQA skips all but the last one.
autoinst-log


At the same time, it writes that it launches the first test but executes the commands of the last test
main.pm
no problem with perl tests problem only for python tests

Acceptance criteria

  • AC1: Multiple Python-based test modules are covered by unit tests and working
  • AC2: Confirmed to work on live instance

Suggestions

  • Add an automated test in os-autoinst to load two test modules with python
  • It is still clear from instructions on http://open.qa/docs how python test modules should be created

Files

main.pm (335 Bytes) main.pm NoF3X, 2023-07-13 13:21
t01_update_system.py (671 Bytes) t01_update_system.py NoF3X, 2023-07-13 13:21
t02_plasma5_breeze_theme.py (1.32 KB) t02_plasma5_breeze_theme.py NoF3X, 2023-07-13 13:21
t03_plasma5_breeze_twilight_theme.py (1.42 KB) t03_plasma5_breeze_twilight_theme.py NoF3X, 2023-07-13 13:21

Related issues 1 (1 open0 closed)

Related to openQA Project - action #132938: Allow inheritance in python test modulesNew2023-07-18

Actions
Actions #1

Updated by okurz 10 months ago

  • Assignee deleted (openSUSE-Team-at-SUSE)
  • Target version set to Ready

I don't think the "openSUSE-Team-at-SUSE" effectively still exists. Resetting assignee.

Actions #2

Updated by mkittler 10 months ago

Do you have a full example test? This would make it easier to start working on this.

Actions #3

Updated by mkittler 10 months ago

  • Status changed from New to In Progress
  • Assignee set to mkittler

Updated by NoF3X 10 months ago

mkittler wrote:

Do you have a full example test? This would make it easier to start working on this.

I am attaching files.
at runtime the first test is run but the commands from the last one are executed

Actions #5

Updated by mkittler 10 months ago

Thanks, that was fast. In the meantime I've created my own reproducer (https://github.com/Martchus/os-autoinst-distri-openQA/commit/93953377467abff488e1ac123d90368069cfd77a). So yes, all modules are executed but all of them end up executing the code from the last module. I'll check what's going on.

Note that we haven't noticed that because Python test modules aren't widely used and in our openQA-in-openQA test scenario we only execute exactly one module.

Actions #6

Updated by mkittler 10 months ago

Looks like the Python-loading is very stupid. It just invokes the code as-is, so the second run function will override/shadow the first and so on. I guess some kind of scoping is required here.

Actions #7

Updated by mkittler 10 months ago

  • Status changed from In Progress to New
  • Assignee deleted (mkittler)

This is not that easy, my current attempt of just prefixing the functions (https://github.com/Martchus/os-autoinst/pull/new/python) doesn't work as these functions cannot be found.

Using a higher order function to encapsulate the test module functions like

my \$script = \"def gen_$name():\\n\" . join(\"\\n\", map { \"    \$_\" } split \"\\n\", path('$casedir/$script')->slurp);
use Inline Python => \$script;
my \$module = gen_$name();
sub run { \$module->run(\@_) }
sub test_flags { \$module->test_flags(\@_) }

also didn't work as one needed to take import statements into account as well. I suppose both would potentially work if I'd just get it right.

That's the modified openQA-in-openQA test I used: https://github.com/os-autoinst/os-autoinst-distri-openQA/commit/b897e26768efbac9a2043a110d435dd5c2c6bdf6

Actions #8

Updated by okurz 10 months ago

  • Category changed from Support to Feature requests
  • Priority changed from Normal to High
Actions #9

Updated by okurz 10 months ago

  • Priority changed from High to Normal
Actions #10

Updated by tinita 10 months ago

  • Status changed from New to In Progress
  • Assignee set to tinita
Actions #11

Updated by openqa_review 10 months ago

  • Due date set to 2023-08-01

Setting due date based on mean cycle time of SUSE QE Tools

Actions #12

Updated by tinita 10 months ago

Actions #13

Updated by tinita 10 months ago

Ready: https://github.com/os-autoinst/os-autoinst/pull/2343

I was also thinking to add the tests path and the distribution lib path to the syspaths, so that we can import other modules from the python module, but that requires finding out the correct paths from the given script name and casedir, and it's just a bit too much for this ticket. Not complicated though.
That could be done in the related ticket #132938

Actions #14

Updated by tinita 10 months ago

  • Related to action #132938: Allow inheritance in python test modules added
Actions #15

Updated by tinita 10 months ago

  • Status changed from In Progress to Feedback
Actions #16

Updated by okurz 10 months ago

  • Subject changed from Runs only the last Python test in os-autoinst to Runs only the last Python test in os-autoinst size:M
  • Description updated (diff)
Actions #17

Updated by tinita 10 months ago

  • Status changed from Feedback to Resolved

Tested on osd: https://openqa.suse.de/tests/11629026 (not deployed on o3 yet)

@NoF3X you can try it out now :)

Actions #18

Updated by snowmix 10 months ago

tinita wrote:

@NoF3X you can try it out now :)

NoF3X is currently on vacation. We checked the new version, now everything really works. thank you for fixing.

Actions

Also available in: Atom PDF