1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 01:06:17 +02:00
github.com_openSUSE_osc/behave
2024-08-27 10:44:56 +02:00
..
features Fix behave test for repairwc command 2024-08-27 10:44:56 +02:00
fixtures Improve 'build' and 'buildinfo' commands by uploading *.inc files to OBS for parsing BuildRequires (boo#1221340) 2024-05-07 13:45:51 +02:00
container-build.sh behave: Propagate exit codes in the shell scripts properly 2023-06-19 09:27:24 +02:00
container-oscrc Move behave tests from Kanku to Podman, run them in GitHub actions 2022-12-07 15:05:15 +01:00
container-pull.sh behave: Add container-pull.sh script 2024-01-11 10:01:57 +01:00
container-run.sh behave: Add --rm to container-run.sh to automatically remove containers that have exited 2024-01-11 09:44:55 +01:00
container-setup-common.sh Move behave tests from Kanku to Podman, run them in GitHub actions 2022-12-07 15:05:15 +01:00
container-setup-initial-data.sh Fix 'branch' command to allow using '--new-package' option on packages that do not exist 2024-04-12 16:49:49 +02:00
container-setup-prebuilt-rpms.sh GHA: Fix obs-server test container to own files created under /srv/obs/build by obsrun 2024-01-26 13:52:11 +01:00
container-setup.sh behave: Decouple obs-* services from obs-api-support.target 2024-01-15 10:02:56 +01:00
container-shell.sh behave: Propagate exit codes in the shell scripts properly 2023-06-19 09:27:24 +02:00
Containerfile behave: Switch the container image to leap:15.5 2023-06-19 09:32:56 +02:00
README.md Propagate exit code from the run() and do_() commandline methods 2024-04-10 15:04:05 +02:00

Install requirements

On openSUSE:

$ zypper install osc podman python3-behave

On Fedora:

$ dnf install osc podman python3-behave

Build a container with OBS

$ cd behave

# optional: refresh the base image
$ podman pull opensuse/leap:15.5

# build the container image
$ ./container-build.sh [--no-cache]

Use a prebuilt container with OBS

$ cd behave
$ ./container-pull.sh

Use the container

$ cd behave

# run 'obs-server' container on port 1443
# running this command again replaces the current container with a fresh one
$ ./container-run.sh

# shell into the started container
$ ./container-shell.sh

Cleanup

# stop the started container
$ podman stop|kill obs-server

# remove container image
$ podman rmi obs-server

Install test dependencies

$ zypper install python3-behave diffstat diffutils obs-service-replace_using_env python3 python3-cryptography python3-pip python3-rpm python3-setuptools python3-urllib3 build obs-service-set_version

Run tests

Run all tests

$ cd behave
$ behave -Dosc=../osc-wrapper.py

Run selected tests

$ cd behave
$ behave -Dosc=../osc-wrapper.py features/<file>.feature

Run tests being worked on (decorated with @wip)

$ cd behave
behave -Dosc=../osc-wrapper.py --wip -k

Run osc commands

osc -A https://localhost:1443 ...

Filesystem layout

<project topdir>
+- behave
     +- features
        +- *.feature       # tests (that use steps defined in the `steps` directory)
                           #   * https://behave.readthedocs.io/en/stable/tutorial.html#feature-files
        +- environment.py  # code that runs before/after certain events (steps, features, etc.)
                           #   * https://behave.readthedocs.io/en/stable/tutorial.html#environmental-controls
                           #   * frequently used to modify ``context``
        +- steps           # step definitions, support code
                           #   * https://behave.readthedocs.io/en/stable/tutorial.html#python-step-implementations
     +- fixtures           # test data
     +- *                  # additional support files

Good to know

  • context provides state information to the tests; you can think of it as passing self to python methods.
  • context.config.userdata contains values of defines specified on the command-line: -D NAME=VALUE -> context.config.userdata[NAME] = VALUE