From 809302e77fbd629b6a23b72c0e75ecfddfeb7a42 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 1 Sep 2022 18:23:03 +0100 Subject: [PATCH] ci: enable windows for testing heartbeat (#32937) (cherry picked from commit 8552e34a6ad31c9f7ed3bf2a1202a00c401cfa43) # Conflicts: # x-pack/heartbeat/Jenkinsfile.yml # x-pack/heartbeat/monitors/browser/source/project.go # x-pack/heartbeat/monitors/browser/source/project_test.go # x-pack/heartbeat/monitors/browser/source/source.go # x-pack/heartbeat/scenarios/basics_test.go # x-pack/heartbeat/scenarios/scenarios.go --- x-pack/heartbeat/Jenkinsfile.yml | 33 +++++ .../monitors/browser/source/inline.go | 2 + .../monitors/browser/source/inline_test.go | 2 + .../monitors/browser/source/local.go | 3 + .../monitors/browser/source/local_test.go | 3 + .../monitors/browser/source/offline.go | 2 + .../monitors/browser/source/project.go | 132 ++++++++++++++++++ .../monitors/browser/source/project_test.go | 100 +++++++++++++ .../monitors/browser/source/source.go | 6 + .../browser/source/validatepackage.go | 3 + .../browser/source/validatepackage_test.go | 3 + .../monitors/browser/source/zipurl.go | 3 + .../monitors/browser/source/zipurl_test.go | 3 + x-pack/heartbeat/scenarios/basics_test.go | 79 +++++++++++ x-pack/heartbeat/scenarios/scenarios.go | 73 ++++++++++ 15 files changed, 447 insertions(+) create mode 100644 x-pack/heartbeat/monitors/browser/source/project.go create mode 100644 x-pack/heartbeat/monitors/browser/source/project_test.go create mode 100644 x-pack/heartbeat/scenarios/basics_test.go create mode 100644 x-pack/heartbeat/scenarios/scenarios.go diff --git a/x-pack/heartbeat/Jenkinsfile.yml b/x-pack/heartbeat/Jenkinsfile.yml index edafbb437e15..92653912183a 100644 --- a/x-pack/heartbeat/Jenkinsfile.yml +++ b/x-pack/heartbeat/Jenkinsfile.yml @@ -32,6 +32,7 @@ stages: - "macosTest" tags: true ## for all the tags stage: extended +<<<<<<< HEAD # TODO: there are windows test failures already reported # https://github.com/elastic/beats/issues/23957 and https://github.com/elastic/beats/issues/23958 # waiting for being fixed. @@ -75,6 +76,38 @@ stages: # platforms: ## override default labels in this specific stage. # - "windows-7-32-bit" # stage: extended_win +======= + windows-2022: + mage: "mage build test" + platforms: ## override default labels in this specific stage. + - "windows-2022" + stage: mandatory + windows-2019: + mage: "mage build test" + platforms: ## override default labels in this specific stage. + - "windows-2019" + stage: extended_win + windows-2016: + mage: "mage build test" + platforms: ## override default labels in this specific stage. + - "windows-2016" + stage: mandatory + windows-2012: + mage: "mage build test" + platforms: ## override default labels in this specific stage. + - "windows-2012-r2" + stage: extended_win + windows-10: + mage: "mage build test" + platforms: ## override default labels in this specific stage. + - "windows-10" + stage: extended_win + windows-8: + mage: "mage build test" + platforms: ## override default labels in this specific stage. + - "windows-8" + stage: extended_win +>>>>>>> 8552e34a6a (ci: enable windows for testing heartbeat (#32937)) packaging-linux: packaging-linux: "mage package" e2e: diff --git a/x-pack/heartbeat/monitors/browser/source/inline.go b/x-pack/heartbeat/monitors/browser/source/inline.go index abdce2a87e99..bf203411951d 100644 --- a/x-pack/heartbeat/monitors/browser/source/inline.go +++ b/x-pack/heartbeat/monitors/browser/source/inline.go @@ -1,6 +1,8 @@ // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. +//go:build linux || darwin +// +build linux darwin package source diff --git a/x-pack/heartbeat/monitors/browser/source/inline_test.go b/x-pack/heartbeat/monitors/browser/source/inline_test.go index d97dbd8a1205..24f9a6efa945 100644 --- a/x-pack/heartbeat/monitors/browser/source/inline_test.go +++ b/x-pack/heartbeat/monitors/browser/source/inline_test.go @@ -1,6 +1,8 @@ // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. +//go:build linux || darwin +// +build linux darwin package source diff --git a/x-pack/heartbeat/monitors/browser/source/local.go b/x-pack/heartbeat/monitors/browser/source/local.go index e4a4563dc651..da78ec422391 100644 --- a/x-pack/heartbeat/monitors/browser/source/local.go +++ b/x-pack/heartbeat/monitors/browser/source/local.go @@ -2,6 +2,9 @@ // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. +//go:build linux || darwin +// +build linux darwin + package source import ( diff --git a/x-pack/heartbeat/monitors/browser/source/local_test.go b/x-pack/heartbeat/monitors/browser/source/local_test.go index 40a9b9b1affc..c391b49719d9 100644 --- a/x-pack/heartbeat/monitors/browser/source/local_test.go +++ b/x-pack/heartbeat/monitors/browser/source/local_test.go @@ -2,6 +2,9 @@ // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. +//go:build linux || darwin +// +build linux darwin + package source import ( diff --git a/x-pack/heartbeat/monitors/browser/source/offline.go b/x-pack/heartbeat/monitors/browser/source/offline.go index 0347958a8120..a16ed88ff52d 100644 --- a/x-pack/heartbeat/monitors/browser/source/offline.go +++ b/x-pack/heartbeat/monitors/browser/source/offline.go @@ -1,6 +1,8 @@ // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. +//go:build linux || darwin +// +build linux darwin package source diff --git a/x-pack/heartbeat/monitors/browser/source/project.go b/x-pack/heartbeat/monitors/browser/source/project.go new file mode 100644 index 000000000000..421b54f2d7c7 --- /dev/null +++ b/x-pack/heartbeat/monitors/browser/source/project.go @@ -0,0 +1,132 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. +//go:build linux || darwin +// +build linux darwin + +package source + +import ( + "bytes" + "encoding/base64" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "regexp" + "strings" + + "github.com/elastic/elastic-agent-libs/mapstr" +) + +type ProjectSource struct { + Content string `config:"content" json:"content"` + TargetDirectory string +} + +var ErrNoContent = fmt.Errorf("no 'content' value specified for project monitor source") + +func (p *ProjectSource) Validate() error { + if !regexp.MustCompile(`\S`).MatchString(p.Content) { + return ErrNoContent + } + + return nil +} + +func (p *ProjectSource) Fetch() error { + decodedBytes, err := base64.StdEncoding.DecodeString(p.Content) + if err != nil { + return err + } + + tf, err := ioutil.TempFile(os.TempDir(), "elastic-synthetics-zip-") + if err != nil { + return fmt.Errorf("could not create tmpfile for project monitor source: %w", err) + } + defer os.Remove(tf.Name()) + + // copy the encoded contents in to a temp file for unzipping later + _, err = io.Copy(tf, bytes.NewReader(decodedBytes)) + if err != nil { + return err + } + + p.TargetDirectory, err = ioutil.TempDir(os.TempDir(), "elastic-synthetics-unzip-") + if err != nil { + return fmt.Errorf("could not make temp dir for unzipping project source: %w", err) + } + + err = unzip(tf, p.Workdir(), "") + if err != nil { + p.Close() + return err + } + + // Offline is not required for project resources as we are only linking + // to the globally installed agent, but useful for testing purposes + if !Offline() { + // set up npm project and ensure synthetics is installed + err = setupProjectDir(p.Workdir()) + if err != nil { + return fmt.Errorf("setting up project dir failed: %w", err) + } + } + + return nil +} + +type PackageJSON struct { + Name string `json:"name"` + Private bool `json:"private"` + Dependencies mapstr.M `json:"dependencies"` +} + +// setupProjectDir sets ups the required package.json file and +// links the synthetics dependency to the globally installed one that is +// baked in to the Heartbeat image to maintain compatibility and +// allows us to control the synthetics agent version +func setupProjectDir(workdir string) error { + fname, err := exec.LookPath("elastic-synthetics") + if err == nil { + fname, err = filepath.Abs(fname) + } + if err != nil { + return fmt.Errorf("cannot resolve global synthetics library: %w", err) + } + + globalPath := strings.Replace(fname, "bin/elastic-synthetics", "lib/node_modules/@elastic/synthetics", 1) + symlinkPath := fmt.Sprintf("file:%s", globalPath) + pkgJson := PackageJSON{ + Name: "project-journey", + Private: true, + Dependencies: mapstr.M{ + "@elastic/synthetics": symlinkPath, + }, + } + pkgJsonContent, err := json.MarshalIndent(pkgJson, "", " ") + if err != nil { + return err + } + err = ioutil.WriteFile(filepath.Join(workdir, "package.json"), pkgJsonContent, 0755) + if err != nil { + return err + } + + // setup the project linking to the global synthetics library + return runSimpleCommand(exec.Command("npm", "install"), workdir) +} + +func (p *ProjectSource) Workdir() string { + return p.TargetDirectory +} + +func (p *ProjectSource) Close() error { + if p.TargetDirectory != "" { + return os.RemoveAll(p.TargetDirectory) + } + return nil +} diff --git a/x-pack/heartbeat/monitors/browser/source/project_test.go b/x-pack/heartbeat/monitors/browser/source/project_test.go new file mode 100644 index 000000000000..e9a3caec246e --- /dev/null +++ b/x-pack/heartbeat/monitors/browser/source/project_test.go @@ -0,0 +1,100 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. +//go:build linux || darwin +// +build linux darwin + +package source + +import ( + "os" + "path" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v2" + + "github.com/elastic/elastic-agent-libs/config" + "github.com/elastic/elastic-agent-libs/mapstr" +) + +func setUpTests() func() { + GoOffline() + return func() { + GoOnline() + } +} + +func TestProjectSource(t *testing.T) { + teardown := setUpTests() + defer teardown() + + type testCase struct { + name string + cfg mapstr.M + wantErr bool + } + testCases := []testCase{ + { + "decode project content", + mapstr.M{ + "content": "UEsDBBQACAAIAJ27qVQAAAAAAAAAAAAAAAAiAAAAZXhhbXBsZXMvdG9kb3MvYWR2YW5jZWQuam91cm5leS50c5VRPW/CMBDd+RWnLA0Sigt0KqJqpbZTN+iEGKzkIC6JbfkuiBTx3+uEEAGlgi7Rnf38viIESCLkR/FJ6Eis1VIjpanATBKrWFCpOUU/kcCNzG2GJNgkhoRM1lLHmERfpnAay4ipo3JrHMMWmjPYwcKZHILn33zBqIV3ADIjkxdrJ4y251eZJFNJq3b1Hh1XJx+KeKK+8XATpxiv3o07RidI7Ex5OOocTEQixcz6mF66MRgGXkmxMhqkTiA2VcJ6NQsgpZcZAnueoAfhFqxcYs9/ncwJdl0YP9XeY6OJgb3qFDcMYwhejb5jsAUDyYxBaSi9HmCJlfZJ2vCYNCpc1h2d5m8AB/r99cU+GmS/hpwXc4nmrKh/K917yK57VqZe1lU6zM26WvIiY2WbHunWIiusb3IWVBP0/bP9NGinYTC/qcqWLloY9ybjNAy5VbzYdP1sdz3+8FqJleqsP7/ONPjjp++TPgS3eaks/wBQSwcIVYIEHGwBAADRAwAAUEsDBBQACAAIAJ27qVQAAAAAAAAAAAAAAAAZAAAAZXhhbXBsZXMvdG9kb3MvaGVscGVycy50c5VUTYvbMBC9768YRGAVyKb0uktCu9CeektvpRCtM4nFKpKQxt2kwf+9I9lJ5cRb6MWW5+u9eTOW3nsXCE4QCf0M8OCxImhhG9wexCc0KpKuPsSjpRr5FMXTXeVsJDBObT57v+I8WID0aoczaIKZwmIJpzvIFaUwqrFVDcp7MQPFdSqQlxAA9aY0QUqe7xw5mQo8saflZ3uGUpvNdxVfh1DEliHWmuOyGSan9GrXY4hdSW19Q1yswJ9Ika1zi28P5DZOZCZnjp2Pjh5lhr71+YAxSvHFEgZx20UqGVdoWGAXGFo0Zp5sD0YnOXX+uMi71TY3nTh2PYy0HZCaYMsm0umrC2cYuWYpStwWlksgPNBC9CKJ9UDqGDFQAv7GrFb6N/aqD0hEtl9pX9VYvQLViroR5KZqFXmlVEXmyDNJWS0wkT1aiqPD6fZPynIsEznoYDqdG7Q7qqcs2DPKzOVG7EyHhSj25n0Zyw62PJvcwH2vzz1PN3czSrifwHlaZfUbThuMFNzxPyj1GVeE/rHWRr2guaz1e6wu0foSmhPTL3DwiuqFshVDu/D4aPSPjz/FIK1n9dwQOfu3gk7pL9k4jK+M5lk0LBRy9CB7nn2yD+cStfuFQQ5+riK9kJQ3JV9cbCmuh1n6HF3h5LleimS7GkoynWVL5+KWS6h/AFBLBwgvDHpj+wEAAC8FAABQSwECLQMUAAgACACdu6lUVYIEHGwBAADRAwAAIgAAAAAAAAAAACAApIEAAAAAZXhhbXBsZXMvdG9kb3MvYWR2YW5jZWQuam91cm5leS50c1BLAQItAxQACAAIAJ27qVQvDHpj+wEAAC8FAAAZAAAAAAAAAAAAIACkgbwBAABleGFtcGxlcy90b2Rvcy9oZWxwZXJzLnRzUEsFBgAAAAACAAIAlwAAAP4DAAAAAA==", + }, + false, + }, + { + "bad encoded content", + mapstr.M{ + "content": "12312edasd", + }, + true, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + psrc, err := dummyPSource(tc.cfg) + if tc.wantErr { + err = psrc.Fetch() + require.Error(t, err) + return + } + require.NoError(t, err) + fetchAndValidate(t, psrc) + }) + } +} + +func validateFileContents(t *testing.T, dir string) { + expected := []string{ + "examples/todos/helpers.ts", + "examples/todos/advanced.journey.ts", + } + for _, file := range expected { + _, err := os.Stat(path.Join(dir, file)) + assert.NoError(t, err) + } +} + +func fetchAndValidate(t *testing.T, psrc *ProjectSource) { + err := psrc.Fetch() + require.NoError(t, err) + + validateFileContents(t, psrc.Workdir()) + // check if the working directory is deleted + require.NoError(t, psrc.Close()) + _, err = os.Stat(psrc.TargetDirectory) + require.True(t, os.IsNotExist(err), "TargetDirectory %s should have been deleted", psrc.TargetDirectory) +} + +func dummyPSource(conf map[string]interface{}) (*ProjectSource, error) { + psrc := &ProjectSource{} + y, _ := yaml.Marshal(conf) + c, err := config.NewConfigWithYAML(y, string(y)) + if err != nil { + return nil, err + } + err = c.Unpack(psrc) + return psrc, err +} diff --git a/x-pack/heartbeat/monitors/browser/source/source.go b/x-pack/heartbeat/monitors/browser/source/source.go index be40351d05b0..108711c20129 100644 --- a/x-pack/heartbeat/monitors/browser/source/source.go +++ b/x-pack/heartbeat/monitors/browser/source/source.go @@ -1,6 +1,12 @@ // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. +<<<<<<< HEAD +======= + +//go:build linux || darwin +// +build linux darwin +>>>>>>> 8552e34a6a (ci: enable windows for testing heartbeat (#32937)) package source diff --git a/x-pack/heartbeat/monitors/browser/source/validatepackage.go b/x-pack/heartbeat/monitors/browser/source/validatepackage.go index bc606ffe8373..f75e3b843304 100644 --- a/x-pack/heartbeat/monitors/browser/source/validatepackage.go +++ b/x-pack/heartbeat/monitors/browser/source/validatepackage.go @@ -2,6 +2,9 @@ // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. +//go:build linux || darwin +// +build linux darwin + package source import ( diff --git a/x-pack/heartbeat/monitors/browser/source/validatepackage_test.go b/x-pack/heartbeat/monitors/browser/source/validatepackage_test.go index 014e1fd2fa98..ab2b298efcca 100644 --- a/x-pack/heartbeat/monitors/browser/source/validatepackage_test.go +++ b/x-pack/heartbeat/monitors/browser/source/validatepackage_test.go @@ -2,6 +2,9 @@ // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. +//go:build linux || darwin +// +build linux darwin + package source import ( diff --git a/x-pack/heartbeat/monitors/browser/source/zipurl.go b/x-pack/heartbeat/monitors/browser/source/zipurl.go index 2f2cc0bb6ff9..b7f2409cf648 100644 --- a/x-pack/heartbeat/monitors/browser/source/zipurl.go +++ b/x-pack/heartbeat/monitors/browser/source/zipurl.go @@ -2,6 +2,9 @@ // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. +//go:build linux || darwin +// +build linux darwin + package source import ( diff --git a/x-pack/heartbeat/monitors/browser/source/zipurl_test.go b/x-pack/heartbeat/monitors/browser/source/zipurl_test.go index 9c1606846422..e6fd20a839ce 100644 --- a/x-pack/heartbeat/monitors/browser/source/zipurl_test.go +++ b/x-pack/heartbeat/monitors/browser/source/zipurl_test.go @@ -2,6 +2,9 @@ // or more contributor license agreements. Licensed under the Elastic License; // you may not use this file except in compliance with the Elastic License. +//go:build linux || darwin +// +build linux darwin + package source import ( diff --git a/x-pack/heartbeat/scenarios/basics_test.go b/x-pack/heartbeat/scenarios/basics_test.go new file mode 100644 index 000000000000..38dec26b4ddb --- /dev/null +++ b/x-pack/heartbeat/scenarios/basics_test.go @@ -0,0 +1,79 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package scenarios + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/elastic/go-lookslike" + "github.com/elastic/go-lookslike/isdef" + "github.com/elastic/go-lookslike/testslike" + + "github.com/elastic/beats/v7/heartbeat/hbtestllext" + _ "github.com/elastic/beats/v7/heartbeat/monitors/active/http" + _ "github.com/elastic/beats/v7/heartbeat/monitors/active/icmp" + _ "github.com/elastic/beats/v7/heartbeat/monitors/active/tcp" +) + +func TestSimpleScenariosBasicFields(t *testing.T) { + Scenarios.RunAll(t, func(mtr *MonitorTestRun, err error) { + require.GreaterOrEqual(t, len(mtr.Events()), 1) + lastCg := "" + for i, e := range mtr.Events() { + testslike.Test(t, lookslike.MustCompile(map[string]interface{}{ + "monitor": map[string]interface{}{ + "id": mtr.StdFields.ID, + "name": mtr.StdFields.Name, + "type": mtr.StdFields.Type, + "check_group": isdef.IsString, + }, + }), e.Fields) + + // Ensure that all check groups are equal and don't change + cg, err := e.GetValue("monitor.check_group") + require.NoError(t, err) + cgStr := cg.(string) + if i == 0 { + lastCg = cgStr + } else { + require.Equal(t, lastCg, cgStr) + } + } + }) +} + +func TestLightweightUrls(t *testing.T) { + Scenarios.RunTag(t, "lightweight", func(mtr *MonitorTestRun, err error) { + for _, e := range mtr.Events() { + testslike.Test(t, lookslike.MustCompile(map[string]interface{}{ + "url": map[string]interface{}{ + "full": isdef.IsNonEmptyString, + "domain": isdef.IsNonEmptyString, + "scheme": mtr.StdFields.Type, + }, + }), e.Fields) + } + }) +} + +func TestLightweightSummaries(t *testing.T) { + Scenarios.RunTag(t, "lightweight", func(mtr *MonitorTestRun, err error) { + all := mtr.Events() + lastEvent, firstEvents := all[len(all)-1], all[:len(all)-1] + testslike.Test(t, lookslike.MustCompile(map[string]interface{}{ + "summary": map[string]interface{}{ + "up": hbtestllext.IsUint16, + "down": hbtestllext.IsUint16, + }, + }), lastEvent.Fields) + + for _, e := range firstEvents { + summary, _ := e.GetValue("summary") + require.Nil(t, summary) + } + }) +} diff --git a/x-pack/heartbeat/scenarios/scenarios.go b/x-pack/heartbeat/scenarios/scenarios.go new file mode 100644 index 000000000000..3ab193c4f556 --- /dev/null +++ b/x-pack/heartbeat/scenarios/scenarios.go @@ -0,0 +1,73 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package scenarios + +import ( + "fmt" + "net/http/httptest" + "net/url" + "sync" + + "github.com/elastic/elastic-agent-libs/mapstr" + + "github.com/elastic/beats/v7/heartbeat/hbtest" +) + +var Scenarios = &ScenarioDB{ + initOnce: &sync.Once{}, + ByTag: map[string][]Scenario{}, + All: []Scenario{ + { + Name: "http-simple", + Type: "http", + Tags: []string{"lightweight", "http"}, + Runner: func() (config mapstr.M, close func(), err error) { + server := httptest.NewServer(hbtest.HelloWorldHandler(200)) + config = mapstr.M{ + "id": "http-test-id", + "name": "http-test-name", + "type": "http", + "schedule": "@every 1m", + "urls": []string{server.URL}, + } + return config, server.Close, nil + }, + }, + { + Name: "tcp-simple", + Type: "tcp", + Tags: []string{"lightweight", "tcp"}, + Runner: func() (config mapstr.M, close func(), err error) { + server := httptest.NewServer(hbtest.HelloWorldHandler(200)) + parsedUrl, err := url.Parse(server.URL) + if err != nil { + panic(fmt.Sprintf("URL %s should always be parsable: %s", server.URL, err)) + } + config = mapstr.M{ + "id": "tcp-test-id", + "name": "tcp-test-name", + "type": "tcp", + "schedule": "@every 1m", + "hosts": []string{fmt.Sprintf("%s:%s", parsedUrl.Host, parsedUrl.Port())}, + } + return config, server.Close, nil + }, + }, + { + Name: "simple-icmp", + Type: "icmp", + Tags: []string{"icmp"}, + Runner: func() (config mapstr.M, close func(), err error) { + return mapstr.M{ + "id": "icmp-test-id", + "name": "icmp-test-name", + "type": "icmp", + "schedule": "@every 1m", + "hosts": []string{"127.0.0.1"}, + }, func() {}, nil + }, + }, + }, +}