diff --git a/test/integration/cert_storage_failed_test.go b/test/integration/cert_storage_failed_test.go index 0d4be3fa4..53720805e 100644 --- a/test/integration/cert_storage_failed_test.go +++ b/test/integration/cert_storage_failed_test.go @@ -21,6 +21,7 @@ import ( "github.com/letsencrypt/boulder/sa" "github.com/letsencrypt/boulder/test" ocsp_helper "github.com/letsencrypt/boulder/test/ocsp/helper" + "github.com/letsencrypt/boulder/test/vars" "golang.org/x/crypto/ocsp" ) @@ -36,6 +37,8 @@ func getPrecertByName(db *sql.DB, name string) (*x509.Certificate, error) { FROM issuedNames JOIN precertificates USING (serial) WHERE reversedName = ? + ORDER BY issuedNames.id DESC + LIMIT 1 `, name) for rows.Next() { err = rows.Scan(&der) @@ -95,11 +98,7 @@ func TestIssuanceCertStorageFailed(t *testing.T) { t.Skip("Skipping test because it requires the StoreLintingCertificateInsteadOfPrecertificate feature flag") } - // Note: DROP / CREATE TRIGGER does not work with prepared statements. Go's - // database/sql usually uses prepared statements, so we have to work to prevent that. - // We do this by using the interpolateParams=true option in the connection string, - // and by not passing any parameters to db.Exec other than the query string. - db, err := sql.Open("mysql", "test_setup@tcp(boulder-proxysql:6033)/boulder_sa_integration?interpolateParams=true") + db, err := sql.Open("mysql", vars.DBConnSAIntegrationFullPerms) test.AssertNotError(t, err, "failed to open db connection") _, err = db.Exec(`DROP TRIGGER IF EXISTS fail_ready`) @@ -112,6 +111,9 @@ func TestIssuanceCertStorageFailed(t *testing.T) { // off of the serial being updated. // We limit this to UPDATEs that set the status to "good" because otherwise we // would fail to revoke the certificate later. + // NOTE: CREATE and DROP TRIGGER do not work in prepared statements. Go's + // database/sql will automatically try to use a prepared statement if you pass + // any arguments to Exec besides the query itself, so don't do that. _, err = db.Exec(` CREATE TRIGGER fail_ready BEFORE UPDATE ON certificateStatus diff --git a/test/vars/vars.go b/test/vars/vars.go index 22dd51bd3..deb2b56df 100644 --- a/test/vars/vars.go +++ b/test/vars/vars.go @@ -13,6 +13,9 @@ var ( DBConnSAMailer = fmt.Sprintf(dbURL, "mailer", "boulder_sa_test") // DBConnSAFullPerms is the sa database connection with full perms DBConnSAFullPerms = fmt.Sprintf(dbURL, "test_setup", "boulder_sa_test") + // DBConnSAIntegrationFullPerms is the sa database connection for the + // integration test DB, with full perms + DBConnSAIntegrationFullPerms = fmt.Sprintf(dbURL, "test_setup", "boulder_sa_integration") // DBInfoSchemaRoot is the root user and the information_schema connection. DBInfoSchemaRoot = fmt.Sprintf(dbURL, "root", "information_schema") // DBConnIncidents is the incidents database connection.