| 28 | ) |
| 29 | |
| 30 | func TestConcurrencyLimit(tt *testing.T) { |
| 31 | tt.Parallel() |
| 32 | t := tests.NewT(tt) |
| 33 | t.DNS(nil) |
| 34 | t.Port("smtp") |
| 35 | t.Config(` |
| 36 | smtp tcp://127.0.0.1:{env:TEST_PORT_smtp} { |
| 37 | hostname mx.maddy.test |
| 38 | tls off |
| 39 | |
| 40 | defer_sender_reject no |
| 41 | limits { |
| 42 | all concurrency 1 |
| 43 | } |
| 44 | |
| 45 | deliver_to dummy |
| 46 | } |
| 47 | `) |
| 48 | t.Run(1) |
| 49 | defer t.Close() |
| 50 | |
| 51 | c1 := t.Conn("smtp") |
| 52 | defer c1.Close() |
| 53 | c1.SMTPNegotation("localhost", nil, nil) |
| 54 | c1.Writeln("MAIL FROM:<testing@maddy.test>") |
| 55 | c1.ExpectPattern("250 *") |
| 56 | // Down on semaphore. |
| 57 | |
| 58 | c2 := t.Conn("smtp") |
| 59 | defer c2.Close() |
| 60 | c2.SMTPNegotation("localhost", nil, nil) |
| 61 | c1.Writeln("MAIL FROM:<testing@maddy.test>") |
| 62 | // Temporary error due to lock timeout. |
| 63 | c1.ExpectPattern("451 *") |
| 64 | } |
| 65 | |
| 66 | func TestPerIPConcurrency(tt *testing.T) { |
| 67 | tt.Parallel() |