Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge-queue: embarking main (a5d7b9c) and #3903 together #3939

Closed
wants to merge 28 commits into from
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5ce0dee
Make command test matching code accept generic regexes
teor2345 Mar 17, 2022
2148dd4
Document test command structs
teor2345 Mar 17, 2022
e5c42b8
Support matching multiple regexes internally in the test command
teor2345 Mar 17, 2022
c4389fc
Make it easier to call the generic regex methods
teor2345 Mar 17, 2022
a6d809b
Add a missing API usage comment
teor2345 Mar 17, 2022
0241624
Fix a potential hang in test child error reports
teor2345 Mar 17, 2022
3b7887a
Revert Option<Child> process handling
teor2345 Mar 17, 2022
d5c6d49
Revert "Revert Option<Child> process handling"
teor2345 Mar 17, 2022
78627d9
Add a set of failure regexes to test command output
teor2345 Mar 17, 2022
8301438
Allow debug-printing TestChild again
teor2345 Mar 17, 2022
bf92877
When the child is dropped, check any remaining output
teor2345 Mar 18, 2022
ad52dda
Document a wait_with_output edge case
teor2345 Mar 17, 2022
3ef8f1f
Improve failure regex panic output
teor2345 Mar 17, 2022
ff1770f
Improve builder ergonomics
teor2345 Mar 17, 2022
e0dcb43
Add internal tests for failure regex panics
teor2345 Mar 17, 2022
bf01b53
Add some module structure TODOs
teor2345 Mar 17, 2022
f566a0e
Stop panicking if the child process has already been taken
teor2345 Mar 17, 2022
7c0668b
Add test APIs for consuming child output lines
teor2345 Mar 17, 2022
fa0026c
Fix a hang on child process drop
teor2345 Mar 17, 2022
fdf0466
Handle output being already taken in wait_with_output
teor2345 Mar 17, 2022
a43b047
Use bash's read command in the TestChild stderr test
teor2345 Mar 18, 2022
be934cc
Pretty print full failure regex list
teor2345 Mar 18, 2022
fcfc61e
Add the test child command line to the failure regex logs
teor2345 Mar 18, 2022
7bb1de8
Simplify the sync_until test code
teor2345 Mar 18, 2022
c56d0ca
Check logs for failure messages in lightwalletd integration tests
teor2345 Mar 18, 2022
cec838b
Add more TODOs and improve comments
teor2345 Mar 18, 2022
9bdf749
Allow missing branch ID 00000000 provided by zcashd
teor2345 Mar 20, 2022
32ef8a4
Merge of #3903
mergify[bot] Mar 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 115 additions & 7 deletions zebrad/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ fn full_sync_testnet() {
/// The timeout is specified using an environment variable, with the name configured by the
/// `timeout_argument_name` parameter. The value of the environment variable must the number of
/// minutes specified as an integer.
fn full_sync_test(network: Network, timeout_argument_name: &'static str) -> Result<()> {
fn full_sync_test(network: Network, timeout_argument_name: &str) -> Result<()> {
let timeout_argument: Option<u64> = env::var(timeout_argument_name)
.ok()
.and_then(|timeout_string| timeout_string.parse().ok());
Expand All @@ -678,18 +678,17 @@ fn full_sync_test(network: Network, timeout_argument_name: &'static str) -> Resu
// TODO: if full validation performance improves, do another test with checkpoint_sync off
true,
true,
)
.map(|_| ())
)?;
} else {
tracing::info!(
?network,
"skipped full sync test, \
set the {:?} environmental variable to run the test",
timeout_argument_name,
);

Ok(())
}

Ok(())
}

