Skip to content

Commit

Permalink
add integration test for nxdomain retry schedule
Browse files Browse the repository at this point in the history
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: #271
  • Loading branch information
wez committed Sep 19, 2024
1 parent 70472aa commit 42d811d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
24 changes: 18 additions & 6 deletions crates/integration-tests/source.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
Expand Down
21 changes: 16 additions & 5 deletions crates/integration-tests/src/test/retry_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
Expand Down

0 comments on commit 42d811d

Please sign in to comment.