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 e2e test for maxDimensionTest #1650

Merged
merged 31 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0507601
:white_check_mark: implement e2e for maxDimensionTest
vankichi May 12, 2022
7f53f83
:green_heart: add new wf for maxDimensionE2EInsert
vankichi May 12, 2022
9c6e3e9
:green_heart: create e2e-max-dim test wf
vankichi May 16, 2022
99b6635
:white_check_mark: use ngt.VectorMaxDimensionLimit
vankichi May 16, 2022
e1e6882
:green_heart: fix ci error
vankichi May 16, 2022
f482222
:green_heart: add search process
vankichi May 17, 2022
8a04a82
:white_check_mark: remove unused constant value
vankichi May 17, 2022
f748e32
:white_check_mark: update test error message
vankichi May 17, 2022
83a5aa1
:white_check_mark: :green_heart: show log for friendly debuging
vankichi May 17, 2022
517aca9
:green_heart: update ci
vankichi May 17, 2022
a4ebbe5
:green_heart: update ci
vankichi May 17, 2022
73b1c66
:white_check_mark: :green_heart: fix
vankichi May 17, 2022
4c165fe
:white_check_mark: :green_heart: fix
vankichi May 17, 2022
e257de5
:white_check_mark: :green_heart: fix
vankichi May 17, 2022
fc2bd5b
:white_check_mark: :green_heart: fix
vankichi May 17, 2022
1a1514d
:white_check_mark: :green_heart: fix
vankichi May 18, 2022
575ddb7
:robot: Update license headers / Format go codes and yaml files
vdaas-ci May 18, 2022
34eeddb
Revert ":robot: Update license headers / Format go codes and yaml files"
vankichi May 18, 2022
3df94d1
:white_check_mark: fix license text
vankichi May 18, 2022
94b7256
:green_heart: fix ci
vankichi May 19, 2022
73a71ee
Merge branch 'master' into test/e2e/add-max-dimension-e2e-test
vankichi May 19, 2022
db92b95
:recycle: set maxVectorLimit by math.MaxUint32
vankichi May 23, 2022
55abe01
:recycle: remove dimension limit definition from ngt
vankichi May 23, 2022
3ff34c6
:green_heart: update ci
vankichi May 23, 2022
3e6c767
:recycle: fix test
vankichi May 23, 2022
3a35ab8
:recycle: fix test
vankichi May 23, 2022
eeb51fe
:white_check_mark: fix invalid import
vankichi May 23, 2022
ed3307e
:green_heart: update ci
vankichi May 23, 2022
30169a2
:green_heart: update test/ci
vankichi May 24, 2022
7e01b5c
:recycle: fix
vankichi May 24, 2022
71b01f9
Merge branch 'master' into test/e2e/add-max-dimension-e2e-test
kpango May 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/helm/values/values-max-dim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#
# Copyright (C) 2019-2022 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

defaults:
logging:
level: info

gateway:
lb:
enabled: true
minReplicas: 1
maxReplicas: 1
hpa:
enabled: false
resources:
requests:
cpu: 100m
memory: 50Mi
gateway_config:
index_replica: 1

agent:
minReplicas: 1
maxReplicas: 1
podManagementPolicy: Parallel
hpa:
enabled: false
resources:
requests:
cpu: 100m
memory: 50Mi
ngt:
auto_index_duration_limit: 1m
auto_index_check_duration: 40s
auto_index_length: 100
dimension: 2

discoverer:
minReplicas: 1
maxReplicas: 1
hpa:
enabled: false
resources:
requests:
cpu: 100m
memory: 50Mi

manager:
index:
replicas: 1
resources:
requests:
cpu: 100m
memory: 30Mi
indexer:
auto_index_duration_limit: 40s
auto_index_check_duration: 20s
auto_index_length: 100
164 changes: 164 additions & 0 deletions .github/workflows/e2e-max-dim.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#
# Copyright (C) 2019-2022 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: "Run E2E Max Dimension test"
on:
push:
tags:
- "*.*.*"
- "v*.*.*"
- "*.*.*-*"
- "v*.*.*-*"
pull_request:
types:
- "labeled"

