-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
generate_xpack_metricbeat_pipeline.sh
executable file
·196 lines (168 loc) · 6.02 KB
/
generate_xpack_metricbeat_pipeline.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/env bash
source .buildkite/scripts/common.sh
set -euo pipefail
pipelineName="pipeline.xpack-metricbeat-dynamic.yml"
echo "Add the mandatory and extended tests without additional conditions into the pipeline"
if are_conditions_met_mandatory_tests; then
cat > $pipelineName <<- YAML
steps:
- group: "Mandatory Tests"
key: "mandatory-tests"
steps:
- label: ":linux: Ubuntu Unit Tests"
key: "mandatory-linux-unit-test"
command: "cd $BEATS_PROJECT_NAME && mage build unitTest"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
- label: ":go: Go Integration Tests"
key: "mandatory-int-test"
command: ".buildkite/scripts/go_int_tests.sh"
env:
MODULE: $MODULE
agents:
provider: "gcp"
image: "${DEFAULT_UBUNTU_X86_64_IMAGE}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
- label: ":python: Python Integration Tests"
key: "mandatory-python-int-test"
command: ".buildkite/scripts/py_int_tests.sh"
env:
MODULE: $MODULE
agents:
provider: "gcp"
image: "${DEFAULT_UBUNTU_X86_64_IMAGE}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.xml"
- label: ":windows: Windows Unit Tests - {{matrix.image}}"
command: ".buildkite/scripts/win_unit_tests.ps1"
key: "mandatory-win-unit-tests"
agents:
provider: "gcp"
image: "{{matrix.image}}"
machineType: "${GCP_WIN_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
matrix:
setup:
image:
- "${IMAGE_WIN_2016}"
- "${IMAGE_WIN_2022}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
## TODO: this condition will be changed in the Phase 3 of the Migration Plan https://docs.google.com/document/d/1IPNprVtcnHlem-uyGZM0zGzhfUuFAh4LeSl9JFHMSZQ/edit#heading=h.sltz78yy249h
- group: "Extended Windows Tests"
key: "extended-win-tests"
steps:
- label: ":windows: Windows 10 Unit Tests"
key: "extended-win-10-unit-tests"
command: ".buildkite/scripts/win_unit_tests.ps1"
agents:
provider: "gcp"
image: "${IMAGE_WIN_10}"
machineType: "${GCP_WIN_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
- label: ":windows: Windows 11 Unit Tests"
key: "extended-win-11-unit-tests"
command: ".buildkite/scripts/win_unit_tests.ps1"
agents:
provider: "gcp"
image: "${IMAGE_WIN_11}"
machineType: "${GCP_WIN_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
- label: ":windows: Win 2019 Unit Tests"
key: "extended-win-2019-unit-tests"
command: ".buildkite/scripts/win_unit_tests.ps1"
agents:
provider: "gcp"
image: "${IMAGE_WIN_2019}"
machineType: "${GCP_WIN_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
YAML
else
echo "The conditions don't match to requirements for generating pipeline steps."
exit 0
fi
#TODO: replace by commented-out below condition when issues mentioned in the PR https://github.com/elastic/beats/pull/38081 are resolved
if [[ are_conditions_met_aws_tests || are_conditions_met_macos_tests ]]; then
# if [[ are_conditions_met_macos_tests ]]; then
cat >> $pipelineName <<- YAML
- group: "Extended Tests"
key: "extended-tests"
steps:
YAML
fi
if are_conditions_met_macos_tests; then
cat >> $pipelineName <<- YAML
- label: ":mac: MacOS Unit Tests"
key: "extended-macos-unit-tests"
command: ".buildkite/scripts/unit_tests.sh"
agents:
provider: "orka"
imagePrefix: "${IMAGE_MACOS_X86_64}"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
YAML
fi
if are_conditions_met_aws_tests; then
cat >> $pipelineName <<- YAML
- label: ":linux: ${MODULE^^} Cloud Tests"
key: "extended-cloud-test"
command: ".buildkite/scripts/cloud_tests.sh"
env:
MODULE: $MODULE
agents:
provider: "gcp"
image: "${DEFAULT_UBUNTU_X86_64_IMAGE}"
machineType: "${GCP_DEFAULT_MACHINE_TYPE}"
disk_size: 100
disk_type: "pd-ssd"
artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*"
YAML
fi
echo "Check and add the Packaging into the pipeline"
if are_conditions_met_packaging; then
cat >> $pipelineName <<- YAML
- wait: ~
depends_on:
- step: "mandatory-tests"
allow_failure: false
- group: "Packaging" # TODO: check conditions for future the main pipeline migration: https://github.com/elastic/beats/pull/28589
key: "packaging"
steps:
- label: ":linux: Packaging Linux"
key: "packaging-linux"
command: "cd $BEATS_PROJECT_NAME && mage package"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
machineType: "${GCP_HI_PERF_MACHINE_TYPE}"
env:
PLATFORMS: "${PACKAGING_PLATFORMS}"
- label: ":linux: Packaging ARM"
key: "packaging-arm"
command: "cd $BEATS_PROJECT_NAME && mage package"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "${AWS_ARM_INSTANCE_TYPE}"
env:
PLATFORMS: "${PACKAGING_ARM_PLATFORMS}"
PACKAGES: "docker"
YAML
fi
echo "--- Printing dynamic steps" #TODO: remove if the pipeline is public
cat $pipelineName
echo "--- Loading dynamic steps"
buildkite-agent pipeline upload $pipelineName