@@ -38,24 +38,24 @@ import (
3838
3939type testCase struct {
4040 query string
41- fingerprint string
41+ stmtNoConst string
4242 count int64
4343}
4444
4545var testQueries = []testCase {
4646 {
4747 query : "SELECT 1" ,
48- fingerprint : "SELECT _" ,
48+ stmtNoConst : "SELECT _" ,
4949 count : 3 ,
5050 },
5151 {
5252 query : "SELECT 1, 2, 3" ,
53- fingerprint : "SELECT _, _, _" ,
53+ stmtNoConst : "SELECT _, _, _" ,
5454 count : 10 ,
5555 },
5656 {
5757 query : "SELECT 1, 1 WHERE 1 < 10" ,
58- fingerprint : "SELECT _, _ WHERE _ < _" ,
58+ stmtNoConst : "SELECT _, _ WHERE _ < _" ,
5959 count : 7 ,
6060 },
6161}
@@ -120,8 +120,8 @@ func TestSQLStatsFlush(t *testing.T) {
120120 // For each test case, we verify that it's being properly inserted exactly
121121 // once and it is exactly executed tc.count number of times.
122122 for _ , tc := range testQueries {
123- verifyNumOfInsertedEntries (t , secondSQLConn , tc .fingerprint , firstServer .SQLInstanceID (), 1 /* expectedStmtEntryCnt */ , 1 /* expectedTxnEntryCtn */ )
124- verifyInsertedFingerprintExecCount (t , secondSQLConn , tc .fingerprint , fakeTime .getAggTimeTs (), firstServer .SQLInstanceID (), tc .count )
123+ verifyNumOfInsertedEntries (t , secondSQLConn , tc .stmtNoConst , firstServer .SQLInstanceID (), 1 /* expectedStmtEntryCnt */ , 1 /* expectedTxnEntryCtn */ )
124+ verifyInsertedFingerprintExecCount (t , secondSQLConn , tc .stmtNoConst , fakeTime .getAggTimeTs (), firstServer .SQLInstanceID (), tc .count )
125125 }
126126 }
127127
@@ -145,10 +145,10 @@ func TestSQLStatsFlush(t *testing.T) {
145145 verifyInMemoryStatsEmpty (t , testQueries , secondServerSQLStats )
146146
147147 for _ , tc := range testQueries {
148- verifyNumOfInsertedEntries (t , secondSQLConn , tc .fingerprint , firstServer .SQLInstanceID (), 1 /* expectedStmtEntryCnt */ , 1 /* expectedTxnEntryCtn */ )
148+ verifyNumOfInsertedEntries (t , secondSQLConn , tc .stmtNoConst , firstServer .SQLInstanceID (), 1 /* expectedStmtEntryCnt */ , 1 /* expectedTxnEntryCtn */ )
149149 // The execution count is doubled here because we execute all of the
150150 // statements here in the same aggregation interval.
151- verifyInsertedFingerprintExecCount (t , secondSQLConn , tc .fingerprint , fakeTime .getAggTimeTs (), firstServer .SQLInstanceID (), tc .count + tc .count - 1 /* expectedCount */ )
151+ verifyInsertedFingerprintExecCount (t , secondSQLConn , tc .stmtNoConst , fakeTime .getAggTimeTs (), firstServer .SQLInstanceID (), tc .count + tc .count - 1 /* expectedCount */ )
152152 }
153153 }
154154
@@ -172,8 +172,8 @@ func TestSQLStatsFlush(t *testing.T) {
172172
173173 for _ , tc := range testQueries {
174174 // We expect exactly 2 entries since we are in a different aggregation window.
175- verifyNumOfInsertedEntries (t , secondSQLConn , tc .fingerprint , firstServer .SQLInstanceID (), 2 /* expectedStmtEntryCnt */ , 2 /* expectedTxnEntryCtn */ )
176- verifyInsertedFingerprintExecCount (t , secondSQLConn , tc .fingerprint , fakeTime .getAggTimeTs (), firstServer .SQLInstanceID (), tc .count )
175+ verifyNumOfInsertedEntries (t , secondSQLConn , tc .stmtNoConst , firstServer .SQLInstanceID (), 2 /* expectedStmtEntryCnt */ , 2 /* expectedTxnEntryCtn */ )
176+ verifyInsertedFingerprintExecCount (t , secondSQLConn , tc .stmtNoConst , fakeTime .getAggTimeTs (), firstServer .SQLInstanceID (), tc .count )
177177 }
178178 }
179179
@@ -196,10 +196,10 @@ func TestSQLStatsFlush(t *testing.T) {
196196 // Ensure that we encode the correct node_id for the new entry and did not
197197 // accidentally tamper the entries written by another server.
198198 for _ , tc := range testQueries {
199- verifyNumOfInsertedEntries (t , firstSQLConn , tc .fingerprint , secondServer .SQLInstanceID (), 1 /* expectedStmtEntryCnt */ , 1 /* expectedTxnEntryCtn */ )
200- verifyInsertedFingerprintExecCount (t , firstSQLConn , tc .fingerprint , fakeTime .getAggTimeTs (), secondServer .SQLInstanceID (), tc .count )
201- verifyNumOfInsertedEntries (t , secondSQLConn , tc .fingerprint , firstServer .SQLInstanceID (), 2 /* expectedStmtEntryCnt */ , 2 /* expectedTxnEntryCtn */ )
202- verifyInsertedFingerprintExecCount (t , secondSQLConn , tc .fingerprint , fakeTime .getAggTimeTs (), firstServer .SQLInstanceID (), tc .count )
199+ verifyNumOfInsertedEntries (t , firstSQLConn , tc .stmtNoConst , secondServer .SQLInstanceID (), 1 /* expectedStmtEntryCnt */ , 1 /* expectedTxnEntryCtn */ )
200+ verifyInsertedFingerprintExecCount (t , firstSQLConn , tc .stmtNoConst , fakeTime .getAggTimeTs (), secondServer .SQLInstanceID (), tc .count )
201+ verifyNumOfInsertedEntries (t , secondSQLConn , tc .stmtNoConst , firstServer .SQLInstanceID (), 2 /* expectedStmtEntryCnt */ , 2 /* expectedTxnEntryCtn */ )
202+ verifyInsertedFingerprintExecCount (t , secondSQLConn , tc .stmtNoConst , fakeTime .getAggTimeTs (), firstServer .SQLInstanceID (), tc .count )
203203 }
204204 }
205205}
@@ -800,8 +800,8 @@ func verifyInMemoryStatsCorrectness(
800800) {
801801 for _ , tc := range tcs {
802802 err := statsProvider .SQLStats .IterateStatementStats (context .Background (), sqlstats.IteratorOptions {}, func (ctx context.Context , statistics * appstatspb.CollectedStatementStatistics ) error {
803- if tc .fingerprint == statistics .Key .Query {
804- require .Equal (t , tc .count , statistics .Stats .Count , "fingerprint: %s" , tc .fingerprint )
803+ if tc .stmtNoConst == statistics .Key .Query {
804+ require .Equal (t , tc .count , statistics .Stats .Count , "fingerprint: %s" , tc .stmtNoConst )
805805 }
806806
807807 // All the queries should be under 1 minute
@@ -827,8 +827,8 @@ func verifyInMemoryStatsEmpty(
827827) {
828828 for _ , tc := range tcs {
829829 err := statsProvider .SQLStats .IterateStatementStats (context .Background (), sqlstats.IteratorOptions {}, func (ctx context.Context , statistics * appstatspb.CollectedStatementStatistics ) error {
830- if tc .fingerprint == statistics .Key .Query {
831- require .Equal (t , 0 /* expected */ , statistics .Stats .Count , "fingerprint: %s" , tc .fingerprint )
830+ if tc .stmtNoConst == statistics .Key .Query {
831+ require .Equal (t , 0 /* expected */ , statistics .Stats .Count , "fingerprint: %s" , tc .stmtNoConst )
832832 }
833833 return nil
834834 })
0 commit comments