jobs:
e2e-max-dimension-insert:
name: "E2E test (Max Dimension Insert: skip strict exist check)"
runs-on: ubuntu-latest
timeout-minutes: 60
if: startsWith( github.ref, 'refs/tags/') || github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-max-dim'
steps:
- uses: actions/checkout@v3
- name: Wait for Docker images
if: startsWith( github.ref, 'refs/tags/')
id: wait_for_docker_images
uses: ./.github/actions/wait-for-docker-image
- name: Get PR number
id: get_pr_number
if: github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-deploy'
run: |
pr_num=`cat $GITHUB_EVENT_PATH | jq -r ".number"`
echo "::set-output name=PR_NUM::${pr_num}"
- name: Specify container versions
if: github.event.action == 'labeled' && github.event.label.name == 'actions/e2e-deploy'
id: specify_container_versions
uses: ./.github/actions/detect-docker-image-tags
with:
tag_name: pr-${{ steps.get_pr_number.outputs.PR_NUM }}
- name: Fetch Helm version
run: |
HELM_VERSION=`make version/helm`
echo "::set-output name=helm::${HELM_VERSION}"
id: version
- uses: rinx/[email protected]
with:
version: latest
name: vald
agents: 1
- name: check k3d
run: |
kubectl cluster-info
- uses: azure/setup-helm@v1
with:
version: ${{ steps.version.outputs.helm }}
- name: Helm version
run: |
helm version
- name: deploy Vald
id: deploy_vald
uses: ./.github/actions/e2e-deploy-vald
with:
helm_extra_options: ${{ steps.specify_container_versions.outputs.HELM_EXTRA_OPTIONS }}
values: .github/helm/values/values-max-dim.yaml
wait_for_selector: app=vald-lb-gateway
- name: Fetch golang version
run: |
GO_VERSION=`make version/go`
echo "::set-output name=version::${GO_VERSION}"
id: golang_version
- uses: actions/setup-go@v3
with:
go-version: ${{ steps.golang_version.outputs.version }}
- name: run E2E MaxDimension
run: |
go version
go get github.com/vdaas/vald-client-go/v1/payload
go get github.com/vdaas/vald-client-go/v1/vald
BIT=1
RELEASE=`helm list | grep vald | awk '{print $1}'`
while [ $BIT -ne 32 ]; do
echo "Start: Bit=${BIT}"
FILE="tmp.log"
touch ${FILE}
FILEPATH=`readlink -f ${FILE}`
DIM=$((1<<$BIT))
if [ $BIT = "32" ]; then
DIM=$(($DIM-1))
fi
helm upgrade ${RELEASE} charts/vald \
--values ${VALUES} \
--set defaults.image.tag=nightly \
--set agent.ngt.dimension=${DIM}
sleep 3
kubectl rollout restart statefulset vald-agent-ngt
sleep 30
kubectl wait --for=condition=Ready pod -l ${WAIT_FOR_SELECTOR} --timeout=${WAIT_FOR_TIMEOUT}
POD_NAME=`kubectl get pods | grep vald-lb-gateway | awk '{print $1}'`
go test \
-race \
-v tests/e2e/performance/max_vector_dim_test.go \
-tags "e2e" \
-file ${FILEPATH} \
-timeout 30m \
-bit=${BIT} \
-host=localhost \
-port=8081 \
-portforward \
-portforward-pod-name=${POD_NAME} \
-kubeconfig=${KUBECONFIG} \
-namespace=default
CODE=`sed -n 1P ${FILEPATH}`
if [ ${CODE} = "ResourceExhausted" ]; then
echo "Finish: Bit=${BIT} with ${CODE}"
BIT=$(($BIT-1))
rm ${FILEPATH}
break;
fi
if [ ${CODE} != "OK" ]; then
echo "Finish: Bit=${BIT} with Error: ${CODE}"
rm ${FILEPATH}
break;
fi
echo "Finish: Bit=${BIT}"
BIT=$(($BIT+1))
rm ${FILEPATH}
done
echo "::set-output name=MAX_BIT::${BIT}"
echo "MAX_BIT=${BIT}"
env:
WAIT_FOR_SELECTOR: app=vald-agent-ngt
WAIT_FOR_TIMEOUT: 29m
VALUES: .github/helm/values/values-max-dim.yaml
timeout-minutes: 60
slack-notification:
name: "Slack notification"
needs:
- e2e-max-dimension-insert
runs-on: ubuntu-latest
if: startsWith( github.ref, 'refs/tags/')
steps:
- uses: technote-space/workflow-conclusion-action@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: 8398a7/action-slack@v3
with:
author_name: "E2E max dim test"
status: ${{ env.WORKFLOW_CONCLUSION }}
only_mention_fail: channel
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFY_WEBHOOK_URL }}
2 changes: 1 addition & 1 deletion internal/core/algorithm/algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "math"

