Skip to content

Commit

Permalink
added servrless tests step
Browse files Browse the repository at this point in the history
  • Loading branch information
oakrizan committed Oct 30, 2024
1 parent 0b80879 commit 90de89c
Show file tree
Hide file tree
Showing 9 changed files with 1,058 additions and 260 deletions.
4 changes: 2 additions & 2 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ fi
if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-xpack-agentbeat" && "$BUILDKITE_STEP_KEY" == *"agentbeat-it"* ]]; then
out=$(.buildkite/scripts/agentbeat/setup_agentbeat.py)
echo "$out"
AGENTBEAT_PATH=$(echo "$out" | tail -n 1)
export AGENTBEAT_PATH
AGENT_BUILD_DIR=$(echo "$out" | tail -n 1)
export AGENT_BUILD_DIR
fi

if [[ "$BUILDKITE_PIPELINE_SLUG" == "auditbeat" || \
Expand Down
144 changes: 63 additions & 81 deletions .buildkite/x-pack/pipeline.xpack.agentbeat.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
env:
ASDF_MAGE_VERSION: 1.15.0
ASDF_NODEJS_VERSION: 18.17.1

GCP_HI_PERF_MACHINE_TYPE: "c2d-highcpu-16"
IMAGE_UBUNTU_X86_64: "family/platform-ingest-beats-ubuntu-2204"

AWS_ARM_INSTANCE_TYPE: "m6g.xlarge"
AWS_IMAGE_UBUNTU_ARM_64: "platform-ingest-beats-ubuntu-2204-aarch64"

IMAGE_MACOS_ARM: "generic-13-ventura-arm"
IMAGE_MACOS_X86_64: "generic-13-ventura-x64"

IMAGE_WIN_2022: "family/platform-ingest-beats-windows-2022"

IMAGE_BEATS_WITH_HOOKS_LATEST: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-beats-ci-with-hooks:latest"

AGENTBEAT_SPEC: "./agentbeat.spec.yml"

steps:
- group: "Check/Update"
key: "x-pack-agentbeat-check-update"
Expand Down Expand Up @@ -47,6 +35,7 @@ steps:
key: "agentbeat-package-linux"
env:
PLATFORMS: "+all linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64"
PACKAGES: tar.gz,zip
SNAPSHOT: true
command: |
set -euo pipefail
Expand All @@ -70,15 +59,38 @@ steps:
- github_commit_status:
context: "agentbeat: Packaging"

- label: ":ubuntu: x-pack/agentbeat: Ubuntu x86_64 Spec tests"
key: "agentbeat-it-linux-x86-64"
env:
PLATFORM: "linux/amd64"
- label: ":linux: Agentbeat/Integration tests Linux"
key: "agentbeat-it-linux"
depends_on:
- agentbeat-package-linux
env:
ASDF_NODEJS_VERSION: 18.17.1
PLATFORMS: "+all linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64"
SNAPSHOT: true
command: |
set -euo pipefail
echo "~~~ Downloading artifacts"
buildkite-agent artifact download x-pack/agentbeat/build/distributions/** . --step 'agentbeat-package-linux'
ls -lah x-pack/agentbeat/build/distributions/
echo "~~~ Installing @elastic/synthetics with npm"
npm install -g @elastic/synthetics
echo "~~~ Running tests"
cd x-pack/agentbeat
mage -v testWithSpec
mage goIntegTest
artifact_paths:
- x-pack/agentbeat/build/distributions/**/*
- "x-pack/agentbeat/build/*.xml"
- "x-pack/agentbeat/build/*.json"
plugins:
- test-collector#v1.10.2:
files: "x-pack/agentbeat/build/TEST-*.xml"
format: "junit"
branches: "main"
debug: true
retry:
automatic:
- limit: 1
timeout_in_minutes: 60
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
Expand All @@ -87,76 +99,46 @@ steps:
disk_type: "pd-ssd"
notify:
- github_commit_status:
context: "agentbeat: Ubuntu x86_64 Spec tests"
context: "agentbeat: Integration tests"

- label: ":ubuntu: x-pack/agentbeat: Ubuntu arm64 Spec tests"
key: "agentbeat-it-linux-arm64"
env:
PLATFORM: "linux/arm64"
depends_on:
- agentbeat-package-linux
command: |
cd x-pack/agentbeat
mage -v testWithSpec
agents:
provider: "aws"
imagePrefix: "${AWS_IMAGE_UBUNTU_ARM_64}"
instanceType: "${AWS_ARM_INSTANCE_TYPE}"
notify:
- github_commit_status:
context: "agentbeat: Ubuntu arm64 Spec tests"
- group: "Agentbeat: Servelress Tests"
key: "agentbeat-serverless-tests"

- label: ":windows: x-pack/agentbeat: Windows x86_64 Spec tests"
key: "agentbeat-it-windows"
env:
PLATFORM: "windows/amd64"
depends_on:
- agentbeat-package-linux
command: |
Set-Location -Path x-pack/agentbeat
mage -v testWithSpec
agents:
provider: "gcp"
image: "${IMAGE_WIN_2022}"
machine_type: "${GCP_WIN_MACHINE_TYPE}"
disk_size: 200
disk_type: "pd-ssd"
notify:
- github_commit_status:
context: "agentbeat: Windows x86_64 Spec tests"

- label: ":macos: x-pack/agentbeat: macOS x86_64 Spec tests"
key: "agentbeat-it-macos-x86-64"
steps:
- label: ":ubuntu: Serverless tests"
key: "agentbeat-it-serverless"
depends_on:
- agentbeat-package-linux
env:
PLATFORM: "darwin/amd64"
command: |
set -euo pipefail
source .buildkite/scripts/install_macos_tools.sh
cd x-pack/agentbeat
mage -v testWithSpec
agents:
provider: "orka"
imagePrefix: "${IMAGE_MACOS_X86_64}"
notify:
- github_commit_status:
context: "agentbeat: macOS x86_64 Spec tests"
AGENT_STACK_VERSION: "8.16.0-SNAPSHOT"
TEST_INTEG_AUTH_GCP_DATACENTER: "us-central1-a"
GOFLAGS: "-buildvcs=false"
TEST_INTEG_CLEAN_ON_EXIT: true
TEST_PLATFORMS: "linux/amd64"
SNAPSHOT: true
command: echo test

- label: ":macos: x-pack/agentbeat: macOS arm64 Spec tests"
key: "agentbeat-it-macos-arm64"
depends_on:
- agentbeat-package-linux
env:
PLATFORM: "darwin/arm64"
command: |
set -euo pipefail
source .buildkite/scripts/install_macos_tools.sh
cd x-pack/agentbeat
mage -v testWithSpec
artifact_paths:
- x-pack/agentbeat/build/TEST-**
- x-pack/agentbeat/build/diagnostics/*
plugins:
- test-collector#v1.10.2:
files: "x-pack/agentbeat/build/TEST-*.xml"
format: "junit"
branches: "main"
debug: true
retry:
automatic:
- limit: 1
timeout_in_minutes: 60
concurrency_group: elastic-agent-extended-testing/serverless-integration
concurrency: 8
agents:
provider: "orka"
imagePrefix: "${IMAGE_MACOS_ARM}"
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_STANDARD_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
notify:
- github_commit_status:
context: "agentbeat: macOS arm64 Spec tests"
context: "agentbeat: Serverless tests"
52 changes: 52 additions & 0 deletions dev-tools/mage/agentbeat-serverless.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package mage

import (
"fmt"
"log"
"os"
)

// TestBeatServerless todo description
func TestBeatServerless(beat string) {
if os.Getenv("AGENT_BUILD_DIR") == "" {
log.Fatal("AGENT_BUILD_DIR is not defined")
}

setStackProvisioner()
setTestBinaryName(beat)

}

func setStackProvisioner() {
stackProvisioner := os.Getenv("STACK_PROVISIONER")
if stackProvisioner == "" {
if err := os.Setenv("STACK_PROVISIONER", "serverless"); err != nil {
log.Fatal("error setting serverless stack var: %w", err)
}
} else if stackProvisioner == "stateful" {
fmt.Println("--- Warning: running TestBeatServerless as stateful")
}
}

func setTestBinaryName(beat string) {
if err := os.Setenv("TEST_BINARY_NAME", beat); err != nil {
log.Fatal("error setting binary name: %w", err)
}
}
100 changes: 0 additions & 100 deletions dev-tools/mage/spec.go

This file was deleted.

Loading

0 comments on commit 90de89c

Please sign in to comment.