Skip to content

Commit

Permalink
cleanup: fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
parvit committed Oct 5, 2024
1 parent 9fd1255 commit 20c1127
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 69 deletions.
2 changes: 1 addition & 1 deletion workers/client/client_network_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (s *ClientNetworkSuite) BeforeTest(_, testName string) {
configuration.QPepConfig.Security.Certificate = "cert.pem"
configuration.QPepConfig.Security.PrivateKey = "key.pem"

configuration.QPepConfig.Client.GatewayHost = "127.0.0.1"
configuration.QPepConfig.Client.GatewayHost = "127.0.0.2"
configuration.QPepConfig.Client.GatewayPort = 9443
configuration.QPepConfig.Client.LocalListeningAddress = "127.0.0.1"
configuration.QPepConfig.Client.LocalListenPort = 9090
Expand Down
66 changes: 0 additions & 66 deletions workers/client/client_patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,72 +184,6 @@ func (s *ClientSuite) TestHandleServices_FailGateway() {
assert.True(s.T(), calledFailedConnectionSecond)
}

func (s *ClientSuite) TestHandleServices_FailStatistics() {
wg2 := &sync.WaitGroup{}
wg2.Add(3)
var calledInitialCheck = false
monkey.Patch(initialCheckConnection, func() {
if !calledInitialCheck {
calledInitialCheck = true
wg2.Done()
}
})
var calledGatewayCheck = false
monkey.Patch(gatewayStatusCheck, func(string, string, int) (bool, *api.EchoResponse) {
if !calledGatewayCheck {
calledGatewayCheck = true
wg2.Done()
}
return true, &api.EchoResponse{
Address: "172.20.50.150",
Port: 54635,
ServerVersion: "0.1.0",
}
})
var calledFailedConnectionFirst = false
var calledFailedConnectionSecond = false
monkey.Patch(failedCheckConnection, func() bool {
if !calledFailedConnectionFirst {
calledFailedConnectionFirst = true
return false
}
if !calledFailedConnectionSecond {
calledFailedConnectionSecond = true
wg2.Done()
}
return true
})

wg := &sync.WaitGroup{}
wg.Add(1)
ctx, cancel := context.WithCancel(context.Background())
go handleServices(ctx, cancel, wg)

ch := make(chan struct{})

go func() {
wg2.Wait()
cancel()
wg.Wait()

ch <- struct{}{}
}()

select {
case <-time.After(10 * time.Second):
s.T().Logf("Test Timed out waiting for routines to finish")
s.T().FailNow()
return
case <-ch:
break
}

assert.True(s.T(), calledInitialCheck)
assert.True(s.T(), calledGatewayCheck)
assert.True(s.T(), calledFailedConnectionFirst)
assert.True(s.T(), calledFailedConnectionSecond)
}

func (s *ClientSuite) TestInitProxy() {
monkey.Patch(gateway.SetSystemProxy, func(active bool) {
assert.True(s.T(), active)
Expand Down
2 changes: 1 addition & 1 deletion workers/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (s *ClientSuite) BeforeTest(_, testName string) {
configuration.QPepConfig = configuration.QPepConfigType{}
configuration.QPepConfig.Merge(&configuration.DefaultConfig)

configuration.QPepConfig.Client.GatewayHost = "127.0.0.1"
configuration.QPepConfig.Client.GatewayHost = "127.0.0.2"
configuration.QPepConfig.Client.GatewayPort = 9443
configuration.QPepConfig.Client.LocalListeningAddress = "127.0.0.1"
configuration.QPepConfig.Client.LocalListenPort = 9090
Expand Down
4 changes: 3 additions & 1 deletion workers/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"context"
"fmt"
"github.com/Project-Faster/monkey"
"github.com/julienschmidt/httprouter"
"github.com/Project-Faster/qpep/api"
"github.com/Project-Faster/qpep/backend"
"github.com/Project-Faster/qpep/shared/configuration"
stderr "github.com/Project-Faster/qpep/shared/errors"
"github.com/Project-Faster/qpep/shared/logger"
"github.com/Project-Faster/qpep/shared/protocol"
"github.com/Project-Faster/qpep/workers/gateway"
"github.com/julienschmidt/httprouter"
"github.com/rs/cors"
log "github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -386,6 +386,8 @@ func (s *ServerSuite) TestRunServer_APIConnection_LimitSrc() {
// incoming speed limit
addr, _ := gateway.GetDefaultLanListeningAddress("127.0.0.1", "")

s.T().Logf("address: %v", addr)

clientsMap := map[string]string{
addr + "/32": "300K",
}
Expand Down

0 comments on commit 20c1127

Please sign in to comment.