Skip to content

Commit 96fcf94

Browse files
Merge branch '8.12' into mergify/bp/8.12/pr-3293
2 parents 79b8ff2 + 12cd1f5 commit 96fcf94

File tree

10 files changed

+194
-15
lines changed

10 files changed

+194
-15
lines changed

.buildkite/hooks/pre-command

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server-package-mbp" ]]; then
4040
check_if_file_exist_in_repo "infra" "${BUILDKITE_BRANCH}" #TODO should be changed to "main" for rollback...
4141
fi
4242

43-
if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server" ]]; then
44-
if [[ "$BUILDKITE_STEP_KEY" == "publish" || "$BUILDKITE_STEP_KEY" == "cloud-e2e-test" ]]; then
43+
if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server" || "$BUILDKITE_PIPELINE_SLUG" == "fleet-server-perf-tests" ]]; then
44+
if [[ "$BUILDKITE_STEP_KEY" == "publish" || "$BUILDKITE_STEP_KEY" == "cloud-e2e-test" || "$BUILDKITE_STEP_KEY" == "create-image" ]]; then
4545
export DOCKER_USERNAME_SECRET=$(retry 5 vault kv get -field user "${DOCKER_REGISTRY_SECRET_PATH}")
4646
export DOCKER_PASSWORD_SECRET=$(retry 5 vault kv get -field password "${DOCKER_REGISTRY_SECRET_PATH}")
4747
docker login -u "${DOCKER_USERNAME_SECRET}" -p "${DOCKER_PASSWORD_SECRET}" "${DOCKER_REGISTRY}" 2>/dev/null

.buildkite/hooks/pre-exit

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set -euo pipefail
44

55
source .buildkite/scripts/common.sh
66

7-
if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server" ]]; then
8-
if [[ "$BUILDKITE_STEP_KEY" == "publish" || "$BUILDKITE_STEP_KEY" == "cloud-e2e-test" ]]; then
7+
if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server" || "$BUILDKITE_PIPELINE_SLUG" == "fleet-server-perf-tests" ]]; then
8+
if [[ "$BUILDKITE_STEP_KEY" == "publish" || "$BUILDKITE_STEP_KEY" == "cloud-e2e-test" || "$BUILDKITE_STEP_KEY" == "create-image" ]]; then
99
docker logout ${DOCKER_REGISTRY}
1010
fi
1111
fi

.buildkite/pipeline.perf-tests.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
2+
3+
env:
4+
DOCKER_REGISTRY: "docker.elastic.co"
5+
DOCKER_IMAGE: "${DOCKER_REGISTRY}/observability-ci/fleet-server" # needs to rename for rollback
6+
DOCKER_IMAGE_GIT_TAG: "${BUILDKITE_BRANCH}" # needs to rename for rollback
7+
DOCKER_IMAGE_LATEST_TAG: "latest" # needs to rename for rollback
8+
DOCKER_IMAGE_SHA_TAG: "git-${BUILDKITE_COMMIT:0:12}" # needs to rename for rollback, should be "git-${BUILDKITE_COMMIT:0:12}"
9+
10+
steps:
11+
- label: ":docker: Publish docker image"
12+
key: "create-image"
13+
command: ".buildkite/scripts/build_push_docker_image.sh"
14+
agents:
15+
provider: "gcp"
16+
17+
- label: "perf test"
18+
key: "obs-perf-test"
19+
trigger: observability-perf
20+
build:
21+
branch: "main"
22+
message: "10k serverless perf test for PR https://github.com/elastic/fleet-server/pull/${BUILDKITE_PULL_REQUEST}"
23+
env:
24+
OBLT_cluster_perf_provider: serverless
25+
OBLT_serverless_project_type: observability
26+
OBLT_serverless_fleet_image: "${DOCKER_IMAGE}:${DOCKER_IMAGE_SHA_TAG}"
27+
OBLT_cluster_perf_totalAgents: 10000
28+
depends_on:
29+
- step: "create-image"
30+
allow_failure: false

.buildkite/pull-requests.json

+15-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,19 @@
2525
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:package)\\W+(?:this|it))|^/package$",
2626

2727
"fail_on_not_mergeable": true
28-
}]
28+
},
29+
{
30+
"enabled": true,
31+
"pipeline_slug": "fleet-server-perf-tests",
32+
"allow_org_users": true,
33+
"allowed_repo_permissions": ["admin", "write"],
34+
"allowed_list": ["mergify[bot]"],
35+
"set_commit_status": false,
36+
"build_on_commit": false,
37+
"build_on_comment": true,
38+
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:run)\\W+(?:perf-tests))|^/perf-tests$",
39+
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:run)\\W+(?:perf-tests))|^/perf-tests$",
40+
"fail_on_not_mergeable": true
41+
}
42+
]
2943
}

Makefile

