You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: cert_manager_test.go
    path of file: ./repos/cockroach/pkg/security/certmgr
    
    the code of the file until where you have to start completion: // Copyright 2021 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package certmgr

import (
	"context"
	"encoding/json"
	"errors"
	"math"
	"regexp"
	"strings"
	"sync"
	"sync/atomic"
	"testing"
	"time"

	"github.com/cockroachdb/cockroach/pkg/testutils"
	"github.com/cockroachdb/cockroach/pkg/util/leaktest"
	"github.com/cockroachdb/cockroach/pkg/util/log"
	"github.com/cockroachdb/cockroach/pkg/util/log/eventpb"
	"github.com/cockroachdb/cockroach/pkg/util/timeutil"
	"github.com/golang/mock/gomock"
	"github.com/stretchr/testify/require"
	"golang.org/x/sys/unix"
)

func TestCertManager_ManageCert_RemoveCert(t *testing.T) {
	defer leaktest.AfterTest(t)()
	ctx, cancel := context.WithCancel(context.Back
    
func TestCertManager_Reload_Failure(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()
	defer leaktest.AfterTest(t)()
	defer log.ScopeWithoutShowLogs(t).Close(t)
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	cm := NewCertManager(ctx)

	cert1 := NewMockCert(ctrl)
	cert1.EXPECT().Err().AnyTimes()
	cert1.EXPECT().Reload(gomock.Any()).Times(1).Do(
		func(_ context.Context) {
			t.Log("called Reload() on cert1")
		})
	cm.ManageCert("cert1", cert1)

	cert2 := NewMockCert(ctrl)
	cert2.EXPECT().Err().AnyTimes().Return(errors.New("reload failed"))
	cert2.EXPECT().Reload(gomock.Any()).Times(1).Do(
		func(_ context.Context) {
			t.Log("called Reload() on cert2")
		})
	cm.ManageCert("cert2", cert2)

	beforeReload := timeutil.Now()
	t.Log("issuing SIGHUP")
	if err := unix.Kill(unix.Getpid(), unix.SIGHUP); err != nil {
		t.Fatal(err)
	}

	// We use SucceedsSoon here because there may be a delay between
	// the moment SIGHUP is processed and certs are reloaded, and
	// the moment the structured logging event is actually
	// written to the log file.
	testutils.SucceedsSoon(t, func() error {
		return checkLogStructEntry(t, false, beforeReload)
	})
}