Skip to content

Commit

Permalink
added windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oakrizan committed Jan 2, 2024
1 parent 9bc9859 commit 38fc689
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 29 deletions.
87 changes: 65 additions & 22 deletions .buildkite/filebeat/filebeat-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
DEBIAN_FRONTEND: "noninteractive"

steps:
- group: "Mandatory Testing"
- group: "Filebeat Mandatory Testing"
key: "mandatory-tests"
if: build.env("GITHUB_PR_TRIGGER_COMMENT") == "filebeat" || build.env("BUILDKITE_PULL_REQUEST") != "false"

Expand All @@ -22,6 +22,7 @@ steps:
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"

- label: ":ubuntu: Integration Tests"
command:
- "sudo apt-get update"
Expand All @@ -30,6 +31,7 @@ steps:
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"

- label: ":ubuntu: Python Integration Tests"
command:
- "sudo apt-get update"
Expand All @@ -38,26 +40,67 @@ steps:
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
# - label: ":windows: Unit Tests / {{matrix.platform}}"
# command: ".buildkite/filebeat/scripts/win-tests.ps1"

# - label: ":windows: Unit Tests"
# command: ".buildkite/filebeat/scripts/unit-tests-win.ps1"
# agents:
# provider: "gcp"
# imagePrefix: {{matrix.platform}}
# matrix:
# setup:
# platform:
# - "family/core-windows-2022"
# - "family/core-windows-2016"


# steps:
# - label: ":linux: Test Filebeat: ARM"
# command: echo "THIS IS MSG ${GITHUB_PR_TRIGGER_COMMENT}"
# if: build.pull_request.labels includes \"arm\"
# notify:
# - github_commit_status:
# context: "Test Filebeat/ARM"
# agents:
# provider: "aws"
# imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
# instanceType: "t4g.large"
# image: "family/core-windows-2016"
# machine_type: "n2-standard-8"
# disk_size: 200
# disk_type: "pd-ssd"

- label: ":windows:-{{matrix.image}} Unit Tests"
command: ".buildkite/filebeat/scripts/unit-tests-win.ps1"
agents:
provider: "gcp"
image: "{{matrix.image}}"
# image: "family/core-windows-2022"
machine_type: "n2-standard-8"
disk_size: 200
disk_type: "pd-ssd"
matrix:
setup:
image:
- "family/core-windows-2022"
- "family/core-windows-2016"

- group: "Extended Testing"
key: "extended-tests"
if: build.env("BUILDKITE_PULL_REQUEST") != "false"

steps:
- label: ":linux:-ARM Unit Tests"
if: build.env("GITHUB_PR_TRIGGER_COMMENT") == "filebeat for arm" || build.env("GITHUB_PR_LABELS") =~ /.*arm.*/
command:
- "sudo apt-get update"
- "sudo apt-get install -y libsystemd-dev"
- "sudo apt install -y python3-pip"
- "sudo apt-get install -y python3-venv"
- ".buildkite/filebeat/scripts/unit-tests.sh"
notify:
- github_commit_status:
context: "Test Filebeat/ARM"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "t4g.large"

- label: ":mac: MacOS Unit Tests"
# if: build.env("GITHUB_PR_TRIGGER_COMMENT") == "filebeat for macos" || build.env("GITHUB_PR_LABELS") =~ /.*macOS.*/
command:
# - "sudo ulimit -n 10240"
- "ulimit -Sn 50000"
- ".buildkite/filebeat/scripts/unit-tests.sh"
agents:
provider: "orka"
imagePrefix: "generic-13-ventura-x64"

- label: ":windows:-2109 Unit Tests"
command: ".buildkite/filebeat/scripts/unit-tests-win.ps1"
agents:
provider: "gcp"
image: "family/core-windows-2019"
machine_type: "n2-standard-8"
disk_size: 200
disk_type: "pd-ssd"
8 changes: 4 additions & 4 deletions .buildkite/filebeat/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

