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

tests: fix failing logger tests #1766

Merged
merged 1 commit into from
May 9, 2024
Merged
Changes from all commits
Commits
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
30 changes: 19 additions & 11 deletions logger/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fn cleanup() {
mod needs_docker {
use super::*;
use pretty_assertions::assert_eq;
use tokio::time::sleep;

#[tokio::test]
async fn store_and_get_logs() {
Expand Down Expand Up @@ -82,6 +83,9 @@ mod needs_docker {
.into_inner();
assert!(response.success);

// Allow some time for the logs to be inserted into the DB
sleep(Duration::from_millis(500)).await;

// Get logs
let logs = client
.get_logs(Request::new(LogsRequest {
Expand Down Expand Up @@ -127,7 +131,11 @@ mod needs_docker {
deployment_id: deployment_id.to_string(),
log_line: Some(LogLine {
service_name: SHUTTLE_SERVICE.to_string(),
tx_timestamp: Some(Timestamp::from(SystemTime::UNIX_EPOCH)),
tx_timestamp: Some(Timestamp::from(
SystemTime::UNIX_EPOCH
.checked_add(Duration::from_secs(10))
.unwrap(),
)),
data: "log 1 example".as_bytes().to_vec(),
}),
},
Expand All @@ -137,23 +145,14 @@ mod needs_docker {
service_name: SHUTTLE_SERVICE.to_string(),
tx_timestamp: Some(Timestamp::from(
SystemTime::UNIX_EPOCH
.checked_add(Duration::from_secs(10))
.checked_add(Duration::from_secs(20))
.unwrap(),
)),
data: "log 2 example".as_bytes().to_vec(),
}),
},
];

let response = client
.store_logs(Request::new(StoreLogsRequest {
logs: expected_stored_logs.clone(),
}))
.await
.unwrap()
.into_inner();
assert!(response.success);

// Subscribe to stream
let mut response = client
.get_logs_stream(Request::new(LogsRequest {
Expand All @@ -165,6 +164,15 @@ mod needs_docker {
.unwrap()
.into_inner();

let stored_response = client
.store_logs(Request::new(StoreLogsRequest {
logs: expected_stored_logs.clone(),
}))
.await
.unwrap()
.into_inner();
assert!(stored_response.success);

let log = timeout(std::time::Duration::from_millis(500), response.message())
.await
.unwrap()
Expand Down