Skip to content

Commit 45587c5

Browse files
committed
chore: adjust sing-mux test
1 parent b48f566 commit 45587c5

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ jobs:
316316
- name: Test
317317
if: ${{ matrix.jobs.test == 'test' }}
318318
run: |
319+
export SKIP_CONCURRENT_TEST=1
319320
go test ./...
320321
echo "---test with_gvisor---"
321322
go test ./... -tags "with_gvisor" -count=1

listener/inbound/common_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"io"
1010
"net"
1111
"net/netip"
12+
"os"
1213
"strconv"
1314
"sync"
1415
"testing"
@@ -61,7 +62,6 @@ type TestTunnel struct {
6162
HandleUDPPacketFn func(packet C.UDPPacket, metadata *C.Metadata)
6263
NatTableFn func() C.NatTable
6364
CloseFn func() error
64-
DoTestFn func(t *testing.T, proxy C.ProxyAdapter)
6565
DoSequentialTestFn func(t *testing.T, proxy C.ProxyAdapter)
6666
DoConcurrentTestFn func(t *testing.T, proxy C.ProxyAdapter)
6767
}
@@ -83,7 +83,8 @@ func (tt *TestTunnel) Close() error {
8383
}
8484

8585
func (tt *TestTunnel) DoTest(t *testing.T, proxy C.ProxyAdapter) {
86-
tt.DoTestFn(t, proxy)
86+
tt.DoSequentialTestFn(t, proxy)
87+
tt.DoConcurrentTestFn(t, proxy)
8788
}
8889

8990
func (tt *TestTunnel) DoSequentialTest(t *testing.T, proxy C.ProxyAdapter) {
@@ -236,6 +237,9 @@ func NewHttpTestTunnel() *TestTunnel {
236237
concurrentTestFn := func(t *testing.T, proxy C.ProxyAdapter) {
237238
// Concurrent testing to detect stress
238239
t.Run("Concurrent", func(t *testing.T) {
240+
if skip, _ := strconv.ParseBool(os.Getenv("SKIP_CONCURRENT_TEST")); skip {
241+
t.Skip("skip concurrent test")
242+
}
239243
wg := sync.WaitGroup{}
240244
num := len(httpData) / 1024
241245
for i := 1; i <= num; i++ {
@@ -296,11 +300,7 @@ func NewHttpTestTunnel() *TestTunnel {
296300
}
297301
<-c.ch
298302
},
299-
CloseFn: ln.Close,
300-
DoTestFn: func(t *testing.T, proxy C.ProxyAdapter) {
301-
sequentialTestFn(t, proxy)
302-
concurrentTestFn(t, proxy)
303-
},
303+
CloseFn: ln.Close,
304304
DoSequentialTestFn: sequentialTestFn,
305305
DoConcurrentTestFn: concurrentTestFn,
306306
}

listener/inbound/mux_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import (
66
"github.com/metacubex/mihomo/adapter/outbound"
77

88
"github.com/stretchr/testify/assert"
9+
"golang.org/x/exp/slices"
910
)
1011

11-
var singMuxProtocolList = []string{"smux", "yamux"} // don't test "h2mux" because it has some confused bugs
12+
var singMuxProtocolList = []string{"h2mux", "smux", "yamux"}
13+
var singMuxProtocolListLong = []string{"yamux"} // don't test "smux", "h2mux" because it has some confused bugs
1214

1315
// notCloseProxyAdapter is a proxy adapter that does not close the underlying outbound.ProxyAdapter.
1416
// The outbound.SingMux will close the underlying outbound.ProxyAdapter when it is closed, but we don't want to close it.
@@ -37,7 +39,10 @@ func testSingMux(t *testing.T, tunnel *TestTunnel, out outbound.ProxyAdapter) {
3739
}
3840
defer out.Close()
3941

40-
tunnel.DoTest(t, out)
42+
tunnel.DoSequentialTest(t, out)
43+
if slices.Contains(singMuxProtocolListLong, protocol) {
44+
tunnel.DoConcurrentTest(t, out)
45+
}
4146
})
4247
}
4348
})

0 commit comments

Comments
 (0)