forked from alibaba/loongcollector
-
Notifications
You must be signed in to change notification settings - Fork 1
300 lines (262 loc) · 10 KB
/
e2e.yaml
File metadata and controls
300 lines (262 loc) · 10 KB
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# Copyright 2021 iLogtail Authors
#
# Licensed 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.
name: E2E Test
on:
pull_request:
paths-ignore:
- "changes/**"
- "config_server/**"
- "docs/**"
- "example_config/**"
- "k8s_template/**"
- "licenses/**"
- "CHANGELOG.md"
push:
branches:
- main
- 1.*
- 2.*
- 3.*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# 生成E2E测试用例列表
GenerateE2ETestCasesList:
runs-on: ubuntu-latest
outputs:
cases: ${{ steps.discover.outputs.cases }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Discover Test Cases
id: discover
run: |
# 使用JSON格式输出用例列表
cases=($(find test/e2e/test_cases -mindepth 1 -maxdepth 1 -type d -printf "%f\n"))
# 检查是否找到用例
if [ ${#cases[@]} -eq 0 ]; then
echo "Error: No test cases found"
exit 1
fi
# 转换为JSON数组格式
json="["
for i in "${!cases[@]}"; do
json+="\"${cases[$i]}\""
if [ $i -lt $((${#cases[@]}-1)) ]; then
json+=","
fi
done
json+="]"
# 输出JSON到文件和控制台
echo "$json" > cases.json
cat cases.json
echo "cases=$json" >> $GITHUB_OUTPUT
# 生成e2e镜像
GenerateE2ETestImage:
runs-on: arc-runner-set-ilogtail
timeout-minutes: 60
permissions:
packages: write
steps:
- name: Check out code
uses: actions/checkout@v4
with:
submodules: false
- name: Set custom submodule URL and fetch
run: |
SUBMODULE_PATH="core/_thirdparty/coolbpf"
git config submodule.$SUBMODULE_PATH.url "https://github.com/aliyun/coolbpf.git"
git submodule update --init
cd $SUBMODULE_PATH
echo "Current commit: $(git rev-parse HEAD)"
- name: Build Image
run: |
docker build \
--tag aliyun/loongcollector:0.0.1 \
--file ./docker/Dockerfile_edge_linux \
--build-arg VERSION=0.0.1 \
--build-arg BUILD_LOGTAIL_UT=OFF \
--build-arg ENABLE_AGENTSIGHT=ON \
--build-arg ENABLE_COMPATIBLE_MODE=ON \
--build-arg ENABLE_STATIC_LINK_CRT=ON \
--build-arg WITHOUTGDB=ON \
--build-arg WITHSPL=ON \
--build-arg MAKE_JOBS=16 \
--build-arg HOST_OS=Linux \
.
- name: Export Image to Tar
run: docker save -o image.tar aliyun/loongcollector:0.0.1
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: loongcollector-image
path: image.tar
# E2E测试
E2E:
runs-on: ubuntu-latest
needs:
- GenerateE2ETestCasesList
- GenerateE2ETestImage
strategy:
matrix:
test_case: ${{ fromJson(needs.GenerateE2ETestCasesList.outputs.cases) }}
fail-fast: false
timeout-minutes: 60
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23.12
- name: Check out code
uses: actions/checkout@v4
with:
submodules: false
- name: Update Docker-compose to v2
run: |
sudo curl -SL https://github.com/docker/compose/releases/download/v2.7.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: loongcollector-image
- name: Import Image from Tar
run: docker load -i ./image.tar
- name: E2E Behavior Test Case ${{ matrix.test_case }}
env:
TEST_CASE: ${{ matrix.test_case }}
run: |
./scripts/e2e.sh e2e
# E2E测试 - Docker Engine版本兼容性测试
E2EWithDockerEngineVersions:
runs-on: ubuntu-22.04
needs:
- GenerateE2ETestImage
strategy:
matrix:
docker_engine_version: ["29.1", "28.5", "27.5", "26.1", "25.0", "24.0", "23.0", "20.10"]
test_case: ["input_container_stdio", "input_docker_static_file"]
fail-fast: false
timeout-minutes: 60
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23.12
- name: Check out code
uses: actions/checkout@v4
with:
submodules: false
- name: Install Docker Engine ${{ matrix.docker_engine_version }}
run: |
# 移除现有的docker(包括docker-ce)
sudo apt-get remove -y docker docker-engine docker.io docker-ce docker-ce-cli containerd runc 2>/dev/null || true
sudo apt-get purge -y docker docker-engine docker.io docker-ce docker-ce-cli containerd runc 2>/dev/null || true
# 安装依赖
sudo apt-get update
sudo apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-release \
apt-transport-https
# 添加Docker官方GPG密钥
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# 设置Docker仓库
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# 更新包列表
sudo apt-get update
# 根据版本号确定要安装的版本
VERSION="${{ matrix.docker_engine_version }}"
# 查找可用的docker-ce版本
AVAILABLE_VERSIONS=$(apt-cache madison docker-ce | awk '{print $3}' | sort -V)
echo "Available Docker CE versions:"
echo "$AVAILABLE_VERSIONS"
# 根据主版本号匹配
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f2)
# 查找匹配的版本,选择最高的小版本
MATCHED_VERSION=$(echo "$AVAILABLE_VERSIONS" | grep "^5:$MAJOR\.$MINOR\." | tail -1)
if [ -z "$MATCHED_VERSION" ]; then
# 如果找不到精确匹配,尝试匹配主版本号,选择最高版本
MATCHED_VERSION=$(echo "$AVAILABLE_VERSIONS" | grep "^5:$MAJOR\." | tail -1)
fi
if [ -n "$MATCHED_VERSION" ]; then
echo "Installing Docker CE version: $MATCHED_VERSION"
sudo apt-get install -y --allow-downgrades docker-ce=$MATCHED_VERSION docker-ce-cli=$MATCHED_VERSION containerd.io
else
echo "Warning: Exact version $VERSION not found, trying to install latest version in major version $MAJOR"
LATEST_MAJOR=$(echo "$AVAILABLE_VERSIONS" | grep "^5:$MAJOR\." | tail -1)
if [ -n "$LATEST_MAJOR" ]; then
echo "Installing latest available version in major version $MAJOR: $LATEST_MAJOR"
sudo apt-get install -y --allow-downgrades docker-ce=$LATEST_MAJOR docker-ce-cli=$LATEST_MAJOR containerd.io
else
echo "::warning::Docker $VERSION is not available on this Ubuntu version"
echo "Available versions:"
echo "$AVAILABLE_VERSIONS"
echo "Skipping Docker $VERSION test"
exit 0
fi
fi
# 启动Docker服务
sudo systemctl start docker || sudo service docker start
sudo systemctl enable docker || true
# 等待Docker服务就绪
sleep 5
# 输出Docker Engine版本信息
echo "========================================="
echo "Docker Engine Version Information:"
echo "========================================="
docker --version
echo ""
echo "Docker Engine Server Version:"
docker version --format '{{.Server.Version}}'
echo "========================================="
- name: Update Docker-compose to v2
run: |
sudo curl -SL https://github.com/docker/compose/releases/download/v2.7.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: loongcollector-image
- name: Check if Docker is installed
id: check_docker
run: |
if command -v docker &> /dev/null; then
echo "docker_installed=true" >> $GITHUB_OUTPUT
echo "Docker is installed"
else
echo "docker_installed=false" >> $GITHUB_OUTPUT
echo "Docker is not installed, skipping test"
fi
- name: Import Image from Tar
if: steps.check_docker.outputs.docker_installed == 'true'
run: docker load -i ./image.tar
- name: E2E Test with Docker Engine ${{ matrix.docker_engine_version }} - ${{ matrix.test_case }}
if: steps.check_docker.outputs.docker_installed == 'true'
env:
TEST_CASE: ${{ matrix.test_case }}
run: |
./scripts/e2e.sh e2e
actions-timeline:
needs: [E2E, E2EWithDockerEngineVersions]
runs-on: ubuntu-latest
permissions:
actions: read
steps:
- uses: Kesin11/actions-timeline@v2