+5-6
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,12 @@ test-e2e-set: ## - Run the blackbox end to end tests without setup.
386386
##################################################
387387
.PHONY: test-cloude2e
388388
test-cloude2e: prepare-test-context ## - Run cloude2e tests with full setup (slow!)
389-
@make -C ${CLOUD_TESTING_BASE} cloud-deploy
390-
$(eval FLEET_SERVER_URL := $(shell make -C ${CLOUD_TESTING_BASE} cloud-get-fleet-url))
391-
-@set -o pipefail; $(MAKE) test-cloude2e-set | tee build/test-cloude2e.out
392-
@make -C ${CLOUD_TESTING_BASE} cloud-clean
389+
@# Triggered using a shell script to ensure deployment is cleaned up even if errors (using trap).
390+
@# it would also ensure to exit with failure if any error happens
391+
@$(CLOUD_TESTING_BASE)/launch_cloud_e2e_tests.sh
393392

394393
.PHONY: test-cloude2e-set
395394
test-cloude2e-set: ## Run cloude2e test
396-
$(eval FLEET_SERVER_URL := $(shell make -C ${CLOUD_TESTING_BASE} cloud-get-fleet-url))
395+
$(eval FLEET_SERVER_URL := $(shell make --no-print-directory -C ${CLOUD_TESTING_BASE} cloud-get-fleet-url))
397396
make -C ${CLOUD_TESTING_BASE} cloud-get-fleet-url
398-
FLEET_SERVER_URL=${FLEET_SERVER_URL} go test -v -tags=cloude2e -count=1 -race -p 1 ./testing/cloude2e
397+
FLEET_SERVER_URL="${FLEET_SERVER_URL}" go test -v -tags=cloude2e -count=1 -race -p 1 ./testing/cloude2e

catalog-info.yaml

+43
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,46 @@ spec:
143143
access_level: MANAGE_BUILD_AND_READ
144144
everyone:
145145
access_level: READ_ONLY
146+
---
147+
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
148+
apiVersion: backstage.io/v1alpha1
149+
kind: Resource
150+
metadata:
151+
name: fleet-server-perf-tests
152+
description: Pipeline tests for serverless scale testing a PR
153+
links:
154+
- title: Pipeline
155+
url: https://buildkite.com/elastic/fleet-server-perf-tests
156+
spec:
157+
type: buildkite-pipeline
158+
owner: group:ingest-fp
159+
system: buildkite
160+
implementation:
161+
apiVersion: buildkite.elastic.dev/v1
162+
kind: Pipeline
163+
metadata:
164+
name: fleet-server-perf-tests
165+
description: fleet-server observability-perf tests
166+
spec:
167+
repository: elastic/fleet-server
168+
pipeline_file: .buildkite/pipeline.perf-tests.yaml
169+
branch_configuration: "main"
170+
provider_settings:
171+
build_pull_request_forks: false
172+
build_pull_requests: true
173+
build_tags: false
174+
build_branches: false
175+
filter_enabled: true
176+
filter_condition: >-
177+
build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
178+
cancel_intermediate_builds: true
179+
cancel_intermediate_builds_branch_filter: '!main !7.* !8.*'
180+
skip_intermediate_builds: true
181+
skip_intermediate_builds_branch_filter: '!main !7.* !8.*'
182+
teams:
183+
ingest-fp:
184+
access_level: MANAGE_BUILD_AND_READ
185+
cloud-tooling:
186+
access_level: MANAGE_BUILD_AND_READ
187+
everyone:
188+
access_level: READ_ONLY
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Kind can be one of:
2+
# - breaking-change: a change to previously-documented behavior
3+
# - deprecation: functionality that is being removed in a later release
4+
# - bug-fix: fixes a problem in a previous version
5+
# - enhancement: extends functionality but does not break or fix existing behavior
6+
# - feature: new functionality
7+
# - known-issue: problems that we are aware of in a given version
8+
# - security: impacts on the security of a product or a user’s deployment.
9+
# - upgrade: important information for someone upgrading from a prior version
10+
# - other: does not fit into any of the other categories
11+
kind: bug-fix
12+
13+
# Change summary; a 80ish characters long description of the change.
14+
summary: fix file reassembly for large files
15+
16+
# Long description; in case the summary is not enough to describe the change
17+
# this field accommodate a description without length limits.
18+
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
19+
#description:
20+
21+
# Affected component; a word indicating the component this changeset affects.
22+
component:
23+
24+
# PR URL; optional; the PR number that added the changeset.
25+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
26+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
27+
# Please provide it if you are adding a fragment for a different PR.
28+
pr: 3283
29+
30+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
31+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
32+
#issue: https://github.com/owner/repo/1234

dev-tools/cloud/Makefile

+2-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,5 @@ cloud-clean: ## Clean cloud deployment
3636
@cd ${TERRAFORM_PATH}; terraform destroy -auto-approve
3737

3838
.PHONY: cloud-get-fleet-url
39-
cloud-get-fleet-url: ## Clean cloud deployment
40-
$(eval FLEET_SERVER_URL := $(shell terraform output --state=${TERRAFORM_PATH}/terraform.tfstate fleet_url))
41-
@echo '${FLEET_SERVER_URL}'
42-
39+
cloud-get-fleet-url: ## Get Fleet URL from this deployment
40+
@terraform output --raw --state=${TERRAFORM_PATH}/terraform.tfstate fleet_url

