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

Implement pkg/agent/handler createAndSaveIndex test case #1794

Merged
merged 10 commits into from
Oct 17, 2022

Conversation

kevindiu
Copy link
Contributor

@kevindiu kevindiu commented Sep 28, 2022

Signed-off-by: kevindiu kevindiujp@gmail.com

Description:

This PR implements pkg/agent/handler createAndSaveIndex test case, including the following changes:

  • Updated fields to initialize ngt and server instance through New() using functional option pattern
  • Updated want to check error using errCode

Related Issue:

How Has This Been Tested?:

Environment:

  • Go Version: 1.19.1
  • Docker Version: 20.10.8
  • Kubernetes Version: 1.22.0
  • NGT Version: 1.14.7

Types of changes:

  • Bug fix [type/bug]
  • New feature [type/feature]
  • Add tests [type/test]
  • Security related changes [type/security]
  • Add documents [type/documentation]
  • Refactoring [type/refactoring]
  • Update dependencies [type/dependency]
  • Update benchmarks and performances [type/bench]
  • Update CI [type/ci]

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Checklist:

  • I have read the CONTRIBUTING document.
  • I have checked open Pull Requests for the similar feature or fixes?
  • I have added tests and benchmarks to cover my changes.
  • I have ensured all new and existing tests passed.
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly.

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

@kevindiu kevindiu requested review from vankichi, a team and hlts2 and removed request for a team September 28, 2022 07:26
@codecov
Copy link

codecov bot commented Sep 28, 2022

Codecov Report

Base: 50.23% // Head: 30.29% // Decreases project coverage by -19.94% ⚠️

Coverage data is based on head (984aa7d) compared to base (97eed29).
Patch coverage: 57.72% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1794       +/-   ##
===========================================
- Coverage   50.23%   30.29%   -19.95%     
===========================================
  Files         231      371      +140     
  Lines       13464    34019    +20555     
===========================================
+ Hits         6764    10305     +3541     
- Misses       6499    23293    +16794     
- Partials      201      421      +220     
Impacted Files Coverage Δ
cmd/tools/cli/loadtest/main.go 0.00% <ø> (ø)
hack/benchmark/assets/x1b/loader.go 0.00% <ø> (ø)
hack/benchmark/internal/assets/dataset.go 0.00% <ø> (ø)
hack/benchmark/internal/operation/insert.go 0.00% <ø> (ø)
hack/benchmark/internal/operation/operation.go 0.00% <ø> (ø)
hack/benchmark/internal/operation/option.go 0.00% <ø> (ø)
hack/benchmark/internal/operation/remove.go 0.00% <ø> (ø)
hack/benchmark/internal/operation/search.go 0.00% <ø> (ø)
hack/benchmark/internal/operation/util.go 0.00% <ø> (ø)
hack/license/gen/main.go 0.00% <0.00%> (ø)
... and 249 more

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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 4, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 984aa7d
Status: ✅  Deploy successful!
Preview URL: https://29ff5dac.vald.pages.dev
Branch Preview URL: https://test-pkg-add-pkg-agent-handl-3o9f.vald.pages.dev

View logs

@kevindiu kevindiu requested a review from vankichi October 4, 2022 00:14
@vankichi
Copy link
Contributor

vankichi commented Oct 5, 2022

LGTM (only test case plan)

hlts2
hlts2 previously approved these changes Oct 6, 2022
Signed-off-by: kevindiu <kevindiujp@gmail.com>
Signed-off-by: kevindiu <kevindiujp@gmail.com>
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,
Copy link
Contributor

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)

Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this warning means that checkBackupFolder accept context parameter, and this warning warn us to pass the context to serviceNew().
it doesn't require the context on our implementation, so I cannot fix it and I think we can ignore it.

@kevindiu kevindiu marked this pull request as ready for review October 13, 2022 01:02
@kevindiu kevindiu changed the title [WIP] Implement pkg/agent/handler createAndSaveIndex test case Implement pkg/agent/handler createAndSaveIndex test case Oct 13, 2022
@kevindiu kevindiu requested a review from hlts2 October 13, 2022 01:04
pkg/agent/core/ngt/handler/grpc/index_test.go Outdated Show resolved Hide resolved
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,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix it.

kevindiu and others added 2 commits October 14, 2022 17:32
Signed-off-by: kevindiu <kevindiujp@gmail.com>
Co-authored-by: Kiichiro YUKAWA <kyukawa315@gmail.com>
Signed-off-by: kevindiu <kevindiujp@gmail.com>
Copy link
Contributor

@hlts2 hlts2 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +1205 to +1214
beforeFunc: func(t *testing.T, ctx context.Context, s Server, n service.NGT, test test) {
t.Helper()
var err error
if ir, err = request.GenMultiInsertReq(request.Float, vector.Gaussian, insertCnt, dim, defaultInsertConfig); err != nil {
t.Error(err)
}
if _, err := s.MultiInsert(ctx, ir); err != nil {
t.Error(err)
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

[ask]

When beforeFunc fails, is Error ok? 🤔
I ask because I was wondering if we basically need to run tests on the target function when beforeFunc fails!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

t.Error fails the test so I think it is ok to use t.Error.
t.Fatal also fails the case, but it stops executing the test cases afterward, so I decided to use t.Error here.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I got it! Thank you!

@kevindiu kevindiu merged commit 767a226 into main Oct 17, 2022
@kevindiu kevindiu deleted the test/pkg/add-pkg-agent-handler-create-save-index-test branch October 17, 2022 09:05
@kpango kpango mentioned this pull request Oct 18, 2022
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.

4 participants