-
Notifications
You must be signed in to change notification settings - Fork 77
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 agent handler saveIndex test case #1731
Implement agent handler saveIndex test case #1731
Conversation
[CHATOPS:HELP] ChatOps commands.
|
Codecov ReportBase: 30.29% // Head: 30.38% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1731 +/- ##
==========================================
+ Coverage 30.29% 30.38% +0.08%
==========================================
Files 370 370
Lines 33689 33689
==========================================
+ Hits 10206 10235 +29
+ Misses 23062 23040 -22
+ Partials 421 414 -7
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. |
2bc9812
to
be3becc
Compare
Deploying with Cloudflare Pages
|
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 about case
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
6afc6b5
to
a3048a4
Compare
9c8ae91
to
b92f0f8
Compare
checkBackupFolder := func(fields fields, ctx context.Context, wantVecs []*payload.Insert_Request) error { | ||
// create another server instance to check if any vector is inserted and saved to the backup dir | ||
eg, _ := errgroup.New(ctx) | ||
ngt, err := service.New(fields.svcCfg, append(fields.svcOpts, |
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.
🚫 [golangci] reported by reviewdog 🐶
Function New->mktmp->initNGT
should pass the context parameter (contextcheck)
220e937
to
a5846ba
Compare
Signed-off-by: kevindiu <[email protected]>
Signed-off-by: kevindiu <[email protected]>
defaultAfterFunc := func(test test) { | ||
os.RemoveAll(test.fields.indexPath) | ||
} | ||
checkBackupFolder := func(fields fields, ctx context.Context, wantVecs []*payload.Insert_Request) error { |
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.
could you please add the description when it is used.
And, i think it would be better to move it into the defaultCheckFunc
.
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.
It cannot be moved to defaultCheckFunc because we need the wantVecs
, which is created in the test function.
e.g. https://github.com/vdaas/vald/pull/1731/files#diff-86c3d3eae3293a28f5a4f5d3b45b9e0ec9c6654f36980af45bf9111f6a3fa22dR908
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.
Did you add the discription?
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.
added :)
@@ -508,106 +508,529 @@ func Test_server_CreateIndex(t *testing.T) { | |||
func Test_server_SaveIndex(t *testing.T) { | |||
t.Parallel() | |||
type args struct { | |||
ctx context.Context | |||
in1 *payload.Empty |
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.
could you update this value to more understandable?
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 am sorry that I cant understand what you mean?
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.
fixed by rename it to in
}, | ||
} | ||
}(), | ||
{ |
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.
please format coding style
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.
do you mean writing it as
func() test {
....
}(),
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.
yes
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.
fixed
Signed-off-by: kevindiu <[email protected]>
Signed-off-by: kevindiu <[email protected]>
timeout := time.After(10 * time.Second) | ||
ticker := time.Tick(10 * time.Millisecond) | ||
for { | ||
select { | ||
case <-timeout: | ||
// execute save index twice | ||
go s.SaveIndex(ctx, emptyPayload) | ||
|
||
gotRes, err := s.SaveIndex(ctx, emptyPayload) | ||
if err := defaultCheckFunc(t, ctx, s, n, w, gotRes, err); err != nil { | ||
return err | ||
} | ||
case <-ticker: | ||
// execute save index twice | ||
go s.SaveIndex(ctx, emptyPayload) | ||
|
||
gotRes, err := s.SaveIndex(ctx, emptyPayload) | ||
if err := defaultCheckFunc(t, ctx, s, n, w, gotRes, err); err == nil { | ||
return nil | ||
} | ||
} | ||
} |
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.
Can you please explain the background of this implementation? 🙏
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.
since we cannot guarantee the first saveIndex call on line 773 is executed asynchronously when we execute the actual saveIndex call on line 1041, I wanted to check it multiple times when it is not happen.
Signed-off-by: kevindiu <[email protected]>
Signed-off-by: kevindiu [email protected]
Description:
This PR implements saveIndex test cases.
It updates the
args
,fields
,want
and thedefaultCheckFunc
from the generated test stub.context
fromargs
and create it in test code to ensure that the context is handled correctly in test code.fields
are changed to the functional options and configurations to initializeserver
instance.want
anddefaultCheckFunc
are updated to check the error code only in the test case, otherwise it is very hard to ensure the correct error is produce by the function.Related Issue:
How Has This Been Tested?:
Environment:
Types of changes:
Changes to Core Features:
Checklist: