Project

General

Profile

action #14626

[epic] backend and console capabilities interface to increase extensibility and code reuse

Added by rpalethorpe over 3 years ago. Updated 20 days ago.

Status:
Blocked
Priority:
Normal
Assignee:
Category:
Feature requests
Target version:
Start date:
2019-02-17
Due date:
% Done:

17%

Estimated time:
(Total: 0.00 h)
Difficulty:
Duration:

Description

Motivation

Prevent "if/else" in tests needing to distinguish different backends

Acceptance criteria

  • AC1: No obvious "if/else" for different types of consoles in os-autoinst-distri-opensuse are necessary anymore
  • AC2: Same as AC1 for different backends

Suggestions

Further details

Background

In an ideal world all the backends (QEMU, bare metal, Xen) and consoles (VNC, serial or hybrid) would be accessed in a uniform manner by testapi so that the distribution and test writers could write their test case once and then have it run across all available platforms without modification. In practice however different Operating systems, hardware, hypervisors and console combinations differ significantly enough in behaviour that a completely uniform API is not possible without either significantly disadvantaging some platforms or providing support for edge cases in the distribution itself.

While the functions in testapi can be kept mostly uniform in availability and behaviour it requires that the distribution handles changes in the Operating System's behaviour due to the machine (virtual or physical) which it is running on and what user interface (console) is selected. Many things can be abstracted away into the console or backend classes in os-autoinst, however OS specific behaviour can not be without making os-autoinst specific to one type of OS or even Linux distribution. Currently the SUSE os-autoinst distribution handles differences between backends by reading variables to determine which backend or architecture is being used in a variety of different places and performing some particular action for that backend. Unfortunately this doesn't just happen in (suse)distribution.pm or other modules in the lib folder, but throughout the test cases.

The problem with branching on a particular architecture or backend is that the contents of the branch statement may actually apply to a whole class of backends not just one. Thus by restricting it to one particular backend you have missed an opportunity to maximise the benefit of your code, which will lead to duplication of effort. However in some cases it may be wasted effort to try inventing general abstractions when they will only be used in one or two instances, but then that is a universal problem, we just have to make a judgement on each and every case.

Proposal

At any rate my proposal is to introduce the notion of capabilities which can apply to consoles or backends. Any console or backend should have to declare its capabilities in a standard way which can then be read by the distribution and in some very rare cases, the distribution's test modules. Capabilities should be validated against a central list in the appropriate base class, attempting to access or set a capability which does not exist should be an error. This should make them better structured than simply adding more global variables which already serve this purpose to some extent. A list of quirks could also be maintained to indicate negative platform attributes.

The actual implementation could be done using a Perl map, object mixins from some Perl OO library or something else.

Further rambling

In the case of the serial terminal feature, I would remove the new testapi function I have added called is_serial_terminal and instead replace it with one or more console/backend capabilities. Perhaps something like direct_read_text and direct_write_text which indicates to the distribution that we are reading and writing raw text to the terminal, the backend would of course require a serial port capability to activate the console. The Linux VNC text console would have something like redirect_write_text which indicates we can redirect output to the serial port and some other capabilities to indicate that we can use needles and send key presses. Any console on some other OS/hardware combo which doesn't support serial ports will be missing the capabilities which indicate we can do this so either run_script and wait_serial will return an error indicating the missing capability or the distribution will have to implement the testapi functions using some other capabilities or workarounds.

Along with having capabilities comes the idea of having interfaces to take advantage of them, so that a backend, console and distribution with compatible capabilities can be plugged together. Such interfaces and their associated capabilities can be invented and implemented on a rolling basis rather than attempting to do some massive overhaul of the code base. This may slow down feature development for some time, but will eventually speed it up and creates a basis for a backend/console plugin architecture. I am willing to implement this in so far that it is required for #14582 and other platform specific features I think that the LTP, and other test suites I may work with, can take advantage of.

Alternatives

