Skip to content

Commit

Permalink
Relax vexplain test for upcoming changes
Browse files Browse the repository at this point in the history
The fix in vitessio#16988 makes a change
here that's not really a breaking change, but it does break the test as
the test matches the exact string output which changes here due to a
binary value.

Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink committed Oct 22, 2024
1 parent 1a3b5a1 commit 406e763
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions go/test/endtoend/vtgate/queries/vexplain/vexplain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package vexplain

import (
"context"
"fmt"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -75,24 +76,29 @@ func TestVtGateVExplain(t *testing.T) {
`vexplain queries insert into user (id,lookup,lookup_unique) values (4,'apa','foo'),(5,'apa','bar'),(6,'monkey','nobar')`,
"vexplain queries/all will actually run queries")

expected := `[
binaryPrefix := ""
if utils.BinaryIsAtLeastAtVersion(22, "vtgate") {
binaryPrefix = "_binary"
}

expected := fmt.Sprintf(`[
[VARCHAR("ks") VARCHAR("-40") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("insert into lookup(lookup, id, keyspace_id) values ('apa', 1, '\x16k@\xb4J\xbaK\xd6') on duplicate key update lookup = values(lookup), id = values(id), keyspace_id = values(keyspace_id)")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("insert into lookup(lookup, id, keyspace_id) values ('apa', 1, %s'\x16k@\xb4J\xbaK\xd6') on duplicate key update lookup = values(lookup), id = values(id), keyspace_id = values(keyspace_id)")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("insert into lookup(lookup, id, keyspace_id) values ('monkey', 3, 'N\xb1\x90ɢ\xfa\x16\x9c') on duplicate key update lookup = values(lookup), id = values(id), keyspace_id = values(keyspace_id)")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("insert into lookup(lookup, id, keyspace_id) values ('monkey', 3, %s'N\xb1\x90ɢ\xfa\x16\x9c') on duplicate key update lookup = values(lookup), id = values(id), keyspace_id = values(keyspace_id)")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("commit")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("commit")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("insert into lookup_unique(lookup_unique, keyspace_id) values ('monkey', 'N\xb1\x90ɢ\xfa\x16\x9c')")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("insert into lookup_unique(lookup_unique, keyspace_id) values ('monkey', %s'N\xb1\x90ɢ\xfa\x16\x9c')")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("insert into lookup_unique(lookup_unique, keyspace_id) values ('apa', '\x16k@\xb4J\xbaK\xd6')")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("insert into lookup_unique(lookup_unique, keyspace_id) values ('apa', %s'\x16k@\xb4J\xbaK\xd6')")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("commit")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("commit")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("insert into ` + "`user`" + `(id, lookup, lookup_unique) values (3, 'monkey', 'monkey')")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("insert into `+"`user`"+`(id, lookup, lookup_unique) values (3, 'monkey', 'monkey')")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("insert into ` + "`user`" + `(id, lookup, lookup_unique) values (1, 'apa', 'apa')")]
]`
[VARCHAR("ks") VARCHAR("-40") VARCHAR("insert into `+"`user`"+`(id, lookup, lookup_unique) values (1, 'apa', 'apa')")]
]`, binaryPrefix, binaryPrefix, binaryPrefix, binaryPrefix)
assertVExplainEquals(t, conn, `vexplain /*vt+ EXECUTE_DML_QUERIES */ queries insert into user (id,lookup,lookup_unique) values (1,'apa','apa'),(3,'monkey','monkey')`, expected)

