Skip to content

Commit

Permalink
Fixed data race in registry unit tests
Browse files Browse the repository at this point in the history
Initialize the log level just once. Disable upload purging.

Signed-off-by: Michal Minář <[email protected]>
  • Loading branch information
Michal Minář committed Mar 8, 2017
1 parent 81fbc33 commit fdfda0f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
8 changes: 5 additions & 3 deletions pkg/dockerregistry/server/blobdescriptorservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"testing"
"time"

log "github.com/Sirupsen/logrus"

"github.com/docker/distribution"
"github.com/docker/distribution/configuration"
"github.com/docker/distribution/context"
Expand Down Expand Up @@ -49,7 +47,6 @@ func GetTestPassThroughToUpstream(ctx context.Context) bool {
// It relies on the fact that blobDescriptorService requires higher levels to set repository object on given
// context. If the object isn't given, its method will err out.
func TestBlobDescriptorServiceIsApplied(t *testing.T) {
log.SetLevel(log.DebugLevel)
// don't do any authorization check
installFakeAccessController(t)
m := fakeBlobDescriptorService(t)
Expand Down Expand Up @@ -86,6 +83,11 @@ func TestBlobDescriptorServiceIsApplied(t *testing.T) {
"delete": configuration.Parameters{
"enabled": true,
},
"maintenance": configuration.Parameters{
"uploadpurging": map[interface{}]interface{}{
"enabled": false,
},
},
},
Middleware: map[string][]configuration.Middleware{
"registry": {{Name: "openshift"}},
Expand Down
4 changes: 0 additions & 4 deletions pkg/dockerregistry/server/pullthroughblobstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"testing"
"time"

log "github.com/Sirupsen/logrus"

"github.com/docker/distribution"
"github.com/docker/distribution/context"
"github.com/docker/distribution/digest"
Expand All @@ -31,7 +29,6 @@ import (
func TestPullthroughServeBlob(t *testing.T) {
namespace, name := "user", "app"
repoName := fmt.Sprintf("%s/%s", namespace, name)
log.SetLevel(log.DebugLevel)
installFakeAccessController(t)
setPassthroughBlobDescriptorServiceFactory()

Expand Down Expand Up @@ -221,7 +218,6 @@ func TestPullthroughServeBlobInsecure(t *testing.T) {
repo1Name := fmt.Sprintf("%s/%s", namespace, repo1)
repo2Name := fmt.Sprintf("%s/%s", namespace, repo2)

log.SetLevel(log.DebugLevel)
installFakeAccessController(t)
setPassthroughBlobDescriptorServiceFactory()

Expand Down
5 changes: 5 additions & 0 deletions pkg/dockerregistry/server/pullthroughmanifestservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func createTestRegistryServer(t *testing.T, ctx context.Context) *httptest.Serve
"delete": configuration.Parameters{
"enabled": true,
},
"maintenance": configuration.Parameters{
"uploadpurging": map[interface{}]interface{}{
"enabled": false,
},
},
},
})

Expand Down
5 changes: 4 additions & 1 deletion pkg/dockerregistry/server/repositorymiddleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const (
testImageLayerCount = 2
)

func init() {
log.SetLevel(log.DebugLevel)
}

func TestRepositoryBlobStat(t *testing.T) {
quotaEnforcing = &quotaEnforcingConfig{}

Expand Down Expand Up @@ -326,7 +330,6 @@ func TestRepositoryBlobStat(t *testing.T) {
}

func TestRepositoryBlobStatCacheEviction(t *testing.T) {
log.SetLevel(log.DebugLevel)
const blobRepoCacheTTL = time.Millisecond * 500

quotaEnforcing = &quotaEnforcingConfig{}
Expand Down
10 changes: 10 additions & 0 deletions pkg/dockerregistry/server/signaturedispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ func TestSignatureGet(t *testing.T) {
"delete": configuration.Parameters{
"enabled": true,
},
"maintenance": configuration.Parameters{
"uploadpurging": map[interface{}]interface{}{
"enabled": false,
},
},
},
Middleware: map[string][]configuration.Middleware{
"registry": {{Name: "openshift"}},
Expand Down Expand Up @@ -185,6 +190,11 @@ func TestSignaturePut(t *testing.T) {
"delete": configuration.Parameters{
"enabled": true,
},
"maintenance": configuration.Parameters{
"uploadpurging": map[interface{}]interface{}{
"enabled": false,
},
},
},
Middleware: map[string][]configuration.Middleware{
"registry": {{Name: "openshift"}},
Expand Down

0 comments on commit fdfda0f

Please sign in to comment.