etcd-io / gofail Goto Github PK
View Code? Open in Web Editor NEWfailpoints for go
License: Apache License 2.0
failpoints for go
License: Apache License 2.0
When trying to disable enabled failpoint through http DELETE method, the server hangs up:
curl
-L http://localhost:22381/github.com/coreos/gofail/examples/ExampleLabelsGo
-X DELETE
Encountered when running this command on the examples folder
If failpoint is injected within for-loop, lock may never be released. And delete call would block.
OK, defer is broken in general. e.g., this will starve the delete too:
for ctx.Err() == nil {
// gofail: var abc struct{}
// fmt.Println("abc")
whatever()
}
Useful for etcd-io/etcd#17680
If I use a http and setup a failpoint with a long sleep (e.g. 1s), deactivating it runs into a problem.
Execution and failpoint change run under the same lock. Deactivation will be really delayed as it's racing against execution for the same lock. For example in etcd-io/etcd#17680, I want to inject a sleep into watch write loop, results in continuous execution of the endpoint to sleep. As result it can take a long time to deactivate it.
I would expect that failpoint execution only uses lock to copy the failpoint term, and then execution is done outside of critical section, allowing deactivation to be immediate.
Currently there is only unit test. It would be great if we have an e2e test suite, and it's supposed to be triggered on each PR or commits on master.
Now the package path is calculated based on the relative relationship between GOPATH and the directory where the file is located:
Lines 130 to 150 in 51ce9a7
With the go mod support after go1.11, source files can be outside of GOPATH. So when I run gofail, I can see the error: "missing package for %q; using %q as failpoint path".
I can think of several ways to get the package import path more accurately:
go.mod
file which contains the import path of the module.cmd.Exec
to call go list
to get the import path.foo.fail.go
to determine import path.I personally think that the third method is better as it relies less on the executing environment. It can be done by generating such code:
type __fp_foo struct{}
var __fp_fooBar *runtime.Failpoint = runtime.NewFailpoint(reflect.TypeOf(__fp_foo{}).PkgPath(), "fooBar")
After #69 gets merged, we are going to release v0.2.0.
func (t *terms) eval() (interface{}, error) {
t.mu.Lock()
defer t.mu.Unlock()
for _, term := range t.chain {
if term.mods.allow() {
return term.do(), nil
}
}
return nil, nil
}
return term.do(), nil
causes the following term to not be executed
I expect gofail version
could display the info similar to etcd.
$ etcd --version
etcd Version: 3.5.5
Git SHA: 19002cfc6
Go Version: go1.16.15
Go OS/Arch: darwin/amd64
Gofail currently uses golang 1.20 which is no longer supported. We should update to ensure gofail to golang 1.21.8
.
This would involve three updates;
Line 3 in 806f13e
Additionally - We should also keep golangci-lint
up to date by bumping the version here
Let's release the first formal version v0.1.0, and update etcd to pin to the specific version.
We start to track changes in https://github.com/etcd-io/gofail/blob/master/CHANGELOG.md
WDYT?
A go function may return multiple values, such as func a() (string, int).
In this case, how should I define failpoint variables?
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.