mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: reorg agent config (#853)
* fn: reorg agent config *) Moving constants in agent to agent config, which helps with testing, tuning. *) Added max total cpu & memory for testing & clamping max mem & cpu usage if needed. * fn: adjust PipeIO time * fn: for hot, cannot reliably test EndOfLogs in TestRouteRunnerExecution
This commit is contained in:
@@ -154,7 +154,7 @@ func TestRouteRunnerIOPipes(t *testing.T) {
|
||||
// more timing related issues below. Slightly gains us a bit more
|
||||
// determinism.
|
||||
tweaker1 := envTweaker("FN_FREEZE_IDLE_MSECS", "0")
|
||||
tweaker2 := envTweaker("FN_MAX_LOG_SIZE", "5")
|
||||
tweaker2 := envTweaker("FN_MAX_LOG_SIZE_BYTES", "5")
|
||||
defer tweaker1()
|
||||
defer tweaker2()
|
||||
|
||||
@@ -187,7 +187,7 @@ func TestRouteRunnerIOPipes(t *testing.T) {
|
||||
// sleep between logs and with debug enabled, fn-test-utils will log header/footer below:
|
||||
immediateGarbage := `{"isDebug": true, "postOutGarbage": "YOGURT_YOGURT_YOGURT", "postSleepTime": 0}`
|
||||
immediateJsonValidGarbage := `{"isDebug": true, "postOutGarbage": "\r", "postSleepTime": 0}`
|
||||
delayedGarbage := `{"isDebug": true, "postOutGarbage": "YOGURT_YOGURT_YOGURT", "postSleepTime": 1000}`
|
||||
delayedGarbage := `{"isDebug": true, "postOutGarbage": "YOGURT_YOGURT_YOGURT", "postSleepTime": 1500}`
|
||||
ok := `{"isDebug": true}`
|
||||
|
||||
containerIds := make([]string, 0)
|
||||
@@ -211,7 +211,7 @@ func TestRouteRunnerIOPipes(t *testing.T) {
|
||||
{"/r/zoo/json/", immediateGarbage, "GET", http.StatusOK, "", nil, 0},
|
||||
|
||||
// CASE II: delayed garbage: make sure delayed output lands in between request processing, should be blocked until next req
|
||||
{"/r/zoo/json/", delayedGarbage, "GET", http.StatusOK, "", nil, time.Second * 2},
|
||||
{"/r/zoo/json/", delayedGarbage, "GET", http.StatusOK, "", nil, time.Millisecond * 2500},
|
||||
|
||||
// CASE III: normal, but should get faulty I/O from previous
|
||||
{"/r/zoo/json/", ok, "GET", http.StatusBadGateway, "invalid json", nil, 0},
|
||||
@@ -355,7 +355,11 @@ func TestRouteRunnerExecution(t *testing.T) {
|
||||
|
||||
expHeaders := map[string][]string{"X-Function": {"Test"}, "Content-Type": {"application/json; charset=utf-8"}}
|
||||
expCTHeaders := map[string][]string{"X-Function": {"Test"}, "Content-Type": {"foo/bar"}}
|
||||
multiLogExpect := []string{"BeginOfLogs", "EndOfLogs"}
|
||||
|
||||
// Checking for EndOfLogs currently depends on scheduling of go-routines (in docker/containerd) that process stderr & stdout.
|
||||
// Therefore, not testing for EndOfLogs for hot containers (which has complex I/O processing) anymore.
|
||||
multiLogExpectCold := []string{"BeginOfLogs", "EndOfLogs"}
|
||||
multiLogExpectHot := []string{"BeginOfLogs" /*, "EndOfLogs" */}
|
||||
|
||||
crasher := `{"echoContent": "_TRX_ID_", "isDebug": true, "isCrash": true}` // crash container
|
||||
oomer := `{"echoContent": "_TRX_ID_", "isDebug": true, "allocateMemory": 12000000}` // ask for 12MB
|
||||
@@ -400,8 +404,8 @@ func TestRouteRunnerExecution(t *testing.T) {
|
||||
{"/r/myapp/mydneregistry", ``, "GET", http.StatusInternalServerError, nil, "connection refused", nil},
|
||||
|
||||
{"/r/myapp/myoom", oomer, "GET", http.StatusBadGateway, nil, "container out of memory", nil},
|
||||
{"/r/myapp/myhot", multiLog, "GET", http.StatusOK, nil, "", multiLogExpect},
|
||||
{"/r/myapp/", multiLog, "GET", http.StatusOK, nil, "", multiLogExpect},
|
||||
{"/r/myapp/myhot", multiLog, "GET", http.StatusOK, nil, "", multiLogExpectHot},
|
||||
{"/r/myapp/", multiLog, "GET", http.StatusOK, nil, "", multiLogExpectCold},
|
||||
{"/r/myapp/mybigoutputjson", bigoutput, "GET", http.StatusBadGateway, nil, "function response too large", nil},
|
||||
{"/r/myapp/mybigoutputjson", smalloutput, "GET", http.StatusOK, nil, "", nil},
|
||||
{"/r/myapp/mybigoutputhttp", bigoutput, "GET", http.StatusBadGateway, nil, "function response too large", nil},
|
||||
|
||||
Reference in New Issue
Block a user