Skip to content

Commit

Permalink
vtcombo: connection leak test review feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Brendan Dougherty <[email protected]>
  • Loading branch information
brendar committed Aug 21, 2024
1 parent ed488f8 commit c903014
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions go/test/endtoend/vtcombo/recreate/recreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"os"
"os/exec"
"strconv"
"strings"
"testing"

Expand Down Expand Up @@ -112,6 +113,8 @@ func TestDropAndRecreateWithSameShards(t *testing.T) {

assertTabletsPresent(t)

// Check the connection count after the CREATE. There will be zero connections after the DROP as the database
// no longer exists, but after it gets recreated any open pools will be able to reestablish connections.
mysqlConnCountAfter, err := getMySQLConnectionCount(ctx, cur)
require.Nil(t, err)

Expand All @@ -121,16 +124,11 @@ func TestDropAndRecreateWithSameShards(t *testing.T) {
}

func getMySQLConnectionCount(ctx context.Context, session *vtgateconn.VTGateSession) (int, error) {
result, err := session.Execute(ctx, "SELECT COUNT(*) FROM information_schema.processlist", nil)
result, err := session.Execute(ctx, "select variable_value from performance_schema.global_status where variable_name='threads_connected'", nil)
if err != nil {
return 0, err
}
row := result.Rows[0][0]
toInt, err := row.ToInt()
if err != nil {
return 0, err
}
return toInt, nil
return strconv.Atoi(result.Rows[0][0].ToString())
}

func assertTabletsPresent(t *testing.T) {
Expand Down

0 comments on commit c903014

Please sign in to comment.