GithubHelp home page GithubHelp logo

gofail's People

Contributors

ahrtr avatar arkasaha30 avatar dependabot[bot] avatar elbehery avatar ericchiang avatar gyuho avatar henrybear327 avatar heyitsanthony avatar ivanvc avatar jmhbnz avatar lorneli avatar mzacho avatar ramil600 avatar serathius avatar spzala avatar xiang90 avatar zhoujianms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gofail's Issues

failpoint delete may block on "defer Release"

If failpoint is injected within for-loop, lock may never be released. And delete call would block.

#13 (comment)

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()
}

Execution of failpoint should not block deactivation

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.

Add e2e test

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.

Failed to determine package path when source file is not inside GOPATH

Now the package path is calculated based on the relative relationship between GOPATH and the directory where the file is located:

gofail/gofail.go

Lines 130 to 150 in 51ce9a7

pkgAbsDir := path.Dir(file)
pkg := path.Base(pkgAbsDir)
pkgDir := ""
for _, srcdir := range build.Default.SrcDirs() {
if strings.HasPrefix(pkgAbsDir, srcdir) {
pkgDir = strings.Replace(pkgAbsDir, srcdir, "", 1)
break
}
}
fppath := pkg
if pkgDir == "" {
fmt.Fprintf(
os.Stderr,
"missing package for %q; using %q as failpoint path\n",
pkgAbsDir,
pkg)
} else {
fppath = pkgDir[1:]
}
code.NewBinding(pkg, fppath, fps).Write(out)
out.Close()

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:

  1. Search parent directories for the go.mod file which contains the import path of the module.
  2. Use cmd.Exec to call go list to get the import path.
  3. Use reflect in generated 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")

`sleep(1000)->100.0%panic` ,panic is not executed

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

Implement `gofail version` command

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

Update gofail golang and golangci-lint versions

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;

go-version: 1.20.10

go-version: 1.20.10

go 1.20

Additionally - We should also keep golangci-lint up to date by bumping the version here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.