// Assert that the output of vexplain all doesn't have begin queries because they aren't explainable
Expand All @@ -109,27 +115,27 @@ func TestVtGateVExplain(t *testing.T) {

// transaction explicitly started to no commit in the end.
utils.Exec(t, conn, "begin")
expected = `[
expected = fmt.Sprintf(`[
[VARCHAR("ks") VARCHAR("-40") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("insert into lookup(lookup, id, keyspace_id) values ('apa', 4, '\xd2\xfd\x88g\xd5\\r-\xfe'), ('apa', 5, 'p\xbb\x02<\x81\f\xa8z') on duplicate key update lookup = values(lookup), id = values(id), keyspace_id = values(keyspace_id)")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("insert into lookup(lookup, id, keyspace_id) values ('apa', 4, %s'\xd2\xfd\x88g\xd5\\r-\xfe'), ('apa', 5, %s'p\xbb\x02<\x81\f\xa8z') on duplicate key update lookup = values(lookup), id = values(id), keyspace_id = values(keyspace_id)")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("insert into lookup(lookup, id, keyspace_id) values ('monkey', 6, '\xf0\x98H\\n\xc4ľq') on duplicate key update lookup = values(lookup), id = values(id), keyspace_id = values(keyspace_id)")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("insert into lookup(lookup, id, keyspace_id) values ('monkey', 6, %s'\xf0\x98H\\n\xc4ľq') on duplicate key update lookup = values(lookup), id = values(id), keyspace_id = values(keyspace_id)")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("commit")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("commit")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("insert into lookup_unique(lookup_unique, keyspace_id) values ('foo', '\xd2\xfd\x88g\xd5\\r-\xfe')")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("insert into lookup_unique(lookup_unique, keyspace_id) values ('foo', %s'\xd2\xfd\x88g\xd5\\r-\xfe')")]
[VARCHAR("ks") VARCHAR("80-c0") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("80-c0") VARCHAR("insert into lookup_unique(lookup_unique, keyspace_id) values ('bar', 'p\xbb\x02<\x81\f\xa8z')")]
[VARCHAR("ks") VARCHAR("80-c0") VARCHAR("insert into lookup_unique(lookup_unique, keyspace_id) values ('bar', %s'p\xbb\x02<\x81\f\xa8z')")]
[VARCHAR("ks") VARCHAR("c0-") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("c0-") VARCHAR("insert into lookup_unique(lookup_unique, keyspace_id) values ('nobar', '\xf0\x98H\\n\xc4ľq')")]
[VARCHAR("ks") VARCHAR("c0-") VARCHAR("insert into lookup_unique(lookup_unique, keyspace_id) values ('nobar', %s'\xf0\x98H\\n\xc4ľq')")]
[VARCHAR("ks") VARCHAR("-40") VARCHAR("commit")]
[VARCHAR("ks") VARCHAR("80-c0") VARCHAR("commit")]
[VARCHAR("ks") VARCHAR("c0-") VARCHAR("commit")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("insert into ` + "`user`" + `(id, lookup, lookup_unique) values (5, 'apa', 'bar')")]
[VARCHAR("ks") VARCHAR("40-80") VARCHAR("insert into `+"`user`"+`(id, lookup, lookup_unique) values (5, 'apa', 'bar')")]
[VARCHAR("ks") VARCHAR("c0-") VARCHAR("begin")]
[VARCHAR("ks") VARCHAR("c0-") VARCHAR("insert into ` + "`user`" + `(id, lookup, lookup_unique) values (4, 'apa', 'foo'), (6, 'monkey', 'nobar')")]
]`
[VARCHAR("ks") VARCHAR("c0-") VARCHAR("insert into `+"`user`"+`(id, lookup, lookup_unique) values (4, 'apa', 'foo'), (6, 'monkey', 'nobar')")]
]`, binaryPrefix, binaryPrefix, binaryPrefix, binaryPrefix, binaryPrefix, binaryPrefix)
assertVExplainEquals(t, conn, `vexplain /*vt+ EXECUTE_DML_QUERIES */ queries insert into user (id,lookup,lookup_unique) values (4,'apa','foo'),(5,'apa','bar'),(6,'monkey','nobar')`, expected)

utils.Exec(t, conn, "rollback")
Expand Down

0 comments on commit 406e763

Please sign in to comment.