Skip to content

Commit

Permalink
Adjust test cases to support automated test
Browse files Browse the repository at this point in the history
Signed-off-by: bill fort <fxbao@hotmail.com>
  • Loading branch information
billfort authored and yilunzhang committed May 12, 2023
1 parent 78ad146 commit 075926a
Show file tree
Hide file tree
Showing 15 changed files with 169 additions and 446 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name: Go

on:
[push]
[push, pull_request, workflow_dispatch]

jobs:

Expand Down
14 changes: 0 additions & 14 deletions tests/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,4 @@ const (
httpServiceUrl = "http://" + httpServerAddr + "/httpEcho"

tunaNodeStarted = "tuna node is started"

webServerIsReady = "web server is ready"
webServerExited = "web server exited"
webClientExited = "web client exited"

tcpServerIsReady = "tcp server is ready"
tcpServerExited = "tcp server exited"
tcpClientExited = "tcp client exited"

udpServerIsReady = "udp server is ready"
udpServerExited = "udp server exited"
udpClientExited = "udp client exited"

exited = "exited"
)
19 changes: 19 additions & 0 deletions tests/dns.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package tests

import (
"fmt"
"time"

"github.com/txthinking/brook"
)

func dnsQuery() {
for i := 1; i <= rounds; i++ {
err := brook.Socks5Test(proxyAddr, "", "", "http3.ooo", "137.184.237.95", "8.8.8.8:53")
if err != nil {
fmt.Printf("TestDNSProxy try %v err: %v\n", i, err)
time.Sleep(time.Duration(i) * time.Second)
break
}
}
}
41 changes: 0 additions & 41 deletions tests/dns_proxy_test.go

This file was deleted.

41 changes: 0 additions & 41 deletions tests/dns_tun_test.go

This file was deleted.

101 changes: 0 additions & 101 deletions tests/http_tun_test.go

This file was deleted.

4 changes: 4 additions & 0 deletions tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ package tests
import (
"os"
"testing"
"time"
)

func TestMain(m *testing.M) {
go StartTcpServer()
go StartWebServer()
go StartUdpServer()

go StartNconnectServerWithTunaNode(true, true, false)
time.Sleep(15 * time.Second)

exitVal := m.Run()
os.Exit(exitVal)
}
25 changes: 25 additions & 0 deletions tests/proxy_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package tests

import (
"fmt"
"testing"
"time"
)

// go test -v -run=TestProxy
func TestProxy(t *testing.T) {
tuna, udp, tun := true, true, false
go func() {
err := startNconnect("client.json", tuna, udp, tun, nil)
if err != nil {
fmt.Printf("start nconnect client err: %v\n", err)
return
}
}()
time.Sleep(15 * time.Second)

dnsQuery()
StartWebClient()
StartTCPClient()
StartUDPClient()
}
2 changes: 1 addition & 1 deletion tests/pub.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ func startNconnect(configFile string, tuna, udp, tun bool, n *types.Node) error
}

if opts.Client {
port++
proxyAddr = fmt.Sprintf("127.0.0.1:%v", port)
opts.LocalSocksAddr = proxyAddr
port++
}
nc, _ := nconnect.NewNconnect(opts)
if opts.Server {
Expand Down
Loading

0 comments on commit 075926a

Please sign in to comment.