action #109891
closedcoordination #109783: [epic][qe-core] Using Robot Framework in openQA
[qe-core] Writing openQA tests with python
0%
Description
For a while now, it is possible to write tests in openQA using python, which makes it more attractive for test engineers, as Perl might not be everybody's cup of tea.
As a Test developer I would like to write tests for openQA in python, so that I can write tests with a language that might be more readable for a newcomer.
Now while this is a whole topic, there are questions we need to be able to answer, to see if this is really worth the effort.
- Can we import Perl libraries? or do we have to start from scratch and do everything, like ensure_unlocked desktop
- How difficult is to write the test (1 to 10)
- Could it be that in the future, as a follow up, we can look into pytest?
- What could be a proposed structure from an object-oriented perspective?
- Conclusions after the experiment
Acceptance Criteria¶
- loadtests mechanism uses
python/tests/$squad
as default - library should be self contained to
python/lib
when possible - Optional: A test that uses ssh locally (ssh root@localhost) and runs some commands are written in python
- Optional: Write a test for Open Broadcaster Software (boot installed system, install obs, open obs, check app starts, close, shutdown the machine) on Tumbleweed, schedule in its testsuite.
- Findings are documented in this ticket, with all pull requests related to it
- Above questions were answered (during the Sprint review)
Constraints¶
Do not refactor at this stage or create unnecessary libraries beyond what is needed to complete the tasks.
Considerations¶
Acceptance criteria can be moved to a separate ticket before the agreement with the PO if they are deemed too big (or if two persons want to work on the ticket, splitting the task further) except for the findings.
Updated by szarate over 2 years ago
- Copied to action #109894: [qe-core][spike] Using Robot Framework in openQA - Writing openQA tests using Robot framework added
Updated by szarate over 2 years ago
- Subject changed from [qe-core][spike] Writing openQA tests with python to [qe-core][spike] Using Robot Framework in openQA - Writing openQA tests with python
Updated by szarate over 2 years ago
- Sprint set to QE-Core: April Sprint (Apr 13 - May 11)
Updated by szarate over 2 years ago
- Sprint deleted (
QE-Core: April Sprint (Apr 13 - May 11))
Updated by szarate over 1 year ago
- Related to action #126590: [qe-core] loading tests in Python is broken when using YAML added
Updated by szarate over 1 year ago
- Status changed from New to Workable
- Target version set to QE-Core: Ready
Updated by szarate over 1 year ago
- Sprint set to QE-Core: April Sprint 23 (Apr 05 - May 03)
Updated by szarate over 1 year ago
- Subject changed from [qe-core][spike] Using Robot Framework in openQA - Writing openQA tests with python to [qe-core] Writing openQA tests with python
Updated by ph03nix over 1 year ago
- Related to deleted (action #126590: [qe-core] loading tests in Python is broken when using YAML)
Updated by ph03nix over 1 year ago
- Blocked by action #126590: [qe-core] loading tests in Python is broken when using YAML added
Updated by szarate over 1 year ago
- Tags changed from qe-core-april-sprint to qe-core-april-sprint, platform-team, qaaas
- Priority changed from Normal to High
Updated by szarate over 1 year ago
- Sprint changed from QE-Core: April Sprint 23 (Apr 05 - May 03) to QE-Core: May Sprint 23 (May 10 - May 31)
Updated by mgrifalconi over 1 year ago
- Status changed from Workable to In Progress
Will need to fix the check for non-existing tests: https://github.com/os-autoinst/os-autoinst-distri-opensuse/blob/b0ce65de2065af1bfa6f1cf00bc8b1822a1069e4/tools/detect_nonexistent_modules_in_yaml_schedule#L88
To allow either no extension, or pm or py. Like on loadtest: https://github.com/michaelgrifalconi/os-autoinst-distri-opensuse/blob/master/lib/main_common.pm#L141
Updated by mgrifalconi over 1 year ago
- Can we import Perl libraries? or do we have to start from scratch and do everything, like ensure_unlocked desktop => Libraries should be exposed for python as well. If not, we should open a ticket. See: https://kalikiana.gitlab.io/post/2021-07-15-writing-openqa-tests-in-python/#fn:1
- How difficult is to write the test (1 to 10) => Can't answer here, since it is subjective and mainly depends on your python knowledge I would say. Might edit this when close to close the story
- Could it be that in the future, as a follow up, we can look into pytest? => Sure, why not? Would be nice to have unit tests for our test code. Should make our tests more stable.
- What could be a proposed structure from an object-oriented perspective? => I expect the test structure to be the direct translation of https://kalikiana.gitlab.io/post/2021-07-15-writing-openqa-tests-in-python/#how-do-i-translate-camel-to-parseltongue Then of course internal methods can use python specific features
Conclusions after the experiment => TBD
loadtests mechanism uses python/tests/$squad as default => This does not work at the moment, I would propose to use tests/python/$squad to be compatible without big structure changes
library should be self contained to python/lib when possible => Same logic as above, lib/python/..
Optional: A test that uses ssh locally (ssh root@localhost) and runs some commands are written in python => WIP
Optional: Write a test for Open Broadcaster Software (boot installed system, install obs, open obs, check app starts, close, shutdown the machine) on Tumbleweed, schedule in its testsuite. => ToDo
Findings are documented in this ticket, with all pull requests related to it => ToDo
Above questions were answered (during the Sprint review)
Updated by okurz over 1 year ago
Because it was mentioned nowhere in this ticket: Please be aware that the official documentation for openQA lives in http://open.qa
The section
http://open.qa/docs/#_test_case_examples
in particular covers writing openQA test modules in python with example code snippets.
Updated by szarate over 1 year ago
if memory serves well, this is the thing being used: https://metacpan.org/dist/Inline-Python/view/Python.pod
Updated by szarate over 1 year ago
- Sprint changed from QE-Core: May Sprint 23 (May 10 - May 31) to QE-Core: June Sprint 23 (Jun 14 - Jun 28)
Updated by szarate over 1 year ago
- Tags changed from qe-core-april-sprint, platform-team, qaaas, qe-core-may-sprint to qe-core-april-sprint, platform-team, qaaas, qe-core-may-sprint, qe-core-june-sprint
There's a conversation at: https://suse.slack.com/archives/C02CANHLANP/p1686649742068749
Named argunments are not supported apparently:
perl.require("x11utils")
perl.x11utils.x11_start_program("flatpak run com.obsproject.Studio")
I would consider named parameters being a blocker for being able to use this thing.
perl.x11utils.x11_start_program("flatpak run com.obsproject.Studio", 30, 1, "flatpak-obsproject") // Ignores other arguments
or
perl.x11utils.x11_start_program("flatpak run com.obsproject.Studio", target_match="flatpak-obsproject") // Fails to even call the program, tries to call "ARRAY(..."
# this doesn't work either
perl.x11utils.x11_start_program("flatpak run com.obsproject.Studio", {"target_match":"flatpak-obsproject"})
Updated by mgrifalconi over 1 year ago
Created https://github.com/os-autoinst/os-autoinst-distri-opensuse/pull/17325 to continue discussion
Updated by okurz over 1 year ago
szarate wrote:
There's a conversation at: https://suse.slack.com/archives/C02CANHLANP/p1686649742068749
Named argunments are not supported apparently:
perl.require("x11utils") perl.x11utils.x11_start_program("flatpak run com.obsproject.Studio")
I would consider named parameters being a blocker for being able to use this thing.
perl.x11utils.x11_start_program("flatpak run com.obsproject.Studio", 30, 1, "flatpak-obsproject") // Ignores other arguments or perl.x11utils.x11_start_program("flatpak run com.obsproject.Studio", target_match="flatpak-obsproject") // Fails to even call the program, tries to call "ARRAY(..."
I think you found a way with perl.x11utils.x11_start_program("flatpak run com.obsproject.Studio", "target_match", "flatpak-obsproject")
, right?
Updated by fgerling over 1 year ago
- Status changed from In Progress to Feedback
Updated by mgrifalconi over 1 year ago
Sorry @okurz I missed to answer your question. Yes you are correct, thanks to Sebastian in the discuss-perl channel!
Updated by mgrifalconi over 1 year ago
Now PR is merged and it should schedule on the TW Dev job group: https://openqa.opensuse.org/group_overview/38 with job name extra_tests_gnome_development
All was setup yesterday but unfortunately we don't have a TW build today :(
We have it now: https://openqa.opensuse.org/tests/3411838
Updated by mgrifalconi over 1 year ago
PR to enhance docs was merged https://github.com/os-autoinst/openQA/pull/5253#event-9874509079
Updated by mgrifalconi over 1 year ago
- Status changed from Feedback to Resolved
Updated by szarate about 1 year ago
- Related to coordination #138596: [epic][qe-core] Using Avocado Framework wrapper added
Updated by szarate about 1 year ago
- Related to coordination #90758: [epic] python bindings for openQA added
Updated by szarate about 1 year ago
PR documenting further how the python backend works: https://github.com/os-autoinst/openQA/pull/5333
Updated by szarate about 1 year ago
openQA in openQA test provides the simplest python test example: https://github.com/os-autoinst/os-autoinst-distri-openQA/blob/master/tests/openQA/search.py
Updated by szarate about 1 year ago
- There are several limitations already documented in multiple pull requests and in poo#09891
- See http://open.qa/docs/#_notes_on_the_python_api and the how to write tests guide to be able to follow through
- Porting Perl tests to Python would require an immense effort, it can only be used for new test modules that aren't complex (i.e requiring too many things from the perl api.
- Writting tests is possible and loading them is possible too, both: via the schedule and via the main.pm facility, see the openQA in openQA example https://github.com/os-autoinst/os-autoinst-distri-openQA/blob/master/tests/openQA/search.py