const (
// MaximumVectorDimensionSize is maximum value of vector dimension.
MaximumVectorDimensionSize = math.MaxInt64
MaximumVectorDimensionSize = math.MaxUint32
// MinimumVectorDimensionSize is minimum value of vector dimension.
MinimumVectorDimensionSize = 2
)
13 changes: 3 additions & 10 deletions internal/core/algorithm/ngt/ngt.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,6 @@ const (
// -------------------------------------------------------------.
ErrorCode = C._Bool(false)
// -------------------------------------------------------------.

// -------------------------------------------------------------
// dimension constraints
// -------------------------------------------------------------.
VectorDimensionSizeLimit = 1<<32 - 1
minimumDimensionSize = algorithm.MinimumVectorDimensionSize
// -------------------------------------------------------------.
)

func (o objectType) String() string {
Expand Down Expand Up @@ -685,8 +678,8 @@ func (n *ngt) GetVector(id uint) ([]float32, error) {
if results == nil {
return nil, n.newGoError(ebuf)
}
ret = (*[VectorDimensionSizeLimit]float32)(unsafe.Pointer(results))[:dimension:dimension]
// for _, elem := range (*[VectorDimensionSizeLimit]C.float)(unsafe.Pointer(results))[:dimension:dimension]{
ret = (*[algorithm.MaximumVectorDimensionSize]float32)(unsafe.Pointer(results))[:dimension:dimension]
// for _, elem := range (*[algorithm.MaximumVectorDimensionSize]C.float)(unsafe.Pointer(results))[:dimension:dimension]{
// ret = append(ret, float32(elem))
// }
case Uint8:
Expand All @@ -697,7 +690,7 @@ func (n *ngt) GetVector(id uint) ([]float32, error) {
return nil, n.newGoError(ebuf)
}
ret = make([]float32, 0, dimension)
for _, elem := range (*[VectorDimensionSizeLimit]C.uint8_t)(unsafe.Pointer(results))[:dimension:dimension] {
for _, elem := range (*[algorithm.MaximumVectorDimensionSize]C.uint8_t)(unsafe.Pointer(results))[:dimension:dimension] {
ret = append(ret, float32(elem))
}
default:
Expand Down
5 changes: 3 additions & 2 deletions internal/core/algorithm/ngt/ngt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/vdaas/vald/internal/core/algorithm"
"github.com/vdaas/vald/internal/errors"
"github.com/vdaas/vald/internal/file"
"github.com/vdaas/vald/internal/log"
Expand Down Expand Up @@ -183,7 +184,7 @@ func TestNew(t *testing.T) {
},
},
want: want{
err: errors.NewErrCriticalOption("dimension", 1, errors.ErrInvalidDimensionSize(1, VectorDimensionSizeLimit)),
err: errors.NewErrCriticalOption("dimension", 1, errors.ErrInvalidDimensionSize(1, algorithm.MaximumVectorDimensionSize)),
},
},
}
Expand Down Expand Up @@ -761,7 +762,7 @@ func Test_gen(t *testing.T) {
},
},
want: want{
err: errors.NewErrCriticalOption("dimension", 1, errors.ErrInvalidDimensionSize(1, VectorDimensionSizeLimit)),
err: errors.NewErrCriticalOption("dimension", 1, errors.ErrInvalidDimensionSize(1, algorithm.MaximumVectorDimensionSize)),
},
},
}
Expand Down
7 changes: 4 additions & 3 deletions internal/core/algorithm/ngt/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"strconv"

"github.com/kpango/fastime"
"github.com/vdaas/vald/internal/core/algorithm"
"github.com/vdaas/vald/internal/errors"
"github.com/vdaas/vald/internal/strings"
)
Expand All @@ -41,7 +42,7 @@ var (

defaultOptions = []Option{
WithIndexPath("/tmp/ngt-" + strconv.FormatInt(fastime.UnixNanoNow(), 10)),
WithDimension(minimumDimensionSize),
WithDimension(algorithm.MinimumVectorDimensionSize),
WithDefaultRadius(DefaultRadius),
WithDefaultEpsilon(DefaultEpsilon),
WithDefaultPoolSize(DefaultPoolSize),
Expand Down Expand Up @@ -86,8 +87,8 @@ func WithBulkInsertChunkSize(size int) Option {
// WithDimension represents the option to set the dimension for NGT.
func WithDimension(size int) Option {
return func(n *ngt) error {
if size > VectorDimensionSizeLimit || size < minimumDimensionSize {
err := errors.ErrInvalidDimensionSize(size, VectorDimensionSizeLimit)
if size > algorithm.MaximumVectorDimensionSize || size < algorithm.MinimumVectorDimensionSize {
err := errors.ErrInvalidDimensionSize(size, algorithm.MaximumVectorDimensionSize)
return errors.NewErrCriticalOption("dimension", size, err)
}

Expand Down
Loading