-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fluvio-test harness bug (#2790)
Addresses #2695 A race condition existed in the logic to evaluate whether or not tests run with `fluvio-test` passed, making it possible for a non-passing-test to appear to succeed. Also, tests that timed-out were erroneously set as passing. Note that this effect was obscured as default timeout of one-hour was higher than github action timeout. 1. Added test harness validation tests that "failed to fail" using previous logic. 2. Added `--expect-fail` and `--expect-timeout` flags for tests that are supposed to fail or timeout and added `--expect-timeout` to longevity tests. 3. Tightened up logic so as to eliminate race condition. **Note: This fix exposes genuine failing tests, so it will not consistently pass CI pipeline.** ### validate-test-harness example output (ignoring stderr) ``` ./build-scripts/install_target.sh cargo build --bin fluvio-test -p fluvio-test cargo build --bin fluvio -p fluvio-cli cargo build --bin fluvio-run -p fluvio-run echo "clean up previous installation" clean up previous installation ./target/debug/fluvio cluster delete ./target/debug/fluvio-test expected_pass --local --cluster-start Start running fluvio test runner Starting cluster and testing connection remove cluster skipped installing cluster starting test in child process Creating the topic: unused topic "unused" created Starting example test that passes test complete, signaling to parent Test passed +----------+--------------+ | Pass? | true | |----------+--------------| | Duration | 827.659539ms | +----------+--------------+ ./target/debug/fluvio-test expected_fail --expect-fail Start running fluvio test runner Testing connection to Fluvio cluster in profile starting test in child process Creating the topic: unused topic "unused" already exists Starting example test that fails test failed as expected, signaling parent test complete, signaling to parent Test passed +----------+--------------+ | Pass? | true | |----------+--------------| | Duration | 2.731820019s | +----------+--------------+ ./target/debug/fluvio-test expected_fail_join_fail_first --expect-fail Start running fluvio test runner Testing connection to Fluvio cluster in profile starting test in child process Creating the topic: unused topic "unused" already exists Starting example test that fails test failed as expected, signaling parent test complete, signaling to parent Test passed +----------+--------------+ | Pass? | true | |----------+--------------| | Duration | 2.511258335s | +----------+--------------+ ./target/debug/fluvio-test expected_fail_join_success_first --expect-fail Start running fluvio test runner Testing connection to Fluvio cluster in profile starting test in child process Creating the topic: unused topic "unused" already exists Starting example test that fails test failed as expected, signaling parent test complete, signaling to parent Test passed +----------+--------------+ | Pass? | true | |----------+--------------| | Duration | 925.028775ms | +----------+--------------+ ./target/debug/fluvio-test expected_timeout --timeout 5sec --expect-timeout Start running fluvio test runner Testing connection to Fluvio cluster in profile starting test in child process Creating the topic: unused topic "unused" already exists Starting example test that timeouts Test timed out as expected after 5 seconds killing child test pid 1250657 name fluvio-test killing child test pid 1250686 name fluvio-test +----------+--------------+ | Pass? | true | |----------+--------------| | Duration | 5.405322312s | +----------+--------------+ ```
- Loading branch information
1 parent
3adb7fb
commit 3a739ee
Showing
11 changed files
with
301 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use std::any::Any; | ||
use std::time::Duration; | ||
|
||
use clap::Parser; | ||
use fluvio_future::timer::sleep; | ||
use fluvio_test_derive::fluvio_test; | ||
use fluvio_test_util::test_meta::{TestOption, TestCase}; | ||
use fluvio_test_util::async_process; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct ExpectedFailTestCase {} | ||
|
||
impl From<TestCase> for ExpectedFailTestCase { | ||
fn from(_test_case: TestCase) -> Self { | ||
ExpectedFailTestCase {} | ||
} | ||
} | ||
|
||
#[derive(Debug, Parser, Clone)] | ||
#[clap(name = "Fluvio Expected Fail Test")] | ||
pub struct ExpectedFailTestOption {} | ||
impl TestOption for ExpectedFailTestOption { | ||
fn as_any(&self) -> &dyn Any { | ||
self | ||
} | ||
} | ||
|
||
#[fluvio_test(name = "expected_fail", topic = "unused")] | ||
pub fn run(mut test_driver: FluvioTestDriver, mut test_case: TestCase) { | ||
println!("\nStarting example test that fails"); | ||
|
||
let fast_fail = async_process!( | ||
async { | ||
sleep(Duration::from_millis(2000)).await; | ||
panic!("This test should fail"); | ||
}, | ||
"fast-fail" | ||
); | ||
fast_fail.join().unwrap(); | ||
} |
48 changes: 48 additions & 0 deletions
48
crates/fluvio-test/src/tests/expected_fail_join_fail_first.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use std::any::Any; | ||
use std::time::Duration; | ||
|
||
use clap::Parser; | ||
use fluvio_future::timer::sleep; | ||
use fluvio_test_derive::fluvio_test; | ||
use fluvio_test_util::test_meta::{TestOption, TestCase}; | ||
use fluvio_test_util::async_process; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct ExpectedFailJoinFailFirstTestCase {} | ||
|
||
impl From<TestCase> for ExpectedFailJoinFailFirstTestCase { | ||
fn from(_test_case: TestCase) -> Self { | ||
ExpectedFailJoinFailFirstTestCase {} | ||
} | ||
} | ||
|
||
#[derive(Debug, Parser, Clone)] | ||
#[clap(name = "Fluvio Expected FailJoinFailFirst Test")] | ||
pub struct ExpectedFailJoinFailFirstTestOption {} | ||
impl TestOption for ExpectedFailJoinFailFirstTestOption { | ||
fn as_any(&self) -> &dyn Any { | ||
self | ||
} | ||
} | ||
|
||
#[fluvio_test(name = r#"expected_fail_join_fail_first"#, topic = "unused")] | ||
pub fn run(mut test_driver: FluvioTestDriver, mut test_case: TestCase) { | ||
println!("\nStarting example test that fails"); | ||
|
||
let success = async_process!( | ||
async { | ||
sleep(Duration::from_millis(2000)).await; | ||
}, | ||
"success" | ||
); | ||
|
||
let fail = async_process!( | ||
async { | ||
sleep(Duration::from_millis(200)).await; | ||
panic!("This test should fail"); | ||
}, | ||
"fail" | ||
); | ||
fail.join().unwrap(); | ||
success.join().unwrap(); | ||
} |
48 changes: 48 additions & 0 deletions
48
crates/fluvio-test/src/tests/expected_fail_join_success_first.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use std::any::Any; | ||
use std::time::Duration; | ||
|
||
use clap::Parser; | ||
use fluvio_future::timer::sleep; | ||
use fluvio_test_derive::fluvio_test; | ||
use fluvio_test_util::test_meta::{TestOption, TestCase}; | ||
use fluvio_test_util::async_process; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct ExpectedFailJoinSuccessFirstTestCase {} | ||
|
||
impl From<TestCase> for ExpectedFailJoinSuccessFirstTestCase { | ||
fn from(_test_case: TestCase) -> Self { | ||
ExpectedFailJoinSuccessFirstTestCase {} | ||
} | ||
} | ||
|
||
#[derive(Debug, Parser, Clone)] | ||
#[clap(name = "Fluvio Expected FailJoinSuccessFirst Test")] | ||
pub struct ExpectedFailJoinSuccessFirstTestOption {} | ||
impl TestOption for ExpectedFailJoinSuccessFirstTestOption { | ||
fn as_any(&self) -> &dyn Any { | ||
self | ||
} | ||
} | ||
|
||
#[fluvio_test(name = "expected_fail_join_success_first", topic = "unused")] | ||
pub fn run(mut test_driver: FluvioTestDriver, mut test_case: TestCase) { | ||
println!("\nStarting example test that fails"); | ||
|
||
let success = async_process!( | ||
async { | ||
sleep(Duration::from_millis(100)).await; | ||
}, | ||
"success" | ||
); | ||
|
||
let fail = async_process!( | ||
async { | ||
sleep(Duration::from_millis(200)).await; | ||
panic!("This test should fail"); | ||
}, | ||
"fail" | ||
); | ||
success.join().unwrap(); | ||
fail.join().unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use std::any::Any; | ||
|
||
use clap::Parser; | ||
use fluvio_test_derive::fluvio_test; | ||
use fluvio_test_util::test_meta::{TestOption, TestCase}; | ||
use fluvio_test_util::async_process; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct ExpectedPassTestCase {} | ||
|
||
impl From<TestCase> for ExpectedPassTestCase { | ||
fn from(_test_case: TestCase) -> Self { | ||
ExpectedPassTestCase {} | ||
} | ||
} | ||
|
||
#[derive(Debug, Parser, Clone)] | ||
#[clap(name = "Fluvio Expected Fail Test")] | ||
pub struct ExpectedPassTestOption {} | ||
impl TestOption for ExpectedPassTestOption { | ||
fn as_any(&self) -> &dyn Any { | ||
self | ||
} | ||
} | ||
|
||
#[fluvio_test(name = "expected_pass", topic = "unused")] | ||
pub fn run(mut test_driver: FluvioTestDriver, mut test_case: TestCase) { | ||
println!("\nStarting example test that passes"); | ||
|
||
let fast_success = async_process!( | ||
async { | ||
// Do nothing and exit | ||
}, | ||
"fast-success" | ||
); | ||
fast_success.join().unwrap(); | ||
} |
Oops, something went wrong.