storage: etcd: shorten sub-test names

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
This commit is contained in:
Steve Kuznetsov 2022-02-16 14:10:43 -08:00
parent 7729691f5c
commit 4e166ff74d
No known key found for this signature in database
GPG Key ID: 8821C29EC988D9B4

View File

@ -300,17 +300,17 @@ func TestUnconditionalDelete(t *testing.T) {
key, storedObj := testPropogateStore(ctx, t, store, &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}) key, storedObj := testPropogateStore(ctx, t, store, &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}})
tests := []struct { tests := []struct {
name string name string
key string key string
expectedObj *example.Pod expectedObj *example.Pod
expectNotFoundErr bool expectNotFoundErr bool
}{{ }{{
name: "test unconditional delete on existing key", name: "existing key",
key: key, key: key,
expectedObj: storedObj, expectedObj: storedObj,
expectNotFoundErr: false, expectNotFoundErr: false,
}, { }, {
name: "test unconditional delete on non-existing key", name: "non-existing key",
key: "/non-existing", key: "/non-existing",
expectedObj: nil, expectedObj: nil,
expectNotFoundErr: true, expectNotFoundErr: true,
@ -341,15 +341,15 @@ func TestConditionalDelete(t *testing.T) {
key, storedObj := testPropogateStore(ctx, t, store, &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo", UID: "A"}}) key, storedObj := testPropogateStore(ctx, t, store, &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo", UID: "A"}})
tests := []struct { tests := []struct {
name string name string
precondition *storage.Preconditions precondition *storage.Preconditions
expectInvalidObjErr bool expectInvalidObjErr bool
}{{ }{{
name: "test conditional delete with UID match", name: "UID match",
precondition: storage.NewUIDPreconditions("A"), precondition: storage.NewUIDPreconditions("A"),
expectInvalidObjErr: false, expectInvalidObjErr: false,
}, { }, {
name: "test conditional delete with UID mismatch", name: "UID mismatch",
precondition: storage.NewUIDPreconditions("B"), precondition: storage.NewUIDPreconditions("B"),
expectInvalidObjErr: true, expectInvalidObjErr: true,
}} }}
@ -560,71 +560,71 @@ func TestGetToList(t *testing.T) {
rvMatch metav1.ResourceVersionMatch rvMatch metav1.ResourceVersionMatch
expectRVTooLarge bool expectRVTooLarge bool
}{{ }{{
name: "test GetToList on existing key", name: "existing key",
key: key, key: key,
pred: storage.Everything, pred: storage.Everything,
expectedOut: []*example.Pod{storedObj}, expectedOut: []*example.Pod{storedObj},
}, { }, {
name: "test GetToList on existing key with minimum resource version set to 0", name: "existing key, resourceVersion=0",
key: key, key: key,
pred: storage.Everything, pred: storage.Everything,
expectedOut: []*example.Pod{storedObj}, expectedOut: []*example.Pod{storedObj},
rv: "0", rv: "0",
}, { }, {
name: "test GetToList on existing key with minimum resource version set to 0, match=minimum", name: "existing key, resourceVersion=0, resourceVersionMatch=notOlderThan",
key: key, key: key,
pred: storage.Everything, pred: storage.Everything,
expectedOut: []*example.Pod{storedObj}, expectedOut: []*example.Pod{storedObj},
rv: "0", rv: "0",
rvMatch: metav1.ResourceVersionMatchNotOlderThan, rvMatch: metav1.ResourceVersionMatchNotOlderThan,
}, { }, {
name: "test GetToList on existing key with minimum resource version set to current resource version", name: "existing key, resourceVersion=current",
key: key, key: key,
pred: storage.Everything, pred: storage.Everything,
expectedOut: []*example.Pod{storedObj}, expectedOut: []*example.Pod{storedObj},
rv: fmt.Sprintf("%d", currentRV), rv: fmt.Sprintf("%d", currentRV),
}, { }, {
name: "test GetToList on existing key with minimum resource version set to current resource version, match=minimum", name: "existing key, resourceVersion=current, resourceVersionMatch=notOlderThan",
key: key, key: key,
pred: storage.Everything, pred: storage.Everything,
expectedOut: []*example.Pod{storedObj}, expectedOut: []*example.Pod{storedObj},
rv: fmt.Sprintf("%d", currentRV), rv: fmt.Sprintf("%d", currentRV),
rvMatch: metav1.ResourceVersionMatchNotOlderThan, rvMatch: metav1.ResourceVersionMatchNotOlderThan,
}, { }, {
name: "test GetToList on existing key with minimum resource version set to previous resource version, match=minimum", name: "existing key, resourceVersion=previous, resourceVersionMatch=notOlderThan",
key: key, key: key,
pred: storage.Everything, pred: storage.Everything,
expectedOut: []*example.Pod{storedObj}, expectedOut: []*example.Pod{storedObj},
rv: fmt.Sprintf("%d", prevRV), rv: fmt.Sprintf("%d", prevRV),
rvMatch: metav1.ResourceVersionMatchNotOlderThan, rvMatch: metav1.ResourceVersionMatchNotOlderThan,
}, { }, {
name: "test GetToList on existing key with resource version set to current resource version, match=exact", name: "existing key, resourceVersion=current, resourceVersionMatch=exact",
key: key, key: key,
pred: storage.Everything, pred: storage.Everything,
expectedOut: []*example.Pod{storedObj}, expectedOut: []*example.Pod{storedObj},
rv: fmt.Sprintf("%d", currentRV), rv: fmt.Sprintf("%d", currentRV),
rvMatch: metav1.ResourceVersionMatchExact, rvMatch: metav1.ResourceVersionMatchExact,
}, { }, {
name: "test GetToList on existing key with resource version set to previous resource version, match=exact", name: "existing key, resourceVersion=current, resourceVersionMatch=exact",
key: prevKey, key: prevKey,
pred: storage.Everything, pred: storage.Everything,
expectedOut: []*example.Pod{prevStoredObj}, expectedOut: []*example.Pod{prevStoredObj},
rv: fmt.Sprintf("%d", prevRV), rv: fmt.Sprintf("%d", prevRV),
rvMatch: metav1.ResourceVersionMatchExact, rvMatch: metav1.ResourceVersionMatchExact,
}, { }, {
name: "test GetToList on existing key with minimum resource version set too high", name: "existing key, resourceVersion=too high",
key: key, key: key,
pred: storage.Everything, pred: storage.Everything,
expectedOut: []*example.Pod{storedObj}, expectedOut: []*example.Pod{storedObj},
rv: fmt.Sprintf("%d", currentRV+1), rv: fmt.Sprintf("%d", currentRV+1),
expectRVTooLarge: true, expectRVTooLarge: true,
}, { }, {
name: "test GetToList on non-existing key", name: "non-existing key",
key: "/non-existing", key: "/non-existing",
pred: storage.Everything, pred: storage.Everything,
expectedOut: nil, expectedOut: nil,
}, { }, {
name: "test GetToList with matching pod name", name: "with matching pod name",
key: "/non-existing", key: "/non-existing",
pred: storage.SelectionPredicate{ pred: storage.SelectionPredicate{
Label: labels.Everything(), Label: labels.Everything(),
@ -650,7 +650,7 @@ func TestGetToList(t *testing.T) {
} }
if err != nil { if err != nil {
t.Fatalf("GetToList failed: %v", err) t.Fatalf("%s: GetToList failed: %v", tt.name, err)
} }
if len(out.ResourceVersion) == 0 { if len(out.ResourceVersion) == 0 {
t.Errorf("%s: unset resourceVersion", tt.name) t.Errorf("%s: unset resourceVersion", tt.name)
@ -684,7 +684,7 @@ func TestGuaranteedUpdate(t *testing.T) {
transformStale bool transformStale bool
hasSelfLink bool hasSelfLink bool
}{{ }{{
name: "GuaranteedUpdate on non-existing key with ignoreNotFound=false", name: "non-existing key, ignoreNotFound=false",
key: "/non-existing", key: "/non-existing",
ignoreNotFound: false, ignoreNotFound: false,
precondition: nil, precondition: nil,
@ -692,7 +692,7 @@ func TestGuaranteedUpdate(t *testing.T) {
expectInvalidObjErr: false, expectInvalidObjErr: false,
expectNoUpdate: false, expectNoUpdate: false,
}, { }, {
name: "GuaranteedUpdate on non-existing key with ignoreNotFound=true", name: "non-existing key, ignoreNotFound=true",
key: "/non-existing", key: "/non-existing",
ignoreNotFound: true, ignoreNotFound: true,
precondition: nil, precondition: nil,
@ -700,7 +700,7 @@ func TestGuaranteedUpdate(t *testing.T) {
expectInvalidObjErr: false, expectInvalidObjErr: false,
expectNoUpdate: false, expectNoUpdate: false,
}, { }, {
name: "GuaranteedUpdate on existing key", name: "existing key",
key: key, key: key,
ignoreNotFound: false, ignoreNotFound: false,
precondition: nil, precondition: nil,
@ -708,7 +708,7 @@ func TestGuaranteedUpdate(t *testing.T) {
expectInvalidObjErr: false, expectInvalidObjErr: false,
expectNoUpdate: false, expectNoUpdate: false,
}, { }, {
name: "GuaranteedUpdate with same data", name: "same data",
key: key, key: key,
ignoreNotFound: false, ignoreNotFound: false,
precondition: nil, precondition: nil,
@ -716,7 +716,7 @@ func TestGuaranteedUpdate(t *testing.T) {
expectInvalidObjErr: false, expectInvalidObjErr: false,
expectNoUpdate: true, expectNoUpdate: true,
}, { }, {
name: "GuaranteedUpdate with same data AND a selfLink", name: "same data, a selfLink",
key: key, key: key,
ignoreNotFound: false, ignoreNotFound: false,
precondition: nil, precondition: nil,
@ -725,7 +725,7 @@ func TestGuaranteedUpdate(t *testing.T) {
expectNoUpdate: true, expectNoUpdate: true,
hasSelfLink: true, hasSelfLink: true,
}, { }, {
name: "GuaranteedUpdate with same data but stale", name: "same data, stale",
key: key, key: key,
ignoreNotFound: false, ignoreNotFound: false,
precondition: nil, precondition: nil,
@ -734,7 +734,7 @@ func TestGuaranteedUpdate(t *testing.T) {
expectNoUpdate: false, expectNoUpdate: false,
transformStale: true, transformStale: true,
}, { }, {
name: "GuaranteedUpdate with UID match", name: "UID match",
key: key, key: key,
ignoreNotFound: false, ignoreNotFound: false,
precondition: storage.NewUIDPreconditions("A"), precondition: storage.NewUIDPreconditions("A"),
@ -742,7 +742,7 @@ func TestGuaranteedUpdate(t *testing.T) {
expectInvalidObjErr: false, expectInvalidObjErr: false,
expectNoUpdate: true, expectNoUpdate: true,
}, { }, {
name: "GuaranteedUpdate with UID mismatch", name: "UID mismatch",
key: key, key: key,
ignoreNotFound: false, ignoreNotFound: false,
precondition: storage.NewUIDPreconditions("B"), precondition: storage.NewUIDPreconditions("B"),