Remote UI Control

This is actually a continuation of my previous Hackweek project YaST Integration Tests Using Cucumber. That project worked but in the end it turned out to be too big step forward. And was bound to one specific testing framework (cucumber).

Better Approach - REST API

So I was thinking about it how to make it more generic and my idea is: provide a REST API (using HTTP + JSON) for querying the UI and sending the actions.

API Examples

Here are some examples how the API could look. They are not final, it is just a proposal for starting the discussion:

Read (GET):

# dump whole dialog content
curl http://localhost:<port>/dialog
# dump only specific widget(s):
# by internal ID
curl http://localhost:<port>/widget?id=`checkbox
# by label (as displayed = translated!)
curl http://localhost:<port>/widget?label=Enabled
# by type (e.g. check all check box states)
curl http://localhost:<port>/widget?type=YCheckBox

Write, run actions (POST):

# by label (similar to read above)
curl -X POST http://localhost:<port>/widget?label=Enabled&checked=true
curl -X POST http://localhost:<port>/widget?label=Next&action=click

The read output could look like:

{
    "class": "YDialog",
    "children": [
        {
            "class": "YWizard",
            "id": "`wizard",
            "children": [
                 ...
            ]
         }
     ]
}

Advantages

  • Not specific to any testing framework, you can write wrappers for RSpec, Cucumber,... adapting the openQA should be easier than adding the Cucumber support
  • HTTP + JSON is easy to process (even from shell using curl and jq)
  • Can be used remotely when running inside a virtual machine (important for openQA), the only complication is network-less machine, in that case the HTTP requests could be sent from another console via a curl command locally
  • Allows using HTTP Basic/Digest Auth for authentication
  • Switching to secure HTTPS should be relatively easy, then you could send your root password securely over network

Implementation Details

Existing Proof of Concept

I already have a proof of concept code:

  • Compile libyui from my fork, use the http_server branch
  • Compile libyui-qt from my fork, use the http_server branch
  • Recompile/reinstall the yast2-ycp-ui-bindings package (because of the ABI changes in libyui)
  • Run YUI_HTTP_PORT=8888 yast2 <module> as root
  • Run curl http://localhost:8888, you will see the dump of the current dialog in the JSON format (not complete yet, some values might be missing)

It does not support the paths mentioned in the proposal above or POST actions yet, but at least it shows that embedding an HTTP server and processing JSON is not that difficult in C++ as it could look at the first sight.

TODO

  • Propose the REST API endpoints and parameters
  • Improve the JSON dumper
  • Implement the proposed API paths
  • Error handling (widget not found, action not possible)
  • Make the feature optional (e.g. enable/disable by a cmake option, users outside (open)SUSE might not be interested in this feature, it also adds some build and runtime dependencies)
  • Implement the support also in the ncurses UI
  • Implement support also for the packager widget (libyui-qt-pkg and libyui-ncurses-pkg)
  • Write some simple wrappers/helpers for RSpec or Cucumber (see the previous project for the Cucumber step definitions)
  • Document the API
  • As this is a generic libyui solution add also some plain C++ examples (to demonstrate the usage outside YaST)
  • Announce the feature so it can be really used

Related Project

There is the Make YaST Testing Independent of Keyboard Shortcuts hackweek project which is a bit related to this project. It's advantage is that it is simpler and can be possibly easier integrated into the current openQA.

=================================================================================================

Looking for mad skills in:

c++ rest http json testing yast yastui integration libyui libyui-qt libyui-ncurses

This project is part of:

Hack Week 16

Activity Show All

  • about 1 month ago: ancorgs liked Controlling and Testing the YaST UI Remotely (for Integration Tests, openQA)
  • about 1 month ago: okurz liked Controlling and Testing the YaST UI Remotely (for Integration Tests, openQA)
  • about 1 month ago: wanghaisu liked Controlling and Testing the YaST UI Remotely (for Integration Tests, openQA)
  • about 1 month ago: lslezak added keyword "libyui-ncurses" to Controlling and Testing the YaST UI Remotely (for Integration Tests, openQA)
  • about 1 month ago: lslezak added keyword "libyui-qt" to Controlling and Testing the YaST UI Remotely (for Integration Tests, openQA)
  • Comments