Project

General

Profile

action #102131

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 7 months ago. Updated 4 months 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');

History

#1 Updated by JERiveraMoya 7 months ago

  • Tags set to qe-yast-refinement

#2 Updated by JERiveraMoya 6 months ago

  • Priority changed from Normal to Low

#3 Updated by JERiveraMoya 5 months 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

#4 Updated by JERiveraMoya 5 months ago

  • Description updated (diff)

#5 Updated by JERiveraMoya 5 months ago

  • Priority changed from High to Normal

#6 Updated by JERiveraMoya 5 months ago

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

#7 Updated by oorlov 4 months ago

  • Description updated (diff)

#8 Updated by oorlov 4 months ago

  • Description updated (diff)

#9 Updated by oorlov 4 months ago

  • Description updated (diff)

#10 Updated by oorlov 4 months ago

  • Description updated (diff)

#11 Updated by oorlov 4 months ago

  • Description updated (diff)

#12 Updated by oorlov 4 months ago

  • Description updated (diff)

#13 Updated by geor 4 months ago

  • Status changed from Workable to In Progress
  • Assignee set to geor

#15 Updated by geor 4 months ago

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

#16 Updated by geor 4 months ago

Addressing AC2: PR and accompanying MR

#17 Updated by geor 4 months ago

  • Status changed from In Progress to Closed

Also available in: Atom PDF