Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement failpoint counter #58

Merged
merged 2 commits into from
Nov 12, 2023
Merged

Conversation

ZhouJianMS
Copy link
Contributor

@ZhouJianMS ZhouJianMS commented Nov 9, 2023

This is PR based out of @ramil600 PR #37 and @pchan PR #47 and is intended to address etcd-io/etcd#14729.

New changes include:

  1. Update the design doc and readme (#47(comment1))
  2. Move tests to terms_test.go (#47(comment2))

cc: @ramil600 @pchan @serathius @ahrtr @lavacat

Signed-off-by: Ramil Mirhasanov <ramil600@yahoo.com>
Signed-off-by: Prasad Chandrasekaran <prasadc@vmware.com>
Co-authored-by: Marek Siarkowicz <marek.siarkowicz@protonmail.com>
Co-authored-by: Benjamin Wang <wachao@vmware.com>
runtime/http.go Outdated
lines[i] = fps[i] + "=" + s
}
w.Write([]byte(strings.Join(lines, "\n") + "\n"))
} else if strings.HasSuffix(key, "/execution-count") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think the change from "/count" to "/execution-count" was needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recovered to "/count"

Copy link
Member

@serathius serathius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge it and start using in robustness tests so we can iterate.

@serathius
Copy link
Member

Please fix the failures

@ZhouJianMS
Copy link
Contributor Author

Please fix the failures

lint failures fixed, please review

doc/design.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
runtime/terms_test.go Outdated Show resolved Hide resolved
@serathius
Copy link
Member

cc @ahrtr

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good with two minor comments. Thanks.

doc/design.md Outdated
@@ -69,6 +69,16 @@ Similarly, you can set multiple failpoints using endpoint `/failpoints`,
curl http://127.0.0.1:22381/failpoints -X PUT -d'failpoint1=return("hello");failpoint2=sleep(10)'
```

You can get the execution count of the failpoint in the dynamic way,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
You can get the execution count of the failpoint in the dynamic way,
You can get the execution count of a failpoint in the dynamic way,

Comment on lines 84 to 88
// This example tests mods which allows users to restrict the
// number of failpoint actions as against their callsite executions.
// This is the reason why wantCount < runAfterEnabling
// In a real world example you can hit a code spot a million times but
// using mods restrict the associated fallpoint actions to run twice.
Copy link
Member

@ahrtr ahrtr Nov 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good test case, but the comment isn't clear to me.

Suggested change
// This example tests mods which allows users to restrict the
// number of failpoint actions as against their callsite executions.
// This is the reason why wantCount < runAfterEnabling
// In a real world example you can hit a code spot a million times but
// using mods restrict the associated fallpoint actions to run twice.
// Note the chain of terms is allowed to be executed 11 times at most,
// including 10 times for the first term `10*sleep(10)` and 1 time for
// the second term `1*return("abc")`. So it's only evaluated 11 times
// even it's triggered 12 times.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks for your suggestions!

Copy link
Member

@jmhbnz jmhbnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @ZhouJianMS. Looks good, one minor suggestion below.

runtime/http.go Outdated
fp := key[:len(key)-len("/count")]
_, count, err := status(fp)
if err != nil {
if err == ErrNoExist {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - Suggest errors.Is.

Suggested change
if err == ErrNoExist {
if errors.Is(err, io.ErrNoExist) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks for your suggestion!

Signed-off-by: ZhouJianMS <zhoujian@microsoft.com>
Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Thanks.

@ahrtr ahrtr merged commit a18b2d2 into etcd-io:master Nov 12, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants