MCPcopy Create free account
hub / github.com/foxcpp/maddy / TestPerIPConcurrency

Function TestPerIPConcurrency

tests/limits_test.go:66–107  ·  view source on GitHub ↗
(tt *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func TestPerIPConcurrency(tt *testing.T) {
67 tt.Parallel()
68 t := tests.NewT(tt)
69 t.DNS(nil)
70 t.Port("smtp")
71 t.Config(`
72 smtp tcp://127.0.0.1:{env:TEST_PORT_smtp} {
73 hostname mx.maddy.test
74 tls off
75
76 defer_sender_reject no
77 limits {
78 ip concurrency 1
79 }
80
81 deliver_to dummy
82 }
83 `)
84 t.Run(1)
85 defer t.Close()
86
87 c1 := t.Conn("smtp")
88 defer c1.Close()
89 c1.SMTPNegotation("localhost", nil, nil)
90 c1.Writeln("MAIL FROM:<testing@maddy.test>")
91 c1.ExpectPattern("250 *")
92 // Down on semaphore.
93
94 c3 := t.Conn4("127.0.0.2", "smtp")
95 defer c3.Close()
96 c3.SMTPNegotation("localhost", nil, nil)
97 c3.Writeln("MAIL FROM:<testing@maddy.test>")
98 c3.ExpectPattern("250 *")
99 // Down on semaphore (different IP).
100
101 c2 := t.Conn("smtp")
102 defer c2.Close()
103 c2.SMTPNegotation("localhost", nil, nil)
104 c1.Writeln("MAIL FROM:<testing@maddy.test>")
105 // Temporary error due to lock timeout.
106 c1.ExpectPattern("451 *")
107}

Callers

nothing calls this directly

Calls 12

DNSMethod · 0.95
PortMethod · 0.95
ConfigMethod · 0.95
RunMethod · 0.95
CloseMethod · 0.95
ConnMethod · 0.95
Conn4Method · 0.95
NewTFunction · 0.92
SMTPNegotationMethod · 0.80
WritelnMethod · 0.80
ExpectPatternMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected