Skip to content

Commit

Permalink
Merge #133609
Browse files Browse the repository at this point in the history
133609: kv: fix assertion in TestProxyTracing r=nvanbenschoten a=nvanbenschoten

This commit fixes the assertion in `TestProxyTracing` so that the test will fail if request proxying is not working as expected. The test was fooling itself, expecting `QueryRowContext` to return a nil `Row` if no matching trace event was found. This is not the case, as a nil `Row` is never returned. Instead, `Row.Scan` returns `ErrNoRows` if no matching row is found.

Also, the query wasn't even running because it was passing the last line of the query string in as a parameter, leading to the error: `"pq: got 1 parameters but the statement requires 0"`.

I confirmed that before this change, the test passes even with request proxying disabled. After this change, the test fails.

Epic: None
Release note: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
  • Loading branch information
craig[bot] and nvanbenschoten committed Oct 28, 2024
2 parents 41d3a4e + ade2d9b commit c061bd6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions pkg/kv/kvclient/kvcoord/dist_sender_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package kvcoord_test
import (
"bytes"
"context"
gosql "database/sql"
"fmt"
"reflect"
"sort"
Expand Down Expand Up @@ -4898,11 +4899,17 @@ func TestProxyTracing(t *testing.T) {

// Expect the "proxy request complete" message to be in the trace and that it
// comes from the proxy node n2.
row := conn.QueryRowContext(ctx, "SELECT message, tag, location "+
"FROM [SHOW TRACE FOR SESSION] "+
"WHERE message LIKE '%proxy request complete%'"+
"AND location LIKE '%server/node%'",
"AND tag LIKE '%n2%'",
)
require.NotNil(t, row)
var msg, tag, loc string
if err = conn.QueryRowContext(ctx, `SELECT message, tag, location
FROM [SHOW TRACE FOR SESSION]
WHERE message LIKE '%proxy request complete%'
AND location LIKE '%server/node%'
AND tag LIKE '%n2%'`,
).Scan(&msg, &tag, &loc); err != nil {
if errors.Is(err, gosql.ErrNoRows) {
t.Fatalf("request succeeded without proxying")
}
t.Fatal(err)
}
t.Logf("found trace event; msg=%s, tag=%s, loc=%s", msg, tag, loc)
}

0 comments on commit c061bd6

Please sign in to comment.