Skip to content

Commit

Permalink
[api] Add threads and timestamps to api tests (#9349)
Browse files Browse the repository at this point in the history
This commit builds threads and run ID on top of the consistent API testing introduced here. See proposal for more high level information.

Changes:

Refactored tests into dedicated file tests.rs.
Switched to creating accounts for every tests instead of using the same and created pre test set up routines in testsetups.rs.
Added run ID start_time to metrics.
  • Loading branch information
ngkuru committed Aug 7, 2023
1 parent 89df0a5 commit 81a362a
Show file tree
Hide file tree
Showing 7 changed files with 711 additions and 577 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/aptos-api-tester/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ aptos-push-metrics = { workspace = true }
aptos-rest-client = { workspace = true }
aptos-sdk = { workspace = true }
aptos-types = { workspace = true }
futures = { workspace = true }
move-core-types = { workspace = true }
once_cell = { workspace = true }
prometheus = { workspace = true }
Expand Down
30 changes: 18 additions & 12 deletions crates/aptos-api-tester/src/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,55 @@ pub static API_TEST_SUCCESS: Lazy<HistogramVec> = Lazy::new(|| {
register_histogram_vec!(
"api_test_success",
"Number of user flows which succesfully passed",
&["test_name", "network_name"],
&["test_name", "network_name", "start_time"],
)
.unwrap()
});

pub fn test_success(test_name: &str, network_name: &str) -> Histogram {
API_TEST_SUCCESS.with_label_values(&[test_name, network_name])
pub fn test_success(test_name: &str, network_name: &str, start_time: &str) -> Histogram {
API_TEST_SUCCESS.with_label_values(&[test_name, network_name, start_time])
}

pub static API_TEST_FAIL: Lazy<HistogramVec> = Lazy::new(|| {
register_histogram_vec!(
"api_test_fail",
"Number of user flows which failed checks",
&["test_name", "network_name"],
&["test_name", "network_name", "start_time"],
)
.unwrap()
});

pub fn test_fail(test_name: &str, network_name: &str) -> Histogram {
API_TEST_FAIL.with_label_values(&[test_name, network_name])
pub fn test_fail(test_name: &str, network_name: &str, start_time: &str) -> Histogram {
API_TEST_FAIL.with_label_values(&[test_name, network_name, start_time])
}

pub static API_TEST_ERROR: Lazy<HistogramVec> = Lazy::new(|| {
register_histogram_vec!("api_test_error", "Number of user flows which crashed", &[
"test_name",
"network_name",
])
"start_time"
],)
.unwrap()
});

pub fn test_error(test_name: &str, network_name: &str) -> Histogram {
API_TEST_ERROR.with_label_values(&[test_name, network_name])
pub fn test_error(test_name: &str, network_name: &str, start_time: &str) -> Histogram {
API_TEST_ERROR.with_label_values(&[test_name, network_name, start_time])
}

pub static API_TEST_LATENCY: Lazy<HistogramVec> = Lazy::new(|| {
register_histogram_vec!(
"api_test_latency",
"Time it takes to complete a user flow",
&["test_name", "network_name", "result"],
&["test_name", "network_name", "start_time", "result"],
)
.unwrap()
});

pub fn test_latency(test_name: &str, network_name: &str, result: &str) -> Histogram {
API_TEST_LATENCY.with_label_values(&[test_name, network_name, result])
pub fn test_latency(
test_name: &str,
network_name: &str,
start_time: &str,
result: &str,
) -> Histogram {
API_TEST_LATENCY.with_label_values(&[test_name, network_name, start_time, result])
}
Loading

0 comments on commit 81a362a

Please sign in to comment.