diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 27348930fdf..571faef670a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -21,7 +21,7 @@ // Use 'postCreateCommand' to run commands after the container is created. // Mage is installed this way, and not via the feature plugin because that plugin was // broken for me, and mage install is simple enough - "postCreateCommand": "cd /opt/; sudo mkdir mage; sudo chown $USER:$(id -g) mage; git clone --depth=1 https://github.com/magefile/mage && cd mage && go run bootstrap.go" + "postCreateCommand": "cd /opt/; sudo mkdir mage; sudo chown $USER:$(id -g) mage; git clone --depth=1 https://github.com/magefile/mage && cd mage && go run bootstrap.go; npm i -g @elastic/synthetics; sudo env \"PATH=$PATH\" npx -yes playwright install-deps" // Configure tool-specific properties. // "customizations": {}, diff --git a/heartbeat/monitors/wrappers/wrappers_test.go b/heartbeat/monitors/wrappers/wrappers_test.go index 5e51f8d24cb..4ebc653d8fc 100644 --- a/heartbeat/monitors/wrappers/wrappers_test.go +++ b/heartbeat/monitors/wrappers/wrappers_test.go @@ -87,7 +87,7 @@ func testCommonWrap(t *testing.T, tt testDef) { results, err := jobs.ExecJobsAndConts(t, wrapped) assert.NoError(t, err) - require.Len(t, results, len(tt.want), "Expected test def wants to correspond exactly to number results.") + assert.Len(t, results, len(tt.want), "Expected test def wants to correspond exactly to number results.") for idx, r := range results { t.Run(fmt.Sprintf("result at index %d", idx), func(t *testing.T) { @@ -354,44 +354,46 @@ func TestRetryMultiCont(t *testing.T) { state monitorstate.State }{ { - "up", + "down", summarizer.JobSummary{ - Status: "up", + Status: "down", FinalAttempt: true, // we expect two up since this is a lightweight // job and all events get a monitor status // since no errors are returned that's 2 - Up: 2, - Down: 0, + Up: 0, + Down: 2, Attempt: 1, MaxAttempts: 2, }, monitorstate.State{ - Status: "up", - Up: 2, - Down: 0, - Checks: 1, + Status: "down", + Up: 0, + Down: 2, + Checks: 2, }, }, { - "up", + "down", summarizer.JobSummary{ - Status: "up", + Status: "down", FinalAttempt: true, - Up: 2, - Down: 0, - Attempt: 1, + Up: 0, + Down: 2, + Attempt: 2, MaxAttempts: 2, }, monitorstate.State{ - Status: "up", - Up: 2, - Down: 0, - Checks: 1, + Status: "down", + Up: 0, + Down: 2, + Checks: 2, }, }, } + jobErr := fmt.Errorf("down") + makeContJob := func(t *testing.T, u string) jobs.Job { expIdx := 0 return func(event *beat.Event) ([]jobs.Job, error) { @@ -399,9 +401,9 @@ func TestRetryMultiCont(t *testing.T) { u, err := url.Parse(u) require.NoError(t, err) eventext.MergeEventFields(event, mapstr.M{"url": URLFields(u)}) + return []jobs.Job{ func(event *beat.Event) ([]jobs.Job, error) { - eventext.MergeEventFields(event, mapstr.M{"cont": "2nd"}) eventext.MergeEventFields(event, mapstr.M{"url": URLFields(u)}) @@ -411,12 +413,12 @@ func TestRetryMultiCont(t *testing.T) { } exp := expected[expIdx] if exp.js.Status == "down" { - return nil, fmt.Errorf("got a down status") + return nil, jobErr } return nil, nil }, - }, nil + }, jobErr } } @@ -425,12 +427,16 @@ func TestRetryMultiCont(t *testing.T) { urlValidator(t, u), lookslike.MustCompile(map[string]interface{}{"cont": msg}), lookslike.MustCompile(map[string]interface{}{ + "error": map[string]interface{}{ + "message": isdef.IsString, + "type": isdef.IsString, + }, "monitor": map[string]interface{}{ "duration.us": hbtestllext.IsInt64, "id": uniqScope.IsUniqueTo(u), "name": testMonFields.Name, "type": testMonFields.Type, - "status": "up", + "status": "down", "check_group": uniqScope.IsUniqueTo(u), }, "state": isdef.Optional(hbtestllext.IsMonitorState),