Merge pull request #49474 from sttts/sttts-roundtrip-deepcopy

Automatic merge from submit-queue (batch tested with PRs 48976, 49474, 40050, 49426, 49430)

apimachinery: fail early with deepcopy problems during roundtrip tests

If deepcopy is broken for some type, it's easy to diagnose. This PR let's the roundtrip test to fail early in this case.
This commit is contained in:
Kubernetes Submit Queue 2017-07-25 12:14:41 -07:00 committed by GitHub
commit 636984dcdd

View File

@ -276,6 +276,12 @@ func roundTrip(t *testing.T, scheme *runtime.Scheme, codec runtime.Codec, object
object = copied.(runtime.Object)
name := reflect.TypeOf(object).Elem().Name()
// catch deepcopy errors early
if !apiequality.Semantic.DeepEqual(original, object) {
t.Errorf("%v: DeepCopy did not lead to equal object, diff: %v", name, diff.ObjectReflectDiff(original, object))
return
}
// encode (serialize) the deep copy using the provided codec
data, err := runtime.Encode(codec, object)
if err != nil {