Skip to content

Commit

Permalink
Merge pull request #109515 from maryliag/backport23.1-109444
Browse files Browse the repository at this point in the history
release-23.1: cli, zip: fix column name
  • Loading branch information
maryliag committed Aug 28, 2023
2 parents 8205410 + 8e8e481 commit 8c37b61
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/cli/zip_table_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ var zipInternalTablesPerCluster = DebugZipTableRegistry{
"txn_fingerprint_id",
"query",
"implicit_txn",
"session_id,",
"session_id",
"start_time",
"end_time",
"user_name",
Expand Down Expand Up @@ -896,7 +896,7 @@ var zipInternalTablesPerNode = DebugZipTableRegistry{
"txn_fingerprint_id",
"query",
"implicit_txn",
"session_id,",
"session_id",
"start_time",
"end_time",
"user_name",
Expand Down
32 changes: 31 additions & 1 deletion pkg/cli/zip_table_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package cli
import (
"context"
"fmt"
"strings"
"testing"

"github.com/cockroachdb/cockroach/pkg/base"
Expand Down Expand Up @@ -162,7 +163,7 @@ func TestCustomQuery(t *testing.T) {
ctx := context.Background()

params, _ := tests.CreateTestServerParams()
cluster := serverutils.StartNewTestCluster(t, 3 /* numNodes */, base.TestClusterArgs{
cluster := serverutils.StartNewTestCluster(t, 1 /* numNodes */, base.TestClusterArgs{
ServerArgs: params,
})
testConn := cluster.ServerConn(0 /* idx */)
Expand All @@ -173,3 +174,32 @@ func TestCustomQuery(t *testing.T) {
executeAllCustomQuerys(t, sqlDB, zipInternalTablesPerNode)
executeAllCustomQuerys(t, sqlDB, zipSystemTables)
}

func executeSelectOnNonSensitiveColumns(
t *testing.T, sqlDB *sqlutils.SQLRunner, tableRegistry DebugZipTableRegistry,
) {

for table, regConfig := range tableRegistry {
if len(regConfig.nonSensitiveCols) != 0 {
columns := strings.Join(regConfig.nonSensitiveCols[:], ",")
rows := sqlDB.Query(t, fmt.Sprintf("SELECT %s FROM %s", columns, table))
require.NoError(t, rows.Err(), "failed to select non sensitive columns on table %s", table)
}
}
}

func TestNonSensitiveColumns(t *testing.T) {
defer leaktest.AfterTest(t)()

params, _ := tests.CreateTestServerParams()
cluster := serverutils.StartNewTestCluster(t, 1 /* numNodes */, base.TestClusterArgs{
ServerArgs: params,
})
defer cluster.Stopper().Stop(context.Background())
testConn := cluster.ServerConn(0 /* idx */)
sqlDB := sqlutils.MakeSQLRunner(testConn)

executeSelectOnNonSensitiveColumns(t, sqlDB, zipInternalTablesPerCluster)
executeSelectOnNonSensitiveColumns(t, sqlDB, zipInternalTablesPerNode)
executeSelectOnNonSensitiveColumns(t, sqlDB, zipSystemTables)
}

0 comments on commit 8c37b61

Please sign in to comment.