Project

General

Profile

Actions

action #163952

closed

coordination #163919: [epic] Create automation setup for testing Agama

Run simple script to control an interactive installation

Added by JERiveraMoya 5 months ago. Updated 3 months ago.

Status:
Resolved
Priority:
High
Assignee:
Target version:
-
Start date:
2024-07-15
Due date:
% Done:

0%

Estimated time:

Description

Motivation

In order to start to automate Agama web ui, we need a initial script able to control the browser and introduce a default configuration, click on install, wait for installation to finish and reboot.
Out of scope is to create new test modules in openQA to verify that we really install what we wanted but we should verify that manually at least for now.

To develop such script you can use already created script by YaST devlopers that does that except installation itself:
https://github.com/lslezak/agama/tree/master/puppeteer
I did my own version of this script in TypeScript (which offer us with more chances to catch problems and plain JavaScript):
https://github.com/jknphy/agama-puppeteer

Notice that besides the configuration needed to run that script in nodejs with Typescript, I also switched to use locator method instead of low level waitForSelector because in the latest version of puppeteer is not anymore experimental. Puppeteer docs about locator api: https://pptr.dev/guides/page-interactions
There are a few more subtle details that are up to you to discover.

Why Puppeteer and not Playwright?
One thing you might be wondering, why Puppeteer and not Playwright. Playwright offers much more than a library like Puppeteer that many user use for scraping. With Puppeteer we will need an extra effort for learning things that are already connected in a all-in-one solution with Playwright.
Because Playwright works only with specific versions of browsers and doesn't work with the Firefox that ships with Agama Live ISO.
Puppeteer is using a more modern approach cross-browser called Webdriver BiDi. Using that protocol we can connect without problem in all architectures to Agama running in the Live ISO (this was tested manually successfully and confirmed to developers).

Acceptance criteria

  • AC1: Develop a script that install Tumbleweed using Agama web ui.
  • AC2: When creating the script, favor selectors specific from the Pupetteer that point to text in the web page (as most of them are in the example script by developer), no xpath, etc.
  • AC2: Test for each architecture that the script is runnable and stable.
  • AC3: After the system is install do some simple manual checks cat /etc/os-release, partitioning, networking, etc.

Additional information

This ticket can be worked out without #163922 or #163943 be completed as you can run it in your system or in the Live ISO with yupdate. Enablement of this will be done in #163949.
At this point we don't need to use Page Object Model (POM) we just aim to have an script running in all the architectures. We can work on that in #163946.

Documentation
Webdriver BiDi: https://developer.chrome.com/blog/webdriver-bidi-2023
Puppeteer: https://pptr.dev/category/introduction
Mocha: https://mochajs.org/
Chai: https://www.chaijs.com/
Node.js: https://nodejs.org/en/learn/getting-started/introduction-to-nodejs
TypeScript: https://www.typescriptlang.org/docs/

_Troubleshooting with the browser
This is the situation regarding Firefox according to YaST developer:

About the FF version, unfortunately the openSUSE Leap contains Firefox in the ESR (long term support) version 115, the same as in SLES. The next ESR release should be version 128 in Q4/2024, until that we won't see any newer version in Leap I guess.
For using FF 115 from Git you might try commenting out this line in the test: https://github.com/lslezak/agama/blob/master/puppeteer/tests/test.js#L70
That switches to the older CDP protocol instead of the new WebDriver. But I had some problems with that, I have seen some random failures (not find an element which should be on the page). It seems that FF 115 is really old for it.

Or you could try FF from this OBS repo: https://build.opensuse.org/project/show/mozilla
It contains FF 126 for Leap 15.{4,5,6}

If you are using Leap, I would recommend this option to get your FF adding that repo to your system so you can test in local the script without the extra sync required in the Live ISO.

How I am supposed to find those selectors (Puppeteer, Cypress had their own applications to get them)
No fear, although we are using a different protocol to connect to Firefox, to develop we can still use Chrome and CDT:
https://developers.google.com/codelabs/devtools-recorder#0
https://developer.chrome.com/docs/devtools/recorder/overview
Basically you can start recording, interact with the web ui and save your script to Puppeteer, you can change preference for selectors and finally you will have a .js script with a bunch of Promise.race (which basically means that that the script would try to run all of these and then the one that finish first will be used) which of course you most likely will remove as our preference for locator needs to be only one and it is the text on the screen.

