From 42d811d045335e892196548babd38054ac61f35c Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 18 Sep 2024 17:04:49 -0700 Subject: [PATCH] add integration test for nxdomain retry schedule The reported behavior was that messages seemd to be retried much faster than the retry schedule, and at a quick glance it looked like the nxdomain code path didn't respest the backoff, but from hooking up this test and making the durations longer, it really doesn't seem like the issue was that simple: refs: https://github.com/KumoCorp/kumomta/issues/271 --- crates/integration-tests/source.lua | 24 ++++++++++++++----- .../src/test/retry_schedule.rs | 21 ++++++++++++---- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/crates/integration-tests/source.lua b/crates/integration-tests/source.lua index 8ba71f7db..eb3e28d62 100644 --- a/crates/integration-tests/source.lua +++ b/crates/integration-tests/source.lua @@ -210,13 +210,25 @@ kumo.on('get_queue_config', function(domain, _tenant, _campaign) } end - return kumo.make_queue_config { - protocol = { - -- Redirect traffic to the sink - smtp = { - mx_list = { 'localhost' }, - }, + local protocol = { + -- Redirect traffic to the sink + smtp = { + mx_list = { 'localhost' }, }, + } + + if domain == 'nxdomain' then + -- this nxdomain domain is a special domain that is assumed not + -- to resolve. It is generated by the retry_schedule integration + -- test. for this domain, we don't want to short-circuit dns + -- and go to the sink, because we DO want the dns resolution + -- to successfully return nxdomain in order for the test to + -- exercise the appropriate logic. + protocol = nil + end + + return kumo.make_queue_config { + protocol = protocol, retry_interval = os.getenv 'KUMOD_RETRY_INTERVAL', strategy = os.getenv 'KUMOD_QUEUE_STRATEGY', } diff --git a/crates/integration-tests/src/test/retry_schedule.rs b/crates/integration-tests/src/test/retry_schedule.rs index e78e3e654..a734c55dd 100644 --- a/crates/integration-tests/src/test/retry_schedule.rs +++ b/crates/integration-tests/src/test/retry_schedule.rs @@ -2,20 +2,31 @@ use crate::kumod::{generate_message_text, DaemonWithMaildir, MailGenParams}; use kumo_log_types::RecordType::TransientFailure; use std::time::Duration; +const VALID_DOMAIN: &str = "foo.mx-sink.wezfurlong.org"; +/// this nxdomain string is coupled with logic in source.lua +const NO_DOMAIN: &str = "nxdomain"; + #[tokio::test] async fn retry_schedule_timerwheel() -> anyhow::Result<()> { - retry_schedule_impl("TimerWheel").await + retry_schedule_impl("TimerWheel", VALID_DOMAIN).await } + #[tokio::test] async fn retry_schedule_skiplist() -> anyhow::Result<()> { - retry_schedule_impl("SkipList").await + retry_schedule_impl("SkipList", VALID_DOMAIN).await } + #[tokio::test] async fn retry_schedule_singleton_wheel() -> anyhow::Result<()> { - retry_schedule_impl("SingletonTimerWheel").await + retry_schedule_impl("SingletonTimerWheel", VALID_DOMAIN).await +} + +#[tokio::test] +async fn retry_schedule_nxdomain() -> anyhow::Result<()> { + retry_schedule_impl("SingletonTimerWheel", NO_DOMAIN).await } -async fn retry_schedule_impl(strategy: &str) -> anyhow::Result<()> { +async fn retry_schedule_impl(strategy: &str, domain: &str) -> anyhow::Result<()> { let mut daemon = DaemonWithMaildir::start_with_env(vec![ ("KUMOD_RETRY_INTERVAL", "5s"), ("KUMOD_QUEUE_STRATEGY", strategy), @@ -27,7 +38,7 @@ async fn retry_schedule_impl(strategy: &str) -> anyhow::Result<()> { let body = generate_message_text(1024, 78); let response = MailGenParams { body: Some(&body), - recip: Some("tempfail@foo.mx-sink.wezfurlong.org"), + recip: Some(&format!("tempfail@{domain}")), ..Default::default() } .send(&mut client)