-
Notifications
You must be signed in to change notification settings - Fork 850
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
Add Unit test on pkg/chaosdaemon #232
Conversation
Signed-off-by: lucklove <[email protected]>
pkg/chaosdaemon/setup_test.go
Outdated
@@ -0,0 +1,31 @@ | |||
// Copyright 2019 PingCAP, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/2019/2020
Codecov Report
@@ Coverage Diff @@
## master #232 +/- ##
=========================================
Coverage ? 38.31%
=========================================
Files ? 33
Lines ? 1438
Branches ? 0
=========================================
Hits ? 551
Misses ? 814
Partials ? 73 Continue to review full report at Codecov.
|
/test |
pkg/chaosdaemon/util.go
Outdated
@@ -44,9 +45,14 @@ type ContainerRuntimeInfoClient interface { | |||
ContainerKillByContainerID(ctx context.Context, containerID string) error | |||
} | |||
|
|||
// DockerClientI represents the DockerClient, it's used to simply unit test | |||
type DockerClientI interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/DockerClientI/DockerClientInterface?
pkg/chaosdaemon/util.go
Outdated
@@ -62,9 +68,14 @@ func (c DockerClient) GetPidFromContainerID(ctx context.Context, containerID str | |||
return uint32(container.State.Pid), nil | |||
} | |||
|
|||
// ContainerdClientI represents the ContainerClient, it's used to simply unit test | |||
type ContainerdClientI interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Signed-off-by: lucklove <[email protected]>
Signed-off-by: lucklove <[email protected]>
Signed-off-by: lucklove <[email protected]>
f6514dd
to
5beafdb
Compare
Signed-off-by: lucklove <[email protected]>
1843438
to
81f2781
Compare
@lucklove please solve conflict |
@YangKeao PTAL |
delete(p.m, fpname) | ||
} | ||
|
||
var points = mockPoints{m: make(map[string]interface{})} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't thinks we have to share variables with failpoint injection.
In my opinion, if you want to inject multiple different errors, using multiple failpoint seems a better idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the keao
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand very well, how to archive this? Can you write a tiny demo? We need inject mock values among packages and the values can be any type...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well! I agree that there is no better way. It's ok for me.
Add |
Better not, if someone enable failpoint and forget disable it before submit, another one can revert it by disable failpoint, if these files are ignored, the compile fails and can't be restored |
Signed-off-by: lucklove <[email protected]>
Signed-off-by: lucklove <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Unit test on pkg/chaosdaemon Signed-off-by: lucklove <[email protected]>
Signed-off-by: lucklove [email protected]
What problem does this PR solve?
Add unit test
What is changed and how does it work?
Add unit test
Check List
Tests
Code changes
Side effects
Related changes
Does this PR introduce a user-facing change?: