Skip to content

Commit

Permalink
Try to force to free memory on test to use low specs testing machines
Browse files Browse the repository at this point in the history
  • Loading branch information
gdiazlo committed Feb 26, 2019
1 parent 21b4f30 commit 0bad501
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/http"
"os"
"os/user"
"runtime/debug"
"strings"
"testing"
"time"
Expand All @@ -44,6 +45,10 @@ const (
APIKey = "my-key"
)

func init() {
debug.SetGCPercent(10)
}

// merge function is a helper function that execute all the variadic parameters
// inside a score.TestF function
func merge(list ...scope.TestF) scope.TestF {
Expand Down Expand Up @@ -266,8 +271,6 @@ func setupServer(id int, joinAddr string, tls bool, t *testing.T) (scope.TestF,
conf.EnableTampering = true
conf.EnableTLS = tls

//fmt.Printf("Server config: %+v\n", conf)

srv, err = server.NewServer(conf)
if err != nil {
t.Fatalf("Unable to create a new server: %v", err)
Expand All @@ -283,6 +286,7 @@ func setupServer(id int, joinAddr string, tls bool, t *testing.T) (scope.TestF,
}

after := func(t *testing.T) {
debug.FreeOSMemory()
if srv != nil {
err := srv.Stop()
if err != nil {
Expand All @@ -295,13 +299,9 @@ func setupServer(id int, joinAddr string, tls bool, t *testing.T) (scope.TestF,
return before, after
}

func endPoint(id int) string {
return fmt.Sprintf("http://127.0.0.1:880%d", id)
}

func getClient(id int) *client.HTTPClient {
return client.NewHTTPClient(client.Config{
Endpoints: []string{endPoint(id)},
Endpoints: []string{fmt.Sprintf("http://127.0.0.1:880%d", id)},
APIKey: APIKey,
Insecure: false,
})
Expand Down

0 comments on commit 0bad501

Please sign in to comment.