From c17411a9580a2ed0a1294285d6bd1ae0ce2ee504 Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Wed, 4 Sep 2024 11:49:22 -0300 Subject: [PATCH] Extend timeouts for test reliability (#919) * Extend timeouts for test reliability The tests in this PR fail occasionally in CI test runs and then pass on re-run. I'm extending the timeouts in the hopes this will result in more stability. * Extend timeouts for test reliability The tests in this PR fail occasionally in CI test runs and then pass on re-run. I'm extending the timeouts in the hopes this will result in more stability. --- .../nodejs-engine/tests/integration_test.rs | 2 +- .../tests/integration_test.rs | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/buildpacks/nodejs-engine/tests/integration_test.rs b/buildpacks/nodejs-engine/tests/integration_test.rs index e0f37b9c..8ab4975d 100644 --- a/buildpacks/nodejs-engine/tests/integration_test.rs +++ b/buildpacks/nodejs-engine/tests/integration_test.rs @@ -8,7 +8,7 @@ use test_support::{ set_node_engine, wait_for, PORT, }; -const APPLICATION_STARTUP_TIMEOUT: Duration = Duration::from_secs(5); +const APPLICATION_STARTUP_TIMEOUT: Duration = Duration::from_secs(10); const METRICS_SEND_INTERVAL: Duration = Duration::from_secs(10); const METRICS_SEND_TIMEOUT: Duration = Duration::from_secs(15); diff --git a/buildpacks/nodejs-function-invoker/tests/integration_test.rs b/buildpacks/nodejs-function-invoker/tests/integration_test.rs index 41f8b4a6..2a7433af 100644 --- a/buildpacks/nodejs-function-invoker/tests/integration_test.rs +++ b/buildpacks/nodejs-function-invoker/tests/integration_test.rs @@ -7,10 +7,14 @@ use base64::Engine; use libcnb_test::{assert_contains, assert_not_contains, TestContext}; use rand::RngCore; use std::net::SocketAddr; +use std::time::Duration; use test_support::{ - function_integration_test, retry, start_container, DEFAULT_RETRIES, DEFAULT_RETRY_DELAY, + function_integration_test, retry, start_container, wait_for, DEFAULT_RETRIES, + DEFAULT_RETRY_DELAY, }; +const FUNCTION_LOGGING_TIMEOUT: Duration = Duration::from_secs(5); + #[test] #[ignore] fn simple_javascript_function() { @@ -21,8 +25,13 @@ fn simple_javascript_function() { let payload = serde_json::json!({}); let result = invoke_function(socket_addr, &payload); assert_eq!(result, serde_json::Value::String("hello world".to_string())); - let container_logs = container.logs_now(); - assert_contains!(container_logs.stdout, "logging info is a fun 1"); + wait_for( + || { + let container_logs = container.logs_now(); + assert_contains!(container_logs.stdout, "logging info is a fun 1"); + }, + FUNCTION_LOGGING_TIMEOUT, + ); }); }); } @@ -107,8 +116,13 @@ fn function_with_no_lockfile() { let payload = serde_json::json!({}); let result = invoke_function(socket_addr, &payload); assert_eq!(result, serde_json::Value::String("hello world".to_string())); - let container_logs = container.logs_now(); - assert_contains!(container_logs.stdout, "logging info is a fun 1"); + wait_for( + || { + let container_logs = container.logs_now(); + assert_contains!(container_logs.stdout, "logging info is a fun 1"); + }, + FUNCTION_LOGGING_TIMEOUT, + ); }); }); }