The rust tests
- Shell 82.1%
- Rust 12.5%
- JavaScript 5.4%
Some test systems have catch-all DNS resolvers that point needs-proxy.invalid to loopback, resulting in a connection refused OS error instead the expected Net error. This change uses a known invalid IP to bypass any potential DNS, and also adds an extremely short timeout to enforce a Net error. Also make the test pattern matching a bit more fuzzy to avoid future false positives. Remove the standalone Cargo.toml file and integrate it into the main script to be able to parametrize it. |
||
|---|---|---|
| .fmf | ||
| plans | ||
| tests | ||
| .pre-commit-config.yaml | ||
| README.md | ||
Rust Tests
This repository contains tests for rust packages. These tests are meant to be run on bodhi updates or Pull Requests.
Usage
Tests are executed using TMT (Test Management Tool). The repository includes a TMT plan that runs all the tests by default. All the tests support (and expect) the following context dimensions:
distroarchcollection(only applicable to RHEL 7)
To run the tests:
# Run in the default virtual environment
tmt -c distro=<distro> -c arch=<arch> run -avv
# Run on a scheduled system
tmt -c distro=<distro> -c arch=<arch> run -avv provision -h connect -g <ip_or_hostname>
# Run specific tests
tmt -c distro=<distro> -c arch=<arch> run -avv provision -h connect -g <ip_or_hostname> test -n <regex>
Adding New Tests
Please consider the following when adding new tests:
- Test scripts must be named
runtest.sh. - Prefer using
beakerlibtests overshelltests. If using a shell test cannot be avoided, themain.fmffile must redefine/overwrite the framework key by addingframework: shell. - Tests must be placed in
tests/<category>/<test-name>/, where<category>can beRegression,Sanity,Security, or a new one if required. - This repository has a common configuration under
tests/main.fmf, inherited by all tests. When adding new ones, be careful not to overwrite existing keys from the inheritedtests/main.fmf.
Templates
Use the following templates when creating new tests.
FMF template. Uncomment needed fields, remove the rest.
summary: Descriptive summary for the test
duration: 2m
tier: 1
# Add an additional contact(s) if applicable
# contact+:
# - Somebody <somebody@redhat.com>
# Additional requires
# require+:
# - rpm-build
# Adjustments based on context dimensions
# adjust+:
# - when: collection is defined
# enabled: false
# because: Test not supported in collections
# link+:
# - verifies: https://issues.redhat.com/browse/...
# tag+:
# - sometag
Script template:
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
# Define package name(s) for rlAssertRpm to report installed versions
PACKAGE=$(rpm -qf $(which rustc))
PACKAGES=${PACKAGES:-$PACKAGE}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm --all
# Any additional setup steps.
# ....
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
# Your actual test goes here
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalEnd