summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorinitard <alex.solomes@softwareag.com>2022-07-29 12:05:16 +0100
committerinitard <solo@softwareag.com>2022-08-01 14:19:58 +0100
commite7569b5254962ee5b91a88f3090a340b3bfebe15 (patch)
treefd3174416b8aa6c1c74179c9e08f00ed05e46df2
parent7e29063c59ab37d75333c68ead11cd369562d343 (diff)
removing apt integration tests
- removed two tests that were hidden behind 2 feature flags: `integration-test` and `requires-sudo`. These tests were never running in the pipeline but after #1303 when the CI tool chain changed, they were re-enabled. - these tests will be moved to system tests in the future. Signed-off-by: initard <alex.solomes@softwareag.com>
-rw-r--r--.github/workflows/ci_pipeline.yml29
-rw-r--r--.github/workflows/pull-request-checks.yml4
-rwxr-xr-xci/integration_test/cargo_test_for_amd64.sh8
-rw-r--r--plugins/tedge_apt_plugin/Cargo.toml4
-rw-r--r--plugins/tedge_apt_plugin/tests/main.rs177
5 files changed, 2 insertions, 220 deletions
diff --git a/.github/workflows/ci_pipeline.yml b/.github/workflows/ci_pipeline.yml
index 1eace320..da164d16 100644
--- a/.github/workflows/ci_pipeline.yml
+++ b/.github/workflows/ci_pipeline.yml
@@ -5,8 +5,6 @@ name: ci_pipeline
# are there four times and are almost identical. They only differ in a character
# a,b,c,d that we use to select a runner.
#
-# TODO: Safely move cargo test on amd64 to bash script
-# TODO: Reduce complexity by moving functionality to bash scripts
# TODO: Smoke testing on Azure is disabled, we should check if it works out
# with 4 runners in parallel or enable only one
@@ -68,33 +66,6 @@ jobs:
- name: Run tedge help
run: tedge --help
-#################################################################################
-
- cargo-test-features-amd64:
- name: Run cargo test features
- runs-on: Ubuntu-20.04
- needs: build-amd64
-
- steps:
- - name: Checkout
- uses: actions/checkout@v3
-
- - name: Enable toolchain via github action
- uses: dtolnay/rust-toolchain@1.58.1
-
- - name: Enable cache
- # https://github.com/marketplace/actions/rust-cache
- uses: Swatinem/rust-cache@v1
-
- - name: Compile test
- run: ./ci/integration_test/cargo_test_for_amd64.sh
-
- # If this command is ported to bash script, it runs tests that should be skipped.
- # The tests could fail if GitHub blocks external connections.
- # It seems like they rarely do.
- - name: Cargo test features
- run: cargo test --verbose --features integration-test,requires-sudo -- --skip sending_and_receiving_a_message
-
##################################################################################
build-arm-matrix:
diff --git a/.github/workflows/pull-request-checks.yml b/.github/workflows/pull-request-checks.yml
index fadab059..e0385719 100644
--- a/.github/workflows/pull-request-checks.yml
+++ b/.github/workflows/pull-request-checks.yml
@@ -210,7 +210,7 @@ jobs:
# https://github.com/marketplace/actions/rust-cargo
with:
command: test
- args: --no-fail-fast --features fs-notify
+ args: --no-fail-fast --all-features
cargo-build:
name: Run cargo build
@@ -291,7 +291,7 @@ jobs:
with:
use-cross: true
command: test
- args: --release --no-run --target=armv7-unknown-linux-gnueabihf --features fs-notify
+ args: --release --no-run --target=armv7-unknown-linux-gnueabihf --all-features
### Disable cargo-tarpaulin as some tests failed only in this step
# cargo-tarpaulin:
diff --git a/ci/integration_test/cargo_test_for_amd64.sh b/ci/integration_test/cargo_test_for_amd64.sh
deleted file mode 100755
index 59d79031..00000000
--- a/ci/integration_test/cargo_test_for_amd64.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash -x
-
-set -euo pipefail
-
-# Compile in advance to avoid that cargo compiles during the test run
-# this seems to have an impact on some tests as the timing differs
-cargo test --verbose --no-run --features integration-test
-cargo build -p tedge_dummy_plugin
diff --git a/plugins/tedge_apt_plugin/Cargo.toml b/plugins/tedge_apt_plugin/Cargo.toml
index 74dbaac4..e608aa1e 100644
--- a/plugins/tedge_apt_plugin/Cargo.toml
+++ b/plugins/tedge_apt_plugin/Cargo.toml
@@ -27,7 +27,3 @@ reqwest = { version = "0.11", default-features = false, features = [ "blocking",
serial_test = "0.8"
tedge_utils = { path = "../../crates/common/tedge_utils" }
test-case = "2.2"
-
-[features]
-requires-sudo = []
-integration-test = []
diff --git a/plugins/tedge_apt_plugin/tests/main.rs b/plugins/tedge_apt_plugin/tests/main.rs
deleted file mode 100644
index 08afc293..00000000
--- a/plugins/tedge_apt_plugin/tests/main.rs
+++ /dev/null
@@ -1,177 +0,0 @@
-#[cfg(feature = "integration-test")]
-mod tests {
- use hamcrest2::prelude::*;
- #[cfg(feature = "requires-sudo")]
- use serial_test::serial;
- use std::process::{Command, Stdio};
- #[cfg(feature = "requires-sudo")]
- use std::sync::Once;
- #[cfg(feature = "requires-sudo")]
- use tedge_utils::fs::atomically_write_file_sync;
- use test_case::test_case;
-
- const TEDGE_APT_COMMAND: &str = "/etc/tedge/sm-plugins/apt";
- #[cfg(feature = "requires-sudo")]
- const APT_COMMAND: &str = "/usr/bin/apt-get";
- const PACKAGE_NAME: &str = "rolldice";
- const PACKAGE_VERSION: &str = "1.16-1+b3";
-
- #[cfg(feature = "requires-sudo")]
- #[cfg(target_arch = "x86_64")]
- const PACKAGE_URL: &str =
- "http://ftp.br.debian.org/debian/pool/main/r/rolldice/rolldice_1.16-1+b3_amd64.deb";
-
- #[cfg(target_arch = "x86_64")]
- const PACKAGE_FILE_PATH: &str = "/tmp/rolldice_1.16-1+b3_amd64.deb";
-
- #[cfg(feature = "requires-sudo")]
- #[cfg(target_arch = "aarch64")]
- const PACKAGE_URL: &str =
- "http://ftp.br.debian.org/debian/pool/main/r/rolldice/rolldice_1.16-1+b3_arm64.deb";
-
- #[cfg(target_arch = "aarch64")]
- const PACKAGE_FILE_PATH: &str = "/tmp/rolldice_1.16-1+b3_arm64.deb";
-
- #[cfg(target_arch = "arm")]
- const PACKAGE_URL: &str =
- "http://ftp.br.debian.org/debian/pool/main/r/rolldice/rolldice_1.16-1+b3_armhf.deb";
-
- #[cfg(target_arch = "arm")]
- const PACKAGE_FILE_PATH: &str = "/tmp/rolldice_1.16-1+b3_armhf.deb";
-
- #[cfg(feature = "requires-sudo")]
- static DOWNLOAD_PACKAGE_BINARY: Once = Once::new();
-
- #[cfg(feature = "requires-sudo")]
- pub fn download_package_binary_once() {
- DOWNLOAD_PACKAGE_BINARY.call_once_force(|_state| {
- simple_download(PACKAGE_URL);
- });
- }
-
- #[cfg(feature = "requires-sudo")]
- fn simple_download(url: &str) {
- let response = reqwest::blocking::get(url).unwrap();
- let content = response.bytes().unwrap();
-
- atomically_write_file_sync("/tmp/rolldice.deb", PACKAGE_FILE_PATH, content.as_ref())
- .unwrap();
- }
-
- /// executes a `cmd` with `args`
- /// returns the stdout, stderr and exit code
- fn run_cmd(cmd: &str, args: &str) -> anyhow::Result<(String, String, i32)> {
- let args = args.split_whitespace().collect::<Vec<&str>>();
- let output = Command::new(cmd)
- .args(args)
- .stdin(Stdio::null())
- .stdout(Stdio::piped())
- .stderr(Stdio::piped())
- .output()?;
-
- let stdout = String::from_utf8(output.stdout).unwrap();
- let stderr = String::from_utf8(output.stderr).unwrap();
- let status_code = output.status.code().unwrap();
- Ok((stdout, stderr, status_code))
- }
-
- // Parameters:
- //
- // input command
- //
- // expected stderr
- //
- // expected exit code
- //
- // description about the test
- #[test_case(
- &format!("install {} --file {}", PACKAGE_NAME, "wrong_path"),
- "ERROR: Parsing Debian package failed",
- 5
- ; "wrong path"
- )]
- #[test_case(
- &format!("install {} --file {} --module-version {}", PACKAGE_NAME, "not/a/package/path", PACKAGE_VERSION),
- "ERROR: Parsing Debian package failed",
- 5
- ; "wrong path with right version"
- )]
- #[test_case(
- &format!("install {} --file {} --module-version {}", PACKAGE_NAME, PACKAGE_FILE_PATH, "some_version"),
- "ERROR: Parsing Debian package failed",
- 5
- ; "right path with wrong version"
- )]
- #[test_case(
- &format!("install {} --file {} --module-version {}", PACKAGE_NAME, "not/a/package/path", "some_version"),
- "ERROR: Parsing Debian package failed",
- 5
- ; "wrong path with wrong version"
- )]
- fn install_from_local_file_fail(
- input_command: &str,
- expected_stderr: &str,
- expected_exit_code: i32,
- ) -> anyhow::Result<()> {
- // no setup needed, wrong arguments are provided to tedge apt plugin
- let (stdout, stderr, exit_code) = run_cmd(TEDGE_APT_COMMAND, input_command)?;
-
- // asserting command failed
- assert_that!(stdout.is_empty(), true);
- assert_that!(stderr, match_regex(expected_stderr));
- assert_that!(exit_code, eq(expected_exit_code));
- Ok(())
- }
-
- // Parameters:
- //
- // input command
- //
- // expected stderr
- //
- // expected exit code
- //
- // description about the test
- #[cfg(feature = "requires-sudo")]
- #[test_case(
- &format!("install {} --file {}", PACKAGE_NAME, PACKAGE_FILE_PATH),
- PACKAGE_NAME,
- 0
- ; "path"
- )]
- #[serial]
- #[test_case(
- &format!("install {} --file {} --module-version {}", PACKAGE_NAME, PACKAGE_FILE_PATH, PACKAGE_VERSION),
- PACKAGE_NAME,
- 0
- ; "path with version"
- )]
- #[serial]
- #[test_case(
- &format!("install {} --module-version {} --file {}", PACKAGE_NAME, PACKAGE_VERSION, PACKAGE_FILE_PATH),
- PACKAGE_NAME,
- 0
- ; "version with path"
- )]
- #[serial]
- fn install_from_local_file_success(
- input_command: &str,
- expected_stdout: &str,
- expected_exit_code: i32,
- ) -> anyhow::Result<()> {
- // fetching the debian package & removing rolldice in case it is already installed.
- // only executed once.
- download_package_binary_once();
- let _ = run_cmd(APT_COMMAND, &format!("remove {} -y", PACKAGE_NAME))?;
-
- // execute command to install from local file
- let (stdout, stderr, exit_code) = run_cmd(TEDGE_APT_COMMAND, input_command)?;
-
- // asserting success
- assert_that!(stdout, match_regex(expected_stdout));
- assert_that!(stderr.is_empty(), true);
- assert_that!(exit_code, eq(expected_exit_code));
-
- Ok(())
- }
-}