mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-12-02 02:46:47 +00:00
chore: adjust sing-mux test
This commit is contained in:
1 parent
b48f566bb4
commit
45587c524e
3 files changed
+15
-9
No files matched your search
@@ -316,6 +316,7 @@ jobs:
|
||||
- name: Test
|
||||
if: ${{ matrix.jobs.test == 'test' }}
|
||||
run: |
|
||||
export SKIP_CONCURRENT_TEST=1
|
||||
go test ./...
|
||||
echo "---test with_gvisor---"
|
||||
go test ./... -tags "with_gvisor" -count=1
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"io"
|
||||
"net"
|
||||
"net/netip"
|
||||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -61,7 +62,6 @@ type TestTunnel struct {
|
||||
HandleUDPPacketFn func(packet C.UDPPacket, metadata *C.Metadata)
|
||||
NatTableFn func() C.NatTable
|
||||
CloseFn func() error
|
||||
DoTestFn func(t *testing.T, proxy C.ProxyAdapter)
|
||||
DoSequentialTestFn func(t *testing.T, proxy C.ProxyAdapter)
|
||||
DoConcurrentTestFn func(t *testing.T, proxy C.ProxyAdapter)
|
||||
}
|
||||
@@ -83,7 +83,8 @@ func (tt *TestTunnel) Close() error {
|
||||
}
|
||||
|
||||
func (tt *TestTunnel) DoTest(t *testing.T, proxy C.ProxyAdapter) {
|
||||
tt.DoTestFn(t, proxy)
|
||||
tt.DoSequentialTestFn(t, proxy)
|
||||
tt.DoConcurrentTestFn(t, proxy)
|
||||
}
|
||||
|
||||
func (tt *TestTunnel) DoSequentialTest(t *testing.T, proxy C.ProxyAdapter) {
|
||||
@@ -236,6 +237,9 @@ func NewHttpTestTunnel() *TestTunnel {
|
||||
concurrentTestFn := func(t *testing.T, proxy C.ProxyAdapter) {
|
||||
// Concurrent testing to detect stress
|
||||
t.Run("Concurrent", func(t *testing.T) {
|
||||
if skip, _ := strconv.ParseBool(os.Getenv("SKIP_CONCURRENT_TEST")); skip {
|
||||
t.Skip("skip concurrent test")
|
||||
}
|
||||
wg := sync.WaitGroup{}
|
||||
num := len(httpData) / 1024
|
||||
for i := 1; i <= num; i++ {
|
||||
@@ -296,11 +300,7 @@ func NewHttpTestTunnel() *TestTunnel {
|
||||
}
|
||||
<-c.ch
|
||||
},
|
||||
CloseFn: ln.Close,
|
||||
DoTestFn: func(t *testing.T, proxy C.ProxyAdapter) {
|
||||
sequentialTestFn(t, proxy)
|
||||
concurrentTestFn(t, proxy)
|
||||
},
|
||||
CloseFn: ln.Close,
|
||||
DoSequentialTestFn: sequentialTestFn,
|
||||
DoConcurrentTestFn: concurrentTestFn,
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ import (
|
||||
"github.com/metacubex/mihomo/adapter/outbound"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
var singMuxProtocolList = []string{"smux", "yamux"} // don't test "h2mux" because it has some confused bugs
|
||||
var singMuxProtocolList = []string{"h2mux", "smux", "yamux"}
|
||||
var singMuxProtocolListLong = []string{"yamux"} // don't test "smux", "h2mux" because it has some confused bugs
|
||||
|
||||
// notCloseProxyAdapter is a proxy adapter that does not close the underlying outbound.ProxyAdapter.
|
||||
// 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) {
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
tunnel.DoTest(t, out)
|
||||
tunnel.DoSequentialTest(t, out)
|
||||
if slices.Contains(singMuxProtocolListLong, protocol) {
|
||||
tunnel.DoConcurrentTest(t, out)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user