How to use failpoint in go test
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- go
- 领域
- testing-qa
调研方向
使用 main_test.go、main.go、binding__failpoint_binding__.go 以及所示的 go test 命令重现该报告。将观察到的结果与预期结果 4 进行比较,然后检查 failpoint-toolexec 和 GO_FAILPOINTS 的集成,以确定配置在哪里丢失。当提供的测试命令产生 result: 4,或使用限制已被记录时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
[root@xxx]# cat main_test.go
package main
import (
"testing"
"github.com/pingcap/failpoint"
)
func TestGetValue(t *testing.T) {
failpoint.Enable("main/failpoint-name","return(4)")
t.Log("result:", GetValue())
}
[root@xxx]# cat main.go
package main
import (
"fmt"
"github.com/pingcap/failpoint"
)
func GetValue() int {
if val, _err_ := failpoint.Eval(_curpkg_("failpoint-name")); _err_ == nil {
return val.(int)
}
return 1
}
func main() {
fmt.Println("Hello world ", GetValue())
}
[root@xxx]# GOCACHE=/tmp/failpoint-cache GO_FAILPOINTS="main/failpoint-name=return(4)" CGO_ENABLED=1 GO111MODULE=on go test-v -toolexec /usr/bin/failpoint-toolexec main_test.go main.go binding__failpoint_binding__.go
=== RUN TestGetValue
main_test.go:10: result: 1
--- PASS: TestGetValue (0.00s)
PASS
ok command-line-arguments 0.006s
expect:
[root@xxx]# GOCACHE=/tmp/failpoint-cache GO_FAILPOINTS="main/failpoint-name=return(4)" CGO_ENABLED=1 GO111MODULE=on go test-v -toolexec /usr/bin/failpoint-toolexec main_test.go main.go binding__failpoint_binding__.go
=== RUN TestGetValue
main_test.go:10: result: 4
--- PASS: TestGetValue (0.00s)
PASS
- 主要语言
- Go
- 星标
- 896
- 派生
- 69
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pingcap/failpoint 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 30/100
-
expect `Enable()` inTerm:'off' does not trigger failpoint code, but it's not as expect可能已有人在做 @1fanwang 于 28 天前认领。 未关闭bug
难度 3/5 1-2 天 新手友好度 45/100
-
bug
难度 3/5 1-2 天 新手友好度 35/100
-
bug
难度 3/5 1-2 天 新手友好度 45/100
-
难度 4/5 3-5 天 新手友好度 35/100
查看 pingcap/failpoint 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
scaleway/scaleway-cli#6492 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
taskcluster/taskcluster#9284 · 1 条评论 ·
维护者通常 1 天内回复
-
Review backlog (docs-currency): operator-reference.md dependency-bot sweep paragraph does not mention the transient-triage wording可能已有人在做 @hivecommons-hive 今天认领。 未关闭agent/reviewer approved-direction help wanted hive/claimed-by-scanner
难度 1/5 1 小时以内 新手友好度 82/100
hivecommons/hive#13025 · 7 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
-
难度 2/5 1-3 小时 新手友好度 68/100
fluxcd/go-git-providers#329 ·