Skip to content

Commit

Permalink
tests: fix failing logger tests (#1766)
Browse files Browse the repository at this point in the history
  • Loading branch information
chesedo authored May 9, 2024
1 parent f947dee commit 935ae26
Showing 1 changed file with 19 additions and 11 deletions.
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

0 comments on commit 935ae26

Please sign in to comment.