Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
Container registry
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
3eba2ad1
提交
3eba2ad1
编辑于
2 years ago
作者:
Brian Williams
提交者:
Michael Kozono
2 years ago
浏览文件
操作
下载
补丁
差异文件
Allow PipelineTestReportBuilder to handle missing test reports
上级
fae108c9
No related branches found
No related tags found
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
scripts/pipeline_test_report_builder.rb
+6
-1
6 个添加, 1 个删除
scripts/pipeline_test_report_builder.rb
spec/scripts/pipeline_test_report_builder_spec.rb
+42
-6
42 个添加, 6 个删除
spec/scripts/pipeline_test_report_builder_spec.rb
有
48 个添加
和
7 个删除
scripts/pipeline_test_report_builder.rb
+
6
−
1
浏览文件 @
3eba2ad1
...
@@ -72,6 +72,10 @@ def failed_builds_for_pipeline(pipeline)
...
@@ -72,6 +72,10 @@ def failed_builds_for_pipeline(pipeline)
# Please see for more info: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69053#note_709939709
# Please see for more info: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69053#note_709939709
def
test_report_for_build
(
pipeline
,
build_id
)
def
test_report_for_build
(
pipeline
,
build_id
)
fetch
(
"
#{
pipeline
[
'web_url'
]
}
/tests/suite.json?build_ids[]=
#{
build_id
}
"
)
fetch
(
"
#{
pipeline
[
'web_url'
]
}
/tests/suite.json?build_ids[]=
#{
build_id
}
"
)
rescue
Net
::
HTTPServerException
=>
e
raise
e
unless
e
.
response
.
code
==
404
puts
"Artifacts not found. They may have expired. Skipping this build."
end
end
def
build_test_report_json_for_pipeline
(
pipeline
)
def
build_test_report_json_for_pipeline
(
pipeline
)
...
@@ -92,7 +96,8 @@ def build_test_report_json_for_pipeline(pipeline)
...
@@ -92,7 +96,8 @@ def build_test_report_json_for_pipeline(pipeline)
test_report
[
'suites'
]
||=
[]
test_report
[
'suites'
]
||=
[]
failed_builds_for_test_stage
.
each
do
|
failed_build
|
failed_builds_for_test_stage
.
each
do
|
failed_build
|
test_report
[
'suites'
]
<<
test_report_for_build
(
pipeline
,
failed_build
[
'id'
])
suite
=
test_report_for_build
(
pipeline
,
failed_build
[
'id'
])
test_report
[
'suites'
]
<<
suite
if
suite
end
end
end
end
...
...
此差异已折叠。
点击以展开。
spec/scripts/pipeline_test_report_builder_spec.rb
+
42
−
6
浏览文件 @
3eba2ad1
...
@@ -103,16 +103,18 @@
...
@@ -103,16 +103,18 @@
end
end
describe
'#test_report_for_latest_pipeline'
do
describe
'#test_report_for_latest_pipeline'
do
let
(
:failed_build_uri
)
{
"
#{
failed_pipeline_url
}
/tests/suite.json?build_ids[]=
#{
failed_build_id
}
"
}
before
do
allow
(
subject
).
to
receive
(
:fetch
).
with
(
failed_build_uri
).
and_return
(
failed_builds_for_pipeline
)
end
it
'fetches builds from pipeline related to MR'
do
it
'fetches builds from pipeline related to MR'
do
expect
(
subject
).
to
receive
(
:fetch
).
with
(
"
#{
failed_pipeline_url
}
/tests/suite.json?build_ids[]=
#{
failed_build_id
}
"
).
and_return
(
failed_builds_for_pipeline
)
expect
ed
=
{
"suites"
=>
[
failed_builds_for_pipeline
]
}.
to_json
subject
.
test_report_for_latest_pipeline
expect
(
subject
.
test_report_for_latest_pipeline
).
to
eq
(
expected
)
end
end
context
'canonical pipeline'
do
context
'canonical pipeline'
do
before
do
allow
(
subject
).
to
receive
(
:test_report_for_build
).
and_return
(
test_report_for_build
)
end
context
'no previous pipeline'
do
context
'no previous pipeline'
do
let
(
:mr_pipelines
)
{
[]
}
let
(
:mr_pipelines
)
{
[]
}
...
@@ -171,6 +173,10 @@
...
@@ -171,6 +173,10 @@
end
end
context
'failed pipeline and failed test builds'
do
context
'failed pipeline and failed test builds'
do
before
do
allow
(
subject
).
to
receive
(
:fetch
).
with
(
failed_build_uri
).
and_return
(
test_report_for_build
)
end
it
'returns populated test list for suites'
do
it
'returns populated test list for suites'
do
actual
=
subject
.
test_report_for_latest_pipeline
actual
=
subject
.
test_report_for_latest_pipeline
expected
=
{
expected
=
{
...
@@ -180,6 +186,36 @@
...
@@ -180,6 +186,36 @@
expect
(
actual
).
to
eq
(
expected
)
expect
(
actual
).
to
eq
(
expected
)
end
end
end
end
context
'when receiving a server error'
do
let
(
:response
)
{
instance_double
(
'Net::HTTPResponse'
)
}
let
(
:error
)
{
Net
::
HTTPServerException
.
new
(
'server error'
,
response
)
}
let
(
:test_report_for_latest_pipeline
)
{
subject
.
test_report_for_latest_pipeline
}
before
do
allow
(
response
).
to
receive
(
:code
).
and_return
(
response_code
)
allow
(
subject
).
to
receive
(
:fetch
).
with
(
failed_build_uri
).
and_raise
(
error
)
end
context
'when response code is 404'
do
let
(
:response_code
)
{
404
}
it
'continues without the missing reports'
do
expected
=
{
'suites'
=>
[]
}.
to_json
expect
{
test_report_for_latest_pipeline
}.
not_to
raise_error
expect
(
test_report_for_latest_pipeline
).
to
eq
(
expected
)
end
end
context
'when response code is unexpected'
do
let
(
:response_code
)
{
500
}
it
'raises HTTPServerException'
do
expect
{
test_report_for_latest_pipeline
}.
to
raise_error
(
error
)
end
end
end
end
end
end
end
end
end
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录