From 72fb8f8f40213bab3c5893fa140bfe653a4f14b3 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Wed, 18 Oct 2017 17:43:51 -0700 Subject: [PATCH] Add gc labels to content tests Signed-off-by: Derek McGowan --- content/testsuite/testsuite.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/content/testsuite/testsuite.go b/content/testsuite/testsuite.go index 2f3d91903..647d0e0d6 100644 --- a/content/testsuite/testsuite.go +++ b/content/testsuite/testsuite.go @@ -52,6 +52,10 @@ func makeTest(t *testing.T, name string, storeFn func(ctx context.Context, root } } +var labels = map[string]string{ + "containerd.io/gc.root": time.Now().UTC().Format(time.RFC3339), +} + func checkContentStoreWriter(ctx context.Context, t *testing.T, cs content.Store) { c1, d1 := createContent(256, 1) w1, err := cs.Writer(ctx, "c1", 0, "") @@ -118,7 +122,7 @@ func checkContentStoreWriter(ctx context.Context, t *testing.T, cs content.Store } preCommit := time.Now() - if err := s.writer.Commit(ctx, 0, ""); err != nil { + if err := s.writer.Commit(ctx, 0, "", content.WithLabels(labels)); err != nil { t.Fatal(err) } postCommit := time.Now() @@ -130,6 +134,7 @@ func checkContentStoreWriter(ctx context.Context, t *testing.T, cs content.Store info := content.Info{ Digest: s.digest, Size: int64(len(s.content)), + Labels: labels, } if err := checkInfo(ctx, cs, s.digest, info, preCommit, postCommit, preCommit, postCommit); err != nil { t.Fatalf("Check info failed: %+v", err) @@ -264,7 +269,7 @@ func checkUploadStatus(ctx context.Context, t *testing.T, cs content.Store) { checkStatus(t, w1, expected, d1, preStart, postStart, preUpdate, postUpdate) preCommit := time.Now() - if err := w1.Commit(ctx, 0, ""); err != nil { + if err := w1.Commit(ctx, 0, "", content.WithLabels(labels)); err != nil { t.Fatalf("Commit failed: %+v", err) } postCommit := time.Now() @@ -272,6 +277,7 @@ func checkUploadStatus(ctx context.Context, t *testing.T, cs content.Store) { info := content.Info{ Digest: d1, Size: 256, + Labels: labels, } if err := checkInfo(ctx, cs, d1, info, preCommit, postCommit, preCommit, postCommit); err != nil { @@ -292,9 +298,11 @@ func checkLabels(ctx context.Context, t *testing.T, cs content.Store) { t.Fatalf("Failed to write: %+v", err) } + rootTime := time.Now().UTC().Format(time.RFC3339) labels := map[string]string{ "k1": "v1", "k2": "v2", + "containerd.io/gc.root": rootTime, } preCommit := time.Now() @@ -330,6 +338,7 @@ func checkLabels(ctx context.Context, t *testing.T, cs content.Store) { info.Labels = map[string]string{ "k1": "v1", + "containerd.io/gc.root": rootTime, } preUpdate = time.Now() if _, err := cs.Update(ctx, info, "labels.k3", "labels.k1"); err != nil {