Integrate context with storage package

This changeset integrates context with the storage package. Debug messages have
been added to exported methods. Existing log messages will now include
contextual details through logger fields to aid in debugging. This integration
focuses on logging and may be followed up with a metric-oriented change in the
future.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2015-02-09 14:44:58 -08:00
parent d2bfb5825c
commit d9d84ae269
10 changed files with 49 additions and 21 deletions

View file

@ -13,6 +13,7 @@ import (
"github.com/docker/distribution/storagedriver"
"github.com/docker/distribution/storagedriver/inmemory"
"github.com/docker/distribution/testutil"
"golang.org/x/net/context"
)
// TestSimpleLayerUpload covers the layer upload process, exercising common
@ -30,10 +31,11 @@ func TestSimpleLayerUpload(t *testing.T) {
t.Fatalf("error allocating upload store: %v", err)
}
ctx := context.Background()
imageName := "foo/bar"
driver := inmemory.New()
registry := NewRegistryWithDriver(driver)
ls := registry.Repository(imageName).Layers()
ls := registry.Repository(ctx, imageName).Layers()
h := sha256.New()
rd := io.TeeReader(randomDataReader, h)
@ -133,10 +135,11 @@ func TestSimpleLayerUpload(t *testing.T) {
// open, read, seek, read works. More specific edge cases should be covered in
// other tests.
func TestSimpleLayerRead(t *testing.T) {
ctx := context.Background()
imageName := "foo/bar"
driver := inmemory.New()
registry := NewRegistryWithDriver(driver)
ls := registry.Repository(imageName).Layers()
ls := registry.Repository(ctx, imageName).Layers()
randomLayerReader, tarSumStr, err := testutil.CreateRandomTarFile()
if err != nil {
@ -237,10 +240,11 @@ func TestSimpleLayerRead(t *testing.T) {
// TestLayerUploadZeroLength uploads zero-length
func TestLayerUploadZeroLength(t *testing.T) {
ctx := context.Background()
imageName := "foo/bar"
driver := inmemory.New()
registry := NewRegistryWithDriver(driver)
ls := registry.Repository(imageName).Layers()
ls := registry.Repository(ctx, imageName).Layers()
upload, err := ls.Upload()
if err != nil {