tests: refactor test_api* to support the D-Bus API and add a new test

Implemented a `TargetApi` enum to make the process of implementing
tests for the D-Bus and HTTP API more convenient.

Refactored `test_api_{create_boot, shutdown, pause_resume, delete}` tests
with the `TargetApi` enum to also implement tests for the D-Bus API.

Added a new test named `test_api_dbus_and_http_interleaved` that uses
both the HTTP and D-Bus API at the same time.

Modified integration test scripts to enable the `dbus_api` feature when
compiling and start a dbus-session when integration tests are run.

Signed-off-by: Omer Faruk Bayram <omer.faruk@sartura.hr>
This commit is contained in:
Omer Faruk Bayram 2023-03-30 23:47:21 +03:00 committed by Bo Chen
parent a64d27f841
commit a7aecb5eee
4 changed files with 250 additions and 72 deletions

View file

@ -426,7 +426,7 @@ cmd_tests() {
--env USER="root" \
--env CH_LIBC="${libc}" \
"$CTR_IMAGE" \
./scripts/run_integration_tests_"$(uname -m)".sh "$@" || fix_dir_perms $? || exit $?
dbus-run-session ./scripts/run_integration_tests_"$(uname -m)".sh "$@" || fix_dir_perms $? || exit $?
fi
if [ "$integration_sgx" = true ]; then

View file

@ -231,7 +231,7 @@ fi
export RUST_BACKTRACE=1
cargo build --all --release --target $BUILD_TARGET
cargo build --features "dbus_api" --all --release --target $BUILD_TARGET
# Enable KSM with some reasonable parameters so that it won't take too long
# for the memory to be merged between two processes.

View file

@ -12,10 +12,10 @@ mkdir -p "$WORKLOADS_DIR"
process_common_args "$@"
# For now these values are default for kvm
test_features=""
test_features="--features dbus_api"
if [ "$hypervisor" = "mshv" ] ; then
test_features="--no-default-features --features mshv"
test_features="--no-default-features ${test_features},mshv"
fi
cp scripts/sha1sums-x86_64 $WORKLOADS_DIR
@ -156,7 +156,7 @@ cp $VMLINUX_IMAGE $VFIO_DIR || exit 1
BUILD_TARGET="$(uname -m)-unknown-linux-${CH_LIBC}"
cargo build --no-default-features --features "kvm,mshv" --all --release --target $BUILD_TARGET
cargo build --no-default-features --features "kvm,mshv,dbus_api" --all --release --target $BUILD_TARGET
# We always copy a fresh version of our binary for our L2 guest.
cp target/$BUILD_TARGET/release/cloud-hypervisor $VFIO_DIR