mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Refactor diff into sub pkg
This commit is contained in:
parent
d6e1566509
commit
b0900bf0d4
@ -25,7 +25,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
apitesting "k8s.io/kubernetes/pkg/api/testing"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
|
||||
"github.com/google/gofuzz"
|
||||
)
|
||||
@ -54,7 +54,7 @@ func doDeepCopyTest(t *testing.T, kind unversioned.GroupVersionKind, f *fuzz.Fuz
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(item, itemCopy) {
|
||||
t.Errorf("\nexpected: %#v\n\ngot: %#v\n\ndiff: %v", item, itemCopy, util.ObjectGoPrintSideBySide(item, itemCopy))
|
||||
t.Errorf("\nexpected: %#v\n\ngot: %#v\n\ndiff: %v", item, itemCopy, diff.ObjectGoPrintSideBySide(item, itemCopy))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
|
||||
"github.com/google/gofuzz"
|
||||
)
|
||||
@ -224,7 +224,7 @@ func TestSetListToRuntimeObjectArray(t *testing.T) {
|
||||
}
|
||||
for i := range list {
|
||||
if e, a := list[i], pl.Items[i]; e != a {
|
||||
t.Fatalf("%d: unmatched: %s", i, util.ObjectDiff(e, a))
|
||||
t.Fatalf("%d: unmatched: %s", i, diff.ObjectDiff(e, a))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import (
|
||||
_ "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/runtime/protobuf"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -53,7 +53,7 @@ func TestProtobufRoundTrip(t *testing.T) {
|
||||
}
|
||||
if !api.Semantic.Equalities.DeepEqual(out, obj) {
|
||||
t.Logf("marshal\n%s", hex.Dump(data))
|
||||
t.Fatalf("Unmarshal is unequal\n%s", util.ObjectGoPrintSideBySide(out, obj))
|
||||
t.Fatalf("Unmarshal is unequal\n%s", diff.ObjectGoPrintSideBySide(out, obj))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
"k8s.io/kubernetes/pkg/util/sets"
|
||||
)
|
||||
|
||||
@ -76,7 +76,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
|
||||
return
|
||||
}
|
||||
if !api.Semantic.DeepEqual(item, obj2) {
|
||||
t.Errorf("\n1: %v: diff: %v\nCodec: %v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, util.ObjectGoPrintDiff(item, obj2), codec, printer.Sprintf("%#v", item), string(data), printer.Sprintf("%#v", obj2))
|
||||
t.Errorf("\n1: %v: diff: %v\nCodec: %v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, diff.ObjectGoPrintDiff(item, obj2), codec, printer.Sprintf("%#v", item), string(data), printer.Sprintf("%#v", obj2))
|
||||
return
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
|
||||
return
|
||||
}
|
||||
if !api.Semantic.DeepEqual(item, obj3) {
|
||||
t.Errorf("3: %v: diff: %v\nCodec: %v", name, util.ObjectDiff(item, obj3), codec)
|
||||
t.Errorf("3: %v: diff: %v\nCodec: %v", name, diff.ObjectDiff(item, obj3), codec)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -210,7 +210,7 @@ func TestEncode_Ptr(t *testing.T) {
|
||||
t.Fatalf("Got wrong type")
|
||||
}
|
||||
if !api.Semantic.DeepEqual(obj2, pod) {
|
||||
t.Errorf("\nExpected:\n\n %#v,\n\nGot:\n\n %#vDiff: %v\n\n", pod, obj2, util.ObjectDiff(obj2, pod))
|
||||
t.Errorf("\nExpected:\n\n %#v,\n\nGot:\n\n %#vDiff: %v\n\n", pod, obj2, diff.ObjectDiff(obj2, pod))
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
versioned "k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
func TestPodLogOptions(t *testing.T) {
|
||||
@ -99,7 +99,7 @@ func TestPodLogOptions(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(convertedLogOptions, versionedLogOptions) {
|
||||
t.Fatalf("Unexpected deserialization:\n%s", util.ObjectGoPrintSideBySide(versionedLogOptions, convertedLogOptions))
|
||||
t.Fatalf("Unexpected deserialization:\n%s", diff.ObjectGoPrintSideBySide(versionedLogOptions, convertedLogOptions))
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ func TestPodLogOptions(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(convertedLogOptions, unversionedLogOptions) {
|
||||
t.Fatalf("Unexpected deserialization:\n%s", util.ObjectGoPrintSideBySide(unversionedLogOptions, convertedLogOptions))
|
||||
t.Fatalf("Unexpected deserialization:\n%s", diff.ObjectGoPrintSideBySide(unversionedLogOptions, convertedLogOptions))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
"k8s.io/kubernetes/pkg/util/sets"
|
||||
"k8s.io/kubernetes/pkg/version"
|
||||
"k8s.io/kubernetes/pkg/watch"
|
||||
@ -1892,7 +1893,7 @@ func TestDeleteWithOptions(t *testing.T) {
|
||||
t.Errorf("Unexpected delete: %s, expected %s", simpleStorage.deleted, ID)
|
||||
}
|
||||
if !api.Semantic.DeepEqual(simpleStorage.deleteOptions, item) {
|
||||
t.Errorf("unexpected delete options: %s", util.ObjectDiff(simpleStorage.deleteOptions, item))
|
||||
t.Errorf("unexpected delete options: %s", diff.ObjectDiff(simpleStorage.deleteOptions, item))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
"k8s.io/kubernetes/pkg/util/strategicpatch"
|
||||
)
|
||||
|
||||
@ -255,7 +255,7 @@ func (tc *patchTestCase) Run(t *testing.T) {
|
||||
reallyExpectedPod := expectedObj.(*api.Pod)
|
||||
|
||||
if !reflect.DeepEqual(*reallyExpectedPod, *resultPod) {
|
||||
t.Errorf("%s mismatch: %v\n", tc.name, util.ObjectGoPrintDiff(reallyExpectedPod, resultPod))
|
||||
t.Errorf("%s mismatch: %v\n", tc.name, diff.ObjectGoPrintDiff(reallyExpectedPod, resultPod))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
func makeObjectReference(kind, name, namespace string) api.ObjectReference {
|
||||
@ -118,7 +119,7 @@ func validateEvent(messagePrefix string, actualEvent *api.Event, expectedEvent *
|
||||
}
|
||||
recvEvent.Name = expectedEvent.Name
|
||||
if e, a := expectedEvent, &recvEvent; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%v - diff: %s", messagePrefix, util.ObjectGoPrintDiff(e, a))
|
||||
t.Errorf("%v - diff: %s", messagePrefix, diff.ObjectGoPrintDiff(e, a))
|
||||
}
|
||||
recvEvent.FirstTimestamp = actualFirstTimestamp
|
||||
recvEvent.LastTimestamp = actualLastTimestamp
|
||||
|
@ -29,7 +29,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
utiltesting "k8s.io/kubernetes/pkg/util/testing"
|
||||
)
|
||||
|
||||
@ -114,7 +114,7 @@ func TestDoRequestFailed(t *testing.T) {
|
||||
expected.APIVersion = "v1"
|
||||
expected.Kind = "Status"
|
||||
if !reflect.DeepEqual(&expected, &actual) {
|
||||
t.Errorf("Unexpected mis-match: %s", util.ObjectDiff(status, &actual))
|
||||
t.Errorf("Unexpected mis-match: %s", diff.ObjectDiff(status, &actual))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ import (
|
||||
unversionedcore "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned"
|
||||
fakecloud "k8s.io/kubernetes/pkg/cloudprovider/providers/fake"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
"k8s.io/kubernetes/pkg/util/wait"
|
||||
"k8s.io/kubernetes/pkg/watch"
|
||||
)
|
||||
@ -736,10 +737,10 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
|
||||
t.Errorf("expected %v call, but got %v.", item.expectedRequestCount, item.fakeNodeHandler.RequestCount)
|
||||
}
|
||||
if len(item.fakeNodeHandler.UpdatedNodes) > 0 && !api.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodes) {
|
||||
t.Errorf("Case[%d] unexpected nodes: %s", i, util.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0]))
|
||||
t.Errorf("Case[%d] unexpected nodes: %s", i, diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodes[0]))
|
||||
}
|
||||
if len(item.fakeNodeHandler.UpdatedNodeStatuses) > 0 && !api.Semantic.DeepEqual(item.expectedNodes, item.fakeNodeHandler.UpdatedNodeStatuses) {
|
||||
t.Errorf("Case[%d] unexpected nodes: %s", i, util.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0]))
|
||||
t.Errorf("Case[%d] unexpected nodes: %s", i, diff.ObjectDiff(item.expectedNodes[0], item.fakeNodeHandler.UpdatedNodeStatuses[0]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
"github.com/google/gofuzz"
|
||||
flag "github.com/spf13/pflag"
|
||||
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
var fuzzIters = flag.Int("fuzz-iters", 50, "How many fuzzing iterations to do.")
|
||||
@ -835,12 +835,12 @@ func objDiff(a, b interface{}) string {
|
||||
if err != nil {
|
||||
panic("b")
|
||||
}
|
||||
return util.StringDiff(string(ab), string(bb))
|
||||
return diff.StringDiff(string(ab), string(bb))
|
||||
|
||||
// An alternate diff attempt, in case json isn't showing you
|
||||
// the difference. (reflect.DeepEqual makes a distinction between
|
||||
// nil and empty slices, for example.)
|
||||
//return util.StringDiff(
|
||||
//return diff.StringDiff(
|
||||
// fmt.Sprintf("%#v", a),
|
||||
// fmt.Sprintf("%#v", b),
|
||||
//)
|
||||
|
@ -29,7 +29,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
|
||||
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
func newRedFederalCowHammerConfig() clientcmdapi.Config {
|
||||
@ -725,7 +725,7 @@ func (test configCommandTest) run(t *testing.T) string {
|
||||
testClearLocationOfOrigin(&actualConfig)
|
||||
|
||||
if !api.Semantic.DeepEqual(test.expectedConfig, actualConfig) {
|
||||
t.Errorf("diff: %v", util.ObjectDiff(test.expectedConfig, actualConfig))
|
||||
t.Errorf("diff: %v", diff.ObjectDiff(test.expectedConfig, actualConfig))
|
||||
t.Errorf("expected: %#v\n actual: %#v", test.expectedConfig, actualConfig)
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"testing"
|
||||
|
||||
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
type stepParserTest struct {
|
||||
@ -90,7 +90,7 @@ func (test stepParserTest) run(t *testing.T) {
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(test.expectedNavigationSteps, *actualSteps) {
|
||||
t.Errorf("diff: %v", util.ObjectDiff(test.expectedNavigationSteps, *actualSteps))
|
||||
t.Errorf("diff: %v", diff.ObjectDiff(test.expectedNavigationSteps, *actualSteps))
|
||||
t.Errorf("expected: %#v\n actual: %#v", test.expectedNavigationSteps, *actualSteps)
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/client/restclient"
|
||||
"k8s.io/kubernetes/pkg/client/unversioned/fake"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
"k8s.io/kubernetes/pkg/watch"
|
||||
"k8s.io/kubernetes/pkg/watch/json"
|
||||
)
|
||||
@ -633,7 +633,7 @@ func TestGetMultipleTypeObjectsWithDirectReference(t *testing.T) {
|
||||
expected := []runtime.Object{&svc.Items[0], node}
|
||||
actual := tf.Printer.(*testPrinter).Objects
|
||||
if !api.Semantic.DeepEqual(expected, actual) {
|
||||
t.Errorf("unexpected object: %s", util.ObjectDiff(expected, actual))
|
||||
t.Errorf("unexpected object: %s", diff.ObjectDiff(expected, actual))
|
||||
}
|
||||
if len(buf.String()) == 0 {
|
||||
t.Errorf("unexpected empty output")
|
||||
|
@ -34,7 +34,7 @@ import (
|
||||
kubectltesting "k8s.io/kubernetes/pkg/kubectl/testing"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
yamlserializer "k8s.io/kubernetes/pkg/runtime/serializer/yaml"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
"k8s.io/kubernetes/pkg/util/intstr"
|
||||
"k8s.io/kubernetes/pkg/util/sets"
|
||||
|
||||
@ -182,7 +182,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(testData, poutput) {
|
||||
t.Errorf("Test data and unmarshaled data are not equal: %v", util.ObjectDiff(poutput, testData))
|
||||
t.Errorf("Test data and unmarshaled data are not equal: %v", diff.ObjectDiff(poutput, testData))
|
||||
}
|
||||
|
||||
obj := &api.Pod{
|
||||
@ -202,7 +202,7 @@ func testPrinter(t *testing.T, printer ResourcePrinter, unmarshalFunc func(data
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(obj, &objOut) {
|
||||
t.Errorf("Unexpected inequality:\n%v", util.ObjectDiff(obj, &objOut))
|
||||
t.Errorf("Unexpected inequality:\n%v", diff.ObjectDiff(obj, &objOut))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/bandwidth"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
utilruntime "k8s.io/kubernetes/pkg/util/runtime"
|
||||
"k8s.io/kubernetes/pkg/util/sets"
|
||||
@ -2771,7 +2772,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
if !api.Semantic.DeepEqual(expectedNode, updatedNode) {
|
||||
t.Errorf("unexpected objects: %s", util.ObjectDiff(expectedNode, updatedNode))
|
||||
t.Errorf("unexpected objects: %s", diff.ObjectDiff(expectedNode, updatedNode))
|
||||
}
|
||||
}
|
||||
|
||||
@ -2846,7 +2847,7 @@ func TestUpdateNewNodeOutOfDiskStatusWithTransitionFrequency(t *testing.T) {
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(expectedNodeOutOfDiskCondition, oodCondition) {
|
||||
t.Errorf("unexpected objects: %s", util.ObjectDiff(expectedNodeOutOfDiskCondition, oodCondition))
|
||||
t.Errorf("unexpected objects: %s", diff.ObjectDiff(expectedNodeOutOfDiskCondition, oodCondition))
|
||||
}
|
||||
}
|
||||
|
||||
@ -3282,7 +3283,7 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) {
|
||||
LastTransitionTime: unversioned.Time{},
|
||||
}
|
||||
if !api.Semantic.DeepEqual(expectedNode, updatedNode) {
|
||||
t.Errorf("unexpected objects: %s", util.ObjectDiff(expectedNode, updatedNode))
|
||||
t.Errorf("unexpected objects: %s", diff.ObjectDiff(expectedNode, updatedNode))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
containertest "k8s.io/kubernetes/pkg/kubelet/container/testing"
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -86,7 +87,7 @@ func verifyEvents(t *testing.T, expected, actual []*PodLifecycleEvent) {
|
||||
sort.Sort(sortableEvents(expected))
|
||||
sort.Sort(sortableEvents(actual))
|
||||
if !reflect.DeepEqual(expected, actual) {
|
||||
t.Errorf("Actual events differ from the expected; diff:\n %v", util.ObjectDiff(expected, actual))
|
||||
t.Errorf("Actual events differ from the expected; diff:\n %v", diff.ObjectDiff(expected, actual))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ import (
|
||||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
|
||||
"k8s.io/kubernetes/pkg/kubelet/util/format"
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
"k8s.io/kubernetes/pkg/util/wait"
|
||||
)
|
||||
|
||||
@ -453,7 +453,7 @@ func (m *manager) needsReconcile(uid types.UID, status api.PodStatus) bool {
|
||||
return false
|
||||
}
|
||||
glog.V(3).Infof("Pod status is inconsistent with cached status for pod %q, a reconciliation should be triggered:\n %+v", format.Pod(pod),
|
||||
util.ObjectDiff(podStatus, status))
|
||||
diff.ObjectDiff(podStatus, status))
|
||||
|
||||
return true
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/apiserver"
|
||||
"k8s.io/kubernetes/pkg/probe"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
@ -82,7 +82,7 @@ func TestList_NoError(t *testing.T) {
|
||||
Items: []api.ComponentStatus{*(createTestStatus("test1", api.ConditionTrue, "ok", ""))},
|
||||
}
|
||||
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("Got unexpected object. Diff: %s", util.ObjectDiff(e, a))
|
||||
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a))
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ func TestList_FailedCheck(t *testing.T) {
|
||||
*(createTestStatus("test1", api.ConditionFalse, "", ""))},
|
||||
}
|
||||
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("Got unexpected object. Diff: %s", util.ObjectDiff(e, a))
|
||||
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a))
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ func TestList_UnknownError(t *testing.T) {
|
||||
*(createTestStatus("test1", api.ConditionUnknown, "", "fizzbuzz error"))},
|
||||
}
|
||||
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("Got unexpected object. Diff: %s", util.ObjectDiff(e, a))
|
||||
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a))
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ func TestGet_NoError(t *testing.T) {
|
||||
}
|
||||
expect := createTestStatus("test1", api.ConditionTrue, "ok", "")
|
||||
if e, a := expect, got; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("Got unexpected object. Diff: %s", util.ObjectDiff(e, a))
|
||||
t.Errorf("Got unexpected object. Diff: %s", diff.ObjectDiff(e, a))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -273,7 +273,7 @@ func TestScaleGet(t *testing.T) {
|
||||
}
|
||||
got := obj.(*autoscaling.Scale)
|
||||
if !api.Semantic.DeepEqual(want, got) {
|
||||
t.Errorf("unexpected scale: %s", util.ObjectDiff(want, got))
|
||||
t.Errorf("unexpected scale: %s", diff.ObjectDiff(want, got))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/storage/etcd/etcdtest"
|
||||
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
const defaultReplicas = 100
|
||||
@ -216,7 +216,7 @@ func TestScaleGet(t *testing.T) {
|
||||
}
|
||||
got := obj.(*extensions.Scale)
|
||||
if !api.Semantic.DeepEqual(want, got) {
|
||||
t.Errorf("unexpected scale: %s", util.ObjectDiff(want, got))
|
||||
t.Errorf("unexpected scale: %s", diff.ObjectDiff(want, got))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
apitesting "k8s.io/kubernetes/pkg/api/testing"
|
||||
"k8s.io/kubernetes/pkg/fields"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
func testEvent(name string) *api.Event {
|
||||
@ -65,7 +65,7 @@ func TestGetAttrs(t *testing.T) {
|
||||
t.Fatalf("Unexpected error %v", err)
|
||||
}
|
||||
if e, a := label, (labels.Set{}); !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("diff: %s", util.ObjectDiff(e, a))
|
||||
t.Errorf("diff: %s", diff.ObjectDiff(e, a))
|
||||
}
|
||||
expect := fields.Set{
|
||||
"metadata.name": "f0118",
|
||||
@ -82,7 +82,7 @@ func TestGetAttrs(t *testing.T) {
|
||||
"type": api.EventTypeNormal,
|
||||
}
|
||||
if e, a := expect, field; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("diff: %s", util.ObjectDiff(e, a))
|
||||
t.Errorf("diff: %s", diff.ObjectDiff(e, a))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/storage/etcd/etcdtest"
|
||||
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer) {
|
||||
@ -178,6 +178,6 @@ func TestUpdateStatus(t *testing.T) {
|
||||
pvOut := obj.(*api.PersistentVolume)
|
||||
// only compare the relevant change b/c metadata will differ
|
||||
if !api.Semantic.DeepEqual(pvIn.Status, pvOut.Status) {
|
||||
t.Errorf("unexpected object: %s", util.ObjectDiff(pvIn.Status, pvOut.Status))
|
||||
t.Errorf("unexpected object: %s", diff.ObjectDiff(pvIn.Status, pvOut.Status))
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/storage/etcd/etcdtest"
|
||||
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer) {
|
||||
@ -179,6 +179,6 @@ func TestUpdateStatus(t *testing.T) {
|
||||
pvcOut := obj.(*api.PersistentVolumeClaim)
|
||||
// only compare relevant changes b/c of difference in metadata
|
||||
if !api.Semantic.DeepEqual(pvc.Status, pvcOut.Status) {
|
||||
t.Errorf("unexpected object: %s", util.ObjectDiff(pvc.Status, pvcOut.Status))
|
||||
t.Errorf("unexpected object: %s", diff.ObjectDiff(pvc.Status, pvcOut.Status))
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/storage"
|
||||
"k8s.io/kubernetes/pkg/storage/etcd/etcdtest"
|
||||
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
func newStorage(t *testing.T) (*REST, *BindingREST, *StatusREST, *etcdtesting.EtcdTestServer) {
|
||||
@ -620,7 +620,7 @@ func TestEtcdUpdateNotScheduled(t *testing.T) {
|
||||
podOut := obj.(*api.Pod)
|
||||
// validChangedPod only changes the Labels, so were checking the update was valid
|
||||
if !api.Semantic.DeepEqual(podIn.Labels, podOut.Labels) {
|
||||
t.Errorf("objects differ: %v", util.ObjectDiff(podOut, podIn))
|
||||
t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, podIn))
|
||||
}
|
||||
}
|
||||
|
||||
@ -688,7 +688,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
|
||||
podOut := obj.(*api.Pod)
|
||||
// Check to verify the Spec and Label updates match from change above. Those are the fields changed.
|
||||
if !api.Semantic.DeepEqual(podOut.Spec, podIn.Spec) || !api.Semantic.DeepEqual(podOut.Labels, podIn.Labels) {
|
||||
t.Errorf("objects differ: %v", util.ObjectDiff(podOut, podIn))
|
||||
t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, podIn))
|
||||
}
|
||||
|
||||
}
|
||||
@ -770,6 +770,6 @@ func TestEtcdUpdateStatus(t *testing.T) {
|
||||
if !api.Semantic.DeepEqual(podOut.Spec, podIn.Spec) ||
|
||||
!api.Semantic.DeepEqual(podOut.Labels, podIn.Labels) ||
|
||||
!api.Semantic.DeepEqual(podOut.Status, podIn.Status) {
|
||||
t.Errorf("objects differ: %v", util.ObjectDiff(podOut, podIn))
|
||||
t.Errorf("objects differ: %v", diff.ObjectDiff(podOut, podIn))
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/storage/etcd/etcdtest"
|
||||
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
const defaultReplicas = 100
|
||||
@ -277,7 +277,7 @@ func TestScaleGet(t *testing.T) {
|
||||
t.Fatalf("error fetching scale for %s: %v", name, err)
|
||||
}
|
||||
if !api.Semantic.DeepEqual(got, want) {
|
||||
t.Errorf("unexpected scale: %s", util.ObjectDiff(got, want))
|
||||
t.Errorf("unexpected scale: %s", diff.ObjectDiff(got, want))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||
"k8s.io/kubernetes/pkg/storage/etcd/etcdtest"
|
||||
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer) {
|
||||
@ -185,6 +185,6 @@ func TestUpdateStatus(t *testing.T) {
|
||||
rqOut := obj.(*api.ResourceQuota)
|
||||
// only compare the meaningful update b/c we can't compare due to metadata
|
||||
if !api.Semantic.DeepEqual(resourcequotaIn.Status, rqOut.Status) {
|
||||
t.Errorf("unexpected object: %s", util.ObjectDiff(resourcequotaIn, rqOut))
|
||||
t.Errorf("unexpected object: %s", diff.ObjectDiff(resourcequotaIn, rqOut))
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/runtime/serializer"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
type EmbeddedTest struct {
|
||||
@ -169,7 +169,7 @@ func TestArrayOfRuntimeObject(t *testing.T) {
|
||||
// we want DecodeList to set type meta if possible, even on runtime.Unknown objects
|
||||
internal.Items[2].(*runtime.Unknown).TypeMeta = runtime.TypeMeta{Kind: "OtherTest", APIVersion: "unknown.group/unknown"}
|
||||
if e, a := internal.Items, list; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("mismatched decoded: %s", util.ObjectGoPrintSideBySide(e, a))
|
||||
t.Errorf("mismatched decoded: %s", diff.ObjectGoPrintSideBySide(e, a))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/conversion"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/runtime/serializer"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
var fuzzIters = flag.Int("fuzz-iters", 50, "How many fuzzing iterations to do.")
|
||||
@ -239,7 +239,7 @@ func TestExternalToInternalMapping(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error '%v' (%v)", err, item.encoded)
|
||||
} else if e, a := item.obj, gotDecoded; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%d: unexpected objects:\n%s", i, util.ObjectGoPrintSideBySide(e, a))
|
||||
t.Errorf("%d: unexpected objects:\n%s", i, diff.ObjectGoPrintSideBySide(e, a))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -314,7 +314,7 @@ func TestExtensionMapping(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error '%v' (%v)", err, item.encoded)
|
||||
} else if e, a := item.expected, gotDecoded; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%d: unexpected objects:\n%s", i, util.ObjectGoPrintSideBySide(e, a))
|
||||
t.Errorf("%d: unexpected objects:\n%s", i, diff.ObjectGoPrintSideBySide(e, a))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/conversion"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/google/gofuzz"
|
||||
@ -187,12 +187,12 @@ func objDiff(a, b interface{}) string {
|
||||
if err != nil {
|
||||
panic("b")
|
||||
}
|
||||
return util.StringDiff(string(ab), string(bb))
|
||||
return diff.StringDiff(string(ab), string(bb))
|
||||
|
||||
// An alternate diff attempt, in case json isn't showing you
|
||||
// the difference. (reflect.DeepEqual makes a distinction between
|
||||
// nil and empty slices, for example.)
|
||||
//return util.StringDiff(
|
||||
//return diff.StringDiff(
|
||||
// fmt.Sprintf("%#v", a),
|
||||
// fmt.Sprintf("%#v", b),
|
||||
//)
|
||||
@ -222,7 +222,7 @@ func runTest(t *testing.T, source interface{}) {
|
||||
return
|
||||
}
|
||||
if !semantic.DeepEqual(source, obj2) {
|
||||
t.Errorf("1: %v: diff: %v", name, util.ObjectGoPrintSideBySide(source, obj2))
|
||||
t.Errorf("1: %v: diff: %v", name, diff.ObjectGoPrintSideBySide(source, obj2))
|
||||
return
|
||||
}
|
||||
obj3 := reflect.New(reflect.TypeOf(source).Elem()).Interface()
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/runtime/serializer/json"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
type testDecodable struct {
|
||||
@ -244,7 +244,7 @@ func TestDecode(t *testing.T) {
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(test.expectedObject, obj) {
|
||||
t.Errorf("%d: unexpected object:\n%s", i, util.ObjectGoPrintSideBySide(test.expectedObject, obj))
|
||||
t.Errorf("%d: unexpected object:\n%s", i, diff.ObjectGoPrintSideBySide(test.expectedObject, obj))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
type testDecodable struct {
|
||||
@ -201,11 +201,11 @@ func TestDecode(t *testing.T) {
|
||||
switch {
|
||||
case test.expectedObject != nil:
|
||||
if !reflect.DeepEqual(test.expectedObject, obj) {
|
||||
t.Errorf("%d: unexpected object:\n%s", i, util.ObjectGoPrintSideBySide(test.expectedObject, obj))
|
||||
t.Errorf("%d: unexpected object:\n%s", i, diff.ObjectGoPrintSideBySide(test.expectedObject, obj))
|
||||
}
|
||||
case test.sameObject != nil:
|
||||
if test.sameObject != obj {
|
||||
t.Errorf("%d: unexpected object:\n%s", i, util.ObjectGoPrintSideBySide(test.sameObject, obj))
|
||||
t.Errorf("%d: unexpected object:\n%s", i, diff.ObjectGoPrintSideBySide(test.sameObject, obj))
|
||||
}
|
||||
case obj != nil:
|
||||
t.Errorf("%d: unexpected object: %#v", i, obj)
|
||||
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package util
|
||||
package diff
|
||||
|
||||
import (
|
||||
"bytes"
|
@ -18,10 +18,12 @@ package util
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
func TestStringDiff(t *testing.T) {
|
||||
diff := StringDiff("aaabb", "aaacc")
|
||||
diff := diff.StringDiff("aaabb", "aaacc")
|
||||
expect := "aaa\n\nA: bb\n\nB: cc\n\n"
|
||||
if diff != expect {
|
||||
t.Errorf("diff returned %v", diff)
|
||||
|
@ -35,7 +35,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/auth/authorizer"
|
||||
"k8s.io/kubernetes/pkg/auth/user"
|
||||
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api/v1"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
)
|
||||
|
||||
func TestNewFromConfig(t *testing.T) {
|
||||
@ -467,7 +467,7 @@ func TestWebhook(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
if !reflect.DeepEqual(gotAttr, tt.want) {
|
||||
t.Errorf("case %d: got != want:\n%s", i, util.ObjectGoPrintDiff(gotAttr, tt.want))
|
||||
t.Errorf("case %d: got != want:\n%s", i, diff.ObjectGoPrintDiff(gotAttr, tt.want))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/client/cache"
|
||||
"k8s.io/kubernetes/pkg/client/record"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/diff"
|
||||
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
|
||||
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
|
||||
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
|
||||
@ -155,7 +155,7 @@ func TestScheduler(t *testing.T) {
|
||||
t.Errorf("%v: error: wanted %v, got %v", i, e, a)
|
||||
}
|
||||
if e, a := item.expectBind, gotBinding; !reflect.DeepEqual(e, a) {
|
||||
t.Errorf("%v: error: %s", i, util.ObjectDiff(e, a))
|
||||
t.Errorf("%v: error: %s", i, diff.ObjectDiff(e, a))
|
||||
}
|
||||
<-called
|
||||
events.Stop()
|
||||
@ -268,7 +268,7 @@ func TestSchedulerForgetAssumedPodAfterDelete(t *testing.T) {
|
||||
Target: api.ObjectReference{Kind: "Node", Name: "machine1"},
|
||||
}
|
||||
if ex, ac := expectBind, gotBinding; !reflect.DeepEqual(ex, ac) {
|
||||
t.Errorf("Expected exact match on binding: %s", util.ObjectDiff(ex, ac))
|
||||
t.Errorf("Expected exact match on binding: %s", diff.ObjectDiff(ex, ac))
|
||||
}
|
||||
|
||||
<-called
|
||||
@ -318,7 +318,7 @@ func TestSchedulerForgetAssumedPodAfterDelete(t *testing.T) {
|
||||
Target: api.ObjectReference{Kind: "Node", Name: "machine1"},
|
||||
}
|
||||
if ex, ac := expectBind, gotBinding; !reflect.DeepEqual(ex, ac) {
|
||||
t.Errorf("Expected exact match on binding: %s", util.ObjectDiff(ex, ac))
|
||||
t.Errorf("Expected exact match on binding: %s", diff.ObjectDiff(ex, ac))
|
||||
}
|
||||
<-called
|
||||
events.Stop()
|
||||
|
Loading…
Reference in New Issue
Block a user