|
|
|
@ -128,14 +128,6 @@ func (t *Tester) setObjectMeta(obj runtime.Object, name string) {
|
|
|
|
|
meta.SetGeneration(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func copyOrDie(obj runtime.Object, copier runtime.ObjectCopier) runtime.Object {
|
|
|
|
|
out, err := copier.Copy(obj)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return out
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type AssignFunc func([]runtime.Object) []runtime.Object
|
|
|
|
|
type EmitFunc func(runtime.Object, string) error
|
|
|
|
|
type GetFunc func(genericapirequest.Context, runtime.Object) (runtime.Object, error)
|
|
|
|
@ -148,81 +140,81 @@ type UpdateFunc func(runtime.Object) runtime.Object
|
|
|
|
|
|
|
|
|
|
// Test creating an object.
|
|
|
|
|
func (t *Tester) TestCreate(valid runtime.Object, createFn CreateFunc, getFn GetFunc, invalid ...runtime.Object) {
|
|
|
|
|
t.testCreateHasMetadata(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testCreateHasMetadata(valid.DeepCopyObject())
|
|
|
|
|
if !t.generatesName {
|
|
|
|
|
t.testCreateGeneratesName(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testCreateGeneratesName(valid.DeepCopyObject())
|
|
|
|
|
}
|
|
|
|
|
t.testCreateEquals(copyOrDie(valid, t.scheme), getFn)
|
|
|
|
|
t.testCreateAlreadyExisting(copyOrDie(valid, t.scheme), createFn)
|
|
|
|
|
t.testCreateEquals(valid.DeepCopyObject(), getFn)
|
|
|
|
|
t.testCreateAlreadyExisting(valid.DeepCopyObject(), createFn)
|
|
|
|
|
if t.clusterScope {
|
|
|
|
|
t.testCreateDiscardsObjectNamespace(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testCreateIgnoresContextNamespace(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testCreateIgnoresMismatchedNamespace(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testCreateResetsUserData(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testCreateDiscardsObjectNamespace(valid.DeepCopyObject())
|
|
|
|
|
t.testCreateIgnoresContextNamespace(valid.DeepCopyObject())
|
|
|
|
|
t.testCreateIgnoresMismatchedNamespace(valid.DeepCopyObject())
|
|
|
|
|
t.testCreateResetsUserData(valid.DeepCopyObject())
|
|
|
|
|
} else {
|
|
|
|
|
t.testCreateRejectsMismatchedNamespace(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testCreateRejectsMismatchedNamespace(valid.DeepCopyObject())
|
|
|
|
|
}
|
|
|
|
|
t.testCreateInvokesValidation(invalid...)
|
|
|
|
|
t.testCreateValidatesNames(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testCreateIgnoreClusterName(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testCreateValidatesNames(valid.DeepCopyObject())
|
|
|
|
|
t.testCreateIgnoreClusterName(valid.DeepCopyObject())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test updating an object.
|
|
|
|
|
func (t *Tester) TestUpdate(valid runtime.Object, createFn CreateFunc, getFn GetFunc, updateFn UpdateFunc, invalidUpdateFn ...UpdateFunc) {
|
|
|
|
|
t.testUpdateEquals(copyOrDie(valid, t.scheme), createFn, getFn, updateFn)
|
|
|
|
|
t.testUpdateFailsOnVersionTooOld(copyOrDie(valid, t.scheme), createFn, getFn)
|
|
|
|
|
t.testUpdateOnNotFound(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testUpdateEquals(valid.DeepCopyObject(), createFn, getFn, updateFn)
|
|
|
|
|
t.testUpdateFailsOnVersionTooOld(valid.DeepCopyObject(), createFn, getFn)
|
|
|
|
|
t.testUpdateOnNotFound(valid.DeepCopyObject())
|
|
|
|
|
if !t.clusterScope {
|
|
|
|
|
t.testUpdateRejectsMismatchedNamespace(copyOrDie(valid, t.scheme), createFn, getFn)
|
|
|
|
|
t.testUpdateRejectsMismatchedNamespace(valid.DeepCopyObject(), createFn, getFn)
|
|
|
|
|
}
|
|
|
|
|
t.testUpdateInvokesValidation(copyOrDie(valid, t.scheme), createFn, invalidUpdateFn...)
|
|
|
|
|
t.testUpdateWithWrongUID(copyOrDie(valid, t.scheme), createFn, getFn)
|
|
|
|
|
t.testUpdateRetrievesOldObject(copyOrDie(valid, t.scheme), createFn, getFn)
|
|
|
|
|
t.testUpdatePropagatesUpdatedObjectError(copyOrDie(valid, t.scheme), createFn, getFn)
|
|
|
|
|
t.testUpdateIgnoreGenerationUpdates(copyOrDie(valid, t.scheme), createFn, getFn)
|
|
|
|
|
t.testUpdateIgnoreClusterName(copyOrDie(valid, t.scheme), createFn, getFn)
|
|
|
|
|
t.testUpdateInvokesValidation(valid.DeepCopyObject(), createFn, invalidUpdateFn...)
|
|
|
|
|
t.testUpdateWithWrongUID(valid.DeepCopyObject(), createFn, getFn)
|
|
|
|
|
t.testUpdateRetrievesOldObject(valid.DeepCopyObject(), createFn, getFn)
|
|
|
|
|
t.testUpdatePropagatesUpdatedObjectError(valid.DeepCopyObject(), createFn, getFn)
|
|
|
|
|
t.testUpdateIgnoreGenerationUpdates(valid.DeepCopyObject(), createFn, getFn)
|
|
|
|
|
t.testUpdateIgnoreClusterName(valid.DeepCopyObject(), createFn, getFn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test deleting an object.
|
|
|
|
|
func (t *Tester) TestDelete(valid runtime.Object, createFn CreateFunc, getFn GetFunc, isNotFoundFn IsErrorFunc) {
|
|
|
|
|
t.testDeleteNonExist(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testDeleteNoGraceful(copyOrDie(valid, t.scheme), createFn, getFn, isNotFoundFn)
|
|
|
|
|
t.testDeleteWithUID(copyOrDie(valid, t.scheme), createFn, getFn, isNotFoundFn)
|
|
|
|
|
t.testDeleteNonExist(valid.DeepCopyObject())
|
|
|
|
|
t.testDeleteNoGraceful(valid.DeepCopyObject(), createFn, getFn, isNotFoundFn)
|
|
|
|
|
t.testDeleteWithUID(valid.DeepCopyObject(), createFn, getFn, isNotFoundFn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test gracefully deleting an object.
|
|
|
|
|
func (t *Tester) TestDeleteGraceful(valid runtime.Object, createFn CreateFunc, getFn GetFunc, expectedGrace int64) {
|
|
|
|
|
t.testDeleteGracefulHasDefault(copyOrDie(valid, t.scheme), createFn, getFn, expectedGrace)
|
|
|
|
|
t.testDeleteGracefulWithValue(copyOrDie(valid, t.scheme), createFn, getFn, expectedGrace)
|
|
|
|
|
t.testDeleteGracefulUsesZeroOnNil(copyOrDie(valid, t.scheme), createFn, expectedGrace)
|
|
|
|
|
t.testDeleteGracefulExtend(copyOrDie(valid, t.scheme), createFn, getFn, expectedGrace)
|
|
|
|
|
t.testDeleteGracefulShorten(copyOrDie(valid, t.scheme), createFn, getFn, expectedGrace)
|
|
|
|
|
t.testDeleteGracefulImmediate(copyOrDie(valid, t.scheme), createFn, getFn, expectedGrace)
|
|
|
|
|
t.testDeleteGracefulHasDefault(valid.DeepCopyObject(), createFn, getFn, expectedGrace)
|
|
|
|
|
t.testDeleteGracefulWithValue(valid.DeepCopyObject(), createFn, getFn, expectedGrace)
|
|
|
|
|
t.testDeleteGracefulUsesZeroOnNil(valid.DeepCopyObject(), createFn, expectedGrace)
|
|
|
|
|
t.testDeleteGracefulExtend(valid.DeepCopyObject(), createFn, getFn, expectedGrace)
|
|
|
|
|
t.testDeleteGracefulShorten(valid.DeepCopyObject(), createFn, getFn, expectedGrace)
|
|
|
|
|
t.testDeleteGracefulImmediate(valid.DeepCopyObject(), createFn, getFn, expectedGrace)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test getting object.
|
|
|
|
|
func (t *Tester) TestGet(valid runtime.Object) {
|
|
|
|
|
t.testGetFound(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testGetNotFound(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testGetMimatchedNamespace(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testGetFound(valid.DeepCopyObject())
|
|
|
|
|
t.testGetNotFound(valid.DeepCopyObject())
|
|
|
|
|
t.testGetMimatchedNamespace(valid.DeepCopyObject())
|
|
|
|
|
if !t.clusterScope {
|
|
|
|
|
t.testGetDifferentNamespace(copyOrDie(valid, t.scheme))
|
|
|
|
|
t.testGetDifferentNamespace(valid.DeepCopyObject())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test listing objects.
|
|
|
|
|
func (t *Tester) TestList(valid runtime.Object, assignFn AssignFunc) {
|
|
|
|
|
t.testListNotFound(assignFn)
|
|
|
|
|
t.testListFound(copyOrDie(valid, t.scheme), assignFn)
|
|
|
|
|
t.testListMatchLabels(copyOrDie(valid, t.scheme), assignFn)
|
|
|
|
|
t.testListFound(valid.DeepCopyObject(), assignFn)
|
|
|
|
|
t.testListMatchLabels(valid.DeepCopyObject(), assignFn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test watching objects.
|
|
|
|
|
func (t *Tester) TestWatch(
|
|
|
|
|
valid runtime.Object, emitFn EmitFunc,
|
|
|
|
|
labelsPass, labelsFail []labels.Set, fieldsPass, fieldsFail []fields.Set, actions []string) {
|
|
|
|
|
t.testWatchLabels(copyOrDie(valid, t.scheme), emitFn, labelsPass, labelsFail, actions)
|
|
|
|
|
t.testWatchFields(copyOrDie(valid, t.scheme), emitFn, fieldsPass, fieldsFail, actions)
|
|
|
|
|
t.testWatchLabels(valid.DeepCopyObject(), emitFn, labelsPass, labelsFail, actions)
|
|
|
|
|
t.testWatchFields(valid.DeepCopyObject(), emitFn, fieldsPass, fieldsFail, actions)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
@ -244,7 +236,7 @@ func (t *Tester) delete(ctx genericapirequest.Context, obj runtime.Object) error
|
|
|
|
|
func (t *Tester) testCreateAlreadyExisting(obj runtime.Object, createFn CreateFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(1))
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
@ -260,7 +252,7 @@ func (t *Tester) testCreateAlreadyExisting(obj runtime.Object, createFn CreateFu
|
|
|
|
|
func (t *Tester) testCreateEquals(obj runtime.Object, getFn GetFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(2))
|
|
|
|
|
|
|
|
|
|
created, err := t.storage.(rest.Creater).Create(ctx, foo, false)
|
|
|
|
@ -291,7 +283,7 @@ func (t *Tester) testCreateDiscardsObjectNamespace(valid runtime.Object) {
|
|
|
|
|
objectMeta.SetNamespace("not-default")
|
|
|
|
|
|
|
|
|
|
// Ideally, we'd get an error back here, but at least verify the namespace wasn't persisted
|
|
|
|
|
created, err := t.storage.(rest.Creater).Create(t.TestContext(), copyOrDie(valid, t.scheme), false)
|
|
|
|
|
created, err := t.storage.(rest.Creater).Create(t.TestContext(), valid.DeepCopyObject(), false)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("Unexpected error: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -340,7 +332,7 @@ func (t *Tester) testCreateIgnoresContextNamespace(valid runtime.Object) {
|
|
|
|
|
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), "not-default2")
|
|
|
|
|
|
|
|
|
|
// Ideally, we'd get an error back here, but at least verify the namespace wasn't persisted
|
|
|
|
|
created, err := t.storage.(rest.Creater).Create(ctx, copyOrDie(valid, t.scheme), false)
|
|
|
|
|
created, err := t.storage.(rest.Creater).Create(ctx, valid.DeepCopyObject(), false)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("Unexpected error: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -359,7 +351,7 @@ func (t *Tester) testCreateIgnoresMismatchedNamespace(valid runtime.Object) {
|
|
|
|
|
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), "not-default2")
|
|
|
|
|
|
|
|
|
|
// Ideally, we'd get an error back here, but at least verify the namespace wasn't persisted
|
|
|
|
|
created, err := t.storage.(rest.Creater).Create(ctx, copyOrDie(valid, t.scheme), false)
|
|
|
|
|
created, err := t.storage.(rest.Creater).Create(ctx, valid.DeepCopyObject(), false)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("Unexpected error: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -372,7 +364,7 @@ func (t *Tester) testCreateIgnoresMismatchedNamespace(valid runtime.Object) {
|
|
|
|
|
|
|
|
|
|
func (t *Tester) testCreateValidatesNames(valid runtime.Object) {
|
|
|
|
|
for _, invalidName := range path.NameMayNotBe {
|
|
|
|
|
objCopy := copyOrDie(valid, t.scheme)
|
|
|
|
|
objCopy := valid.DeepCopyObject()
|
|
|
|
|
objCopyMeta := t.getObjectMetaOrFail(objCopy)
|
|
|
|
|
objCopyMeta.SetName(invalidName)
|
|
|
|
|
|
|
|
|
@ -384,7 +376,7 @@ func (t *Tester) testCreateValidatesNames(valid runtime.Object) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, invalidSuffix := range path.NameMayNotContain {
|
|
|
|
|
objCopy := copyOrDie(valid, t.scheme)
|
|
|
|
|
objCopy := valid.DeepCopyObject()
|
|
|
|
|
objCopyMeta := t.getObjectMetaOrFail(objCopy)
|
|
|
|
|
objCopyMeta.SetName(objCopyMeta.GetName() + invalidSuffix)
|
|
|
|
|
|
|
|
|
@ -442,7 +434,7 @@ func (t *Tester) testCreateIgnoreClusterName(valid runtime.Object) {
|
|
|
|
|
objectMeta.SetName(t.namer(3))
|
|
|
|
|
objectMeta.SetClusterName("clustername-to-ignore")
|
|
|
|
|
|
|
|
|
|
obj, err := t.storage.(rest.Creater).Create(t.TestContext(), copyOrDie(valid, t.scheme), false)
|
|
|
|
|
obj, err := t.storage.(rest.Creater).Create(t.TestContext(), valid.DeepCopyObject(), false)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("Unexpected error: %v", err)
|
|
|
|
|
}
|
|
|
|
@ -459,7 +451,7 @@ func (t *Tester) testCreateIgnoreClusterName(valid runtime.Object) {
|
|
|
|
|
func (t *Tester) testUpdateEquals(obj runtime.Object, createFn CreateFunc, getFn GetFunc, updateFn UpdateFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(2))
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
@ -495,7 +487,7 @@ func (t *Tester) testUpdateEquals(obj runtime.Object, createFn CreateFunc, getFn
|
|
|
|
|
func (t *Tester) testUpdateFailsOnVersionTooOld(obj runtime.Object, createFn CreateFunc, getFn GetFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(3))
|
|
|
|
|
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
@ -507,7 +499,7 @@ func (t *Tester) testUpdateFailsOnVersionTooOld(obj runtime.Object, createFn Cre
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
older := copyOrDie(storedFoo, t.scheme)
|
|
|
|
|
older := storedFoo.DeepCopyObject()
|
|
|
|
|
olderMeta := t.getObjectMetaOrFail(older)
|
|
|
|
|
olderMeta.SetResourceVersion("1")
|
|
|
|
|
|
|
|
|
@ -522,14 +514,14 @@ func (t *Tester) testUpdateFailsOnVersionTooOld(obj runtime.Object, createFn Cre
|
|
|
|
|
func (t *Tester) testUpdateInvokesValidation(obj runtime.Object, createFn CreateFunc, invalidUpdateFn ...UpdateFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(4))
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, update := range invalidUpdateFn {
|
|
|
|
|
toUpdate := update(copyOrDie(foo, t.scheme))
|
|
|
|
|
toUpdate := update(foo.DeepCopyObject())
|
|
|
|
|
toUpdateMeta := t.getObjectMetaOrFail(toUpdate)
|
|
|
|
|
got, created, err := t.storage.(rest.Updater).Update(t.TestContext(), toUpdateMeta.GetName(), rest.DefaultUpdatedObjectInfo(toUpdate, t.scheme))
|
|
|
|
|
if got != nil || created {
|
|
|
|
@ -543,7 +535,7 @@ func (t *Tester) testUpdateInvokesValidation(obj runtime.Object, createFn Create
|
|
|
|
|
|
|
|
|
|
func (t *Tester) testUpdateWithWrongUID(obj runtime.Object, createFn CreateFunc, getFn GetFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(5))
|
|
|
|
|
objectMeta := t.getObjectMetaOrFail(foo)
|
|
|
|
|
objectMeta.SetUID(types.UID("UID0000"))
|
|
|
|
@ -563,7 +555,7 @@ func (t *Tester) testUpdateWithWrongUID(obj runtime.Object, createFn CreateFunc,
|
|
|
|
|
|
|
|
|
|
func (t *Tester) testUpdateRetrievesOldObject(obj runtime.Object, createFn CreateFunc, getFn GetFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(6))
|
|
|
|
|
objectMeta := t.getObjectMetaOrFail(foo)
|
|
|
|
|
objectMeta.SetAnnotations(map[string]string{"A": "1"})
|
|
|
|
@ -578,7 +570,7 @@ func (t *Tester) testUpdateRetrievesOldObject(obj runtime.Object, createFn Creat
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
storedFooWithUpdates := copyOrDie(storedFoo, t.scheme)
|
|
|
|
|
storedFooWithUpdates := storedFoo.DeepCopyObject()
|
|
|
|
|
objectMeta = t.getObjectMetaOrFail(storedFooWithUpdates)
|
|
|
|
|
objectMeta.SetAnnotations(map[string]string{"A": "2"})
|
|
|
|
|
|
|
|
|
@ -617,7 +609,7 @@ func (t *Tester) testUpdateRetrievesOldObject(obj runtime.Object, createFn Creat
|
|
|
|
|
|
|
|
|
|
func (t *Tester) testUpdatePropagatesUpdatedObjectError(obj runtime.Object, createFn CreateFunc, getFn GetFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
name := t.namer(7)
|
|
|
|
|
t.setObjectMeta(foo, name)
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
@ -640,7 +632,7 @@ func (t *Tester) testUpdatePropagatesUpdatedObjectError(obj runtime.Object, crea
|
|
|
|
|
func (t *Tester) testUpdateIgnoreGenerationUpdates(obj runtime.Object, createFn CreateFunc, getFn GetFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
name := t.namer(8)
|
|
|
|
|
t.setObjectMeta(foo, name)
|
|
|
|
|
|
|
|
|
@ -653,7 +645,7 @@ func (t *Tester) testUpdateIgnoreGenerationUpdates(obj runtime.Object, createFn
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
older := copyOrDie(storedFoo, t.scheme)
|
|
|
|
|
older := storedFoo.DeepCopyObject()
|
|
|
|
|
olderMeta := t.getObjectMetaOrFail(older)
|
|
|
|
|
olderMeta.SetGeneration(2)
|
|
|
|
|
|
|
|
|
@ -693,7 +685,7 @@ func (t *Tester) testUpdateOnNotFound(obj runtime.Object) {
|
|
|
|
|
func (t *Tester) testUpdateRejectsMismatchedNamespace(obj runtime.Object, createFn CreateFunc, getFn GetFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(1))
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
@ -722,7 +714,7 @@ func (t *Tester) testUpdateRejectsMismatchedNamespace(obj runtime.Object, create
|
|
|
|
|
func (t *Tester) testUpdateIgnoreClusterName(obj runtime.Object, createFn CreateFunc, getFn GetFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
name := t.namer(9)
|
|
|
|
|
t.setObjectMeta(foo, name)
|
|
|
|
|
|
|
|
|
@ -735,7 +727,7 @@ func (t *Tester) testUpdateIgnoreClusterName(obj runtime.Object, createFn Create
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
older := copyOrDie(storedFoo, t.scheme)
|
|
|
|
|
older := storedFoo.DeepCopyObject()
|
|
|
|
|
olderMeta := t.getObjectMetaOrFail(older)
|
|
|
|
|
olderMeta.SetClusterName("clustername-to-ignore")
|
|
|
|
|
|
|
|
|
@ -760,7 +752,7 @@ func (t *Tester) testUpdateIgnoreClusterName(obj runtime.Object, createFn Create
|
|
|
|
|
func (t *Tester) testDeleteNoGraceful(obj runtime.Object, createFn CreateFunc, getFn GetFunc, isNotFoundFn IsErrorFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(1))
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
@ -802,7 +794,7 @@ func (t *Tester) testDeleteNonExist(obj runtime.Object) {
|
|
|
|
|
func (t *Tester) testDeleteWithUID(obj runtime.Object, createFn CreateFunc, getFn GetFunc, isNotFoundFn IsErrorFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(1))
|
|
|
|
|
objectMeta := t.getObjectMetaOrFail(foo)
|
|
|
|
|
objectMeta.SetUID(types.UID("UID0000"))
|
|
|
|
@ -839,7 +831,7 @@ func (t *Tester) testDeleteWithUID(obj runtime.Object, createFn CreateFunc, getF
|
|
|
|
|
func (t *Tester) testDeleteGracefulHasDefault(obj runtime.Object, createFn CreateFunc, getFn GetFunc, expectedGrace int64) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(1))
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
@ -873,7 +865,7 @@ func (t *Tester) testDeleteGracefulHasDefault(obj runtime.Object, createFn Creat
|
|
|
|
|
func (t *Tester) testDeleteGracefulWithValue(obj runtime.Object, createFn CreateFunc, getFn GetFunc, expectedGrace int64) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(2))
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
@ -907,7 +899,7 @@ func (t *Tester) testDeleteGracefulWithValue(obj runtime.Object, createFn Create
|
|
|
|
|
func (t *Tester) testDeleteGracefulExtend(obj runtime.Object, createFn CreateFunc, getFn GetFunc, expectedGrace int64) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(3))
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
@ -949,7 +941,7 @@ func (t *Tester) testDeleteGracefulExtend(obj runtime.Object, createFn CreateFun
|
|
|
|
|
func (t *Tester) testDeleteGracefulImmediate(obj runtime.Object, createFn CreateFunc, getFn GetFunc, expectedGrace int64) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, "foo4")
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
@ -992,7 +984,7 @@ func (t *Tester) testDeleteGracefulImmediate(obj runtime.Object, createFn Create
|
|
|
|
|
func (t *Tester) testDeleteGracefulUsesZeroOnNil(obj runtime.Object, createFn CreateFunc, expectedGrace int64) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(5))
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
@ -1014,7 +1006,7 @@ func (t *Tester) testDeleteGracefulUsesZeroOnNil(obj runtime.Object, createFn Cr
|
|
|
|
|
func (t *Tester) testDeleteGracefulShorten(obj runtime.Object, createFn CreateFunc, getFn GetFunc, expectedGrace int64) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo, t.namer(6))
|
|
|
|
|
if err := createFn(ctx, foo); err != nil {
|
|
|
|
|
t.Errorf("unexpected error: %v", err)
|
|
|
|
@ -1189,9 +1181,9 @@ func listToItems(listObj runtime.Object) ([]runtime.Object, error) {
|
|
|
|
|
func (t *Tester) testListFound(obj runtime.Object, assignFn AssignFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
|
|
|
|
|
foo1 := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo1 := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo1, t.namer(1))
|
|
|
|
|
foo2 := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo2 := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo2, t.namer(2))
|
|
|
|
|
|
|
|
|
|
existing := assignFn([]runtime.Object{foo1, foo2})
|
|
|
|
@ -1216,9 +1208,9 @@ func (t *Tester) testListMatchLabels(obj runtime.Object, assignFn AssignFunc) {
|
|
|
|
|
ctx := t.TestContext()
|
|
|
|
|
testLabels := map[string]string{"key": "value"}
|
|
|
|
|
|
|
|
|
|
foo3 := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo3 := obj.DeepCopyObject()
|
|
|
|
|
t.setObjectMeta(foo3, "foo3")
|
|
|
|
|
foo4 := copyOrDie(obj, t.scheme)
|
|
|
|
|
foo4 := obj.DeepCopyObject()
|
|
|
|
|
foo4Meta := t.getObjectMetaOrFail(foo4)
|
|
|
|
|
foo4Meta.SetName("foo4")
|
|
|
|
|
foo4Meta.SetNamespace(genericapirequest.NamespaceValue(ctx))
|
|
|
|
|