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

add test for api_client slow API call logging #127

Merged
merged 3 commits into from
Oct 17, 2024

Conversation

dfrankland
Copy link
Member

@dfrankland dfrankland commented Oct 10, 2024

depends on #118

Adds more testing for the ApiClient, plus the logging and reporting it performs

@dfrankland dfrankland changed the base branch from main to dylan/add-api-client October 10, 2024 23:29
@dfrankland dfrankland force-pushed the dylan/add-api-client-slow-api-call-logging-tests branch from 415b757 to 7dc5d35 Compare October 10, 2024 23:30
Copy link

trunk-staging-io bot commented Oct 10, 2024

390 tests were run on a5bf039f. ✅ 390 Passed. View Full Report ↗︎

settings

Comment on lines 39 to 58
#[derive(Debug, Clone)]
pub struct MockServerBuilder {
repo_create_handler: MethodRouter<SharedMockServerState>,
create_bundle_handler: MethodRouter<SharedMockServerState>,
get_quarantining_config_handler: MethodRouter<SharedMockServerState>,
s3_upload_handler: MethodRouter<SharedMockServerState>,
}

impl MockServerBuilder {
pub fn new() -> Self {
Self {
repo_create_handler: post(repo_create_handler),
create_bundle_handler: post(create_bundle_handler),
get_quarantining_config_handler: post(get_quarantining_config_handler),
s3_upload_handler: put(s3_upload_handler),
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allows setting the route handlers for doing things like failed API calls, slow API calls, etc.

Comment on lines +255 to +299
let mut mock_server_builder = MockServerBuilder::new();
let logs = mock_logger(None);
let (events, guard) = mock_sentry();

async fn slow_s3_upload_handler() -> Response<String> {
time::sleep(Duration::from_secs(11)).await;
Response::new(String::from("OK"))
}
mock_server_builder.set_s3_upload_handler(slow_s3_upload_handler);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we have some really awesome ability to capture logs, Sentry events, and modify APIs for tests

@dfrankland dfrankland marked this pull request as ready for review October 11, 2024 00:17
@dfrankland dfrankland requested review from gnalh and max-trunk October 11, 2024 00:18
@dfrankland dfrankland force-pushed the dylan/add-api-client branch from 27166f5 to c9483e5 Compare October 17, 2024 16:03
@dfrankland dfrankland force-pushed the dylan/add-api-client-slow-api-call-logging-tests branch from b3b7442 to 52d9a2a Compare October 17, 2024 16:16
Base automatically changed from dylan/add-api-client to main October 17, 2024 17:11
@dfrankland dfrankland force-pushed the dylan/add-api-client-slow-api-call-logging-tests branch from 52d9a2a to ed683ea Compare October 17, 2024 17:14
@dfrankland dfrankland merged commit 82e276d into main Oct 17, 2024
11 checks passed
@dfrankland dfrankland deleted the dylan/add-api-client-slow-api-call-logging-tests branch October 17, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants