Skip to content

Commit a6a7e28

Browse files
serverccl, application_api: Fix some tests relying on statement_statistics
It fixes a testing bug in TestTenantCannotSeeNonTenantStats, TestStatusAPIStatements, TestStatusAPICombinedStatementsWithFullScans, and TestStatusAPICombinedStatements. These tests involve executing a set of statements and verifying that the statement stats response contains the same set of statements. However, they filter out statements with a failure count > 0. This was a bug introduced by pull #120236 which changed the way failed statements were collected in the SQL stats system. Previously, a stmt with the same query that failed to execute would recieve a different fingerprint and thus be included as a different entry in the statements response. These existing tests filtered out statement entries that failed b/c they used to be an additional entry that would fail when comparing with the set of stmts executed. This filtering out from the tests should have been removed as part of pull #120236. Fixes: #152175 Release note: None
1 parent 0e35b2b commit a6a7e28

File tree

2 files changed

+1
-23
lines changed

2 files changed

+1
-23
lines changed

pkg/ccl/serverccl/statusccl/tenant_status_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,6 @@ func TestTenantCannotSeeNonTenantStats(t *testing.T) {
501501

502502
var actualStatements []string
503503
for _, respStatement := range actual.Statements {
504-
if respStatement.Stats.FailureCount > 0 {
505-
// We ignore failed statements here as the INSERT statement can fail and
506-
// be automatically retried, confusing the test success check.
507-
continue
508-
}
509504
if strings.HasPrefix(respStatement.Key.KeyData.App, catconstants.InternalAppNamePrefix) {
510505
// We ignore internal queries, these are not relevant for the
511506
// validity of this test.

pkg/server/application_api/sql_stats_test.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,6 @@ func TestStatusAPIStatements(t *testing.T) {
446446
// See if the statements returned are what we executed.
447447
var statementsInResponse []string
448448
for _, respStatement := range resp.Statements {
449-
if respStatement.Stats.FailureCount > 0 {
450-
// We ignore failed statements here as the INSERT statement can fail and
451-
// be automatically retried, confusing the test success check.
452-
continue
453-
}
454449
if strings.HasPrefix(respStatement.Key.KeyData.App, catconstants.InternalAppNamePrefix) {
455450
// We ignore internal queries, these are not relevant for the
456451
// validity of this test.
@@ -787,14 +782,7 @@ func TestStatusAPICombinedStatementsWithFullScans(t *testing.T) {
787782
// statement statistics received from the server response.
788783
actualResponseStatsMap := make(map[string]serverpb.StatementsResponse_CollectedStatementStatistics)
789784
for _, respStatement := range resp.Statements {
790-
// Skip failed statements: The test app may encounter transient 40001
791-
// errors that are automatically retried. Thus, we only consider
792-
// statements that were that were successfully executed by the test app
793-
// to avoid counting such failures. If a statement that we expect to be
794-
// successful is not found in the response, the test will fail later.
795-
if respStatement.Key.KeyData.App == testAppName && respStatement.Stats.FailureCount == 0 {
796-
actualResponseStatsMap[respStatement.Key.KeyData.Query] = respStatement
797-
}
785+
actualResponseStatsMap[respStatement.Key.KeyData.Query] = respStatement
798786
}
799787

800788
for respQuery, expectedData := range expectedStatementStatsMap {
@@ -904,11 +892,6 @@ func TestStatusAPICombinedStatements(t *testing.T) {
904892
var statementsInResponse []string
905893
expectedTxnFingerprints := map[appstatspb.TransactionFingerprintID]struct{}{}
906894
for _, respStatement := range resp.Statements {
907-
if respStatement.Stats.FailureCount > 0 {
908-
// We ignore failed statements here as the INSERT statement can fail and
909-
// be automatically retried, confusing the test success check.
910-
continue
911-
}
912895
if strings.HasPrefix(respStatement.Key.KeyData.App, catconstants.InternalAppNamePrefix) {
913896
// CombinedStatementStats should filter out internal queries.
914897
t.Fatalf("unexpected internal query: %s", respStatement.Key.KeyData.Query)

0 commit comments

Comments
 (0)