Skip to content

Pullrequest

The pull Request Workflow, defined in the ci-tests.yml file, is triggered on pull_request_target events to the branches master and main has three jobs: linters, build and tests.

graph LR
  A[pull_request_target] --> B[linters];
  B --> C[build];
  C --> D[tests];

Linters

This job performs the following steps:

  1. Checks out the code
  2. Installs pre-commit.
  3. Runs pre-commit hooks to execute code linting based on .pre-commit-config.yaml file

Linters can be executed locally with just make lint

Info

Main purpose for pre-commit is to allow developers to pass the Lint Checks before commiting the code. Same checks will be executed on all the commits once they are pushed to GitHub

Requirements:

  • make
  • pre-commit

$ make lint
Executing pre-commit for all files
pre-commit run --all-files
golangci-lint............................................................Passed
markdownlint.............................................................Passed
Test shell scripts with shellcheck.......................................Passed
check json...............................................................Passed
pre-commit executed.

Build

The "build" job uses the file builders.yml file to build binaries and images, performing the following steps:

  1. Sets up Go 1.19.
  2. Checks out the code.
  3. Builds the code
  4. Builds container images
  5. Builds the documentation
  6. Installs the built artifacts
  7. Uploads the built binary file as an artifact named kube-burner.

Tests

The testing Workflow, defined in the tests-k8s.yml file, runs tests defined in the test directory of the repository.

Tests are orchestrated with bats

Tests can be executed locally with make test, some requirements are needed though:

  • make
  • bats
  • kubectl
  • podman or docker (required to run kind)

Running test with Podman

Since the test suite includes KubeVirt VMs, it must run with rootful Podman. Either run the tests as root, or access the rootful Podman socket.

Allow access to the rootful Podman socket

Assuming the user is in wheel group please do the following (one time):

As root, create a Drop-In file /etc/systemd/system/podman.socket.d/10-socketgroup.conf with the following content:

[Socket]
SocketGroup=wheel
ExecStartPost=/usr/bin/chmod 755 /run/podman

The 1st line is needed in order to create the socket accessible by the wheel group. 2nd line because systemd-tmpfiles recreates the folder as root:root without group reading rights.

Stop podman.socket if it is running, reload the daemon systemctl daemon-reload since we changed the systemd settings and restart it again systemctl enable --now podman.socket

Running the test

Instruct Podman to communicate with the rootful Podman socket by setting the environment variable:

CONTAINER_HOST=unix://run/podman/podman.sock make test-k8s

Running test with an External Cluster

By default, the tests start a local cluster using kind. Instead, you can use an already existsing cluster.

Prerequisites

Since the test suite includes KubeVirt VMs, the cluster must include the kubevirt operator. See the Installation guide for details.

Kubeconfig

Either save the kubeconfig file under ~/.kube/config or set the environment variable KUBECONFIG to its location

Run the tests

In order to instruct the tests to use the existing cluster set USE_EXISTING_CLUSTER=yes when calling make.