Blame test/README.md

Packit Service eebd6f
# Cockpit-Composer Integration Test
Packit Service eebd6f
Packit Service eebd6f
The integration test for Cockpit Composer! It is performed on the
Packit Service eebd6f
application level and tests whether the business requirements are met
Packit Service eebd6f
regardless of app internal architecture, dependencies, data integrity and such.
Packit Service eebd6f
Actually we need to follow the end-user flows and assert they get the intended
Packit Service eebd6f
experience and focus on the behavior of the thing as the user would see it.
Packit Service eebd6f
Packit Service eebd6f
The integration tests are powered by [Cockpit test
Packit Service eebd6f
framework](https://github.com/cockpit-project/cockpit/tree/master/test), which is simple and easy to
Packit Service eebd6f
debug for test development.
Packit Service eebd6f
Packit Service eebd6f
## Requirement
Packit Service eebd6f
Packit Service eebd6f
For testing, the following dependencies are required:
Packit Service eebd6f
Packit Service eebd6f
    $ sudo dnf install curl expect xz rpm-build chromium-headless \
Packit Service eebd6f
        libvirt-daemon-kvm libvirt-client python3-libvirt
Packit Service eebd6f
Packit Service eebd6f
And `chrome-remote-interface` and `sizzle` Javascript libraries need to be installed:
Packit Service eebd6f
Packit Service eebd6f
    $ npm install
Packit Service eebd6f
Packit Service eebd6f
## Introduction
Packit Service eebd6f
Packit Service eebd6f
Before running the tests, ensure Cockpit-Composer environment has been built:
Packit Service eebd6f
Packit Service eebd6f
    $ make vm
Packit Service eebd6f
Packit Service eebd6f
To run all tests run the following:
Packit Service eebd6f
Packit Service eebd6f
    $ make check
Packit Service eebd6f
Packit Service eebd6f
Alternatively you can run an individual test like this:
Packit Service eebd6f
Packit Service eebd6f
    $ ./test/verify/check-image
Packit Service eebd6f
Packit Service eebd6f
To see more verbose output from the test, use the `--verbose` and/or `--trace` flags:
Packit Service eebd6f
Packit Service eebd6f
    $ ./test/verify/check-image --verbose --trace
Packit Service eebd6f
Packit Service eebd6f
In addition if you specify `--sit`, then the test will wait on failure and allow you to log into
Packit Service eebd6f
cockpit and/or the test instance and diagnose the issue. An address will be printed of the test
Packit Service eebd6f
instance.
Packit Service eebd6f
Packit Service eebd6f
    $ ./test/verify/check-image --trace --sit
Packit Service eebd6f
Packit Service eebd6f
Normally each test starts its own chromium headless browser process on a separate random port. To
Packit Service eebd6f
interactively follow what a test is doing, set environment variable `$TEST_SHOW_BROWSER`.
Packit Service eebd6f
Packit Service eebd6f
    $ TEST_SHOW_BROWSER=true ./test/verify/check-image --trace
Packit Service eebd6f
Packit Service eebd6f
## Test Configuration
Packit Service eebd6f
Packit Service eebd6f
You can set these environment variables to configure the test suite:
Packit Service eebd6f
Packit Service eebd6f
    TEST_OS    The OS to run the tests in.  Currently supported values:
Packit Service eebd6f
                  "fedora-32"
Packit Service 0c2606
               "fedora-32" is the default
Packit Service eebd6f
Packit Service eebd6f
    TEST_DATA  Where to find and store test machine images.  The
Packit Service eebd6f
               default is the same directory that this README file is in.
Packit Service eebd6f
Packit Service eebd6f
    TEST_CDP_PORT  Attach to an actually running browser that is compatible with
Packit Service eebd6f
                   the Chrome Debug Protocol, on the given port. Don't use this
Packit Service eebd6f
                   with parallel tests.
Packit Service eebd6f
Packit Service eebd6f
    TEST_BROWSER  What browser should be used for testing. Currently supported values:
Packit Service eebd6f
                     "chromium"
Packit Service eebd6f
                     "firefox"
Packit Service eebd6f
                  "chromium" is the default.
Packit Service eebd6f
Packit Service eebd6f
    TEST_SHOW_BROWSER  Set to run browser interactively. When not specified,
Packit Service eebd6f
                       browser is run in headless mode.
Packit Service eebd6f
Packit Service eebd6f
## Guidelines for writing tests
Packit Service eebd6f
Packit Service eebd6f
Tests decorated with `@nondestructive` will all run against the same test
Packit Service eebd6f
machine. The nondestructive test should clean up after itself and restore the
Packit Service eebd6f
state of the machine, such that the next nondestructive test is not impacted.
Packit Service eebd6f
Packit Service eebd6f
A fast running test suite is more important than independent,
Packit Service eebd6f
small test cases.
Packit Service eebd6f
Packit Service eebd6f
## Code coverage from end-to-end tests
Packit Service eebd6f
Packit Service eebd6f
Before running the tests the application code must be instrumented with
Packit Service eebd6f
istanbul! Then inside the browser scope all coverage information is available
Packit Service eebd6f
from `window.__coverage__` which needs to be passed back to the node scope
Packit Service eebd6f
and made available for the reporting tools to use.
Packit Service eebd6f
Packit Service eebd6f
Please include helper method `check_coverage()` at the end of each test.
Packit Service eebd6f
This helper method will collect coverage result and save result into file
Packit Service eebd6f
`.nyc_output/coverage-<HASH>.json`. The hash value is the sha256 sum of
Packit Service eebd6f
the coverage report itself. Some cases may have identical coverage so
Packit Service eebd6f
the number of json files will be equal or less to the number of test cases.
Packit Service eebd6f
Packit Service eebd6f
## Code Style
Packit Service eebd6f
Packit Service eebd6f
Python code in this project should follow
Packit Service eebd6f
[Flake8](https://www.flake8rules.com/).