internal/pkg/file/delivery/delivery.go

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"errors"
1111
"fmt"
1212
"io"
13+
"sort"
1314

1415
"github.com/elastic/fleet-server/v7/internal/pkg/bulk"
1516
"github.com/elastic/fleet-server/v7/internal/pkg/file"
@@ -77,6 +78,9 @@ func (d *Deliverer) LocateChunks(ctx context.Context, zlog zerolog.Logger, fileI
7778
func (d *Deliverer) SendFile(ctx context.Context, zlog zerolog.Logger, w io.Writer, chunks []file.ChunkInfo, fileID string) error {
7879
span, ctx := apm.StartSpan(ctx, "response", "write")
7980
defer span.End()
81+
sort.SliceStable(chunks, func(i, j int) bool {
82+
return chunks[i].Pos < chunks[j].Pos
83+
})
8084
for _, chunkInfo := range chunks {
8185
body, err := readChunkStream(ctx, d.client, chunkInfo.Index, chunkInfo.ID)
8286
if err != nil {

internal/pkg/file/delivery/delivery_test.go

+59
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"io"
1414
"io/ioutil"
1515
"net/http"
16+
"strconv"
1617
"strings"
1718
"testing"
1819

@@ -253,6 +254,64 @@ func TestSendFileMultipleChunksUsesBackingIndex(t *testing.T) {
253254
require.NoError(t, err)
254255
}
255256

257+
func TestSendFileHandlesDisorderedChunks(t *testing.T) {
258+
buf := bytes.NewBuffer(nil)
259+
260+
fakeBulk := itesting.NewMockBulk()
261+
esClient, esMock := mockESClient(t)
262+
263+
const fileID = "xyz"
264+
idx := fmt.Sprintf(FileDataIndexPattern, "endpoint") + "-0001"
265+
sampleDocBody := hexDecode("A7665F696E64657878212E666C6565742D66696C6564656C69766572792D646174612D656E64706F696E74635F69646578797A2E30685F76657273696F6E01675F7365715F6E6F016D5F7072696D6172795F7465726D0165666F756E64F5666669656C6473A164646174618142ABCD")
266+
267+
chunks := []file.ChunkInfo{
268+
{Index: idx, ID: fileID + ".20", Pos: 20},
269+
{Index: idx, ID: fileID + ".21", Pos: 21},
270+
{Index: idx, ID: fileID + ".22", Pos: 22},
271+
{Index: idx, ID: fileID + ".9", Pos: 9},
272+
{Index: idx, ID: fileID + ".10", Pos: 10},
273+
{Index: idx, ID: fileID + ".11", Pos: 11},
274+
{Index: idx, ID: fileID + ".12", Pos: 12},
275+
{Index: idx, ID: fileID + ".13", Pos: 13},
276+
{Index: idx, ID: fileID + ".14", Pos: 14},
277+
{Index: idx, ID: fileID + ".15", Pos: 15},
278+
{Index: idx, ID: fileID + ".16", Pos: 16},
279+
{Index: idx, ID: fileID + ".17", Pos: 17},
280+
{Index: idx, ID: fileID + ".18", Pos: 18},
281+
{Index: idx, ID: fileID + ".19", Pos: 19},
282+
{Index: idx, ID: fileID + ".0", Pos: 0},
283+
{Index: idx, ID: fileID + ".1", Pos: 1},
284+
{Index: idx, ID: fileID + ".2", Pos: 2},
285+
{Index: idx, ID: fileID + ".3", Pos: 3},
286+
{Index: idx, ID: fileID + ".4", Pos: 4},
287+
{Index: idx, ID: fileID + ".5", Pos: 5},
288+
{Index: idx, ID: fileID + ".6", Pos: 6},
289+
{Index: idx, ID: fileID + ".7", Pos: 7},
290+
{Index: idx, ID: fileID + ".8", Pos: 8},
291+
}
292+
293+
expectedIdx := 0
294+
295+
esMock.RoundTripFn = func(req *http.Request) (*http.Response, error) {
296+
297+
// Parse out the chunk number requested
298+
parts := strings.Split(req.URL.Path, "/") // ["", ".fleet-filedelivery-data-endpoint-0001", "_doc", "xyz.1"]
299+
docIdx := strings.TrimPrefix(parts[3], fileID+".")
300+
docnum, err := strconv.Atoi(docIdx)
301+
require.NoError(t, err)
302+
303+
// should be our expected increasing counter
304+
assert.Equal(t, expectedIdx, docnum)
305+
expectedIdx += 1
306+
307+
return sendBodyBytes(sampleDocBody), nil
308+
}
309+
310+
d := New(esClient, fakeBulk, -1)
311+
err := d.SendFile(context.Background(), zerolog.Logger{}, buf, chunks, fileID)
312+
require.NoError(t, err)
313+
}
314+
256315
/*
257316
Setup to convert a *elasticsearch.Client as a harmless mock
258317
by replacing the Transport to nowhere

0 commit comments

Comments
 (0)