How can I know the line failing in TypeScript if the error comes from JavaScript?
Use --enable-source-maps mocha option to have the mapping between with the transpiled code.


Related issues 1 (0 open1 closed)

Related to qe-yam - action #163946: Integrate Puppeteer script with the Page Object Model (POM) Resolvedrainerkoenig2024-07-15

Actions
Actions #1

Updated by JERiveraMoya 4 months ago

  • Description updated (diff)
Actions #2

Updated by JERiveraMoya 4 months ago

  • Priority changed from Normal to High
Actions #3

Updated by hjluo 4 months ago

  • Status changed from Workable to In Progress
  • Assignee set to hjluo
Actions #4

Updated by rainerkoenig 4 months ago

  • Tags changed from qe-yam-jul-sprint, qe-yam-aug-sprint to qe-yam-aug-sprint
Actions #5

Updated by JERiveraMoya 4 months ago

could you please summarize the progress here? thanks.

Actions #6

Updated by JERiveraMoya 4 months ago

  • Assignee changed from hjluo to jfernandez
Actions #7

Updated by JERiveraMoya 4 months ago ยท Edited

latest info from developer:

Puppeteer with it's dependencies, mocha and chai JS libraries are now part of the standard Agama Live ISO. You can download the latest testing image from https://download.opensuse.org/repositories/systemsmanagement:/Agama:/Devel/images/iso/.
Check the https://github.com/openSUSE/agama/blob/master/puppeteer/README.md documentation how to run the example test from Git and from the Live ISO.
Some notes:
I had to downgrade to Puppeteer 22.13.0 as the latest 22.13.1 does not work with Firefox 127 in the current Tumbleweed, but it works fine with Firefox 128 - it seems that Puppeteer targets the edge versions so be careful when updating it to a newer version.
If you want to run your own tests then just copy them to /usr/share/agama/integration-tests/tests/ and run them using the agama-integration-tests script (see the README above for more details)
If you want to use Typescript then just compile the TS files to JS before uploading to Agama
If you need to include an additional library or you need to upgrade Puppeteer or other library included then just ping me or open a pull request at GitHub
There is an example test https://github.com/openSUSE/agama/blob/master/puppeteer/tests/test_root_password.js, this test is also once a day started in GitHub CI to ensure that both Agama and Puppeteer work properly (started from https://github.com/openSUSE/agama/blob/master/.github/workflows/ci-integration-tests.yml)

It means we need to look to archived documentation of the project in case we are using something too new:
https://github.com/puppeteer/puppeteer/blob/puppeteer-v22.13.0/docs/guides/page-interactions.md

Actions #8

Updated by JERiveraMoya 3 months ago

we will need to add extra code for adding First user (bernhard) as we are doing in parallel in the task for autoinstallation (see this for example). Although is not strictly necessary to install the system any validation forward in openQA will need it when not using only root.

Actions #9

Updated by JERiveraMoya 3 months ago

Updated my branch with your changes:
https://github.com/jknphy/agama-puppeteer/blob/main/tests/test_root_password.ts#L189-L216

Additionally we might need to document AGAMA_INSTALL in the README and introduce a check for one of the first screens that has 3 phases (after product selection and before the overview). For the timeout during installation, because that only affects to those last steps, we can hardcode it for now. Later we will split the script.
Also the name of the script should be changen to something that indicates it is a default installation, not only about setting root password.
I clean up those checks for checking if buttons are enabled due to the locators should do by their own, create code for handle the signing popup and that extra setting to install or not install. The conversion to TS was very smooth. Next time we will do with PR I hope but your changes worked nicely.

Actions #11

Updated by JERiveraMoya 3 months ago

  • Status changed from In Progress to Resolved

Follow-up for integration with openQA: https://progress.opensuse.org/issues/165830

Actions #12

Updated by rainerkoenig 3 months ago

  • Related to action #163946: Integrate Puppeteer script with the Page Object Model (POM) added
Actions

Also available in: Atom PDF