From 41b1c4d6b73e7fd0776b70c43a661166471f89aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Alvarez=20Pi=C3=B1eiro?= <95703246+emilioalvap@users.noreply.github.com> Date: Thu, 5 Sep 2024 00:03:39 +0200 Subject: [PATCH] [Heartbeat] Fix testing pipeline for Windows (#40583) * Fix windows test pipeline by reflecting browser monitor build constraints in the include file --- .../x-pack/pipeline.xpack.heartbeat.yml | 4 +- x-pack/heartbeat/include/list.go | 2 + x-pack/heartbeat/magefile.go | 1 + x-pack/heartbeat/scenarios/basics_test.go | 24 ---------- .../heartbeat/scenarios/browserbasics_test.go | 46 +++++++++++++++++++ 5 files changed, 50 insertions(+), 27 deletions(-) create mode 100644 x-pack/heartbeat/scenarios/browserbasics_test.go diff --git a/.buildkite/x-pack/pipeline.xpack.heartbeat.yml b/.buildkite/x-pack/pipeline.xpack.heartbeat.yml index 10073a873180..76a20ebdfa89 100644 --- a/.buildkite/x-pack/pipeline.xpack.heartbeat.yml +++ b/.buildkite/x-pack/pipeline.xpack.heartbeat.yml @@ -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 @@ -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 @@ -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" diff --git a/x-pack/heartbeat/include/list.go b/x-pack/heartbeat/include/list.go index 20ea9d71688b..d2fac57099d9 100644 --- a/x-pack/heartbeat/include/list.go +++ b/x-pack/heartbeat/include/list.go @@ -4,6 +4,8 @@ // Code generated by beats/dev-tools/cmd/module_include_list/module_include_list.go - DO NOT EDIT. +//go:build linux || darwin || synthetics + package include import ( diff --git a/x-pack/heartbeat/magefile.go b/x-pack/heartbeat/magefile.go index 8e7cd7f664f3..c10004340319 100644 --- a/x-pack/heartbeat/magefile.go +++ b/x-pack/heartbeat/magefile.go @@ -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) } diff --git a/x-pack/heartbeat/scenarios/basics_test.go b/x-pack/heartbeat/scenarios/basics_test.go index 08794c12146b..4d2d7f741322 100644 --- a/x-pack/heartbeat/scenarios/basics_test.go +++ b/x-pack/heartbeat/scenarios/basics_test.go @@ -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" @@ -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 diff --git a/x-pack/heartbeat/scenarios/browserbasics_test.go b/x-pack/heartbeat/scenarios/browserbasics_test.go new file mode 100644 index 000000000000..2543982fb9b0 --- /dev/null +++ b/x-pack/heartbeat/scenarios/browserbasics_test.go @@ -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) + + }) +}