mirror of
https://github.com/openfaas/faas.git
synced 2025-06-12 10:16:46 +00:00
Fixes 251. Set debug_write to false by default. Added log output of byte count when debug is false. Updated tests to match new default
Signed-off-by: Burton Rheutan <rheutan7@gmail.com>
This commit is contained in:
parent
b308388bc2
commit
b9f59f5150
@ -51,32 +51,19 @@ func TestRead_CgiHeaders_DefaultIsTrueConfig(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRead_WriteDebug_DefaultIsTrueConfig(t *testing.T) {
|
func TestRead_WriteDebug_DefaultIsFalseConfig(t *testing.T) {
|
||||||
defaults := NewEnvBucket()
|
defaults := NewEnvBucket()
|
||||||
readConfig := ReadConfig{}
|
readConfig := ReadConfig{}
|
||||||
|
|
||||||
config := readConfig.Read(defaults)
|
config := readConfig.Read(defaults)
|
||||||
|
|
||||||
if config.writeDebug != true {
|
|
||||||
t.Logf("writeDebug should have been true (unspecified)")
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRead_WriteDebug_FalseOverrideConfig(t *testing.T) {
|
|
||||||
defaults := NewEnvBucket()
|
|
||||||
readConfig := ReadConfig{}
|
|
||||||
defaults.Setenv("write_debug", "false")
|
|
||||||
|
|
||||||
config := readConfig.Read(defaults)
|
|
||||||
|
|
||||||
if config.writeDebug != false {
|
if config.writeDebug != false {
|
||||||
t.Logf("writeDebug should have been false (specified)")
|
t.Logf("writeDebug should have been false (unspecified)")
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRead_WriteDebug_TrueConfig(t *testing.T) {
|
func TestRead_WriteDebug_TrueOverrideConfig(t *testing.T) {
|
||||||
defaults := NewEnvBucket()
|
defaults := NewEnvBucket()
|
||||||
readConfig := ReadConfig{}
|
readConfig := ReadConfig{}
|
||||||
defaults.Setenv("write_debug", "true")
|
defaults.Setenv("write_debug", "true")
|
||||||
@ -89,6 +76,19 @@ func TestRead_WriteDebug_TrueConfig(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRead_WriteDebug_FlaseConfig(t *testing.T) {
|
||||||
|
defaults := NewEnvBucket()
|
||||||
|
readConfig := ReadConfig{}
|
||||||
|
defaults.Setenv("write_debug", "false")
|
||||||
|
|
||||||
|
config := readConfig.Read(defaults)
|
||||||
|
|
||||||
|
if config.writeDebug != false {
|
||||||
|
t.Logf("writeDebug should have been false (specified)")
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRead_SuppressLockConfig(t *testing.T) {
|
func TestRead_SuppressLockConfig(t *testing.T) {
|
||||||
defaults := NewEnvBucket()
|
defaults := NewEnvBucket()
|
||||||
readConfig := ReadConfig{}
|
readConfig := ReadConfig{}
|
||||||
|
@ -145,6 +145,8 @@ func pipeRequest(config *WatchdogConfig, w http.ResponseWriter, r *http.Request,
|
|||||||
if config.writeDebug == true {
|
if config.writeDebug == true {
|
||||||
log.Printf("Success=%t, Error=%s\n", targetCmd.ProcessState.Success(), err.Error())
|
log.Printf("Success=%t, Error=%s\n", targetCmd.ProcessState.Success(), err.Error())
|
||||||
log.Printf("Out=%s\n", out)
|
log.Printf("Out=%s\n", out)
|
||||||
|
} else {
|
||||||
|
log.Printf("An Error Occurred\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ri.headerWritten == false {
|
if ri.headerWritten == false {
|
||||||
@ -162,6 +164,8 @@ func pipeRequest(config *WatchdogConfig, w http.ResponseWriter, r *http.Request,
|
|||||||
|
|
||||||
if config.writeDebug == true {
|
if config.writeDebug == true {
|
||||||
os.Stdout.Write(out)
|
os.Stdout.Write(out)
|
||||||
|
} else {
|
||||||
|
log.Printf("Wrote %d Bytes\n", len(out))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(config.contentType) > 0 {
|
if len(config.contentType) > 0 {
|
||||||
|
@ -43,7 +43,7 @@ func parseIntValue(val string) int {
|
|||||||
// Read fetches config from environmental variables.
|
// Read fetches config from environmental variables.
|
||||||
func (ReadConfig) Read(hasEnv HasEnv) WatchdogConfig {
|
func (ReadConfig) Read(hasEnv HasEnv) WatchdogConfig {
|
||||||
cfg := WatchdogConfig{
|
cfg := WatchdogConfig{
|
||||||
writeDebug: true,
|
writeDebug: false,
|
||||||
cgiHeaders: true,
|
cgiHeaders: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user