Save http trace to a file (#5300)

Save http trace to a file instead of displaying it onto the console.
the environment variable MINIO_HTTP_TRACE will be a filepath instead
of a boolean.

This to handle the scenario where both json and http tracing are
turned on. In that case, both http trace and json output are displayed
on the screen making the json not parsable. Loging this trace onto
a file helps us avoid that scenario.

Fixes #5263
This commit is contained in:
kannappanr
2018-01-05 11:24:31 -08:00
committed by GitHub
parent de2ce5acb4
commit 1de3bd6911
6 changed files with 38 additions and 8 deletions

View File

@@ -19,8 +19,10 @@ package cmd
import (
"encoding/json"
"errors"
"io/ioutil"
"net/http"
"net/url"
"os"
"reflect"
"strings"
"testing"
@@ -50,6 +52,19 @@ func TestCloneHeader(t *testing.T) {
}
}
// Tests closing http tracing file.
func TestStopHTTPTrace(t *testing.T) {
var err error
globalHTTPTraceFile, err = ioutil.TempFile("", "")
if err != nil {
defer os.Remove(globalHTTPTraceFile.Name())
stopHTTPTrace()
if globalHTTPTraceFile != nil {
t.Errorf("globalHTTPTraceFile is not nil, it is expected to be nil")
}
}
}
// Tests maximum object size.
func TestMaxObjectSize(t *testing.T) {
sizes := []struct {