@@ -21,19 +21,19 @@ func TestInvalidDSN(t *testing.T) {
2121 _ , err := DBMapForTest ("invalid" )
2222 test .AssertError (t , err , "DB connect string missing the slash separating the database name" )
2323
24- DSN := "policy:password@tcp(boulder-proxysql:6033 )/boulder_policy_integration?readTimeout=800ms&writeTimeout=800ms&stringVarThatDoesntExist=%27whoopsidaisies"
24+ DSN := "policy:password@tcp(foo-database:1337 )/boulder_policy_integration?readTimeout=800ms&writeTimeout=800ms&stringVarThatDoesntExist=%27whoopsidaisies"
2525 _ , err = DBMapForTest (DSN )
2626 test .AssertError (t , err , "Variable does not exist in curated system var list, but didn't return an error and should have" )
2727
28- DSN = "policy:password@tcp(boulder-proxysql:6033 )/boulder_policy_integration?readTimeout=800ms&writeTimeout=800ms&concurrent_insert=2"
28+ DSN = "policy:password@tcp(foo-database:1337 )/boulder_policy_integration?readTimeout=800ms&writeTimeout=800ms&concurrent_insert=2"
2929 _ , err = DBMapForTest (DSN )
3030 test .AssertError (t , err , "Variable is unable to be set in the SESSION scope, but was declared" )
3131
32- DSN = "policy:password@tcp(boulder-proxysql:6033 )/boulder_policy_integration?readTimeout=800ms&writeTimeout=800ms&optimizer_switch=incorrect-quoted-string"
32+ DSN = "policy:password@tcp(foo-database:1337 )/boulder_policy_integration?readTimeout=800ms&writeTimeout=800ms&optimizer_switch=incorrect-quoted-string"
3333 _ , err = DBMapForTest (DSN )
3434 test .AssertError (t , err , "Variable declared with incorrect quoting" )
3535
36- DSN = "policy:password@tcp(boulder-proxysql:6033 )/boulder_policy_integration?readTimeout=800ms&writeTimeout=800ms&concurrent_insert=%272%27"
36+ DSN = "policy:password@tcp(foo-database:1337 )/boulder_policy_integration?readTimeout=800ms&writeTimeout=800ms&concurrent_insert=%272%27"
3737 _ , err = DBMapForTest (DSN )
3838 test .AssertError (t , err , "Integer enum declared, but should not have been quoted" )
3939}
@@ -75,9 +75,8 @@ func TestDbSettings(t *testing.T) {
7575 oldSetConnMaxIdleTime (db , connMaxIdleTime )
7676 }
7777 dsnFile := path .Join (t .TempDir (), "dbconnect" )
78- err := os .WriteFile (dsnFile ,
79- []byte ("sa@tcp(boulder-proxysql:6033)/boulder_sa_integration" ),
80- os .ModeAppend )
78+
79+ err := os .WriteFile (dsnFile , []byte (vars .DBConnSA ), os .ModeAppend )
8180 test .AssertNotError (t , err , "writing dbconnect file" )
8281
8382 config := cmd.DBConfig {
@@ -108,7 +107,7 @@ func TestDbSettings(t *testing.T) {
108107// TODO: Change this to test `newDbMapFromMySQLConfig` instead?
109108func TestNewDbMap (t * testing.T ) {
110109 const mysqlConnectURL = "policy:password@tcp(boulder-proxysql:6033)/boulder_policy_integration?readTimeout=800ms&writeTimeout=800ms"
111- const expected = "policy:password@tcp(boulder-proxysql:6033)/boulder_policy_integration?clientFoundRows=true&parseTime=true&readTimeout=800ms&writeTimeout=800ms&long_query_time=0.640000&max_statement_time=0.760000& sql_mode=%27STRICT_ALL_TABLES%27"
110+ const expected = "policy:password@tcp(boulder-proxysql:6033)/boulder_policy_integration?clientFoundRows=true&parseTime=true&readTimeout=800ms&writeTimeout=800ms&sql_mode=%27STRICT_ALL_TABLES%27"
112111 oldSQLOpen := sqlOpen
113112 defer func () {
114113 sqlOpen = oldSQLOpen
@@ -146,27 +145,6 @@ func TestStrictness(t *testing.T) {
146145 }
147146}
148147
149- func TestTimeouts (t * testing.T ) {
150- dbMap , err := DBMapForTest (vars .DBConnSA + "?max_statement_time=1" )
151- if err != nil {
152- t .Fatal ("Error setting up DB:" , err )
153- }
154- // SLEEP is defined to return 1 if it was interrupted, but we want to actually
155- // get an error to simulate what would happen with a slow query. So we wrap
156- // the SLEEP in a subselect.
157- _ , err = dbMap .ExecContext (ctx , `SELECT 1 FROM (SELECT SLEEP(5)) as subselect;` )
158- if err == nil {
159- t .Fatal ("Expected error when running slow query, got none." )
160- }
161-
162- // We expect to get:
163- // Error 1969: Query execution was interrupted (max_statement_time exceeded)
164- // https://mariadb.com/kb/en/mariadb/mariadb-error-codes/
165- if ! strings .Contains (err .Error (), "Error 1969" ) {
166- t .Fatalf ("Got wrong type of error: %s" , err )
167- }
168- }
169-
170148// TestAutoIncrementSchema tests that all of the tables in the boulder_*
171149// databases that have auto_increment columns use BIGINT for the data type. Our
172150// data is too big for INT.
@@ -190,40 +168,7 @@ func TestAdjustMySQLConfig(t *testing.T) {
190168 conf := & mysql.Config {}
191169 err := adjustMySQLConfig (conf )
192170 test .AssertNotError (t , err , "unexpected err setting server variables" )
193- test .AssertDeepEquals (t , conf .Params , map [string ]string {
194- "sql_mode" : "'STRICT_ALL_TABLES'" ,
195- })
196-
197- conf = & mysql.Config {ReadTimeout : 100 * time .Second }
198- err = adjustMySQLConfig (conf )
199- test .AssertNotError (t , err , "unexpected err setting server variables" )
200- test .AssertDeepEquals (t , conf .Params , map [string ]string {
201- "sql_mode" : "'STRICT_ALL_TABLES'" ,
202- "max_statement_time" : "95.000000" ,
203- "long_query_time" : "80.000000" ,
204- })
205-
206- conf = & mysql.Config {
207- ReadTimeout : 100 * time .Second ,
208- Params : map [string ]string {
209- "max_statement_time" : "0" ,
210- },
211- }
212- err = adjustMySQLConfig (conf )
213- test .AssertNotError (t , err , "unexpected err setting server variables" )
214- test .AssertDeepEquals (t , conf .Params , map [string ]string {
215- "sql_mode" : "'STRICT_ALL_TABLES'" ,
216- "long_query_time" : "80.000000" ,
217- })
218-
219- conf = & mysql.Config {
220- Params : map [string ]string {
221- "max_statement_time" : "0" ,
222- },
223- }
224- err = adjustMySQLConfig (conf )
225- test .AssertNotError (t , err , "unexpected err setting server variables" )
226- test .AssertDeepEquals (t , conf .Params , map [string ]string {
227- "sql_mode" : "'STRICT_ALL_TABLES'" ,
228- })
171+ test .Assert (t , conf .ParseTime , "ParseTime should be enabled" )
172+ test .Assert (t , conf .ClientFoundRows , "ClientFoundRows should be enabled" )
173+ test .AssertDeepEquals (t , conf .Params , map [string ]string {"sql_mode" : "'STRICT_ALL_TABLES'" })
229174}
0 commit comments