set -euo pipefail

WORKSPACE="$(pwd)"
#WORKSPACE="$(pwd)"
BIN="${WORKSPACE}/bin"
HW_TYPE="$(uname -m)"
PLATFORM_TYPE="$(uname)"

if [[ -z "${GOLANG_VERSION-""}" ]]; then
export GOLANG_VERSION=$(cat "${WORKSPACE}/.go-version")
fi
#if [[ -z "${GOLANG_VERSION-""}" ]]; then
# export GOLANG_VERSION=$(cat "${WORKSPACE}/.go-version")
#fi

add_bin_path() {
echo "Adding PATH to the environment variables..."
Expand Down
10 changes: 10 additions & 0 deletions .buildkite/filebeat/scripts/pre-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

prepare_win() {
local os
os="$(uname)"
if [[ $os = MINGW* ]]; then
choco install mingw -y
choco install python --version=3.11.0 -y
fi
}
52 changes: 52 additions & 0 deletions .buildkite/filebeat/scripts/unit-tests-win.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
$ErrorActionPreference = "Stop" # set -e

# Forcing to checkout again all the files with a correct autocrlf.
# Doing this here because we cannot set git clone options before.
function fixCRLF() {
Write-Host "-- Fixing CRLF in git checkout --"
git config core.autocrlf true
git rm --quiet --cached -r .
git reset --quiet --hard
}

function withGolang() {
# Write-Host "-- Install golang $env:GOLANG_VERSION --"
# choco install golang -y --version $env:GOLANG_VERSION

Write-Host "-- Install golang 1.20.7 --"
choco install golang -y --version 1.20.7

$choco = Convert-Path "$((Get-Command choco).Path)\..\.."
Import-Module "$choco\helpers\chocolateyProfile.psm1"
refreshenv
go version
go env
}

function installGoDependencies() {
$installPackages = @(
"github.com/magefile/mage"
"github.com/elastic/go-licenser"
"golang.org/x/tools/cmd/goimports"
"github.com/jstemmer/go-junit-report"
"github.com/tebeka/go2xunit"
)
foreach ($pkg in $installPackages) {
go install "$pkg"
}
}

fixCRLF
withGolang
installGoDependencies

$ErrorActionPreference = "Continue" # set +e

#New-Item -ItemType Directory -Force -Path "build"
Set-Location filebeat
mage build unitTest

$EXITCODE=$LASTEXITCODE
$ErrorActionPreference = "Stop"

Exit $EXITCODE
16 changes: 16 additions & 0 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/filebeat/scripts/pre-common.sh

if [[ "$BUILDKITE_PIPELINE_SLUG" == "filebeat" ]]; then
export WORKSPACE="$(pwd)"

uname
prepare_win

if [[ -z "${GOLANG_VERSION-""}" ]]; then
export GOLANG_VERSION=$(cat "${WORKSPACE}/.go-version")
fi
fi
4 changes: 2 additions & 2 deletions .buildkite/pull-requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"set_commit_status": true,
"build_on_commit": true,
"build_on_comment": true,
"trigger_comment_regex": "^/test filebeat$|^/test filebeat for arm$",
"always_trigger_comment_regex": "^/test filebeat$|^/test filebeat for arm$",
"trigger_comment_regex": "^/test filebeat$|^/test filebeat for arm$|^/test filebeat for macos$",
"always_trigger_comment_regex": "^/test filebeat$|^/test filebeat for arm$|^/test filebeat for macos$",
"skip_ci_labels": [ ],
"skip_target_branches": [ ],
"skip_ci_on_only_changed": [ ],
Expand Down
2 changes: 1 addition & 1 deletion filebeat/Jenkinsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ stages:
- "macos12 && x86_64"
when: ## Override the top-level when.
comments:
- "/test filebeat for macos"
- "/test filebeat for macos"
labels:
- "macOS"
parameters:
Expand Down

0 comments on commit 38fc689

Please sign in to comment.