The alternatives are to forgo taking advantage of platform specific features or add the occasional function to the testapi like is_serial_terminal and use the existing vars mechanism. At least for what I am currently doing, the latter choice is acceptable to me, but it is not extensible beyond a point. There is also the console proxy feature which allows you to tightly couple your test module to a particular console implementation completely bypassing all layers of abstraction while at the same time obfuscating the code flow using Perl meta programming which should be avoided at least from tests perspective.

Problems

It is more difficult to identify and isolate a class of behaviour shared by multiple entities and create an abstraction to encapsulate it than just to write code for a specific case. Sometimes people may attempt to create capabilities when there is no significant advantage to doing so or they may be tempted not to when there clearly is an advantage. The feature will need documenting and require effort on the part of reviewers to learn it and enforce its use. It will probably increase the codebases complexity initially until it has been reasonably taken advantage of. There is the danger of an explosion in capabilities which makes it difficult to write a new distribution which covers multiple platforms without understanding a large number of them. Regressions may be introduced while moving backends and consoles over to this system.


Subtasks

openQA Tests - action #38819: [tools][functional][u][epic] Refactor use of backendsNewSLindoMansilla

openQA Tests - action #33388: [functional][u][easy][pvm] Implement proper split from other backendsResolvedmgriessmeier

action #67417: Remote backend capabilityNew

action #67420: Persistent console console capabilityNew

action #67423: Persistent console backend capabilityNew

action #67426: Raw text backend capabilityNew

action #67429: Raw text console capabilityNew


Related issues

Related to openQA Project - action #14582: Add virtio serial console backend and APIResolved2016-10-31

Related to openQA Project - action #38486: [functional][u] add capability flags to os-autoinst backends (or tests)Rejected2018-07-17

Related to openQA Tests - action #57329: [kernel][functional] PowerVM console is not active all the timeResolved2019-09-25

History

#1 Updated by rpalethorpe over 3 years ago

  • Related to action #14582: Add virtio serial console backend and API added

#2 Updated by rpalethorpe over 3 years ago

  • Priority changed from High to Normal

#3 Updated by rpalethorpe about 3 years ago

  • Assignee deleted (rpalethorpe)

#4 Updated by coolo over 2 years ago

  • Target version set to Ready

this sounds like a good entry level issue

#5 Updated by okurz about 1 year ago

  • Category changed from 132 to Feature requests

#6 Updated by okurz 7 months ago

  • Related to action #38486: [functional][u] add capability flags to os-autoinst backends (or tests) added

#7 Updated by okurz 7 months ago

  • Description updated (diff)

#8 Updated by okurz 7 months ago

  • Related to action #57329: [kernel][functional] PowerVM console is not active all the time added

#9 Updated by okurz 7 months ago

  • Subject changed from Backend and console capabilities interface to increase extensibility and code reuse to [epic] backend and console capabilities interface to increase extensibility and code reuse
  • Description updated (diff)
  • Status changed from New to Workable

#10 Updated by cdywan about 2 months ago

  • Status changed from Workable to In Progress
  • Assignee set to cdywan
  • Target version changed from Ready to Current Sprint

#11 Updated by okurz about 2 months ago

please keep in mind that this ticket is an "epic" so the tasks at hand are to create subtickets as specific user stories, not write any code

#12 Updated by cdywan about 2 months ago

  • Due date set to 2020-05-28

due to changes in a related task: #67417

#13 Updated by cdywan about 2 months ago

  • Due date set to 2020-05-28

due to changes in a related task: #67420

#14 Updated by cdywan about 2 months ago

  • Due date set to 2020-05-28

due to changes in a related task: #67423

#15 Updated by cdywan about 2 months ago

  • Due date set to 2020-05-28

due to changes in a related task: #67426

#16 Updated by cdywan about 2 months ago

  • Due date set to 2020-05-28

due to changes in a related task: #67429

#17 Updated by rpalethorpe about 2 months ago

Added some members of the kernel qa team as watchers. Changing things like is_serial_terminal could have big effect on the kernel tests and baremetal tests.

#18 Updated by cdywan 24 days ago

  • Status changed from In Progress to Blocked
  • Assignee deleted (cdywan)

#19 Updated by okurz 20 days ago

  • Assignee set to okurz

Also available in: Atom PDF