Skip to content

Commit abaa937

Browse files
mergify[bot]yaauie
andauthored
tests: make integration split quantity configurable (#17219) (#17368)
* 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 (cherry picked from commit 3e0f488) Co-authored-by: Rye Biesemeyer <[email protected]>
1 parent 45fa28a commit abaa937

File tree

6 files changed

+192
-91
lines changed

6 files changed

+192
-91
lines changed

.buildkite/aarch64_pipeline.yml

Lines changed: 35 additions & 12 deletions
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

.buildkite/pull_request_pipeline.yml

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ steps:
7979
manual:
8080
allowed: true
8181

82-
- label: ":lab_coat: Integration Tests / part 1"
83-
key: "integration-tests-part-1"
82+
- label: ":lab_coat: Integration Tests / part 1-of-3"
83+
key: "integration-tests-part-1-of-3"
8484
agents:
8585
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci-no-root"
8686
cpu: "8"
@@ -95,10 +95,10 @@ steps:
9595
set -euo pipefail
9696
9797
source .buildkite/scripts/common/container-agent.sh
98-
ci/integration_tests.sh split 0
98+
ci/integration_tests.sh split 0 3
9999
100-
- label: ":lab_coat: Integration Tests / part 2"
101-
key: "integration-tests-part-2"
100+
- label: ":lab_coat: Integration Tests / part 2-of-3"
101+
key: "integration-tests-part-2-of-3"
102102
agents:
103103
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci-no-root"
104104
cpu: "8"
@@ -113,10 +113,47 @@ steps:
113113
set -euo pipefail
114114
115115
source .buildkite/scripts/common/container-agent.sh
116-
ci/integration_tests.sh split 1
116+
ci/integration_tests.sh split 1 3
117117
118-
- label: ":lab_coat: IT Persistent Queues / part 1"
119-
key: "integration-tests-qa-part-1"
118+
- label: ":lab_coat: Integration Tests / part 3-of-3"
119+
key: "integration-tests-part-3-of-3"
120+
agents:
121+
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci-no-root"
122+
cpu: "8"
123+
memory: "16Gi"
124+
ephemeralStorage: "100Gi"
125+
# Run as a non-root user
126+
imageUID: "1002"
127+
retry:
128+
automatic:
129+
- limit: 3
130+
command: |
131+
set -euo pipefail
132+
133+
source .buildkite/scripts/common/container-agent.sh
134+
ci/integration_tests.sh split 2 3
135+
136+
- label: ":lab_coat: IT Persistent Queues / part 1-of-3"
137+
key: "integration-tests-qa-part-1-of-3"
138+
agents:
139+
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci-no-root"
140+
cpu: "8"
141+
memory: "16Gi"
142+
ephemeralStorage: "100Gi"
143+
# Run as non root (logstash) user. UID is hardcoded in image.
144+
imageUID: "1002"
145+
retry:
146+
automatic:
147+
- limit: 3
148+
command: |
149+
set -euo pipefail
150+
151+
source .buildkite/scripts/common/container-agent.sh
152+
export FEATURE_FLAG=persistent_queues
153+
ci/integration_tests.sh split 0 3
154+
155+
- label: ":lab_coat: IT Persistent Queues / part 2-of-3"
156+
key: "integration-tests-qa-part-2-of-3"
120157
agents:
121158
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci-no-root"
122159
cpu: "8"
@@ -132,10 +169,10 @@ steps:
132169
133170
source .buildkite/scripts/common/container-agent.sh
134171
export FEATURE_FLAG=persistent_queues
135-
ci/integration_tests.sh split 0
172+
ci/integration_tests.sh split 1 3
136173
137-
- label: ":lab_coat: IT Persistent Queues / part 2"
138-
key: "integration-tests-qa-part-2"
174+
- label: ":lab_coat: IT Persistent Queues / part 3-of-3"
175+
key: "integration-tests-qa-part-3-of-3"
139176
agents:
140177
image: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-logstash-ci-no-root"
141178
cpu: "8"
@@ -151,7 +188,7 @@ steps:
151188
152189
source .buildkite/scripts/common/container-agent.sh
153190
export FEATURE_FLAG=persistent_queues
154-
ci/integration_tests.sh split 1
191+
ci/integration_tests.sh split 2 3
155192
156193
- label: ":lab_coat: x-pack unit tests"
157194
key: "x-pack-unit-tests"

.buildkite/scripts/jdk-matrix-tests/generate-steps.py

Lines changed: 21 additions & 29 deletions
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(

ci/get-test-half.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

ci/integration_tests.sh

Lines changed: 9 additions & 11 deletions
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)