Project

General

Profile

Actions

action #109891

closed

coordination #109783: [epic][qe-core] Using Robot Framework in openQA

[qe-core] Writing openQA tests with python

Added by szarate over 2 years ago. Updated about 1 year ago.

Status:
Resolved
Priority:
High
Assignee:
Category:
Spike/Research
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Sprint:
QE-Core: June Sprint 23 (Jun 14 - Jun 28)

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.

  1. Can we import Perl libraries? or do we have to start from scratch and do everything, like ensure_unlocked desktop
  2. How difficult is to write the test (1 to 10)
  3. Could it be that in the future, as a follow up, we can look into pytest?
  4. What could be a proposed structure from an object-oriented perspective?
  5. Conclusions after the experiment

Acceptance Criteria

  1. loadtests mechanism uses python/tests/$squad as default
  2. library should be self contained to python/lib when possible
  3. Optional: A test that uses ssh locally (ssh root@localhost) and runs some commands are written in python
  4. 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.
  5. Findings are documented in this ticket, with all pull requests related to it
  6. 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.


Related issues 4 (2 open2 closed)

Related to openQA Tests (public) - coordination #138596: [epic][qe-core] Using Avocado Framework wrapperNewszarate2022-04-13

Actions
Related to openQA Project (public) - coordination #90758: [epic] python bindings for openQAResolvedokurz2021-04-07

Actions
Blocked by openQA Tests (public) - action #126590: [qe-core] loading tests in Python is broken when using YAMLResolvedmgrifalconi2023-03-24

Actions
Copied to openQA Tests (public) - action #109894: [qe-core][spike] Using Robot Framework in openQA - Writing openQA tests using Robot frameworkNew2022-04-13

Actions
Actions #1

Updated by szarate over 2 years ago

  • Tracker changed from coordination to action
Actions #2

Updated by szarate over 2 years ago

  • Description updated (diff)
Actions #3

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
Actions #4

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
Actions #5

Updated by szarate over 2 years ago

  • Target version set to QE-Core: Ready
Actions #6

Updated by szarate over 2 years ago

  • Sprint set to QE-Core: April Sprint (Apr 13 - May 11)
Actions #7

Updated by szarate over 2 years ago

  • Status changed from New to Workable
Actions #8

Updated by szarate over 2 years ago

  • Status changed from Workable to New
Actions #9

Updated by szarate over 2 years ago

  • Sprint deleted (QE-Core: April Sprint (Apr 13 - May 11))
Actions #10

Updated by szarate over 2 years ago

  • Target version deleted (QE-Core: Ready)
Actions #11

Updated by szarate over 1 year ago

  • Related to action #126590: [qe-core] loading tests in Python is broken when using YAML added
Actions #12

Updated by szarate over 1 year ago

  • Status changed from New to Workable
  • Target version set to QE-Core: Ready
Actions #13

Updated by szarate over 1 year ago

  • Sprint set to QE-Core: April Sprint 23 (Apr 05 - May 03)
Actions #14

Updated by szarate over 1 year ago

  • Description updated (diff)
Actions #15

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
Actions #16

Updated by ph03nix over 1 year ago

  • Related to deleted (action #126590: [qe-core] loading tests in Python is broken when using YAML)
Actions #17

Updated by ph03nix over 1 year ago

  • Blocked by action #126590: [qe-core] loading tests in Python is broken when using YAML added
Actions #18

Updated by ph03nix over 1 year ago

  • Status changed from Workable to Blocked
Actions #19

Updated by ph03nix over 1 year ago

  • Description updated (diff)
Actions #20

Updated by szarate over 1 year ago

  • Status changed from Blocked to Workable
Actions #21

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
Actions #22

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)
Actions #23

Updated by mgrifalconi over 1 year ago

  • Assignee set to mgrifalconi
Actions #25

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)

Actions #26

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.

Actions #27

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

Actions #28

Updated by okurz over 1 year ago

that's correct

Actions #29

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)
Actions #30

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"})
Actions #32

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?

Actions #33

Updated by fgerling over 1 year ago

  • Status changed from In Progress to Feedback
Actions #34

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!

Actions #35

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

Actions #37

Updated by mgrifalconi over 1 year ago

  • Status changed from Feedback to Resolved
Actions #39

Updated by szarate about 1 year ago

Actions #40

Updated by szarate about 1 year ago

Actions #41

Updated by szarate about 1 year ago

PR documenting further how the python backend works: https://github.com/os-autoinst/openQA/pull/5333

Actions #42

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

Actions #43

Updated by szarate about 1 year ago

Actions

Also available in: Atom PDF