Unverified Commit 96157a89 authored by Martin Holst Swende's avatar Martin Holst Swende Committed by GitHub

graphql: fix spurious travis failure (#22166)

The tests sometimes failed with certain go versions because
the behavior of http.Server.Shutdown changed over time. A bug
that was fixed in Go 1.15 could cause active connections on unrelated
servers to close unexpectedly. This is fixed by avoiding use of the
same port number in all tests.
parent 2aaff0ad
...@@ -131,7 +131,7 @@ func TestGraphQLBlockSerialization(t *testing.T) { ...@@ -131,7 +131,7 @@ func TestGraphQLBlockSerialization(t *testing.T) {
code: 200, code: 200,
}, },
} { } {
resp, err := http.Post(fmt.Sprintf("http://%s/graphql", "127.0.0.1:9393"), "application/json", strings.NewReader(tt.body)) resp, err := http.Post(fmt.Sprintf("%s/graphql", stack.HTTPEndpoint()), "application/json", strings.NewReader(tt.body))
if err != nil { if err != nil {
t.Fatalf("could not post: %v", err) t.Fatalf("could not post: %v", err)
} }
...@@ -156,7 +156,7 @@ func TestGraphQLHTTPOnSamePort_GQLRequest_Unsuccessful(t *testing.T) { ...@@ -156,7 +156,7 @@ func TestGraphQLHTTPOnSamePort_GQLRequest_Unsuccessful(t *testing.T) {
t.Fatalf("could not start node: %v", err) t.Fatalf("could not start node: %v", err)
} }
body := strings.NewReader(`{"query": "{block{number}}","variables": null}`) body := strings.NewReader(`{"query": "{block{number}}","variables": null}`)
resp, err := http.Post(fmt.Sprintf("http://%s/graphql", "127.0.0.1:9393"), "application/json", body) resp, err := http.Post(fmt.Sprintf("%s/graphql", stack.HTTPEndpoint()), "application/json", body)
if err != nil { if err != nil {
t.Fatalf("could not post: %v", err) t.Fatalf("could not post: %v", err)
} }
...@@ -177,9 +177,9 @@ func TestGraphQLHTTPOnSamePort_GQLRequest_Unsuccessful(t *testing.T) { ...@@ -177,9 +177,9 @@ func TestGraphQLHTTPOnSamePort_GQLRequest_Unsuccessful(t *testing.T) {
func createNode(t *testing.T, gqlEnabled bool) *node.Node { func createNode(t *testing.T, gqlEnabled bool) *node.Node {
stack, err := node.New(&node.Config{ stack, err := node.New(&node.Config{
HTTPHost: "127.0.0.1", HTTPHost: "127.0.0.1",
HTTPPort: 9393, HTTPPort: 0,
WSHost: "127.0.0.1", WSHost: "127.0.0.1",
WSPort: 9393, WSPort: 0,
}) })
if err != nil { if err != nil {
t.Fatalf("could not create node: %v", err) t.Fatalf("could not create node: %v", err)
...@@ -187,11 +187,11 @@ func createNode(t *testing.T, gqlEnabled bool) *node.Node { ...@@ -187,11 +187,11 @@ func createNode(t *testing.T, gqlEnabled bool) *node.Node {
if !gqlEnabled { if !gqlEnabled {
return stack return stack
} }
createGQLService(t, stack, "127.0.0.1:9393") createGQLService(t, stack)
return stack return stack
} }
func createGQLService(t *testing.T, stack *node.Node, endpoint string) { func createGQLService(t *testing.T, stack *node.Node) {
// create backend // create backend
ethConf := &eth.Config{ ethConf := &eth.Config{
Genesis: &core.Genesis{ Genesis: &core.Genesis{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment