Files
kumomta/crates/integration-tests/source-sticky-pool.lua
Wez Furlong 8f9f63b078 egress_source: add sticky source assignment for egress pools
Add a `StickyWeightedRoundRobin` selection strategy for egress pools that
retains the same assigned source for a message across all retries, while
still using weighted round robin for the first attempt.

Implements #670
2026-11-10 16:14:08 +00:00

84 lines
2.1 KiB
Lua

-- Sticky selection keeps a message on one source across retries. The sink
-- in this test identifies senders by EHLO domain.
local kumo = require 'kumo'
package.path = '../../assets/?.lua;' .. package.path
local TEST_DIR = os.getenv 'KUMOD_TEST_DIR'
local SINK_PORT = tonumber(os.getenv 'KUMOD_SMTP_SINK_PORT')
kumo.on('init', function()
kumo.configure_accounting_db_path(TEST_DIR .. '/accounting.db')
kumo.start_esmtp_listener {
listen = '127.0.0.1:0',
relay_hosts = { '0.0.0.0/0' },
deferred_queue = false,
}
kumo.start_http_listener {
listen = '127.0.0.1:0',
}
kumo.configure_local_logs {
log_dir = TEST_DIR .. '/logs',
max_segment_duration = '1s',
meta = { 'sticky_egress_source' },
}
kumo.define_spool {
kind = 'RocksDB',
name = 'data',
path = TEST_DIR .. '/data-spool',
}
kumo.define_spool {
kind = 'RocksDB',
name = 'meta',
path = TEST_DIR .. '/meta-spool',
}
end)
kumo.on('get_listener_domain', function(domain, listener, conn_meta)
return kumo.make_listener_domain { relay_to = true }
end)
kumo.on('get_queue_config', function(domain, tenant, campaign, routing_domain)
return kumo.make_queue_config {
protocol = {
smtp = {
mx_list = { '127.0.0.1:' .. SINK_PORT },
},
},
egress_pool = 'sticky',
-- Keep this well under the test's wait timeouts for delivery.
retry_interval = '2s',
max_retry_interval = '2s',
}
end)
kumo.on('get_egress_pool', function(pool_name)
return kumo.make_egress_pool {
name = pool_name,
selection_strategy = 'StickyWeightedRoundRobin',
entries = {
{ name = 'a' },
{ name = 'b' },
},
}
end)
kumo.on('get_egress_source', function(source_name)
return kumo.make_egress_source {
name = source_name,
source_address = '127.0.0.1',
ehlo_domain = source_name .. '.example.com',
}
end)
kumo.on('get_egress_path_config', function(domain, source_name, _site_name)
return kumo.make_egress_path {
enable_tls = 'OpportunisticInsecure',
prohibited_hosts = {},
ip_lookup_strategy = 'Ipv4Only',
}
end)