Fix listen port for test infra

Update Dockerfile, curl is used for the healthcheck
Add /dump for creating the routine stack trace

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
This commit is contained in:
Flavio Crisciani 2017-11-16 16:19:22 -08:00
parent a41f623b10
commit 4037132b33
3 changed files with 16 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"net"
"net/http"
"strconv"
"sync"
"github.com/sirupsen/logrus"
@ -81,7 +82,7 @@ func (n *Server) EnableDebug(ip string, port int) {
// go func() {
// http.Serve(n.sk, n.mux)
// }()
http.ListenAndServe(":8000", n.mux)
http.ListenAndServe(":"+strconv.Itoa(port), n.mux)
}
// DisableDebug stop the dubug and closes the tcp socket

View File

@ -5,7 +5,9 @@ import (
"net/http"
"strings"
stackdump "github.com/docker/docker/pkg/signal"
"github.com/docker/libnetwork/diagnose"
"github.com/sirupsen/logrus"
)
const (
@ -24,6 +26,7 @@ var NetDbPaths2Func = map[string]diagnose.HTTPHandlerFunc{
"/deleteentry": dbDeleteEntry,
"/getentry": dbGetEntry,
"/gettable": dbGetTable,
"/dump": dbStackTrace,
}
func dbJoin(ctx interface{}, w http.ResponseWriter, r *http.Request) {
@ -240,3 +243,12 @@ func dbGetTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
}
}
}
func dbStackTrace(ctx interface{}, w http.ResponseWriter, r *http.Request) {
path, err := stackdump.DumpStacks("/tmp/")
if err != nil {
logrus.WithError(err).Error("failed to write goroutines dump")
} else {
fmt.Fprintf(w, "goroutine stacks written to %s", path)
}
}

View File

@ -1,5 +1,7 @@
FROM alpine
RUN apk --no-cache add curl
COPY testMain /app/
WORKDIR app