1//go:build integration2// +build integration34/*5Maddy Mail Server - Composable all-in-one email server.6Copyright © 2019-2020 Max Mazurov <fox.cpp@disroot.org>, Maddy Mail Server contributors78This program is free software: you can redistribute it and/or modify9it under the terms of the GNU General Public License as published by10the Free Software Foundation, either version 3 of the License, or11(at your option) any later version.1213This program is distributed in the hope that it will be useful,14but WITHOUT ANY WARRANTY; without even the implied warranty of15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16GNU General Public License for more details.1718You should have received a copy of the GNU General Public License19along with this program. If not, see <https://www.gnu.org/licenses/>.20*/2122package tests_test2324import (25 "testing"2627 "github.com/foxcpp/maddy/tests"28)2930func 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.test38 tls off3940 defer_sender_reject no41 limits {42 all concurrency 143 }4445 deliver_to dummy46 }47 `)48 t.Run(1)49 defer t.Close()5051 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.5758 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}6566func 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.test74 tls off7576 defer_sender_reject no77 limits {78 ip concurrency 179 }8081 deliver_to dummy82 }83 `)84 t.Run(1)85 defer t.Close()8687 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.9394 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).100101 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}