fn create_cached_database(network: Network) -> Result<()> {
Expand Down Expand Up @@ -989,6 +988,95 @@ async fn rpc_endpoint() -> Result<()> {
Ok(())
}

/// Failure log messages for any process, from the OS or shell.
const PROCESS_FAILURE_MESSAGES: &[&str] = &[
// Linux
"Aborted",
// macOS / BSDs
"Abort trap",
// TODO: add other OS or C library errors?
];

/// Failure log messages from Zebra.
const ZEBRA_FAILURE_MESSAGES: &[&str] = &[
// Rust-specific panics
"The application panicked",
// RPC port errors
"Unable to start RPC server",
// TODO: disable if this actually happens during test zebrad shutdown
"Stopping RPC endpoint",
// Missing RPCs in zebrad logs (this log is from PR #3860)
//
// TODO: temporarily disable until enough RPCs are implemented, if needed
"Received unrecognized RPC request",
// RPC argument errors: parsing and data
//
// These logs are produced by jsonrpc_core inside Zebra,
// but it doesn't log them yet.
//
// TODO: log these errors in Zebra, and check for them in the Zebra logs?
"Invalid params",
"Method not found",
];

/// Failure log messages from lightwalletd.
const LIGHTWALLETD_FAILURE_MESSAGES: &[&str] = &[
// Go-specific panics
"panic:",
// Missing RPCs in lightwalletd logs
// TODO: temporarily disable until enough RPCs are implemented, if needed
"unable to issue RPC call",
// RPC response errors: parsing and data
//
// jsonrpc_core error messages from Zebra,
// received by lightwalletd and written to its logs
"Invalid params",
"Method not found",
// Early termination
//
// TODO: temporarily disable until enough RPCs are implemented, if needed
"Lightwalletd died with a Fatal error",
// Go json package error messages:
"json: cannot unmarshal",
"into Go value of type",
// lightwalletd RPC error messages from:
// https://github.com/adityapk00/lightwalletd/blob/master/common/common.go
"block requested is newer than latest block",
"Cache add failed",
"error decoding",
"error marshaling",
"error parsing JSON",
"error reading JSON response",
"error with",
// We expect these errors when lightwalletd reaches the end of the zebrad cached state
// "error requesting block: 0: Block not found",
// "error zcashd getblock rpc",
"received overlong message",
"received unexpected height block",
"Reorg exceeded max",
"unable to issue RPC call",
// Missing fields for each specific RPC
//
// get_block_chain_info
//
// TODO: enable these checks after PR #3891 merges
//
// invalid sapling height
//"Got sapling height 0",
// missing BIP70 chain name, should be "main" or "test"
//" chain ",
// missing branchID, should be 8 hex digits
//" branchID \"",
//
// TODO: complete this list for each RPC with fields?
// get_info
// get_raw_transaction
// z_get_tree_state
// get_address_txids
// get_address_balance
// get_address_utxos
];

/// Launch `zebrad` with an RPC port, and make sure `lightwalletd` works with Zebra.
///
/// This test only runs when the `ZEBRA_TEST_LIGHTWALLETD` env var is set.
Expand All @@ -1011,7 +1099,16 @@ fn lightwalletd_integration() -> Result<()> {
let mut config = random_known_rpc_port_config()?;

let zdir = testdir()?.with_config(&mut config)?;
let mut zebrad = zdir.spawn_child(&["start"])?.with_timeout(LAUNCH_DELAY);
let mut zebrad = zdir
.spawn_child(&["start"])?
.with_timeout(LAUNCH_DELAY)
.with_failure_regex_iter(
// TODO: replace with a function that returns the full list and correct return type
ZEBRA_FAILURE_MESSAGES
.iter()
.chain(PROCESS_FAILURE_MESSAGES)
.cloned(),
);

// Wait until `zebrad` has opened the RPC endpoint
zebrad.expect_stdout_line_matches(
Expand All @@ -1027,7 +1124,15 @@ fn lightwalletd_integration() -> Result<()> {
// Launch the lightwalletd process
let result = ldir.spawn_lightwalletd_child(&[]);
let (lightwalletd, zebrad) = zebrad.kill_on_error(result)?;
let mut lightwalletd = lightwalletd.with_timeout(LIGHTWALLETD_DELAY);
let mut lightwalletd = lightwalletd
.with_timeout(LIGHTWALLETD_DELAY)
.with_failure_regex_iter(
// TODO: replace with a function that returns the full list and correct return type
LIGHTWALLETD_FAILURE_MESSAGES
.iter()
.chain(PROCESS_FAILURE_MESSAGES)
.cloned(),
);

// Wait until `lightwalletd` has launched
let result = lightwalletd.expect_stdout_line_matches("Starting gRPC server");
Expand All @@ -1036,6 +1141,9 @@ fn lightwalletd_integration() -> Result<()> {
// Check that `lightwalletd` is calling the expected Zebra RPCs

// getblockchaininfo
//
// TODO: add correct sapling height, chain, branchID (PR #3891)
// add "Waiting for zcashd height to reach Sapling activation height"
let result = lightwalletd.expect_stdout_line_matches("Got sapling height");
let (_, zebrad) = zebrad.kill_on_error(result)?;

Expand Down