CA: Run all table test subtests in parallel (#7452)

[Previously](https://github.com/letsencrypt/boulder/pull/7438) I had
made a change to run all CA tests in parallel, which was great, but I
failed to account for several table driven tests. By rebinding the
subtest's iterator to the lexical scope, each subtest can now run in
parallel.
This commit is contained in:
Phil Porada 2024-04-25 13:34:36 -04:00 committed by GitHub
parent a4f75c8447
commit 5cc32106e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -334,6 +334,9 @@ func TestIssuePrecertificate(t *testing.T) {
}
for _, testCase := range testCases {
// TODO(#7454) Remove this rebinding
testCase := testCase
// The loop through the issuance modes must be inside the loop through
// |testCases| because the "certificate-for-precertificate" tests use
// the precertificates previously generated from the preceding
@ -341,6 +344,7 @@ func TestIssuePrecertificate(t *testing.T) {
for _, mode := range []string{"precertificate", "certificate-for-precertificate"} {
ca, sa := issueCertificateSubTestSetup(t, nil)
t.Run(fmt.Sprintf("%s - %s", mode, testCase.name), func(t *testing.T) {
t.Parallel()
req, err := x509.ParseCertificateRequest(testCase.csr)
test.AssertNotError(t, err, "Certificate request failed to parse")
issueReq := &capb.IssueCertificateRequest{Csr: testCase.csr, RegistrationID: arbitraryRegID}
@ -701,11 +705,14 @@ func TestProfiles(t *testing.T) {
}
for _, tc := range testCases {
// TODO(#7454) Remove this rebinding
tc := tc
// This is handled by boulder-ca, not the CA package.
if tc.defaultName == "" {
tc.defaultName = ctx.defaultCertProfileName
}
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
tCA, err := NewCertificateAuthorityImpl(
sa,
ctx.pa,
@ -846,6 +853,8 @@ func TestInvalidCSRs(t *testing.T) {
}
for _, testCase := range testCases {
// TODO(#7454) Remove this rebinding
testCase := testCase
testCtx := setup(t)
sa := &mockSA{}
ca, err := NewCertificateAuthorityImpl(
@ -869,6 +878,7 @@ func TestInvalidCSRs(t *testing.T) {
test.AssertNotError(t, err, "Failed to create CA")
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
serializedCSR := mustRead(testCase.csrPath)
issueReq := &capb.IssueCertificateRequest{Csr: serializedCSR, RegistrationID: arbitraryRegID}
_, err = ca.IssuePrecertificate(ctx, issueReq)