Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed blobdescriptorservice unit test flake #13289

Merged
merged 2 commits into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions pkg/dockerregistry/server/blobdescriptorservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,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 Expand Up @@ -256,61 +261,58 @@ func TestBlobDescriptorServiceIsApplied(t *testing.T) {
},

{
name: "get manifest with repository unset",
method: http.MethodGet,
name: "delete manifest with repository unset",
method: http.MethodDelete,
endpoint: v2.RouteNameManifest,
vars: []string{
"name", "user/app",
"reference", "latest",
"reference", testImage.Name,
},
unsetRepository: true,
// failed because we trying to get manifest from storage driver first.
expectedStatus: http.StatusNotFound,
// manifest can't be retrieved from etcd
expectedStatus: http.StatusInternalServerError,
// we don't allow to delete manifests from etcd; in this case, we attempt to delete layer link
expectedMethodInvocations: map[string]int{"Stat": 1},
},

{
name: "get manifest",
method: http.MethodGet,
name: "delete manifest",
method: http.MethodDelete,
endpoint: v2.RouteNameManifest,
vars: []string{
"name", "user/app",
"reference", "latest",
"reference", testImage.Name,
},
expectedStatus: http.StatusOK,
// manifest is retrieved from etcd
expectedStatus: http.StatusNotFound,
// we don't allow to delete manifests from etcd; in this case, we attempt to delete layer link
expectedMethodInvocations: map[string]int{"Stat": 1},
},

{
name: "delete manifest with repository unset",
method: http.MethodDelete,
name: "get manifest with repository unset",
method: http.MethodGet,
endpoint: v2.RouteNameManifest,
vars: []string{
"name", "user/app",
"reference", testImage.Name,
"reference", "latest",
},
unsetRepository: true,
expectedStatus: http.StatusInternalServerError,
// we don't allow to delete manifests from etcd; in this case, we attempt to delete layer link
// failed because we trying to get manifest from storage driver first.
expectedStatus: http.StatusNotFound,
// manifest can't be retrieved from etcd
expectedMethodInvocations: map[string]int{"Stat": 1},
},

{
name: "delete manifest",
method: http.MethodDelete,
name: "get manifest",
method: http.MethodGet,
endpoint: v2.RouteNameManifest,
vars: []string{
"name", "user/app",
"reference", testImage.Name,
},
expectedStatus: http.StatusAccepted,
// we don't allow to delete manifests from etcd; in this case, we attempt to delete layer link
expectedMethodInvocations: map[string]int{
"Stat": 1,
"Clear": 1,
"reference", "latest",
},
expectedStatus: http.StatusOK,
// manifest is retrieved from etcd
expectedMethodInvocations: map[string]int{"Stat": 1},
},
} {
doTest(tc)
Expand Down
5 changes: 0 additions & 5 deletions pkg/dockerregistry/server/pullthroughblobstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,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 @@ -209,7 +206,6 @@ func TestPullthroughServeBlob(t *testing.T) {
func TestPullthroughServeNotSeekableBlob(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 @@ -367,7 +363,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
9 changes: 5 additions & 4 deletions pkg/dockerregistry/server/pullthroughmanifestservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"strings"
"testing"

log "github.com/Sirupsen/logrus"

"github.com/docker/distribution"
"github.com/docker/distribution/configuration"
"github.com/docker/distribution/context"
Expand Down Expand Up @@ -39,6 +37,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 All @@ -59,7 +62,6 @@ func TestPullthroughManifests(t *testing.T) {
repoName := fmt.Sprintf("%s/%s", namespace, repo)
tag := "latest"

log.SetLevel(log.DebugLevel)
client := &testclient.Fake{}

installFakeAccessController(t)
Expand Down Expand Up @@ -179,7 +181,6 @@ func TestPullthroughManifestInsecure(t *testing.T) {
repo := "zapp"
repoName := fmt.Sprintf("%s/%s", namespace, repo)

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

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 @@ -75,6 +75,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 @@ -173,6 +178,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