storage: etcd: pass contexts correctly in TestConsistentList

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>

Kubernetes-commit: 7272aca69d2602b0bcc97bb5cdc8139ba4687ceb
This commit is contained in:
Steve Kuznetsov 2022-02-16 13:18:27 -08:00 committed by Kubernetes Publisher
parent 2e4b017097
commit 67dd3e671d
1 changed files with 6 additions and 5 deletions

View File

@ -2263,6 +2263,7 @@ func (t *fancyTransformer) createObject(ctx context.Context) error {
func TestConsistentList(t *testing.T) { func TestConsistentList(t *testing.T) {
client := testserver.RunEtcd(t, nil) client := testserver.RunEtcd(t, nil)
codec := apitesting.TestCodec(codecs, examplev1.SchemeGroupVersion) codec := apitesting.TestCodec(codecs, examplev1.SchemeGroupVersion)
ctx := context.Background()
transformer := &fancyTransformer{ transformer := &fancyTransformer{
transformer: &prefixTransformer{prefix: []byte(defaultTestPrefix)}, transformer: &prefixTransformer{prefix: []byte(defaultTestPrefix)},
@ -2271,7 +2272,7 @@ func TestConsistentList(t *testing.T) {
transformer.store = store transformer.store = store
for i := 0; i < 5; i++ { for i := 0; i < 5; i++ {
if err := transformer.createObject(context.TODO()); err != nil { if err := transformer.createObject(ctx); err != nil {
t.Fatalf("failed to create object: %v", err) t.Fatalf("failed to create object: %v", err)
} }
} }
@ -2293,7 +2294,7 @@ func TestConsistentList(t *testing.T) {
options := storage.ListOptions{ options := storage.ListOptions{
Predicate: predicate, Predicate: predicate,
} }
if err := store.List(context.TODO(), "/", options, &result1); err != nil { if err := store.List(ctx, "/", options, &result1); err != nil {
t.Fatalf("failed to list objects: %v", err) t.Fatalf("failed to list objects: %v", err)
} }
@ -2305,7 +2306,7 @@ func TestConsistentList(t *testing.T) {
} }
result2 := example.PodList{} result2 := example.PodList{}
if err := store.List(context.TODO(), "/", options, &result2); err != nil { if err := store.List(ctx, "/", options, &result2); err != nil {
t.Fatalf("failed to list objects: %v", err) t.Fatalf("failed to list objects: %v", err)
} }
@ -2317,7 +2318,7 @@ func TestConsistentList(t *testing.T) {
options.ResourceVersionMatch = metav1.ResourceVersionMatchNotOlderThan options.ResourceVersionMatch = metav1.ResourceVersionMatchNotOlderThan
result3 := example.PodList{} result3 := example.PodList{}
if err := store.List(context.TODO(), "/", options, &result3); err != nil { if err := store.List(ctx, "/", options, &result3); err != nil {
t.Fatalf("failed to list objects: %v", err) t.Fatalf("failed to list objects: %v", err)
} }
@ -2325,7 +2326,7 @@ func TestConsistentList(t *testing.T) {
options.ResourceVersionMatch = metav1.ResourceVersionMatchExact options.ResourceVersionMatch = metav1.ResourceVersionMatchExact
result4 := example.PodList{} result4 := example.PodList{}
if err := store.List(context.TODO(), "/", options, &result4); err != nil { if err := store.List(ctx, "/", options, &result4); err != nil {
t.Fatalf("failed to list objects: %v", err) t.Fatalf("failed to list objects: %v", err)
} }