Skip to content

Commit 3e0f488

Browse files
authored
tests: make integration split quantity configurable (#17219)
* tests: make integration split quantity configurable Refactors shared splitter bash function to take a list of files on stdin and split into a configurable number of partitions, emitting only those from the currently-selected partition to stdout. Also refactors the only caller in the integration_tests launcher script to accept an optional partition_count parameter (defaulting to `2` for backward- compatibility), to provide the list of specs to the function's stdin, and to output relevant information about the quantity of partition splits and which was selected. * ci: run integration tests in 3 parts
1 parent 7683983 commit 3e0f488

File tree

6 files changed

+192
-91
lines changed

6 files changed

+192
-91
lines changed

Diff for: .buildkite/aarch64_pipeline.yml

+35-12
Original file line numberDiff line numberDiff line change
@@ -35,48 +35,71 @@ steps:
3535
automatic:
3636
- limit: 3
3737

38-
- label: ":lab_coat: Integration Tests / part 1"
39-
key: "integration-tests-part-1"
38+
- label: ":lab_coat: Integration Tests / part 1-of-3"
39+
key: "integration-tests-part-1-of-3"
4040
command: |
4141
set -euo pipefail
4242
4343
source .buildkite/scripts/common/vm-agent.sh
44-
ci/integration_tests.sh split 0
44+
ci/integration_tests.sh split 0 3
4545
retry:
4646
automatic:
4747
- limit: 3
4848

49-
- label: ":lab_coat: Integration Tests / part 2"
50-
key: "integration-tests-part-2"
49+
- label: ":lab_coat: Integration Tests / part 2-of-3"
50+
key: "integration-tests-part-2-of-3"
5151
command: |
5252
set -euo pipefail
5353
5454
source .buildkite/scripts/common/vm-agent.sh
55-
ci/integration_tests.sh split 1
55+
ci/integration_tests.sh split 1 3
5656
retry:
5757
automatic:
5858
- limit: 3
5959

60-
- label: ":lab_coat: IT Persistent Queues / part 1"
61-
key: "integration-tests-qa-part-1"
60+
- label: ":lab_coat: Integration Tests / part 3-of-3"
61+
key: "integration-tests-part-3-of-3"
62+
command: |
63+
set -euo pipefail
64+
65+
source .buildkite/scripts/common/vm-agent.sh
66+
ci/integration_tests.sh split 2 3
67+
retry:
68+
automatic:
69+
- limit: 3
70+
71+
- label: ":lab_coat: IT Persistent Queues / part 1-of-3"
72+
key: "integration-tests-qa-part-1-of-3"
73+
command: |
74+
set -euo pipefail
75+
76+
source .buildkite/scripts/common/vm-agent.sh
77+
export FEATURE_FLAG=persistent_queues
78+
ci/integration_tests.sh split 0 3
79+
retry:
80+
automatic:
81+
- limit: 3
82+
83+
- label: ":lab_coat: IT Persistent Queues / part 2-of-3"
84+
key: "integration-tests-qa-part-2-of-3"
6285
command: |
6386
set -euo pipefail
6487
6588
source .buildkite/scripts/common/vm-agent.sh
6689
export FEATURE_FLAG=persistent_queues
67-
ci/integration_tests.sh split 0
90+
ci/integration_tests.sh split 1 3
6891
retry:
6992
automatic:
7093
- limit: 3
7194

72-
- label: ":lab_coat: IT Persistent Queues / part 2"
73-
key: "integration-tests-qa-part-2"
95+
- label: ":lab_coat: IT Persistent Queues / part 3-of-3"
96+
key: "integration-tests-qa-part-3-of-3"
7497
command: |
7598
set -euo pipefail
7699
77100
source .buildkite/scripts/common/vm-agent.sh
78101
export FEATURE_FLAG=persistent_queues
79-
ci/integration_tests.sh split 1
102+
ci/integration_tests.sh split 2 3
80103
retry:
81104
automatic:
82105
- limit: 3

Diff for: .buildkite/pull_request_pipeline.yml

+49-12
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ steps:
8181
manual:
8282
allowed: true
8383

84-
- label: ":lab_coat: Integration Tests / part 1"
85-
key: "integration-tests-part-1"
84+
- label: ":lab_coat: Integration Tests / part 1-of-3"
85+
key: "integration-tests-part-1-of-3"
8686
agents:
8787
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci-no-root"
8888
cpu: "8"
@@ -97,10 +97,10 @@ steps:
9797
set -euo pipefail
9898
9999
source .buildkite/scripts/common/container-agent.sh
100-
ci/integration_tests.sh split 0
100+
ci/integration_tests.sh split 0 3
101101
102-
- label: ":lab_coat: Integration Tests / part 2"
103-
key: "integration-tests-part-2"
102+
- label: ":lab_coat: Integration Tests / part 2-of-3"
103+
key: "integration-tests-part-2-of-3"
104104
agents:
105105
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci-no-root"
106106
cpu: "8"
@@ -115,10 +115,47 @@ steps:
115115
set -euo pipefail
116116
117117
source .buildkite/scripts/common/container-agent.sh
118-
ci/integration_tests.sh split 1
118+
ci/integration_tests.sh split 1 3
119119
120-
- label: ":lab_coat: IT Persistent Queues / part 1"
121-
key: "integration-tests-qa-part-1"
120+
- label: ":lab_coat: Integration Tests / part 3-of-3"
121+
key: "integration-tests-part-3-of-3"
122+
agents:
123+
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci-no-root"
124+
cpu: "8"
125+
memory: "16Gi"
126+
ephemeralStorage: "100Gi"
127+
# Run as a non-root user
128+
imageUID: "1002"
129+
retry:
130+
automatic:
131+
- limit: 3
132+
command: |
133+
set -euo pipefail
134+
135+
source .buildkite/scripts/common/container-agent.sh
136+
ci/integration_tests.sh split 2 3
137+
138+
- label: ":lab_coat: IT Persistent Queues / part 1-of-3"
139+
key: "integration-tests-qa-part-1-of-3"
140+
agents:
141+
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci-no-root"
142+
cpu: "8"
143+
memory: "16Gi"
144+
ephemeralStorage: "100Gi"
145+
# Run as non root (logstash) user. UID is hardcoded in image.
146+
imageUID: "1002"
147+
retry:
148+
automatic:
149+
- limit: 3
150+
command: |
151+
set -euo pipefail
152+
153+
source .buildkite/scripts/common/container-agent.sh
154+
export FEATURE_FLAG=persistent_queues
155+
ci/integration_tests.sh split 0 3
156+
157+
- label: ":lab_coat: IT Persistent Queues / part 2-of-3"
158+
key: "integration-tests-qa-part-2-of-3"
122159
agents:
123160
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci-no-root"
124161
cpu: "8"
@@ -134,10 +171,10 @@ steps:
134171
135172
source .buildkite/scripts/common/container-agent.sh
136173
export FEATURE_FLAG=persistent_queues
137-
ci/integration_tests.sh split 0
174+
ci/integration_tests.sh split 1 3
138175
139-
- label: ":lab_coat: IT Persistent Queues / part 2"
140-
key: "integration-tests-qa-part-2"
176+
- label: ":lab_coat: IT Persistent Queues / part 3-of-3"
177+
key: "integration-tests-qa-part-3-of-3"
141178
agents:
142179
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci-no-root"
143180
cpu: "8"
@@ -153,7 +190,7 @@ steps:
153190
154191
source .buildkite/scripts/common/container-agent.sh
155192
export FEATURE_FLAG=persistent_queues
156-
ci/integration_tests.sh split 1
193+
ci/integration_tests.sh split 2 3
157194
158195
- label: ":lab_coat: x-pack unit tests"
159196
key: "x-pack-unit-tests"

Diff for: .buildkite/scripts/jdk-matrix-tests/generate-steps.py

+21-29
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,15 @@ def __init__(self, os: str, jdk: str, group_key: str, agent: typing.Union[GCPAge
177177
super().__init__(os=os, jdk=jdk, group_key=group_key, agent=agent)
178178

179179
def all_jobs(self) -> list[typing.Callable[[], JobRetValues]]:
180-
return [
181-
self.init_annotation,
182-
self.java_unit_test,
183-
self.ruby_unit_test,
184-
self.integration_tests_part_1,
185-
self.integration_tests_part_2,
186-
self.pq_integration_tests_part_1,
187-
self.pq_integration_tests_part_2,
188-
self.x_pack_unit_tests,
189-
self.x_pack_integration,
190-
]
180+
jobs=list()
181+
jobs.append(self.init_annotation)
182+
jobs.append(self.java_unit_test)
183+
jobs.append(self.ruby_unit_test)
184+
jobs.extend(self.integration_test_parts(3))
185+
jobs.extend(self.pq_integration_test_parts(3))
186+
jobs.append(self.x_pack_unit_tests)
187+
jobs.append(self.x_pack_integration)
188+
return jobs
191189

192190
def prepare_shell(self) -> str:
193191
jdk_dir = f"/opt/buildkite-agent/.java/{self.jdk}"
@@ -259,17 +257,14 @@ def ruby_unit_test(self) -> JobRetValues:
259257
retry=copy.deepcopy(ENABLED_RETRIES),
260258
)
261259

262-
def integration_tests_part_1(self) -> JobRetValues:
263-
return self.integration_tests(part=1)
260+
def integration_test_parts(self, parts) -> list[JobRetValues]:
261+
return list(map(lambda idx: integration_tests(self, idx+1, parts), range(parts))
264262

265-
def integration_tests_part_2(self) -> JobRetValues:
266-
return self.integration_tests(part=2)
267-
268-
def integration_tests(self, part: int) -> JobRetValues:
269-
step_name_human = f"Integration Tests - {part}"
270-
step_key = f"{self.group_key}-integration-tests-{part}"
263+
def integration_tests(self, part: int, parts: int) -> JobRetValues:
264+
step_name_human = f"Integration Tests - {part}/{parts}"
265+
step_key = f"{self.group_key}-integration-tests-{part}-of-{parts}"
271266
test_command = f"""
272-
ci/integration_tests.sh split {part-1}
267+
ci/integration_tests.sh split {part-1} {parts}
273268
"""
274269

275270
return JobRetValues(
@@ -281,18 +276,15 @@ def integration_tests(self, part: int) -> JobRetValues:
281276
retry=copy.deepcopy(ENABLED_RETRIES),
282277
)
283278

284-
def pq_integration_tests_part_1(self) -> JobRetValues:
285-
return self.pq_integration_tests(part=1)
286-
287-
def pq_integration_tests_part_2(self) -> JobRetValues:
288-
return self.pq_integration_tests(part=2)
279+
def pq_integration_test_parts(self, parts) -> list[JobRetValues]:
280+
return list(map(lambda idx: pq_integration_tests(self, idx+1, parts), range(parts))
289281

290-
def pq_integration_tests(self, part: int) -> JobRetValues:
291-
step_name_human = f"IT Persistent Queues - {part}"
292-
step_key = f"{self.group_key}-it-persistent-queues-{part}"
282+
def pq_integration_tests(self, part: int, parts: int) -> JobRetValues:
283+
step_name_human = f"IT Persistent Queues - {part}/{parts}"
284+
step_key = f"{self.group_key}-it-persistent-queues-{part}-of-{parts}"
293285
test_command = f"""
294286
export FEATURE_FLAG=persistent_queues
295-
ci/integration_tests.sh split {part-1}
287+
ci/integration_tests.sh split {part-1} {parts}
296288
"""
297289

298290
return JobRetValues(

Diff for: ci/get-test-half.sh

-27
This file was deleted.

Diff for: ci/integration_tests.sh

+9-11
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ export GRADLE_OPTS="-Xmx2g -Dorg.gradle.jvmargs=-Xmx2g -Dorg.gradle.daemon=false
1010
export SPEC_OPTS="--order rand --format documentation"
1111
export CI=true
1212

13-
# Source shared function for splitting integration tests
14-
source "$(dirname "${BASH_SOURCE[0]}")/get-test-half.sh"
15-
1613
if [ -n "$BUILD_JAVA_HOME" ]; then
1714
GRADLE_OPTS="$GRADLE_OPTS -Dorg.gradle.java.home=$BUILD_JAVA_HOME"
1815
fi
@@ -22,14 +19,15 @@ if [[ $1 = "setup" ]]; then
2219
exit 0
2320

2421
elif [[ $1 == "split" ]]; then
25-
if [[ $2 =~ ^[01]$ ]]; then
26-
specs=$(get_test_half "$2")
27-
echo "Running half $2 of integration specs: $specs"
28-
./gradlew runIntegrationTests -PrubyIntegrationSpecs="$specs" --console=plain
29-
else
30-
echo "Error, must specify 0 or 1 after the split. For example ci/integration_tests.sh split 0"
31-
exit 1
32-
fi
22+
# Source shared function for splitting integration tests
23+
source "$(dirname "${BASH_SOURCE[0]}")/partition-files.lib.sh"
24+
25+
index="${2:?index}"
26+
count="${3:-2}"
27+
specs=($(cd qa/integration; partition_files "${index}" "${count}" < <(find specs -name '*_spec.rb') ))
28+
29+
echo "Running integration tests partition[${index}] of ${count}: ${specs[*]}"
30+
./gradlew runIntegrationTests -PrubyIntegrationSpecs="${specs[*]}" --console=plain
3331

3432
elif [[ ! -z $@ ]]; then
3533
echo "Running integration tests 'rspec $@'"

0 commit comments

Comments
 (0)