From a48fe4fb519077c83cb64528b47bc7152b963b0d Mon Sep 17 00:00:00 2001 From: Andrii Yurchuk Date: Mon, 1 Mar 2021 15:33:46 +0100 Subject: [PATCH 1/2] Add a test to demonstrate slowness of tarp's follow-exec --- Cargo.toml | 4 ++++ cobertura.xml | 1 + tests/slow.rs | 27 +++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 cobertura.xml create mode 100644 tests/slow.rs diff --git a/Cargo.toml b/Cargo.toml index 89d45a8..2d74d71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,3 +49,7 @@ path = "src/lib.rs" [[test]] name = "integration" path = "tests/test.rs" + +[[test]] +name = "slow" +path = "tests/slow.rs" diff --git a/cobertura.xml b/cobertura.xml new file mode 100644 index 0000000..ae9be1c --- /dev/null +++ b/cobertura.xml @@ -0,0 +1 @@ +/home/ay/projects/personal/orthanc-cli \ No newline at end of file diff --git a/tests/slow.rs b/tests/slow.rs new file mode 100644 index 0000000..59a7b98 --- /dev/null +++ b/tests/slow.rs @@ -0,0 +1,27 @@ +use std::env; +use std::path::PathBuf; +use std::process::Command; +use std::str; +use std::time::{SystemTime, UNIX_EPOCH}; + +fn executable_path() -> PathBuf { + let mut path = env::current_exe().unwrap(); + path.pop(); + path.pop(); + path.join("orthanc") +} + +fn run_command(args: Vec<&str>) { + Command::new(executable_path()) + .args(&args) + .output() + .unwrap(); +} + +#[test] +fn test_slow() { + let start = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); + run_command(vec!["--server", "http://localhost:8901", "patient", "list"]); + let end = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); + println!("Test run time: {}", end.as_millis() - start.as_millis()); +} From 16d8d855249510062f21f328f091f54dd464e9fe Mon Sep 17 00:00:00 2001 From: Andrii Yurchuk Date: Sat, 6 Mar 2021 15:47:50 +0100 Subject: [PATCH 2/2] Add CI jobs --- .github/workflows/test.yml | 104 ++++--------------------------------- 1 file changed, 11 insertions(+), 93 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b685b47..6258c88 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,9 +11,9 @@ env: ORC_COMPLETION_OUTPUT_DIR: /tmp jobs: - unit_test: + with-follow-exec: runs-on: ubuntu-latest - name: unit_test + name: with-follow-exec steps: - name: checkout @@ -24,79 +24,15 @@ jobs: with: toolchain: stable - - name: run tests - run: make unit_test_coverage - - - name: upload coverage - uses: codecov/codecov-action@v1 - with: - flags: unit_test - fail_ci_if_error: true - - integration_test: - runs-on: ubuntu-latest - name: integration_test - strategy: - matrix: - orthanc: [1.6.1, 1.7.4, 1.8.2] - services: - orthanc: - image: ch00k/orthanc-nginx:${{matrix.orthanc}} - ports: - - 8028:80 - dino: - image: ch00k/dino - env: - DINO_SCP_HOST: ${{env.DINO_SCP_HOST}} - DINO_SCP_PORT: ${{env.DINO_SCP_PORT}} - DINO_SCP_AET: ${{env.DINO_SCP_AET}} - ports: - - 5252:5252 - env: - ORC_ORTHANC_ADDRESS: http://localhost:8028 - ORC_ORTHANC_USERNAME: orthanc - ORC_ORTHANC_PASSWORD: orthanc - ORC_DATAFILES_PATH: /tmp/orc_test_data - DINO_SCP_HOST: 0.0.0.0 - DINO_SCP_PORT: 5252 - DINO_SCP_AET: DINO - - steps: - - name: checkout - uses: actions/checkout@v2 - - - name: prepare rust env - uses: actions-rs/toolchain@v1 - with: - toolchain: stable + - name: install tarpaulin + run: cargo install --git https://github.com/xd009642/tarpaulin.git --branch develop cargo-tarpaulin - name: run tests - run: make integration_test + run: cargo tarpaulin --follow-exec --test slow -- --show-output - integration_test_coverage: + without-follow-exec: runs-on: ubuntu-latest - name: integration_test_coverage - services: - orthanc: - image: ch00k/orthanc-nginx:1.8.2 - ports: - - 8028:80 - dino: - image: ch00k/dino - env: - DINO_SCP_HOST: ${{env.DINO_SCP_HOST}} - DINO_SCP_PORT: ${{env.DINO_SCP_PORT}} - DINO_SCP_AET: ${{env.DINO_SCP_AET}} - ports: - - 5252:5252 - env: - ORC_ORTHANC_ADDRESS: http://localhost:8028 - ORC_ORTHANC_USERNAME: orthanc - ORC_ORTHANC_PASSWORD: orthanc - ORC_DATAFILES_PATH: /tmp/orc_test_data - DINO_SCP_HOST: 0.0.0.0 - DINO_SCP_PORT: 5252 - DINO_SCP_AET: DINO + name: without-follow-exec steps: - name: checkout @@ -107,27 +43,9 @@ jobs: with: toolchain: stable - - name: run tests - run: make integration_test_coverage - - - name: upload coverage - uses: codecov/codecov-action@v1 - with: - flags: integration_test - fail_ci_if_error: true - - check_completion: - runs-on: ubuntu-latest - name: check_completion - - steps: - - name: checkout - uses: actions/checkout@v2 + - name: install tarpaulin + run: cargo install --git https://github.com/xd009642/tarpaulin.git --branch develop cargo-tarpaulin - - name: prepare rust env - uses: actions-rs/toolchain@v1 - with: - toolchain: stable + - name: run tests + run: cargo tarpaulin --test slow -- --show-output - - name: run check - run: make check_completion