Project

General

Profile

Actions

action #102131

closed

coordination #93668: [epic] Redesign Installation test modules

Improve summary parsing in encrypt_lvm_reuse_existing with libyui-rest-api & YuiRestClient and Mojo::DOM

Added by JERiveraMoya over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
2021-11-09
Due date:
% Done:

0%

Estimated time:

Description

Motivation

There is regex used to parse the content of YRichText in verify_module_selection.pm test module (In
$testapi::distri->get_module_selection()->get_selected_modules() function). The Page where it is used: https://github.com/os-autoinst/os-autoinst-distri-opensuse/blob/50427972586cbed7e5f9eea2bae27a34770048bf/lib/Installation/ModuleSelection/ModuleSelectionPage.pm#L44

The regex solution works, but we found out more elegant and easy to read solution: to parse the DOM with Mojo::DOM and then find the elements of the parsed DOM with XPATH.

Task

encrypt_lvm_reuse_existing is used in 'activate_encrypted_volume' and 'activate_encrypted_volume+import_users' (all qemu)
https://openqa.suse.de/tests/overview?arch=&flavor=&machine=&test=&modules=encrypt_lvm_reuse_existing&module_re=&distri=sle&version=15-SP4&build=79.1&groupid=129#

Instead of using regex, we should read the screen in a way more realiable, we can read content in Suggested Partitioning and parse it with Mojo::DOM (afir we might need to put the content of text inside some or other structure for the library to work)

{
    "class" : "YRichText",
    "hstretch" : true,
    "id" : "summary",
    "text" : "<p>Initial layout proposed with the default Guided Setup settings.</p><p>Changes to partitioning:</p><p><ul><li><b>Delete btrfs on /dev/system/root (14.72 GiB)<br>Delete logical volume root (14.72 GiB) on volume group system</b></li><li><b>Delete swap on /dev/system/swap (1.45 GiB)<br>Delete logical volume swap (1.45 GiB) on volume group system</b></li><li><b>Delete xfs on /dev/system/home (6.81 GiB)<br>Delete logical volume home (6.81 GiB) on volume group system</b></li><li><b>Delete volume group system (22.98 GiB)</b></li><li><b>Delete partition /dev/vda2 (22.99 GiB)</b></li><li>Create partition /dev/vda2 (14.72 GiB) for / with btrfs</li><li>Create partition /dev/vda3 (6.82 GiB) for /home with xfs</li><li>Create partition /dev/vda4 (1.45 GiB) for swap</li><li>27 subvolume actions (<a href=\"actions_presenter--subvolumes\">see details</a>)</li></ul></p>",
    "vstretch" : true
  }

AC1: Creation of new test module to parse the summary.
AC2: Merge test suites activate_encrypted_volume activate_encrypted_volume+import_users

Additional info

We discussed this solution some time ago in one of the threads in Slack: https://suse.slack.com/archives/C02CLB2LB7Z/p1635507962072800

So, after investigation of YRichText widget on Module Selection Page we found out several issues that require to be resolved in order to use Mojo:DOM:

  1. It has &nbsp; and \n in the text body written as strings, so in case we would like to parse the xml, we need to get rid of them;
  2. It does not have root tag, only a list of <p> is there, so parser will complain with parser error: Extra content at the end of the document. So, we can use xml_utils, but in this case we need to sanitize and adjust the xml that comes from YRichText. Something like that:
my $xml = get_text();     # get html text
$xml =~ s/&nbsp;//ig;     # remove all &nbsp;
$xml =~ s/\n//ig;         # remove all \n
$xml = "<div>$xml</div>"; # add root tag
my @nodes = map { $_->to_literal() } find_nodes(xpc => get_xpc($xml), xpath => '//a/@href');
Actions #1

Updated by JERiveraMoya over 2 years ago

  • Tags set to qe-yast-refinement
Actions #2

Updated by JERiveraMoya over 2 years ago

  • Priority changed from Normal to Low
Actions #3

Updated by JERiveraMoya over 2 years ago

  • Subject changed from Implement logic of encrypt_lvm_reuse_existing with YuiRestClient and Mojo::DOM to Improve summary parsing in encrypt_lvm_reuse_existing with libyui-rest-api & YuiRestClient and Mojo::DOM
  • Description updated (diff)
  • Priority changed from Low to High
Actions #4

Updated by JERiveraMoya over 2 years ago

  • Description updated (diff)
Actions #5

Updated by JERiveraMoya over 2 years ago

  • Priority changed from High to Normal
Actions #6

Updated by JERiveraMoya over 2 years ago

  • Tags deleted (qe-yast-refinement)
  • Status changed from New to Workable
Actions #7

Updated by oorlov over 2 years ago

  • Description updated (diff)
Actions #8

Updated by oorlov over 2 years ago

  • Description updated (diff)
Actions #9

Updated by oorlov over 2 years ago

  • Description updated (diff)
Actions #10

Updated by oorlov over 2 years ago

  • Description updated (diff)
Actions #11

Updated by oorlov over 2 years ago

  • Description updated (diff)
Actions #12

Updated by oorlov over 2 years ago

  • Description updated (diff)
Actions #13

Updated by geor about 2 years ago

  • Status changed from Workable to In Progress
  • Assignee set to geor
Actions #15

Updated by geor about 2 years ago

I will address AC2: Merge test suites activate_encrypted_volume activate_encrypted_volume+import_users in a new PR.

Actions #16

Updated by geor about 2 years ago

Addressing AC2: PR and accompanying MR

Actions #17

Updated by geor about 2 years ago

  • Status changed from In Progress to Closed
Actions

Also available in: Atom PDF