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

Add Unit test on pkg/chaosdaemon #232

Merged
merged 17 commits into from
Feb 18, 2020
Merged

Conversation

lucklove
Copy link
Contributor

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

  • Unit test

Code changes

Side effects

Related changes

Does this PR introduce a user-facing change?:

NONE

@zhouqiang-cl zhouqiang-cl changed the title Unit test on pkg/chaosdaemon (WIP) [WIP] Unit test on pkg/chaosdaemon Feb 13, 2020
@@ -0,0 +1,31 @@
// Copyright 2019 PingCAP, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/2019/2020

@codecov-io
Copy link

codecov-io commented Feb 13, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@a73030a). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a73030a...f8789f0. Read the comment docs.

@zhouqiang-cl zhouqiang-cl changed the title [WIP] Unit test on pkg/chaosdaemon Add Unit test on pkg/chaosdaemon Feb 14, 2020
@zhouqiang-cl
Copy link
Contributor

/test

@@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/DockerClientI/DockerClientInterface?

@@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@zhouqiang-cl zhouqiang-cl requested review from YangKeao, cwen0, fewdan and mahjonp and removed request for mahjonp February 15, 2020 02:12
Signed-off-by: lucklove <[email protected]>
@zhouqiang-cl
Copy link
Contributor

@lucklove please solve conflict

@cwen0 cwen0 removed the status/PTAL label Feb 18, 2020
@cwen0
Copy link
Member

cwen0 commented Feb 18, 2020

@YangKeao PTAL

Makefile Show resolved Hide resolved
delete(p.m, fpname)
}

var points = mockPoints{m: make(map[string]interface{})}
Copy link
Member

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.

Copy link
Member

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

Copy link
Contributor Author

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...

Copy link
Member

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.

@YangKeao
Copy link
Member

Add *__failpoint_binding__.go and *.go__failpoint_stash__ to .gitignore?

pkg/chaosdaemon/util_test.go Show resolved Hide resolved
pkg/mock/mock.go Show resolved Hide resolved
@lucklove
Copy link
Contributor Author

Add *__failpoint_binding__.go and *.go__failpoint_stash__ to .gitignore?

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]>
Copy link
Member

@cwen0 cwen0 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

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

LGTM

@zhouqiang-cl zhouqiang-cl merged commit 2dd3672 into chaos-mesh:master Feb 18, 2020
@zhouqiang-cl zhouqiang-cl deleted the lucklove-ut branch February 18, 2020 09:44
sjwsl pushed a commit to sjwsl/chaos-mesh that referenced this pull request May 6, 2021
* Unit test on pkg/chaosdaemon

Signed-off-by: lucklove <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants