Skip to content

Commit

Permalink
Vectors: support MySQL 9.0 syntax, stress tests, backup/pitr tests (#…
Browse files Browse the repository at this point in the history
…5669)

* Vectors: Online DDL support

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* Add support for vectors in vreplication workflows. unit and e2e tests. Update cnf file to add loose_with_ps_vectors

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

* Self review fixes. Add e2e TestVector to CI

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

* Simplify unit test CI workflow to debug failure

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

* Skip test on errors on setting with_ps_vectors

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

* Revert debug mods to unit_race.yml

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

* Unit test race is again failing with no logs. So modify CI workflow temporarily to get full detail to debug random failures apparently unrelated to this PR

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

* Setup templating for vectors vreplication build

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

* Add vcopier unit test. Insert additional rows in e2e test after copy phase to test replication phase

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

* Switch shard for vector test to correct one

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

* Use vectors build for unit tests

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

* Refactor tests: move vector unit tests to separate files

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

* endtoend suite: filter with ONLINEDDL_SUITE_TEST_FILTER

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* recognize ERVectorDimensionsMismatch      = ErrorCode(4501) as unrecoverable

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* add expected failign vector test. Rename vector tests

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* recognize ERVectorDimensionsMismatch      = ErrorCode(4501) as unrecoverable

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* Unit race still failing without details:-(. Commenting out the summary code which seems to be redacting the details

Signed-off-by: Rohit Nayak <rohit@planetscale.com>

* adding onlineddl_vector_stress CI tests

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* validate row count primary vs replica

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* comparing primary and replica data

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* onlineddl_vector_stress in clustersRequiringVectors

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* Adding workflow file

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* fix test assertion/concurrency; accept specific errors

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* more queries in transaction

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* remove testing.T from goroutines

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* uncomment static/workload tests

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* 'onlineddl_vrepl_suite' now requires a vectors build

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* explicit primary/replica test names

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* use vector build

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* update mysql version

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* apply mysql version to vector stress workflow

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* updating MySQL image version

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* fixes per review

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* update mysql image version

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* update mysql image version

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* bail out early if the migration si failed. Accept error 1317 (ERQueryInterrupted) as valid

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* more DDL scenarios

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* more scenario

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* using --force-cut-over-after=30s

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* support direct alter. Support ONLINEDDL_VECTOR_TEST_FILTER environment variable. More tests

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* add test: dropping all indexes

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* add test: adding a null index (index on a column that only has nulls)

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* one vector column is not null

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* adding mixed direct & onlineddl test scenario

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* preWorkloadQuery, preCutoverQuery, more tests

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* more test scenario

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* fix sql error

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* update MySQL image

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* add massDML option to run table-wide UPDATE or DELETE

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* remove debugging sections

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* make generate_ci_workflows

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* more test scenarios

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* increase test timeout

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* introducing 'repeats'

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* improved filtering

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* Adding shards for onlineddl_fulltext_stress, onlineddl_blob_stress.

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* wording

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* LIMIT 10000 for when we increase number of rows

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* update go version

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* Vectors: update to MySQL 9.0 syntax

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* update MySQL image version

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* update to mysql 8.0 vector function names

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* resolved conflict

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* update mysql image version for unit tests

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* update mysql image version for unit tests

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* allow changing vector length

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* adapt new column_length and decimals

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* Vectors: add vector column and data in 'backup_pitr'

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* update mysql image version

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* resolve conflicts

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* resolve conflicts

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* Add 'backup_pitr' to list of vector-enabled tests. This help reducing conflicts with planetscale/vitess-private#5659

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* remove blob_stress and fulltext_stress as they were only introduced to test START_GTID inconsistencies. This has since evolved to planetscale/vitess-private#5629 and external to this PR

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* Update evalengine to handle basic vector types

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

* Add vector dimensionality medetata flag

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

* Remove custom vector check

This now should have it's own specific type in MySQL.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>

* update mysql image

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* update vector function

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* backup tests: distinguish test with vector support and without vector support

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

* remove onlineddl_fulltext_stress and onlineddl_blob_stress

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>

---------

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Co-authored-by: Rohit Nayak <rohit@planetscale.com>
Co-authored-by: Dirkjan Bussink <d.bussink@gmail.com>
  • Loading branch information
3 people authored Jul 17, 2024
1 parent 202589e commit 997539e
Show file tree
Hide file tree
Showing 33 changed files with 1,471 additions and 68 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cluster_endtoend_backup_pitr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ jobs:
sudo apt-get -qq install -y make unzip g++ etcd curl git wget awscli eatmydata xz-utils libncurses5
sudo service etcd stop
# Pin this to 8.0.34
LAST_BUILD="mysql/main/8.0.34.20240216-ps-6ce6a79427b/dist/mysql-8.0.34.20240216-ps-6ce6a79427b-jammy-linux-x86_64.tar.gz"
# Using the 8.0.37 MySQL Vectors build
LAST_BUILD="mysql/main/8.0.37.20240716-ps-6982681f981/dist/mysql-8.0.37.20240716-ps-6982681f981-jammy-linux-x86_64.tar.gz"
echo "installing psdb mysql $LAST_BUILD"
aws s3 cp "s3://planetscale-mysql-server-private-ci-artifacts/${LAST_BUILD}" .
Expand Down
126 changes: 126 additions & 0 deletions .github/workflows/cluster_endtoend_onlineddl_vector_stress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# DO NOT MODIFY: THIS FILE IS GENERATED USING "make generate_ci_workflows"

name: Cluster (onlineddl_vector_stress)
on: [push]

jobs:
build:
name: Run endtoend tests on Cluster (onlineddl_vector_stress)
runs-on: ubuntu-shr-4cpu-16gb
timeout-minutes: 60

steps:
- name: Configure git private repo access
env:
GITHUB_TOKEN: ${{ secrets.PLANETSCALE_ACTIONS_BOT_TOKEN }}
run: |
git config --global --add url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
- name: Check out code
uses: actions/checkout@v4

- name: Check for changes in relevant files
uses: dorny/paths-filter@v3.0.1
id: changes
with:
token: ''
filters: |
end_to_end:
- 'go/**/*.go'
- 'go/vt/sidecardb/**/*.sql'
- 'test.go'
- 'Makefile'
- 'build.env'
- 'go.sum'
- 'go.mod'
- 'proto/*.proto'
- 'tools/**'
- 'config/**'
- 'bootstrap.sh'
- '.github/workflows/cluster_endtoend_onlineddl_vector_stress.yml'
- 'go/test/endtoend/onlineddl/vrepl_suite/**'
- name: Set up Go
if: steps.changes.outputs.end_to_end == 'true'
uses: actions/setup-go@v5
with:
go-version: 1.22.5

- name: Set up python
if: steps.changes.outputs.end_to_end == 'true'
uses: actions/setup-python@v5

- name: Tune the OS
if: steps.changes.outputs.end_to_end == 'true'
run: |
sudo sysctl -w net.ipv4.ip_local_port_range="22768 65535"
# Increase the asynchronous non-blocking I/O. More information at https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_use_native_aio
echo "fs.aio-max-nr = 1048576" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p /etc/sysctl.conf
- name: Check out code
if: steps.changes.outputs.end_to_end == 'true'
uses: actions/checkout@v4

- name: Get dependencies
if: steps.changes.outputs.end_to_end == 'true'
env: # Or as an environment variable
AWS_ACCESS_KEY_ID: ${{ secrets.BUILDKITE_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.BUILDKITE_S3_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
run: |
sudo apt-get -qq update
# stop any existing running instance of mysql
sudo service mysql stop
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
# Uninstall any previously installed MySQL first
sudo DEBIAN_FRONTEND="noninteractive" apt-get -qq remove -y --purge mysql-server mysql-client mysql-common
sudo apt-get -qq -y autoremove
sudo apt-get -qq -y autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
# install necessary tools
sudo apt-get -qq install -y make unzip g++ etcd curl git wget awscli eatmydata xz-utils libncurses5
sudo service etcd stop
# Using the 8.0.37 MySQL Vectors build
LAST_BUILD="mysql/main/8.0.37.20240716-ps-6982681f981/dist/mysql-8.0.37.20240716-ps-6982681f981-jammy-linux-x86_64.tar.gz"
echo "installing psdb mysql $LAST_BUILD"
aws s3 cp "s3://planetscale-mysql-server-private-ci-artifacts/${LAST_BUILD}" .
sudo tar xf $(basename $LAST_BUILD) -v -C /usr --strip-components=1
go mod download
# install JUnit report formatter
go install github.com/vitessio/go-junit-report@HEAD
- name: Run cluster endtoend test
if: steps.changes.outputs.end_to_end == 'true'
timeout-minutes: 45
run: |
# We set the VTDATAROOT to the /tmp folder to reduce the file path of mysql.sock file
# which musn't be more than 107 characters long.
export VTDATAROOT="/tmp/"
source build.env
set -exo pipefail
eatmydata -- go run test.go -docker=false -follow -shard onlineddl_vector_stress | tee -a output.txt | go-junit-report -set-exit-code > report.xml
- name: Print test output
if: steps.changes.outputs.end_to_end == 'true' && always()
run: |
# print test output
cat output.txt
- name: Test Summary
if: steps.changes.outputs.end_to_end == 'true' && always()
uses: test-summary/action@v2
with:
paths: "report.xml"
show: "fail, skip"
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
sudo service etcd stop
# Using the 8.0.37 MySQL Vectors build
LAST_BUILD="mysql/main/8.0.37.20240627-ps-c583fd90bb9/dist/mysql-8.0.37.20240627-ps-c583fd90bb9-jammy-linux-x86_64.tar.gz"
LAST_BUILD="mysql/main/8.0.37.20240716-ps-6982681f981/dist/mysql-8.0.37.20240716-ps-6982681f981-jammy-linux-x86_64.tar.gz"
echo "installing psdb mysql $LAST_BUILD"
aws s3 cp "s3://planetscale-mysql-server-private-ci-artifacts/${LAST_BUILD}" .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend_vreplication_vector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
sudo service etcd stop
# Using the 8.0.37 MySQL Vectors build
LAST_BUILD="mysql/main/8.0.37.20240627-ps-c583fd90bb9/dist/mysql-8.0.37.20240627-ps-c583fd90bb9-jammy-linux-x86_64.tar.gz"
LAST_BUILD="mysql/main/8.0.37.20240716-ps-6982681f981/dist/mysql-8.0.37.20240716-ps-6982681f981-jammy-linux-x86_64.tar.gz"
echo "installing psdb mysql $LAST_BUILD"
aws s3 cp "s3://planetscale-mysql-server-private-ci-artifacts/${LAST_BUILD}" .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_race.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
sudo apt-get -qq install -y make unzip g++ curl git wget ant openjdk-11-jdk eatmydata
# Using the 8.0.37 MySQL Vectors build
LAST_BUILD="mysql/main/8.0.37.20240624-ps-212d2140ff5/dist/mysql-8.0.37.20240624-ps-212d2140ff5-jammy-linux-x86_64.tar.gz"
LAST_BUILD="mysql/main/8.0.37.20240716-ps-6982681f981/dist/mysql-8.0.37.20240716-ps-6982681f981-jammy-linux-x86_64.tar.gz"
aws s3 cp "s3://planetscale-mysql-server-private-ci-artifacts/${LAST_BUILD}" .
sudo tar xf $(basename $LAST_BUILD) -C /usr --strip-components=1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_test_evalengine_mysql80.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
sudo apt-get -qq install -y make unzip g++ curl git wget awscli ant openjdk-8-jdk eatmydata xz-utils
# Using the 8.0.37 MySQL Vectors build
LAST_BUILD="mysql/main/8.0.37.20240624-ps-212d2140ff5/dist/mysql-8.0.37.20240624-ps-212d2140ff5-jammy-linux-x86_64.tar.gz"
LAST_BUILD="mysql/main/8.0.37.20240716-ps-6982681f981/dist/mysql-8.0.37.20240716-ps-6982681f981-jammy-linux-x86_64.tar.gz"
aws s3 cp "s3://planetscale-mysql-server-private-ci-artifacts/${LAST_BUILD}" .
sudo tar xf $(basename $LAST_BUILD) -v -C /usr --strip-components=1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_test_mysql80.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
sudo apt-get -qq install -y make unzip g++ curl git wget awscli ant openjdk-8-jdk eatmydata xz-utils
# Using the 8.0.37 MySQL Vectors build
LAST_BUILD="mysql/main/8.0.37.20240624-ps-212d2140ff5/dist/mysql-8.0.37.20240624-ps-212d2140ff5-jammy-linux-x86_64.tar.gz"
LAST_BUILD="mysql/main/8.0.37.20240716-ps-6982681f981/dist/mysql-8.0.37.20240716-ps-6982681f981-jammy-linux-x86_64.tar.gz"
aws s3 cp "s3://planetscale-mysql-server-private-ci-artifacts/${LAST_BUILD}" .
sudo tar xf $(basename $LAST_BUILD) -v -C /usr --strip-components=1
Expand Down
1 change: 1 addition & 0 deletions go/mysql/binlog_event_rbr.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
tableMapEnumAndSetDefaultCharset
tableMapEnumAndSetColumnCharset
tableMapColumnVisibility
tableMapVectorDimensionality
)

// This byte in the optional metadata indicates that we should
Expand Down
3 changes: 1 addition & 2 deletions go/sqltypes/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ func AreTypesEquivalent(mysqlTypeFromBinlog, mysqlTypeFromSchema querypb.Type) b
(mysqlTypeFromBinlog == Int16 && mysqlTypeFromSchema == Uint16) ||
(mysqlTypeFromBinlog == Int24 && mysqlTypeFromSchema == Uint24) ||
(mysqlTypeFromBinlog == Int32 && mysqlTypeFromSchema == Uint32) ||
(mysqlTypeFromBinlog == Int64 && mysqlTypeFromSchema == Uint64) ||
(mysqlTypeFromBinlog == Vector && mysqlTypeFromSchema == VarBinary)
(mysqlTypeFromBinlog == Int64 && mysqlTypeFromSchema == Uint64)
}

// typeToMySQL is the reverse of mysqlToType.
Expand Down
36 changes: 34 additions & 2 deletions go/test/endtoend/backup/vtctlbackup/backup_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ var (
primary key (id)
) Engine=InnoDB
`
vtInsertTestWithVectors = `
create table vt_insert_test (
id bigint auto_increment,
msg varchar(64),
vec vector(5),
vector key (vec),
primary key (id)
) Engine=InnoDB
`
SetupReplica3Tablet func(extraArgs []string) (*cluster.Vttablet, error)
)

Expand Down Expand Up @@ -939,6 +948,13 @@ func InitTestTable(t *testing.T) {
require.NoError(t, err)
}

func InitTestTableWithVectors(t *testing.T) {
_, err := primary.VttabletProcess.QueryTablet("DROP TABLE IF EXISTS vt_insert_test", keyspaceName, true)
require.NoError(t, err)
_, err = primary.VttabletProcess.QueryTablet(vtInsertTestWithVectors, keyspaceName, true)
require.NoError(t, err)
}

// This will create schema in primary, insert some data to primary and verify the same data in replica
func verifyInitialReplication(t *testing.T) {
InitTestTable(t)
Expand Down Expand Up @@ -1133,16 +1149,32 @@ func GetReplicaGtidPurged(t *testing.T, replicaIndex int) string {
return row.AsString("gtid_purged", "")
}

func InsertRowOnPrimary(t *testing.T, hint string) {
func InsertRowOnPrimaryWithVectors(t *testing.T, hint string) {
if hint == "" {
hint = textutil.RandomHash()[:12]
}
query, err := sqlparser.ParseAndBind("insert into vt_insert_test (msg) values (%a)", sqltypes.StringBindVariable(hint))
vec := fmt.Sprintf("[%d,%d,%d,%d,%d]", rand.IntN(20), rand.IntN(20), rand.IntN(20), rand.IntN(20), rand.IntN(20))
query, err := sqlparser.ParseAndBind("insert into vt_insert_test (msg, vec) values (%a, to_vector(%a))", sqltypes.StringBindVariable(hint), sqltypes.StringBindVariable(vec))
require.NoError(t, err)
_, err = primary.VttabletProcess.QueryTablet(query, keyspaceName, true)
require.NoError(t, err)
}

func ReadVectorsFromReplica(t *testing.T, replicaIndex int) (vecs []string) {
tablet := getReplica(t, replicaIndex)
query := "select from_vector(vec) as v from vt_insert_test"
rs, err := tablet.VttabletProcess.QueryTablet(query, keyspaceName, true)
require.NoError(t, err)
for _, row := range rs.Named().Rows {
v, err := row.ToString("v")
require.NoError(t, err)
assert.NotEmpty(t, v)
assert.Regexp(t, `^\[.+,.+,.+,.+,.+\]`, v)
vecs = append(vecs, v)
}
return vecs
}

func ReadRowsFromTablet(t *testing.T, tablet *cluster.Vttablet) (msgs []string) {
query := "select msg from vt_insert_test"
rs, err := tablet.VttabletProcess.QueryTablet(query, keyspaceName, true)
Expand Down
Loading

0 comments on commit 997539e

Please sign in to comment.