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

Fix deepsource: VET-V0008 Lock erroneously passed by value (pkg/agent) #1868

Merged

Conversation

kevindiu
Copy link
Contributor

@kevindiu kevindiu commented Nov 24, 2022

Description:

SSIA.

For the test implementation fix of vqueue/queue_test.go, I have applied the fix to the test case implementation like below.

type uiimNoLock struct {
	read   atomic.Value
	dirty  map[string]*entryUiim
	misses int
}

...
type fields struct {
		uii  []index
        // define internal structure of uiim without mu
		uiim uiimNoLock
....
	tests := []test{
		func() test {
			var uiim uiim
			for _, idx := range uii {
				uiim.Store(idx.uuid, idx)
			}

			return test{
				name: "return (nil, false) when the uiid dose not exist in uiim",
				fields: fields{
        // copy the uiim internal values created from the test case
					uiim: uiimNoLock{
						read:   uiim.read,
						dirty:  uiim.dirty,
						misses: uiim.misses,
					},
				},
....

	for _, tc := range tests {
		test := tc
		t.Run(test.name, func(tt *testing.T) {
....
			v := &vqueue{
				uii: test.fields.uii,
         // copy the value to uiim
				uiim: uiim{
					read:   test.fields.uiim.read,
					dirty:  test.fields.uiim.dirty,
					misses: test.fields.uiim.misses,
				},

Related Issue:

Versions:

  • Go Version: 1.19.2
  • Docker Version: 20.10.8
  • Kubernetes Version: 1.22.0
  • NGT Version: 1.14.8

Checklist:

Special notes for your reviewer:

Signed-off-by: kevindiu <kevindiujp@gmail.com>
Signed-off-by: kevindiu <kevindiujp@gmail.com>
@vdaas-ci
Copy link
Collaborator

[CHATOPS:HELP] ChatOps commands.

  • 🙆‍♀️ /approve - approve
  • 💌 /changelog - replace the PR body by changelog details
  • 🍱 /format - format codes and add licenses
  • /gen-test - generate test codes
  • 🏷️ /label - add labels
  • /rebase - rebase main
  • 🔚 2️⃣ 🔚 /label actions/e2e-deploy - run E2E deploy & integration test

@codecov
Copy link

codecov bot commented Nov 24, 2022

Codecov Report

Base: 30.52% // Head: 30.56% // Increases project coverage by +0.04% 🎉

Coverage data is based on head (ed2d1d6) compared to base (3153939).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1868      +/-   ##
==========================================
+ Coverage   30.52%   30.56%   +0.04%     
==========================================
  Files         367      367              
  Lines       33829    33829              
==========================================
+ Hits        10325    10340      +15     
+ Misses      23088    23076      -12     
+ Partials      416      413       -3     
Impacted Files Coverage Δ
internal/net/dialer.go 77.40% <0.00%> (-1.00%) ⬇️
internal/worker/worker.go 83.84% <0.00%> (+1.53%) ⬆️
...nt/core/ngt/service/vqueue/uninserted_index_map.go 79.03% <0.00%> (+8.60%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: kevindiu <kevindiujp@gmail.com>
@cloudflare-pages
Copy link

cloudflare-pages bot commented Nov 24, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: ed2d1d6
Status: ✅  Deploy successful!
Preview URL: https://00749ef2.vald.pages.dev
Branch Preview URL: https://refactor-vet-v0008-lock-erro-9r5q.vald.pages.dev

View logs

@github-actions github-actions bot removed the size/XL label Nov 24, 2022
@kevindiu kevindiu marked this pull request as ready for review November 24, 2022 02:52
@kevindiu kevindiu changed the title [WIP] Fix deepsource: VET-V0008 Lock erroneously passed by value (pkg/agent) Fix deepsource: VET-V0008 Lock erroneously passed by value (pkg/agent) Nov 24, 2022
vankichi
vankichi previously approved these changes Nov 24, 2022
datelier
datelier previously approved these changes Nov 24, 2022
@kevindiu kevindiu dismissed stale reviews from datelier and vankichi via 49ae4af November 24, 2022 04:49
@vankichi vankichi merged commit 609bb96 into main Nov 24, 2022
@vankichi vankichi deleted the refactor/VET-V0008/lock-erroneously-passed-by-value-pkg-agent branch November 24, 2022 12:13
@kpango kpango mentioned this pull request Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants