Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Heartbeat] Fix testing pipeline for Windows #40583

Merged
merged 6 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .buildkite/x-pack/pipeline.xpack.heartbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ steps:

- label: ":windows: x-pack/heartbeat: Win 2016 Unit Tests"
key: "mandatory-win-2016-unit-tests"
skip: "skipping due to elastic/beats#23957 and elastic/beats#23958"
skip: "skipping due missing deps, elastic/ingest-dev#3844"
command: |
Set-Location -Path x-pack/heartbeat
mage build test
Expand All @@ -134,7 +134,6 @@ steps:
# Doesn't exist in Jenkins
- label: ":windows: x-pack/heartbeat: Win 2022 Unit Tests"
key: "mandatory-win-2022-unit-tests"
skip: "skipping due to elastic/beats#23957 and elastic/beats#23958"
command: |
Set-Location -Path x-pack/heartbeat
mage build unitTest
Expand All @@ -157,7 +156,6 @@ steps:
- group: "Extended Windows Tests"
key: "x-pack-heartbeat-extended-win-tests"
if: build.env("BUILDKITE_PULL_REQUEST") == "false" || build.env("GITHUB_PR_LABELS") =~ /.*[Ww]indows.*/
skip: "skipping due to elastic/beats#23957 and elastic/beats#23958"

steps:
- label: ":windows: x-pack/heartbeat: Win 10 Unit Tests"
Expand Down
2 changes: 2 additions & 0 deletions x-pack/heartbeat/include/list.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions x-pack/heartbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func TestPackages() error {
func GenerateModuleIncludeListGo() error {
opts := devtools.DefaultIncludeListOptions()
opts.ImportDirs = append(opts.ImportDirs, "monitors/*")
opts.BuildTags = "\n//go:build linux || darwin || synthetics\n"
return devtools.GenerateIncludeListGo(opts)
}

Expand Down
24 changes: 0 additions & 24 deletions x-pack/heartbeat/scenarios/basics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/elastic/go-lookslike/testslike"
"github.com/elastic/go-lookslike/validator"

"github.com/elastic/beats/v7/heartbeat/hbtest"
"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"
Expand Down Expand Up @@ -111,29 +110,6 @@ func TestLightweightSummaries(t *testing.T) {
})
}

func TestBrowserSummaries(t *testing.T) {
t.Parallel()
scenarioDB.RunTagWithSeparateTwists(t, "browser", StdAttemptTwists, func(t *testing.T, mtr *framework.MonitorTestRun, err error) {
all := mtr.Events()
lastEvent := all[len(all)-1]

testslike.Test(t,
lookslike.Compose(
SummaryValidatorForStatus(mtr.Meta.Status),
hbtest.URLChecks(t, mtr.Meta.URL),
),
lastEvent.Fields)

monStatus, _ := lastEvent.GetValue("monitor.status")
summaryIface, _ := lastEvent.GetValue("summary")
summary := summaryIface.(*jobsummary.JobSummary)
require.Equal(t, string(summary.Status), monStatus, "expected summary status and mon status to be equal in event: %v", lastEvent.Fields)

requireOneSummaryPerAttempt(t, all)

})
}

func requireOneSummaryPerAttempt(t *testing.T, events []*beat.Event) {
attemptCounter := uint16(1)
// ensure we only have one summary per attempt
Expand Down
46 changes: 46 additions & 0 deletions x-pack/heartbeat/scenarios/browserbasics_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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 || synthetics

package scenarios

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/elastic/go-lookslike"
"github.com/elastic/go-lookslike/testslike"

"github.com/elastic/beats/v7/heartbeat/hbtest"
_ "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"
"github.com/elastic/beats/v7/heartbeat/monitors/wrappers/summarizer/jobsummary"
"github.com/elastic/beats/v7/x-pack/heartbeat/scenarios/framework"
)

func TestBrowserSummaries(t *testing.T) {
t.Parallel()
scenarioDB.RunTagWithSeparateTwists(t, "browser", StdAttemptTwists, func(t *testing.T, mtr *framework.MonitorTestRun, err error) {
all := mtr.Events()
lastEvent := all[len(all)-1]

testslike.Test(t,
lookslike.Compose(
SummaryValidatorForStatus(mtr.Meta.Status),
hbtest.URLChecks(t, mtr.Meta.URL),
),
lastEvent.Fields)

monStatus, _ := lastEvent.GetValue("monitor.status")
summaryIface, _ := lastEvent.GetValue("summary")
summary := summaryIface.(*jobsummary.JobSummary)
require.Equal(t, string(summary.Status), monStatus, "expected summary status and mon status to be equal in event: %v", lastEvent.Fields)

requireOneSummaryPerAttempt(t, all)

})
}
Loading