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 tests for pkg/agent/controller/traceflow/traceflow_controller.go #4409

Merged
merged 1 commit into from
Dec 13, 2022

Conversation

Atish-iaf
Copy link
Contributor

Add unit tests

For #4142

Signed-off-by: Kumar Atish atish.iaf@gmail.com

@Atish-iaf Atish-iaf self-assigned this Nov 23, 2022
@Atish-iaf Atish-iaf mentioned this pull request Nov 23, 2022
37 tasks
@codecov
Copy link

codecov bot commented Nov 23, 2022

Codecov Report

Merging #4409 (bc55bde) into main (bc55bde) will not change coverage.
The diff coverage is n/a.

❗ Current head bc55bde differs from pull request most recent head 0163404. Consider uploading reports for the commit 0163404 to get more accurate results

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4409   +/-   ##
=======================================
  Coverage   62.00%   62.00%           
=======================================
  Files         392      392           
  Lines       56732    56732           
=======================================
  Hits        35179    35179           
  Misses      18930    18930           
  Partials     2623     2623           
Flag Coverage Δ
integration-tests 34.75% <0.00%> (ø)
kind-e2e-tests 46.50% <0.00%> (ø)
unit-tests 48.82% <0.00%> (ø)

ovsClient *ovsconfigtest.MockOVSBridgeClient
}

func newFakeController(t *testing.T, initObjects []runtime.Object, networkConfig *config.NetworkConfig, nodeConfig *config.NodeConfig) *fakeController {
Copy link
Contributor

Choose a reason for hiding this comment

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

prefer function name and relate to traceflow like newFakeTraceflowController

}
)

type fakeController struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

use specific names for structure like fakeTraceflowController


var (
pod1IP = "1.1.1.1"
pod2IP = "2.2.2.2"
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above, if string type user pod2IPStr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to pod2IPv4, string type can be identified by var type also.

)

var (
pod1IP = "1.1.1.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer using specific types like pod1IPv4 for ipv4

@Atish-iaf Atish-iaf force-pushed the UT/pkg/agent/traceflow/controller branch from 5f94001 to ae289e2 Compare November 24, 2022 11:50
@Atish-iaf Atish-iaf requested a review from tnqn November 24, 2022 12:49
@Atish-iaf Atish-iaf force-pushed the UT/pkg/agent/traceflow/controller branch from ae289e2 to bcebed0 Compare November 28, 2022 04:06

tfc.enqueueTraceflow(tc.tf)

got := tfc.processTraceflowItem()
Copy link
Contributor

Choose a reason for hiding this comment

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

processedTraceflow := tfc.processTraceflowItem()

tfc := newFakeTraceflowController(t, []runtime.Object{tf}, nil, nil, nil)
defer tfc.mockController.Finish()

gotTf, err := tfc.errorTraceflowCRD(tf, reason)
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of gotTf, you can use processedTraceflow, or tfReceived, just a suggestion.

Copy link
Contributor

@jainpulkit22 jainpulkit22 left a comment

Choose a reason for hiding this comment

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

few nits

@Atish-iaf Atish-iaf requested a review from luolanzone November 28, 2022 12:12
@Atish-iaf
Copy link
Contributor Author

@tnqn Can you please review this PR ?
Thanks

@Atish-iaf Atish-iaf force-pushed the UT/pkg/agent/traceflow/controller branch 2 times, most recently from e78ab6f to ba2585d Compare December 9, 2022 13:22
Signed-off-by: Kumar Atish <atish.iaf@gmail.com>
@Atish-iaf Atish-iaf force-pushed the UT/pkg/agent/traceflow/controller branch from ba2585d to 0163404 Compare December 9, 2022 13:24
@Atish-iaf Atish-iaf requested a review from tnqn December 9, 2022 15:17
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@tnqn
Copy link
Member

tnqn commented Dec 13, 2022

/skip-all

@tnqn tnqn merged commit e9490f8 into antrea-io:main Dec 13, 2022
@tnqn
Copy link
Member

tnqn commented Dec 13, 2022

@Atish-iaf please use more meaningful commit title for future PRs, just "Add unit tests" is not helpful to figure out what the commit is created for among so many commits for unit tests.

GraysonWu pushed a commit to GraysonWu/antrea that referenced this pull request Jan 27, 2023
…r.go (antrea-io#4409)

Signed-off-by: Kumar Atish <atish.iaf@gmail.com>
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.

4 participants