Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
79adb99a
Commit
79adb99a
authored
Jan 25, 2017
by
Dr. Stefan Schimanski
Committed by
Dr. Stefan Schimanski
Jan 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkg/api: move Semantic equality to k8s.io/apimachinery/pkg/api/equality
parent
88d9829a
Show whitespace changes
Inline
Side-by-side
Showing
64 changed files
with
261 additions
and
165 deletions
+261
-165
handler_apis_test.go
cmd/kube-aggregator/pkg/apiserver/handler_apis_test.go
+3
-2
init_test.go
federation/pkg/kubefed/init/init_test.go
+6
-5
join_test.go
federation/pkg/kubefed/join_test.go
+3
-2
conversion_test.go
pkg/api/conversion_test.go
+3
-2
deep_copy_test.go
pkg/api/deep_copy_test.go
+4
-3
helpers.go
pkg/api/helpers.go
+1
-1
serialization_proto_test.go
pkg/api/serialization_proto_test.go
+3
-2
serialization_test.go
pkg/api/serialization_test.go
+7
-6
pod_specs.go
pkg/api/testing/pod_specs.go
+2
-2
unstructured_test.go
pkg/api/unstructured_test.go
+3
-2
conversion_test.go
pkg/api/v1/conversion_test.go
+2
-1
helpers_test.go
pkg/api/v1/helpers_test.go
+2
-2
objectmeta.go
pkg/api/validation/genericvalidation/objectmeta.go
+2
-1
validation.go
pkg/api/validation/validation.go
+5
-4
runtime_serializer_protobuf_protobuf_test.go
...hinery/tests/runtime_serializer_protobuf_protobuf_test.go
+2
-1
validation.go
pkg/apis/authorization/validation/validation.go
+4
-4
simple_testclient.go
...client/unversioned/testclient/simple/simple_testclient.go
+2
-1
controller_utils_test.go
pkg/controller/controller_utils_test.go
+2
-1
deployment_controller.go
pkg/controller/deployment/deployment_controller.go
+2
-2
deployment_util.go
pkg/controller/deployment/util/deployment_util.go
+2
-1
deployment_util_test.go
pkg/controller/deployment/util/deployment_util_test.go
+2
-1
jobcontroller_test.go
pkg/controller/job/jobcontroller_test.go
+3
-2
nodecontroller.go
pkg/controller/node/nodecontroller.go
+2
-1
nodecontroller_test.go
pkg/controller/node/nodecontroller_test.go
+3
-3
replica_set_test.go
pkg/controller/replicaset/replica_set_test.go
+3
-2
replication_controller_test.go
pkg/controller/replication/replication_controller_test.go
+3
-2
resource_quota_controller.go
pkg/controller/resourcequota/resource_quota_controller.go
+3
-2
apiserver_test.go
pkg/genericapiserver/endpoints/apiserver_test.go
+7
-6
rest_test.go
pkg/genericapiserver/endpoints/handlers/rest_test.go
+2
-1
store_test.go
pkg/genericapiserver/registry/generic/registry/store_test.go
+2
-1
resttest.go
pkg/genericapiserver/registry/rest/resttest/resttest.go
+6
-5
config_test.go
pkg/kubectl/cmd/config/config_test.go
+2
-2
get_test.go
pkg/kubectl/cmd/get_test.go
+2
-1
describe_test.go
pkg/kubectl/describe_test.go
+2
-1
builder_test.go
pkg/kubectl/resource/builder_test.go
+7
-6
apiserver_test.go
pkg/kubelet/config/apiserver_test.go
+7
-7
config_test.go
pkg/kubelet/config/config_test.go
+2
-1
file_linux_test.go
pkg/kubelet/config/file_linux_test.go
+5
-4
http_test.go
pkg/kubelet/config/http_test.go
+2
-1
docker_manager_test.go
pkg/kubelet/dockertools/docker_manager_test.go
+3
-3
kubelet_node_status_test.go
pkg/kubelet/kubelet_node_status_test.go
+4
-4
kubelet_resources_test.go
pkg/kubelet/kubelet_resources_test.go
+2
-2
status_manager.go
pkg/kubelet/status/status_manager.go
+2
-1
api_test.go
pkg/proxy/config/api_test.go
+13
-12
storage_test.go
pkg/registry/core/persistentvolume/storage/storage_test.go
+2
-1
storage_test.go
...gistry/core/persistentvolumeclaim/storage/storage_test.go
+2
-1
storage_test.go
pkg/registry/core/pod/storage/storage_test.go
+6
-5
storage_test.go
...gistry/core/replicationcontroller/storage/storage_test.go
+2
-1
storage_test.go
pkg/registry/core/resourcequota/storage/storage_test.go
+2
-1
storage_test.go
pkg/registry/extensions/deployment/storage/storage_test.go
+2
-1
storage_test.go
pkg/registry/extensions/replicaset/storage/storage_test.go
+2
-1
cacher_test.go
pkg/storage/cacher_test.go
+2
-1
etcd_watcher_test.go
pkg/storage/etcd/etcd_watcher_test.go
+6
-5
watch_cache_test.go
pkg/storage/watch_cache_test.go
+10
-9
io_test.go
pkg/util/io/io_test.go
+2
-1
gc_admission.go
plugin/pkg/admission/gc/gc_admission.go
+2
-2
admission_test.go
plugin/pkg/admission/limitranger/admission_test.go
+7
-6
semantic.go
staging/src/k8s.io/apimachinery/pkg/api/equality/semantic.go
+46
-0
helpers.go
staging/src/k8s.io/client-go/pkg/api/helpers.go
+1
-1
request_test.go
staging/src/k8s.io/client-go/rest/request_test.go
+8
-7
decoder_test.go
staging/src/k8s.io/client-go/rest/watch/decoder_test.go
+2
-1
encoder_test.go
staging/src/k8s.io/client-go/rest/watch/encoder_test.go
+2
-1
service_account_test.go
test/integration/serviceaccount/service_account_test.go
+4
-3
runners.go
test/utils/runners.go
+2
-1
No files found.
cmd/kube-aggregator/pkg/apiserver/handler_apis_test.go
View file @
79adb99a
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"net/http/httputil"
"net/http/httputil"
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/diff"
...
@@ -305,7 +306,7 @@ func TestAPIs(t *testing.T) {
...
@@ -305,7 +306,7 @@ func TestAPIs(t *testing.T) {
t
.
Errorf
(
"%s: %v"
,
tc
.
name
,
err
)
t
.
Errorf
(
"%s: %v"
,
tc
.
name
,
err
)
continue
continue
}
}
if
!
api
.
Semantic
.
DeepEqual
(
tc
.
expected
,
actual
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
tc
.
expected
,
actual
)
{
t
.
Errorf
(
"%s: %v"
,
tc
.
name
,
diff
.
ObjectDiff
(
tc
.
expected
,
actual
))
t
.
Errorf
(
"%s: %v"
,
tc
.
name
,
diff
.
ObjectDiff
(
tc
.
expected
,
actual
))
continue
continue
}
}
...
@@ -467,7 +468,7 @@ func TestAPIGroup(t *testing.T) {
...
@@ -467,7 +468,7 @@ func TestAPIGroup(t *testing.T) {
t
.
Errorf
(
"%s: %v"
,
tc
.
name
,
err
)
t
.
Errorf
(
"%s: %v"
,
tc
.
name
,
err
)
continue
continue
}
}
if
!
api
.
Semantic
.
DeepEqual
(
tc
.
expected
,
actual
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
tc
.
expected
,
actual
)
{
t
.
Errorf
(
"%s: %v"
,
tc
.
name
,
diff
.
ObjectDiff
(
tc
.
expected
,
actual
))
t
.
Errorf
(
"%s: %v"
,
tc
.
name
,
diff
.
ObjectDiff
(
tc
.
expected
,
actual
))
continue
continue
}
}
...
...
federation/pkg/kubefed/init/init_test.go
View file @
79adb99a
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -767,7 +768,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
...
@@ -767,7 +768,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
!
api
.
Semantic
.
DeepEqual
(
got
,
namespace
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
got
,
namespace
)
{
return
nil
,
fmt
.
Errorf
(
"Unexpected namespace object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
namespace
))
return
nil
,
fmt
.
Errorf
(
"Unexpected namespace object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
namespace
))
}
}
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
codec
,
&
namespace
)},
nil
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
codec
,
&
namespace
)},
nil
...
@@ -781,7 +782,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
...
@@ -781,7 +782,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
!
api
.
Semantic
.
DeepEqual
(
got
,
svc
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
got
,
svc
)
{
return
nil
,
fmt
.
Errorf
(
"Unexpected service object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
svc
))
return
nil
,
fmt
.
Errorf
(
"Unexpected service object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
svc
))
}
}
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
codec
,
&
svc
)},
nil
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
codec
,
&
svc
)},
nil
...
@@ -812,7 +813,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
...
@@ -812,7 +813,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
case
cmKubeconfigSecretName
:
case
cmKubeconfigSecretName
:
want
=
cmKubeconfigSecret
want
=
cmKubeconfigSecret
}
}
if
!
api
.
Semantic
.
DeepEqual
(
got
,
want
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
got
,
want
)
{
return
nil
,
fmt
.
Errorf
(
"Unexpected secret object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
want
))
return
nil
,
fmt
.
Errorf
(
"Unexpected secret object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
want
))
}
}
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
codec
,
&
want
)},
nil
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
codec
,
&
want
)},
nil
...
@@ -826,7 +827,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
...
@@ -826,7 +827,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
!
api
.
Semantic
.
DeepEqual
(
got
,
pvc
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
got
,
pvc
)
{
return
nil
,
fmt
.
Errorf
(
"Unexpected PVC object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
pvc
))
return
nil
,
fmt
.
Errorf
(
"Unexpected PVC object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
pvc
))
}
}
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
codec
,
&
pvc
)},
nil
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
codec
,
&
pvc
)},
nil
...
@@ -846,7 +847,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
...
@@ -846,7 +847,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
case
cmName
:
case
cmName
:
want
=
cm
want
=
cm
}
}
if
!
api
.
Semantic
.
DeepEqual
(
got
,
want
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
got
,
want
)
{
return
nil
,
fmt
.
Errorf
(
"Unexpected deployment object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
want
))
return
nil
,
fmt
.
Errorf
(
"Unexpected deployment object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
want
))
}
}
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
extCodec
,
&
want
)},
nil
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
extCodec
,
&
want
)},
nil
...
...
federation/pkg/kubefed/join_test.go
View file @
79adb99a
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"net/http"
"net/http"
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/dynamic"
...
@@ -189,7 +190,7 @@ func testJoinFederationFactory(clusterName, secretName, server string) cmdutil.F
...
@@ -189,7 +190,7 @@ func testJoinFederationFactory(clusterName, secretName, server string) cmdutil.F
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
!
api
.
Semantic
.
DeepEqual
(
got
,
want
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
got
,
want
)
{
return
nil
,
fmt
.
Errorf
(
"Unexpected cluster object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
want
))
return
nil
,
fmt
.
Errorf
(
"Unexpected cluster object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
want
))
}
}
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
codec
,
&
want
)},
nil
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
codec
,
&
want
)},
nil
...
@@ -265,7 +266,7 @@ func fakeJoinHostFactory(clusterName, clusterCtx, secretName, server, token stri
...
@@ -265,7 +266,7 @@ func fakeJoinHostFactory(clusterName, clusterCtx, secretName, server, token stri
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
!
api
.
Semantic
.
DeepEqual
(
got
,
secretObject
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
got
,
secretObject
)
{
return
nil
,
fmt
.
Errorf
(
"Unexpected secret object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
secretObject
))
return
nil
,
fmt
.
Errorf
(
"Unexpected secret object
\n\t
Diff: %s"
,
diff
.
ObjectGoPrintDiff
(
got
,
secretObject
))
}
}
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
codec
,
&
secretObject
)},
nil
return
&
http
.
Response
{
StatusCode
:
http
.
StatusCreated
,
Header
:
kubefedtesting
.
DefaultHeader
(),
Body
:
kubefedtesting
.
ObjBody
(
codec
,
&
secretObject
)},
nil
...
...
pkg/api/conversion_test.go
View file @
79adb99a
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"math/rand"
"math/rand"
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/diff"
...
@@ -80,7 +81,7 @@ func BenchmarkNodeConversion(b *testing.B) {
...
@@ -80,7 +81,7 @@ func BenchmarkNodeConversion(b *testing.B) {
result
=
obj
.
(
*
api
.
Node
)
result
=
obj
.
(
*
api
.
Node
)
}
}
b
.
StopTimer
()
b
.
StopTimer
()
if
!
api
.
Semantic
.
DeepDerivative
(
node
,
*
result
)
{
if
!
api
equality
.
Semantic
.
DeepDerivative
(
node
,
*
result
)
{
b
.
Fatalf
(
"Incorrect conversion: %s"
,
diff
.
ObjectDiff
(
node
,
*
result
))
b
.
Fatalf
(
"Incorrect conversion: %s"
,
diff
.
ObjectDiff
(
node
,
*
result
))
}
}
}
}
...
@@ -110,7 +111,7 @@ func BenchmarkReplicationControllerConversion(b *testing.B) {
...
@@ -110,7 +111,7 @@ func BenchmarkReplicationControllerConversion(b *testing.B) {
result
=
obj
.
(
*
api
.
ReplicationController
)
result
=
obj
.
(
*
api
.
ReplicationController
)
}
}
b
.
StopTimer
()
b
.
StopTimer
()
if
!
api
.
Semantic
.
DeepDerivative
(
replicationController
,
*
result
)
{
if
!
api
equality
.
Semantic
.
DeepDerivative
(
replicationController
,
*
result
)
{
b
.
Fatalf
(
"Incorrect conversion: expected %v, got %v"
,
replicationController
,
*
result
)
b
.
Fatalf
(
"Incorrect conversion: expected %v, got %v"
,
replicationController
,
*
result
)
}
}
}
}
pkg/api/deep_copy_test.go
View file @
79adb99a
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
...
@@ -140,7 +141,7 @@ func BenchmarkPodCopy(b *testing.B) {
...
@@ -140,7 +141,7 @@ func BenchmarkPodCopy(b *testing.B) {
}
}
result
=
obj
.
(
*
api
.
Pod
)
result
=
obj
.
(
*
api
.
Pod
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
benchmarkPod
,
*
result
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
benchmarkPod
,
*
result
)
{
b
.
Fatalf
(
"Incorrect copy: expected %v, got %v"
,
benchmarkPod
,
*
result
)
b
.
Fatalf
(
"Incorrect copy: expected %v, got %v"
,
benchmarkPod
,
*
result
)
}
}
}
}
...
@@ -163,7 +164,7 @@ func BenchmarkNodeCopy(b *testing.B) {
...
@@ -163,7 +164,7 @@ func BenchmarkNodeCopy(b *testing.B) {
}
}
result
=
obj
.
(
*
api
.
Node
)
result
=
obj
.
(
*
api
.
Node
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
node
,
*
result
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
node
,
*
result
)
{
b
.
Fatalf
(
"Incorrect copy: expected %v, got %v"
,
node
,
*
result
)
b
.
Fatalf
(
"Incorrect copy: expected %v, got %v"
,
node
,
*
result
)
}
}
}
}
...
@@ -186,7 +187,7 @@ func BenchmarkReplicationControllerCopy(b *testing.B) {
...
@@ -186,7 +187,7 @@ func BenchmarkReplicationControllerCopy(b *testing.B) {
}
}
result
=
obj
.
(
*
api
.
ReplicationController
)
result
=
obj
.
(
*
api
.
ReplicationController
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
replicationController
,
*
result
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
replicationController
,
*
result
)
{
b
.
Fatalf
(
"Incorrect copy: expected %v, got %v"
,
replicationController
,
*
result
)
b
.
Fatalf
(
"Incorrect copy: expected %v, got %v"
,
replicationController
,
*
result
)
}
}
}
}
pkg/api/helpers.go
View file @
79adb99a
...
@@ -67,7 +67,7 @@ func NonConvertibleFields(annotations map[string]string) map[string]string {
...
@@ -67,7 +67,7 @@ func NonConvertibleFields(annotations map[string]string) map[string]string {
}
}
// Semantic can do semantic deep equality checks for api objects.
// Semantic can do semantic deep equality checks for api objects.
// Example: api.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true
// Example: api
equality
.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true
var
Semantic
=
conversion
.
EqualitiesOrDie
(
var
Semantic
=
conversion
.
EqualitiesOrDie
(
func
(
a
,
b
resource
.
Quantity
)
bool
{
func
(
a
,
b
resource
.
Quantity
)
bool
{
// Ignore formatting, only care that numeric value stayed the same.
// Ignore formatting, only care that numeric value stayed the same.
...
...
pkg/api/serialization_proto_test.go
View file @
79adb99a
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"testing"
"testing"
"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/proto"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
...
@@ -68,7 +69,7 @@ func TestUniversalDeserializer(t *testing.T) {
...
@@ -68,7 +69,7 @@ func TestUniversalDeserializer(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"%s: %v"
,
mediaType
,
err
)
t
.
Fatalf
(
"%s: %v"
,
mediaType
,
err
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
obj
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
obj
)
{
t
.
Fatalf
(
"%s: %#v"
,
mediaType
,
obj
)
t
.
Fatalf
(
"%s: %#v"
,
mediaType
,
obj
)
}
}
}
}
...
@@ -88,7 +89,7 @@ func TestProtobufRoundTrip(t *testing.T) {
...
@@ -88,7 +89,7 @@ func TestProtobufRoundTrip(t *testing.T) {
if
err
:=
out
.
Unmarshal
(
data
);
err
!=
nil
{
if
err
:=
out
.
Unmarshal
(
data
);
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
!
api
.
Semantic
.
Equalities
.
DeepEqual
(
out
,
obj
)
{
if
!
api
equality
.
Semantic
.
Equalities
.
DeepEqual
(
out
,
obj
)
{
t
.
Logf
(
"marshal
\n
%s"
,
hex
.
Dump
(
data
))
t
.
Logf
(
"marshal
\n
%s"
,
hex
.
Dump
(
data
))
t
.
Fatalf
(
"Unmarshal is unequal
\n
%s"
,
diff
.
ObjectGoPrintDiff
(
out
,
obj
))
t
.
Fatalf
(
"Unmarshal is unequal
\n
%s"
,
diff
.
ObjectGoPrintDiff
(
out
,
obj
))
}
}
...
...
pkg/api/serialization_test.go
View file @
79adb99a
...
@@ -32,6 +32,7 @@ import (
...
@@ -32,6 +32,7 @@ import (
flag
"github.com/spf13/pflag"
flag
"github.com/spf13/pflag"
"github.com/ugorji/go/codec"
"github.com/ugorji/go/codec"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -321,7 +322,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
...
@@ -321,7 +322,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
// ensure that the deep copy is equal to the original; neither the deep
// ensure that the deep copy is equal to the original; neither the deep
// copy or conversion should alter the object
// copy or conversion should alter the object
if
!
api
.
Semantic
.
DeepEqual
(
original
,
item
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
original
,
item
)
{
t
.
Errorf
(
"0: %v: encode altered the object, diff: %v"
,
name
,
diff
.
ObjectReflectDiff
(
original
,
item
))
t
.
Errorf
(
"0: %v: encode altered the object, diff: %v"
,
name
,
diff
.
ObjectReflectDiff
(
original
,
item
))
return
return
}
}
...
@@ -335,7 +336,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
...
@@ -335,7 +336,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
// ensure that the object produced from decoding the encoded data is equal
// ensure that the object produced from decoding the encoded data is equal
// to the original object
// to the original object
if
!
api
.
Semantic
.
DeepEqual
(
original
,
obj2
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
original
,
obj2
)
{
t
.
Errorf
(
"
\n
1: %v: diff: %v
\n
Codec: %#v
\n
Source:
\n\n
%#v
\n\n
Encoded:
\n\n
%s
\n\n
Final:
\n\n
%#v"
,
name
,
diff
.
ObjectReflectDiff
(
item
,
obj2
),
codec
,
printer
.
Sprintf
(
"%#v"
,
item
),
dataAsString
(
data
),
printer
.
Sprintf
(
"%#v"
,
obj2
))
t
.
Errorf
(
"
\n
1: %v: diff: %v
\n
Codec: %#v
\n
Source:
\n\n
%#v
\n\n
Encoded:
\n\n
%s
\n\n
Final:
\n\n
%#v"
,
name
,
diff
.
ObjectReflectDiff
(
item
,
obj2
),
codec
,
printer
.
Sprintf
(
"%#v"
,
item
),
dataAsString
(
data
),
printer
.
Sprintf
(
"%#v"
,
obj2
))
return
return
}
}
...
@@ -350,7 +351,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
...
@@ -350,7 +351,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
// ensure that the new runtime object is equal to the original after being
// ensure that the new runtime object is equal to the original after being
// decoded into
// decoded into
if
!
api
.
Semantic
.
DeepEqual
(
item
,
obj3
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
item
,
obj3
)
{
t
.
Errorf
(
"3: %v: diff: %v
\n
Codec: %#v"
,
name
,
diff
.
ObjectReflectDiff
(
item
,
obj3
),
codec
)
t
.
Errorf
(
"3: %v: diff: %v
\n
Codec: %#v"
,
name
,
diff
.
ObjectReflectDiff
(
item
,
obj3
),
codec
)
return
return
}
}
...
@@ -383,7 +384,7 @@ func TestEncodePtr(t *testing.T) {
...
@@ -383,7 +384,7 @@ func TestEncodePtr(t *testing.T) {
if
_
,
ok
:=
obj2
.
(
*
api
.
Pod
);
!
ok
{
if
_
,
ok
:=
obj2
.
(
*
api
.
Pod
);
!
ok
{
t
.
Fatalf
(
"Got wrong type"
)
t
.
Fatalf
(
"Got wrong type"
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
obj2
,
pod
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
obj2
,
pod
)
{
t
.
Errorf
(
"
\n
Expected:
\n\n
%#v,
\n\n
Got:
\n\n
%#vDiff: %v
\n\n
"
,
pod
,
obj2
,
diff
.
ObjectDiff
(
obj2
,
pod
))
t
.
Errorf
(
"
\n
Expected:
\n\n
%#v,
\n\n
Got:
\n\n
%#vDiff: %v
\n\n
"
,
pod
,
obj2
,
diff
.
ObjectDiff
(
obj2
,
pod
))
}
}
}
}
...
@@ -480,7 +481,7 @@ func TestObjectWatchFraming(t *testing.T) {
...
@@ -480,7 +481,7 @@ func TestObjectWatchFraming(t *testing.T) {
}
}
resultSecret
.
Kind
=
"Secret"
resultSecret
.
Kind
=
"Secret"
resultSecret
.
APIVersion
=
"v1"
resultSecret
.
APIVersion
=
"v1"
if
!
api
.
Semantic
.
DeepEqual
(
v1secret
,
res
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
v1secret
,
res
)
{
t
.
Fatalf
(
"objects did not match: %s"
,
diff
.
ObjectGoPrintDiff
(
v1secret
,
res
))
t
.
Fatalf
(
"objects did not match: %s"
,
diff
.
ObjectGoPrintDiff
(
v1secret
,
res
))
}
}
...
@@ -514,7 +515,7 @@ func TestObjectWatchFraming(t *testing.T) {
...
@@ -514,7 +515,7 @@ func TestObjectWatchFraming(t *testing.T) {
}
}
}
}
if
!
api
.
Semantic
.
DeepEqual
(
secret
,
outEvent
.
Object
.
Object
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
secret
,
outEvent
.
Object
.
Object
)
{
t
.
Fatalf
(
"%s: did not match after frame decoding: %s"
,
info
.
MediaType
,
diff
.
ObjectGoPrintDiff
(
secret
,
outEvent
.
Object
.
Object
))
t
.
Fatalf
(
"%s: did not match after frame decoding: %s"
,
info
.
MediaType
,
diff
.
ObjectGoPrintDiff
(
secret
,
outEvent
.
Object
.
Object
))
}
}
}
}
...
...
pkg/api/testing/pod_specs.go
View file @
79adb99a
...
@@ -21,7 +21,7 @@ import (
...
@@ -21,7 +21,7 @@ import (
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
)
)
// DeepEqualSafePodSpec returns a PodSpec which is ready to be used with api.Semantic.DeepEqual
// DeepEqualSafePodSpec returns a PodSpec which is ready to be used with api
equality
.Semantic.DeepEqual
func
DeepEqualSafePodSpec
()
api
.
PodSpec
{
func
DeepEqualSafePodSpec
()
api
.
PodSpec
{
grace
:=
int64
(
30
)
grace
:=
int64
(
30
)
return
api
.
PodSpec
{
return
api
.
PodSpec
{
...
@@ -33,7 +33,7 @@ func DeepEqualSafePodSpec() api.PodSpec {
...
@@ -33,7 +33,7 @@ func DeepEqualSafePodSpec() api.PodSpec {
}
}
}
}
// V1DeepEqualSafePodSpec returns a PodSpec which is ready to be used with api.Semantic.DeepEqual
// V1DeepEqualSafePodSpec returns a PodSpec which is ready to be used with api
equality
.Semantic.DeepEqual
func
V1DeepEqualSafePodSpec
()
v1
.
PodSpec
{
func
V1DeepEqualSafePodSpec
()
v1
.
PodSpec
{
grace
:=
int64
(
30
)
grace
:=
int64
(
30
)
return
v1
.
PodSpec
{
return
v1
.
PodSpec
{
...
...
pkg/api/unstructured_test.go
View file @
79adb99a
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"reflect"
"reflect"
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/testapi"
...
@@ -89,7 +90,7 @@ func doRoundTrip(t *testing.T, group testapi.TestGroup, kind string) {
...
@@ -89,7 +90,7 @@ func doRoundTrip(t *testing.T, group testapi.TestGroup, kind string) {
t
.
Errorf
(
"Error when unmarshaling to object: %v"
,
err
)
t
.
Errorf
(
"Error when unmarshaling to object: %v"
,
err
)
return
return
}
}
if
!
api
.
Semantic
.
DeepEqual
(
item
,
unmarshalledObj
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
item
,
unmarshalledObj
)
{
t
.
Errorf
(
"Object changed during JSON operations, diff: %v"
,
diff
.
ObjectReflectDiff
(
item
,
unmarshalledObj
))
t
.
Errorf
(
"Object changed during JSON operations, diff: %v"
,
diff
.
ObjectReflectDiff
(
item
,
unmarshalledObj
))
return
return
}
}
...
@@ -111,7 +112,7 @@ func doRoundTrip(t *testing.T, group testapi.TestGroup, kind string) {
...
@@ -111,7 +112,7 @@ func doRoundTrip(t *testing.T, group testapi.TestGroup, kind string) {
return
return
}
}
if !api.Semantic.DeepEqual(item, newObj) {
if !api
equality
.Semantic.DeepEqual(item, newObj) {
t.Errorf("Object changed, diff: %v", diff.ObjectReflectDiff(item, newObj))
t.Errorf("Object changed, diff: %v", diff.ObjectReflectDiff(item, newObj))
}
}
*/
*/
...
...
pkg/api/v1/conversion_test.go
View file @
79adb99a
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
...
@@ -210,7 +211,7 @@ func TestResourceListConversion(t *testing.T) {
...
@@ -210,7 +211,7 @@ func TestResourceListConversion(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error for case %d: %v"
,
i
,
err
)
t
.
Fatalf
(
"unexpected error for case %d: %v"
,
i
,
err
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
test
.
expected
,
output
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
test
.
expected
,
output
)
{
t
.
Errorf
(
"unexpected conversion for case %d: Expected %+v; Got %+v"
,
i
,
test
.
expected
,
output
)
t
.
Errorf
(
"unexpected conversion for case %d: Expected %+v; Got %+v"
,
i
,
test
.
expected
,
output
)
}
}
}
}
...
...
pkg/api/v1/helpers_test.go
View file @
79adb99a
...
@@ -20,9 +20,9 @@ import (
...
@@ -20,9 +20,9 @@ import (
"reflect"
"reflect"
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/kubernetes/pkg/api"
)
)
func
TestAddToNodeAddresses
(
t
*
testing
.
T
)
{
func
TestAddToNodeAddresses
(
t
*
testing
.
T
)
{
...
@@ -76,7 +76,7 @@ func TestAddToNodeAddresses(t *testing.T) {
...
@@ -76,7 +76,7 @@ func TestAddToNodeAddresses(t *testing.T) {
for
i
,
tc
:=
range
testCases
{
for
i
,
tc
:=
range
testCases
{
AddToNodeAddresses
(
&
tc
.
existing
,
tc
.
toAdd
...
)
AddToNodeAddresses
(
&
tc
.
existing
,
tc
.
toAdd
...
)
if
!
api
.
Semantic
.
DeepEqual
(
tc
.
expected
,
tc
.
existing
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
tc
.
expected
,
tc
.
existing
)
{
t
.
Errorf
(
"case[%d], expected: %v, got: %v"
,
i
,
tc
.
expected
,
tc
.
existing
)
t
.
Errorf
(
"case[%d], expected: %v, got: %v"
,
i
,
tc
.
expected
,
tc
.
existing
)
}
}
}
}
...
...
pkg/api/validation/genericvalidation/objectmeta.go
View file @
79adb99a
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"fmt"
"fmt"
"strings"
"strings"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
apimachineyvalidation
"k8s.io/apimachinery/pkg/api/validation"
apimachineyvalidation
"k8s.io/apimachinery/pkg/api/validation"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1validation
"k8s.io/apimachinery/pkg/apis/meta/v1/validation"
v1validation
"k8s.io/apimachinery/pkg/apis/meta/v1/validation"
...
@@ -133,7 +134,7 @@ func ValidateNoNewFinalizers(newFinalizers []string, oldFinalizers []string, fld
...
@@ -133,7 +134,7 @@ func ValidateNoNewFinalizers(newFinalizers []string, oldFinalizers []string, fld
func
ValidateImmutableField
(
newVal
,
oldVal
interface
{},
fldPath
*
field
.
Path
)
field
.
ErrorList
{
func
ValidateImmutableField
(
newVal
,
oldVal
interface
{},
fldPath
*
field
.
Path
)
field
.
ErrorList
{
allErrs
:=
field
.
ErrorList
{}
allErrs
:=
field
.
ErrorList
{}
if
!
api
.
Semantic
.
DeepEqual
(
oldVal
,
newVal
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
oldVal
,
newVal
)
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
,
newVal
,
FieldImmutableErrorMsg
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
,
newVal
,
FieldImmutableErrorMsg
))
}
}
return
allErrs
return
allErrs
...
...
pkg/api/validation/validation.go
View file @
79adb99a
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
apimachineryvalidation
"k8s.io/apimachinery/pkg/api/validation"
apimachineryvalidation
"k8s.io/apimachinery/pkg/api/validation"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -1092,7 +1093,7 @@ func ValidatePersistentVolumeClaimUpdate(newPvc, oldPvc *api.PersistentVolumeCla
...
@@ -1092,7 +1093,7 @@ func ValidatePersistentVolumeClaimUpdate(newPvc, oldPvc *api.PersistentVolumeCla
}
}
// changes to Spec are not allowed, but updates to label/and some annotations are OK.
// changes to Spec are not allowed, but updates to label/and some annotations are OK.
// no-op updates pass validation.
// no-op updates pass validation.
if
!
api
.
Semantic
.
DeepEqual
(
newPvc
.
Spec
,
oldPvc
.
Spec
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
newPvc
.
Spec
,
oldPvc
.
Spec
)
{
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
field
.
NewPath
(
"spec"
),
"field is immutable after creation"
))
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
field
.
NewPath
(
"spec"
),
"field is immutable after creation"
))
}
}
...
@@ -2253,7 +2254,7 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList {
...
@@ -2253,7 +2254,7 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList {
activeDeadlineSeconds
:=
*
oldPod
.
Spec
.
ActiveDeadlineSeconds
activeDeadlineSeconds
:=
*
oldPod
.
Spec
.
ActiveDeadlineSeconds
mungedPod
.
Spec
.
ActiveDeadlineSeconds
=
&
activeDeadlineSeconds
mungedPod
.
Spec
.
ActiveDeadlineSeconds
=
&
activeDeadlineSeconds
}
}
if
!
api
.
Semantic
.
DeepEqual
(
mungedPod
.
Spec
,
oldPod
.
Spec
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
mungedPod
.
Spec
,
oldPod
.
Spec
)
{
//TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff
//TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
specPath
,
"pod updates may not change fields other than `containers[*].image` or `spec.activeDeadlineSeconds`"
))
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
specPath
,
"pod updates may not change fields other than `containers[*].image` or `spec.activeDeadlineSeconds`"
))
}
}
...
@@ -2789,7 +2790,7 @@ func ValidateNodeUpdate(node, oldNode *api.Node) field.ErrorList {
...
@@ -2789,7 +2790,7 @@ func ValidateNodeUpdate(node, oldNode *api.Node) field.ErrorList {
// TODO: Enable the code once we have better api object.status update model. Currently,
// TODO: Enable the code once we have better api object.status update model. Currently,
// anyone can update node status.
// anyone can update node status.
// if !api.Semantic.DeepEqual(node.Status, api.NodeStatus{}) {
// if !api
equality
.Semantic.DeepEqual(node.Status, api.NodeStatus{}) {
// allErrs = append(allErrs, field.Invalid("status", node.Status, "must be empty"))
// allErrs = append(allErrs, field.Invalid("status", node.Status, "must be empty"))
// }
// }
...
@@ -2832,7 +2833,7 @@ func ValidateNodeUpdate(node, oldNode *api.Node) field.ErrorList {
...
@@ -2832,7 +2833,7 @@ func ValidateNodeUpdate(node, oldNode *api.Node) field.ErrorList {
oldNode
.
Status
=
node
.
Status
oldNode
.
Status
=
node
.
Status
// TODO: Add a 'real' error type for this error and provide print actual diffs.
// TODO: Add a 'real' error type for this error and provide print actual diffs.
if
!
api
.
Semantic
.
DeepEqual
(
oldNode
,
node
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
oldNode
,
node
)
{
glog
.
V
(
4
)
.
Infof
(
"Update failed validation %#v vs %#v"
,
oldNode
,
node
)
glog
.
V
(
4
)
.
Infof
(
"Update failed validation %#v vs %#v"
,
oldNode
,
node
)
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
field
.
NewPath
(
""
),
"node updates may only change labels or capacity"
))
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
field
.
NewPath
(
""
),
"node updates may only change labels or capacity"
))
}
}
...
...
pkg/apimachinery/tests/runtime_serializer_protobuf_protobuf_test.go
View file @
79adb99a
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"strings"
"strings"
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
...
@@ -344,7 +345,7 @@ func TestDecodeObjects(t *testing.T) {
...
@@ -344,7 +345,7 @@ func TestDecodeObjects(t *testing.T) {
continue
continue
}
}
if
!
api
.
Semantic
.
DeepEqual
(
obj
,
test
.
obj
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
obj
,
test
.
obj
)
{
t
.
Errorf
(
"%d: unexpected object:
\n
%s"
,
i
,
diff
.
ObjectGoPrintDiff
(
test
.
obj
,
obj
))
t
.
Errorf
(
"%d: unexpected object:
\n
%s"
,
i
,
diff
.
ObjectGoPrintDiff
(
test
.
obj
,
obj
))
continue
continue
}
}
...
...
pkg/apis/authorization/validation/validation.go
View file @
79adb99a
...
@@ -17,9 +17,9 @@ limitations under the License.
...
@@ -17,9 +17,9 @@ limitations under the License.
package
validation
package
validation
import
(
import
(
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api"
authorizationapi
"k8s.io/kubernetes/pkg/apis/authorization"
authorizationapi
"k8s.io/kubernetes/pkg/apis/authorization"
)
)
...
@@ -52,7 +52,7 @@ func ValidateSelfSubjectAccessReviewSpec(spec authorizationapi.SelfSubjectAccess
...
@@ -52,7 +52,7 @@ func ValidateSelfSubjectAccessReviewSpec(spec authorizationapi.SelfSubjectAccess
func
ValidateSubjectAccessReview
(
sar
*
authorizationapi
.
SubjectAccessReview
)
field
.
ErrorList
{
func
ValidateSubjectAccessReview
(
sar
*
authorizationapi
.
SubjectAccessReview
)
field
.
ErrorList
{
allErrs
:=
ValidateSubjectAccessReviewSpec
(
sar
.
Spec
,
field
.
NewPath
(
"spec"
))
allErrs
:=
ValidateSubjectAccessReviewSpec
(
sar
.
Spec
,
field
.
NewPath
(
"spec"
))
if
!
api
.
Semantic
.
DeepEqual
(
metav1
.
ObjectMeta
{},
sar
.
ObjectMeta
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
metav1
.
ObjectMeta
{},
sar
.
ObjectMeta
)
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
field
.
NewPath
(
"metadata"
),
sar
.
ObjectMeta
,
`must be empty`
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
field
.
NewPath
(
"metadata"
),
sar
.
ObjectMeta
,
`must be empty`
))
}
}
return
allErrs
return
allErrs
...
@@ -60,7 +60,7 @@ func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) fiel
...
@@ -60,7 +60,7 @@ func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) fiel
func
ValidateSelfSubjectAccessReview
(
sar
*
authorizationapi
.
SelfSubjectAccessReview
)
field
.
ErrorList
{
func
ValidateSelfSubjectAccessReview
(
sar
*
authorizationapi
.
SelfSubjectAccessReview
)
field
.
ErrorList
{
allErrs
:=
ValidateSelfSubjectAccessReviewSpec
(
sar
.
Spec
,
field
.
NewPath
(
"spec"
))
allErrs
:=
ValidateSelfSubjectAccessReviewSpec
(
sar
.
Spec
,
field
.
NewPath
(
"spec"
))
if
!
api
.
Semantic
.
DeepEqual
(
metav1
.
ObjectMeta
{},
sar
.
ObjectMeta
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
metav1
.
ObjectMeta
{},
sar
.
ObjectMeta
)
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
field
.
NewPath
(
"metadata"
),
sar
.
ObjectMeta
,
`must be empty`
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
field
.
NewPath
(
"metadata"
),
sar
.
ObjectMeta
,
`must be empty`
))
}
}
return
allErrs
return
allErrs
...
@@ -71,7 +71,7 @@ func ValidateLocalSubjectAccessReview(sar *authorizationapi.LocalSubjectAccessRe
...
@@ -71,7 +71,7 @@ func ValidateLocalSubjectAccessReview(sar *authorizationapi.LocalSubjectAccessRe
objectMetaShallowCopy
:=
sar
.
ObjectMeta
objectMetaShallowCopy
:=
sar
.
ObjectMeta
objectMetaShallowCopy
.
Namespace
=
""
objectMetaShallowCopy
.
Namespace
=
""
if
!
api
.
Semantic
.
DeepEqual
(
metav1
.
ObjectMeta
{},
objectMetaShallowCopy
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
metav1
.
ObjectMeta
{},
objectMetaShallowCopy
)
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
field
.
NewPath
(
"metadata"
),
sar
.
ObjectMeta
,
`must be empty except for namespace`
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
field
.
NewPath
(
"metadata"
),
sar
.
ObjectMeta
,
`must be empty except for namespace`
))
}
}
...
...
pkg/client/unversioned/testclient/simple/simple_testclient.go
View file @
79adb99a
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"strings"
"strings"
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
...
@@ -99,7 +100,7 @@ func (c *Client) ServerURL() string {
...
@@ -99,7 +100,7 @@ func (c *Client) ServerURL() string {
func
(
c
*
Client
)
Validate
(
t
*
testing
.
T
,
received
runtime
.
Object
,
err
error
)
{
func
(
c
*
Client
)
Validate
(
t
*
testing
.
T
,
received
runtime
.
Object
,
err
error
)
{
c
.
ValidateCommon
(
t
,
err
)
c
.
ValidateCommon
(
t
,
err
)
if
c
.
Response
.
Body
!=
nil
&&
!
api
.
Semantic
.
DeepDerivative
(
c
.
Response
.
Body
,
received
)
{
if
c
.
Response
.
Body
!=
nil
&&
!
api
equality
.
Semantic
.
DeepDerivative
(
c
.
Response
.
Body
,
received
)
{
t
.
Errorf
(
"bad response for request %#v:
\n
expected %#v
\n
got %#v
\n
"
,
c
.
Request
,
c
.
Response
.
Body
,
received
)
t
.
Errorf
(
"bad response for request %#v:
\n
expected %#v
\n
got %#v
\n
"
,
c
.
Request
,
c
.
Response
.
Body
,
received
)
}
}
}
}
...
...
pkg/controller/controller_utils_test.go
View file @
79adb99a
...
@@ -27,6 +27,7 @@ import (
...
@@ -27,6 +27,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
...
@@ -273,7 +274,7 @@ func TestCreatePods(t *testing.T) {
...
@@ -273,7 +274,7 @@ func TestCreatePods(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
}
if
!
api
.
Semantic
.
DeepDerivative
(
&
expectedPod
,
actualPod
)
{
if
!
api
equality
.
Semantic
.
DeepDerivative
(
&
expectedPod
,
actualPod
)
{
t
.
Logf
(
"Body: %s"
,
fakeHandler
.
RequestBody
)
t
.
Logf
(
"Body: %s"
,
fakeHandler
.
RequestBody
)
t
.
Errorf
(
"Unexpected mismatch. Expected
\n
%#v,
\n
Got:
\n
%#v"
,
&
expectedPod
,
actualPod
)
t
.
Errorf
(
"Unexpected mismatch. Expected
\n
%#v,
\n
Got:
\n
%#v"
,
&
expectedPod
,
actualPod
)
}
}
...
...
pkg/controller/deployment/deployment_controller.go
View file @
79adb99a
...
@@ -27,6 +27,7 @@ import (
...
@@ -27,6 +27,7 @@ import (
"time"
"time"
"github.com/golang/glog"
"github.com/golang/glog"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
...
@@ -35,7 +36,6 @@ import (
...
@@ -35,7 +36,6 @@ import (
utilruntime
"k8s.io/apimachinery/pkg/util/runtime"
utilruntime
"k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/cache"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
extensions
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
extensions
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
...
@@ -285,7 +285,7 @@ func (dc *DeploymentController) updateReplicaSet(old, cur interface{}) {
...
@@ -285,7 +285,7 @@ func (dc *DeploymentController) updateReplicaSet(old, cur interface{}) {
}
}
// A number of things could affect the old deployment: labels changing,
// A number of things could affect the old deployment: labels changing,
// pod template changing, etc.
// pod template changing, etc.
if
!
api
.
Semantic
.
DeepEqual
(
oldRS
,
curRS
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
oldRS
,
curRS
)
{
if
oldD
:=
dc
.
getDeploymentForReplicaSet
(
oldRS
);
oldD
!=
nil
{
if
oldD
:=
dc
.
getDeploymentForReplicaSet
(
oldRS
);
oldD
!=
nil
{
dc
.
enqueueDeployment
(
oldD
)
dc
.
enqueueDeployment
(
oldD
)
}
}
...
...
pkg/controller/deployment/util/deployment_util.go
View file @
79adb99a
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
...
@@ -605,7 +606,7 @@ func EqualIgnoreHash(template1, template2 v1.PodTemplateSpec) bool {
...
@@ -605,7 +606,7 @@ func EqualIgnoreHash(template1, template2 v1.PodTemplateSpec) bool {
}
}
// Then, compare the templates without comparing their labels
// Then, compare the templates without comparing their labels
template1
.
Labels
,
template2
.
Labels
=
nil
,
nil
template1
.
Labels
,
template2
.
Labels
=
nil
,
nil
return
api
.
Semantic
.
DeepEqual
(
template1
,
template2
)
return
api
equality
.
Semantic
.
DeepEqual
(
template1
,
template2
)
}
}
// FindNewReplicaSet returns the new RS this given deployment targets (the one with the same pod template).
// FindNewReplicaSet returns the new RS this given deployment targets (the one with the same pod template).
...
...
pkg/controller/deployment/util/deployment_util_test.go
View file @
79adb99a
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
core
"k8s.io/client-go/testing"
core
"k8s.io/client-go/testing"
...
@@ -256,7 +257,7 @@ func TestGetNewRC(t *testing.T) {
...
@@ -256,7 +257,7 @@ func TestGetNewRC(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"In test case %s, got unexpected error %v"
,
test
.
test
,
err
)
t
.
Errorf
(
"In test case %s, got unexpected error %v"
,
test
.
test
,
err
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
rs
,
test
.
expected
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
rs
,
test
.
expected
)
{
t
.
Errorf
(
"In test case %s, expected %#v, got %#v"
,
test
.
test
,
test
.
expected
,
rs
)
t
.
Errorf
(
"In test case %s, expected %#v, got %#v"
,
test
.
test
,
test
.
expected
,
rs
)
}
}
}
}
...
...
pkg/controller/job/jobcontroller_test.go
View file @
79adb99a
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
...
@@ -656,7 +657,7 @@ func TestWatchJobs(t *testing.T) {
...
@@ -656,7 +657,7 @@ func TestWatchJobs(t *testing.T) {
t
.
Errorf
(
"Expected to find job under key %v: %v"
,
key
,
err
)
t
.
Errorf
(
"Expected to find job under key %v: %v"
,
key
,
err
)
return
nil
return
nil
}
}
if
!
api
.
Semantic
.
DeepDerivative
(
*
job
,
testJob
)
{
if
!
api
equality
.
Semantic
.
DeepDerivative
(
*
job
,
testJob
)
{
t
.
Errorf
(
"Expected %#v, but got %#v"
,
testJob
,
*
job
)
t
.
Errorf
(
"Expected %#v, but got %#v"
,
testJob
,
*
job
)
}
}
return
nil
return
nil
...
@@ -699,7 +700,7 @@ func TestWatchPods(t *testing.T) {
...
@@ -699,7 +700,7 @@ func TestWatchPods(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Expected to find job under key %v: %v"
,
key
,
err
)
t
.
Errorf
(
"Expected to find job under key %v: %v"
,
key
,
err
)
}
}
if
!
api
.
Semantic
.
DeepDerivative
(
job
,
testJob
)
{
if
!
api
equality
.
Semantic
.
DeepDerivative
(
job
,
testJob
)
{
t
.
Errorf
(
"
\n
Expected %#v,
\n
but got %#v"
,
testJob
,
job
)
t
.
Errorf
(
"
\n
Expected %#v,
\n
but got %#v"
,
testJob
,
job
)
close
(
received
)
close
(
received
)
return
nil
return
nil
...
...
pkg/controller/node/nodecontroller.go
View file @
79adb99a
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"time"
"time"
"github.com/golang/glog"
"github.com/golang/glog"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
...
@@ -777,7 +778,7 @@ func (nc *NodeController) tryUpdateNodeStatus(node *v1.Node) (time.Duration, v1.
...
@@ -777,7 +778,7 @@ func (nc *NodeController) tryUpdateNodeStatus(node *v1.Node) (time.Duration, v1.
}
}
_
,
currentCondition
:=
v1
.
GetNodeCondition
(
&
node
.
Status
,
v1
.
NodeReady
)
_
,
currentCondition
:=
v1
.
GetNodeCondition
(
&
node
.
Status
,
v1
.
NodeReady
)
if
!
api
.
Semantic
.
DeepEqual
(
currentCondition
,
&
observedReadyCondition
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
currentCondition
,
&
observedReadyCondition
)
{
if
_
,
err
=
nc
.
kubeClient
.
Core
()
.
Nodes
()
.
UpdateStatus
(
node
);
err
!=
nil
{
if
_
,
err
=
nc
.
kubeClient
.
Core
()
.
Nodes
()
.
UpdateStatus
(
node
);
err
!=
nil
{
glog
.
Errorf
(
"Error updating node %s: %v"
,
node
.
Name
,
err
)
glog
.
Errorf
(
"Error updating node %s: %v"
,
node
.
Name
,
err
)
return
gracePeriod
,
observedReadyCondition
,
currentReadyCondition
,
err
return
gracePeriod
,
observedReadyCondition
,
currentReadyCondition
,
err
...
...
pkg/controller/node/nodecontroller_test.go
View file @
79adb99a
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
...
@@ -29,7 +30,6 @@ import (
...
@@ -29,7 +30,6 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
testcore
"k8s.io/client-go/testing"
testcore
"k8s.io/client-go/testing"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/cache"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
extensions
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
extensions
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
...
@@ -1524,10 +1524,10 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
...
@@ -1524,10 +1524,10 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
if
item
.
expectedRequestCount
!=
item
.
fakeNodeHandler
.
RequestCount
{
if
item
.
expectedRequestCount
!=
item
.
fakeNodeHandler
.
RequestCount
{
t
.
Errorf
(
"expected %v call, but got %v."
,
item
.
expectedRequestCount
,
item
.
fakeNodeHandler
.
RequestCount
)
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
)
{
if
len
(
item
.
fakeNodeHandler
.
UpdatedNodes
)
>
0
&&
!
api
equality
.
Semantic
.
DeepEqual
(
item
.
expectedNodes
,
item
.
fakeNodeHandler
.
UpdatedNodes
)
{
t
.
Errorf
(
"Case[%d] unexpected nodes: %s"
,
i
,
diff
.
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
)
{
if
len
(
item
.
fakeNodeHandler
.
UpdatedNodeStatuses
)
>
0
&&
!
api
equality
.
Semantic
.
DeepEqual
(
item
.
expectedNodes
,
item
.
fakeNodeHandler
.
UpdatedNodeStatuses
)
{
t
.
Errorf
(
"Case[%d] unexpected nodes: %s"
,
i
,
diff
.
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
]))
}
}
}
}
...
...
pkg/controller/replicaset/replica_set_test.go
View file @
79adb99a
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
...
@@ -541,7 +542,7 @@ func TestWatchControllers(t *testing.T) {
...
@@ -541,7 +542,7 @@ func TestWatchControllers(t *testing.T) {
t
.
Errorf
(
"Expected to find replica set under key %v"
,
key
)
t
.
Errorf
(
"Expected to find replica set under key %v"
,
key
)
}
}
rsSpec
:=
*
obj
.
(
*
extensions
.
ReplicaSet
)
rsSpec
:=
*
obj
.
(
*
extensions
.
ReplicaSet
)
if
!
api
.
Semantic
.
DeepDerivative
(
rsSpec
,
testRSSpec
)
{
if
!
api
equality
.
Semantic
.
DeepDerivative
(
rsSpec
,
testRSSpec
)
{
t
.
Errorf
(
"Expected %#v, but got %#v"
,
testRSSpec
,
rsSpec
)
t
.
Errorf
(
"Expected %#v, but got %#v"
,
testRSSpec
,
rsSpec
)
}
}
close
(
received
)
close
(
received
)
...
@@ -583,7 +584,7 @@ func TestWatchPods(t *testing.T) {
...
@@ -583,7 +584,7 @@ func TestWatchPods(t *testing.T) {
t
.
Errorf
(
"Expected to find replica set under key %v"
,
key
)
t
.
Errorf
(
"Expected to find replica set under key %v"
,
key
)
}
}
rsSpec
:=
obj
.
(
*
extensions
.
ReplicaSet
)
rsSpec
:=
obj
.
(
*
extensions
.
ReplicaSet
)
if
!
api
.
Semantic
.
DeepDerivative
(
rsSpec
,
testRSSpec
)
{
if
!
api
equality
.
Semantic
.
DeepDerivative
(
rsSpec
,
testRSSpec
)
{
t
.
Errorf
(
"
\n
Expected %#v,
\n
but got %#v"
,
testRSSpec
,
rsSpec
)
t
.
Errorf
(
"
\n
Expected %#v,
\n
but got %#v"
,
testRSSpec
,
rsSpec
)
}
}
close
(
received
)
close
(
received
)
...
...
pkg/controller/replication/replication_controller_test.go
View file @
79adb99a
...
@@ -27,6 +27,7 @@ import (
...
@@ -27,6 +27,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
...
@@ -471,7 +472,7 @@ func TestWatchControllers(t *testing.T) {
...
@@ -471,7 +472,7 @@ func TestWatchControllers(t *testing.T) {
t
.
Errorf
(
"Expected to find controller under key %v"
,
key
)
t
.
Errorf
(
"Expected to find controller under key %v"
,
key
)
}
}
controllerSpec
:=
*
obj
.
(
*
v1
.
ReplicationController
)
controllerSpec
:=
*
obj
.
(
*
v1
.
ReplicationController
)
if
!
api
.
Semantic
.
DeepDerivative
(
controllerSpec
,
testControllerSpec
)
{
if
!
api
equality
.
Semantic
.
DeepDerivative
(
controllerSpec
,
testControllerSpec
)
{
t
.
Errorf
(
"Expected %#v, but got %#v"
,
testControllerSpec
,
controllerSpec
)
t
.
Errorf
(
"Expected %#v, but got %#v"
,
testControllerSpec
,
controllerSpec
)
}
}
close
(
received
)
close
(
received
)
...
@@ -512,7 +513,7 @@ func TestWatchPods(t *testing.T) {
...
@@ -512,7 +513,7 @@ func TestWatchPods(t *testing.T) {
t
.
Errorf
(
"Expected to find controller under key %v"
,
key
)
t
.
Errorf
(
"Expected to find controller under key %v"
,
key
)
}
}
controllerSpec
:=
obj
.
(
*
v1
.
ReplicationController
)
controllerSpec
:=
obj
.
(
*
v1
.
ReplicationController
)
if
!
api
.
Semantic
.
DeepDerivative
(
controllerSpec
,
testControllerSpec
)
{
if
!
api
equality
.
Semantic
.
DeepDerivative
(
controllerSpec
,
testControllerSpec
)
{
t
.
Errorf
(
"
\n
Expected %#v,
\n
but got %#v"
,
testControllerSpec
,
controllerSpec
)
t
.
Errorf
(
"
\n
Expected %#v,
\n
but got %#v"
,
testControllerSpec
,
controllerSpec
)
}
}
close
(
received
)
close
(
received
)
...
...
pkg/controller/resourcequota/resource_quota_controller.go
View file @
79adb99a
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
...
@@ -174,7 +175,7 @@ func (rq *ResourceQuotaController) addQuota(obj interface{}) {
...
@@ -174,7 +175,7 @@ func (rq *ResourceQuotaController) addQuota(obj interface{}) {
resourceQuota
:=
obj
.
(
*
v1
.
ResourceQuota
)
resourceQuota
:=
obj
.
(
*
v1
.
ResourceQuota
)
// if we declared an intent that is not yet captured in status (prioritize it)
// if we declared an intent that is not yet captured in status (prioritize it)
if
!
api
.
Semantic
.
DeepEqual
(
resourceQuota
.
Spec
.
Hard
,
resourceQuota
.
Status
.
Hard
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
resourceQuota
.
Spec
.
Hard
,
resourceQuota
.
Status
.
Hard
)
{
rq
.
missingUsageQueue
.
Add
(
key
)
rq
.
missingUsageQueue
.
Add
(
key
)
return
return
}
}
...
@@ -268,7 +269,7 @@ func (rq *ResourceQuotaController) syncResourceQuotaFromKey(key string) (err err
...
@@ -268,7 +269,7 @@ func (rq *ResourceQuotaController) syncResourceQuotaFromKey(key string) (err err
// syncResourceQuota runs a complete sync of resource quota status across all known kinds
// syncResourceQuota runs a complete sync of resource quota status across all known kinds
func
(
rq
*
ResourceQuotaController
)
syncResourceQuota
(
v1ResourceQuota
v1
.
ResourceQuota
)
(
err
error
)
{
func
(
rq
*
ResourceQuotaController
)
syncResourceQuota
(
v1ResourceQuota
v1
.
ResourceQuota
)
(
err
error
)
{
// quota is dirty if any part of spec hard limits differs from the status hard limits
// quota is dirty if any part of spec hard limits differs from the status hard limits
dirty
:=
!
api
.
Semantic
.
DeepEqual
(
v1ResourceQuota
.
Spec
.
Hard
,
v1ResourceQuota
.
Status
.
Hard
)
dirty
:=
!
api
equality
.
Semantic
.
DeepEqual
(
v1ResourceQuota
.
Spec
.
Hard
,
v1ResourceQuota
.
Status
.
Hard
)
resourceQuota
:=
api
.
ResourceQuota
{}
resourceQuota
:=
api
.
ResourceQuota
{}
if
err
:=
v1
.
Convert_v1_ResourceQuota_To_api_ResourceQuota
(
&
v1ResourceQuota
,
&
resourceQuota
,
nil
);
err
!=
nil
{
if
err
:=
v1
.
Convert_v1_ResourceQuota_To_api_ResourceQuota
(
&
v1ResourceQuota
,
&
resourceQuota
,
nil
);
err
!=
nil
{
...
...
pkg/genericapiserver/endpoints/apiserver_test.go
View file @
79adb99a
...
@@ -34,6 +34,9 @@ import (
...
@@ -34,6 +34,9 @@ import (
"testing"
"testing"
"time"
"time"
"github.com/emicklei/go-restful"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
apitesting
"k8s.io/apimachinery/pkg/api/testing"
...
@@ -57,8 +60,6 @@ import (
...
@@ -57,8 +60,6 @@ import (
"k8s.io/kubernetes/pkg/genericapiserver/registry/rest"
"k8s.io/kubernetes/pkg/genericapiserver/registry/rest"
"k8s.io/kubernetes/plugin/pkg/admission/admit"
"k8s.io/kubernetes/plugin/pkg/admission/admit"
"k8s.io/kubernetes/plugin/pkg/admission/deny"
"k8s.io/kubernetes/plugin/pkg/admission/deny"
"github.com/emicklei/go-restful"
)
)
// This creates fake API versions, similar to api/latest.go.
// This creates fake API versions, similar to api/latest.go.
...
@@ -1739,7 +1740,7 @@ func TestConnectResponderObject(t *testing.T) {
...
@@ -1739,7 +1740,7 @@ func TestConnectResponderObject(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
obj
,
simple
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
obj
,
simple
)
{
t
.
Errorf
(
"Unexpected response: %#v"
,
obj
)
t
.
Errorf
(
"Unexpected response: %#v"
,
obj
)
}
}
}
}
...
@@ -1969,7 +1970,7 @@ func TestDeleteWithOptions(t *testing.T) {
...
@@ -1969,7 +1970,7 @@ func TestDeleteWithOptions(t *testing.T) {
t
.
Errorf
(
"Unexpected delete: %s, expected %s"
,
simpleStorage
.
deleted
,
ID
)
t
.
Errorf
(
"Unexpected delete: %s, expected %s"
,
simpleStorage
.
deleted
,
ID
)
}
}
simpleStorage
.
deleteOptions
.
GetObjectKind
()
.
SetGroupVersionKind
(
schema
.
GroupVersionKind
{})
simpleStorage
.
deleteOptions
.
GetObjectKind
()
.
SetGroupVersionKind
(
schema
.
GroupVersionKind
{})
if
!
api
.
Semantic
.
DeepEqual
(
simpleStorage
.
deleteOptions
,
item
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
simpleStorage
.
deleteOptions
,
item
)
{
t
.
Errorf
(
"unexpected delete options: %s"
,
diff
.
ObjectDiff
(
simpleStorage
.
deleteOptions
,
item
))
t
.
Errorf
(
"unexpected delete options: %s"
,
diff
.
ObjectDiff
(
simpleStorage
.
deleteOptions
,
item
))
}
}
}
}
...
@@ -2006,7 +2007,7 @@ func TestDeleteWithOptionsQuery(t *testing.T) {
...
@@ -2006,7 +2007,7 @@ func TestDeleteWithOptionsQuery(t *testing.T) {
t
.
Fatalf
(
"Unexpected delete: %s, expected %s"
,
simpleStorage
.
deleted
,
ID
)
t
.
Fatalf
(
"Unexpected delete: %s, expected %s"
,
simpleStorage
.
deleted
,
ID
)
}
}
simpleStorage
.
deleteOptions
.
GetObjectKind
()
.
SetGroupVersionKind
(
schema
.
GroupVersionKind
{})
simpleStorage
.
deleteOptions
.
GetObjectKind
()
.
SetGroupVersionKind
(
schema
.
GroupVersionKind
{})
if
!
api
.
Semantic
.
DeepEqual
(
simpleStorage
.
deleteOptions
,
item
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
simpleStorage
.
deleteOptions
,
item
)
{
t
.
Errorf
(
"unexpected delete options: %s"
,
diff
.
ObjectDiff
(
simpleStorage
.
deleteOptions
,
item
))
t
.
Errorf
(
"unexpected delete options: %s"
,
diff
.
ObjectDiff
(
simpleStorage
.
deleteOptions
,
item
))
}
}
}
}
...
@@ -2046,7 +2047,7 @@ func TestDeleteWithOptionsQueryAndBody(t *testing.T) {
...
@@ -2046,7 +2047,7 @@ func TestDeleteWithOptionsQueryAndBody(t *testing.T) {
t
.
Errorf
(
"Unexpected delete: %s, expected %s"
,
simpleStorage
.
deleted
,
ID
)
t
.
Errorf
(
"Unexpected delete: %s, expected %s"
,
simpleStorage
.
deleted
,
ID
)
}
}
simpleStorage
.
deleteOptions
.
GetObjectKind
()
.
SetGroupVersionKind
(
schema
.
GroupVersionKind
{})
simpleStorage
.
deleteOptions
.
GetObjectKind
()
.
SetGroupVersionKind
(
schema
.
GroupVersionKind
{})
if
!
api
.
Semantic
.
DeepEqual
(
simpleStorage
.
deleteOptions
,
item
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
simpleStorage
.
deleteOptions
,
item
)
{
t
.
Errorf
(
"unexpected delete options: %s"
,
diff
.
ObjectDiff
(
simpleStorage
.
deleteOptions
,
item
))
t
.
Errorf
(
"unexpected delete options: %s"
,
diff
.
ObjectDiff
(
simpleStorage
.
deleteOptions
,
item
))
}
}
}
}
...
...
pkg/genericapiserver/endpoints/handlers/rest_test.go
View file @
79adb99a
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"github.com/emicklei/go-restful"
"github.com/emicklei/go-restful"
"github.com/evanphx/json-patch"
"github.com/evanphx/json-patch"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
...
@@ -74,7 +75,7 @@ func TestPatchAnonymousField(t *testing.T) {
...
@@ -74,7 +75,7 @@ func TestPatchAnonymousField(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
actual
,
expected
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
actual
,
expected
)
{
t
.
Errorf
(
"expected %#v, got %#v"
,
expected
,
actual
)
t
.
Errorf
(
"expected %#v, got %#v"
,
expected
,
actual
)
}
}
}
}
...
...
pkg/genericapiserver/registry/generic/registry/store_test.go
View file @
79adb99a
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metainternalversion
"k8s.io/apimachinery/pkg/apis/meta/internalversion"
metainternalversion
"k8s.io/apimachinery/pkg/apis/meta/internalversion"
...
@@ -204,7 +205,7 @@ func TestStoreList(t *testing.T) {
...
@@ -204,7 +205,7 @@ func TestStoreList(t *testing.T) {
}
}
// DeepDerivative e,a is needed here b/c the storage layer sets ResourceVersion
// DeepDerivative e,a is needed here b/c the storage layer sets ResourceVersion
if
e
,
a
:=
item
.
out
,
list
;
!
api
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
if
e
,
a
:=
item
.
out
,
list
;
!
api
equality
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
t
.
Errorf
(
"%v: Expected %#v, got %#v"
,
name
,
e
,
a
)
t
.
Errorf
(
"%v: Expected %#v, got %#v"
,
name
,
e
,
a
)
}
}
destroyFunc
()
destroyFunc
()
...
...
pkg/genericapiserver/registry/rest/resttest/resttest.go
View file @
79adb99a
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/validation/path"
"k8s.io/apimachinery/pkg/api/validation/path"
metainternalversion
"k8s.io/apimachinery/pkg/apis/meta/internalversion"
metainternalversion
"k8s.io/apimachinery/pkg/apis/meta/internalversion"
...
@@ -276,7 +277,7 @@ func (t *Tester) testCreateEquals(obj runtime.Object, getFn GetFunc) {
...
@@ -276,7 +277,7 @@ func (t *Tester) testCreateEquals(obj runtime.Object, getFn GetFunc) {
gotMeta
:=
t
.
getObjectMetaOrFail
(
got
)
gotMeta
:=
t
.
getObjectMetaOrFail
(
got
)
createdMeta
.
ResourceVersion
=
gotMeta
.
ResourceVersion
createdMeta
.
ResourceVersion
=
gotMeta
.
ResourceVersion
if
e
,
a
:=
created
,
got
;
!
api
.
Semantic
.
DeepEqual
(
e
,
a
)
{
if
e
,
a
:=
created
,
got
;
!
api
equality
.
Semantic
.
DeepEqual
(
e
,
a
)
{
t
.
Errorf
(
"unexpected obj: %#v, expected %#v"
,
e
,
a
)
t
.
Errorf
(
"unexpected obj: %#v, expected %#v"
,
e
,
a
)
}
}
}
}
...
@@ -484,7 +485,7 @@ func (t *Tester) testUpdateEquals(obj runtime.Object, createFn CreateFunc, getFn
...
@@ -484,7 +485,7 @@ func (t *Tester) testUpdateEquals(obj runtime.Object, createFn CreateFunc, getFn
gotMeta
:=
t
.
getObjectMetaOrFail
(
got
)
gotMeta
:=
t
.
getObjectMetaOrFail
(
got
)
updatedMeta
.
ResourceVersion
=
gotMeta
.
ResourceVersion
updatedMeta
.
ResourceVersion
=
gotMeta
.
ResourceVersion
if
e
,
a
:=
updated
,
got
;
!
api
.
Semantic
.
DeepEqual
(
e
,
a
)
{
if
e
,
a
:=
updated
,
got
;
!
api
equality
.
Semantic
.
DeepEqual
(
e
,
a
)
{
t
.
Errorf
(
"unexpected obj: %#v, expected %#v"
,
e
,
a
)
t
.
Errorf
(
"unexpected obj: %#v, expected %#v"
,
e
,
a
)
}
}
}
}
...
@@ -1091,7 +1092,7 @@ func (t *Tester) testGetFound(obj runtime.Object) {
...
@@ -1091,7 +1092,7 @@ func (t *Tester) testGetFound(obj runtime.Object) {
}
}
gotMeta
:=
t
.
getObjectMetaOrFail
(
got
)
gotMeta
:=
t
.
getObjectMetaOrFail
(
got
)
gotMeta
.
ResourceVersion
=
existingMeta
.
ResourceVersion
gotMeta
.
ResourceVersion
=
existingMeta
.
ResourceVersion
if
e
,
a
:=
existing
,
got
;
!
api
.
Semantic
.
DeepEqual
(
e
,
a
)
{
if
e
,
a
:=
existing
,
got
;
!
api
equality
.
Semantic
.
DeepEqual
(
e
,
a
)
{
t
.
Errorf
(
"unexpected obj: %#v, expected %#v"
,
e
,
a
)
t
.
Errorf
(
"unexpected obj: %#v, expected %#v"
,
e
,
a
)
}
}
}
}
...
@@ -1174,7 +1175,7 @@ func (t *Tester) testListFound(obj runtime.Object, assignFn AssignFunc) {
...
@@ -1174,7 +1175,7 @@ func (t *Tester) testListFound(obj runtime.Object, assignFn AssignFunc) {
if
len
(
items
)
!=
len
(
existing
)
{
if
len
(
items
)
!=
len
(
existing
)
{
t
.
Errorf
(
"unexpected number of items: %v"
,
len
(
items
))
t
.
Errorf
(
"unexpected number of items: %v"
,
len
(
items
))
}
}
if
!
api
.
Semantic
.
DeepEqual
(
existing
,
items
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
existing
,
items
)
{
t
.
Errorf
(
"expected: %#v, got: %#v"
,
existing
,
items
)
t
.
Errorf
(
"expected: %#v, got: %#v"
,
existing
,
items
)
}
}
}
}
...
@@ -1209,7 +1210,7 @@ func (t *Tester) testListMatchLabels(obj runtime.Object, assignFn AssignFunc) {
...
@@ -1209,7 +1210,7 @@ func (t *Tester) testListMatchLabels(obj runtime.Object, assignFn AssignFunc) {
if
len
(
items
)
!=
len
(
filtered
)
{
if
len
(
items
)
!=
len
(
filtered
)
{
t
.
Errorf
(
"unexpected number of items: %v"
,
len
(
items
))
t
.
Errorf
(
"unexpected number of items: %v"
,
len
(
items
))
}
}
if
!
api
.
Semantic
.
DeepEqual
(
filtered
,
items
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
filtered
,
items
)
{
t
.
Errorf
(
"expected: %#v, got: %#v"
,
filtered
,
items
)
t
.
Errorf
(
"expected: %#v, got: %#v"
,
filtered
,
items
)
}
}
}
}
...
...
pkg/kubectl/cmd/config/config_test.go
View file @
79adb99a
...
@@ -26,10 +26,10 @@ import (
...
@@ -26,10 +26,10 @@ import (
"strings"
"strings"
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi
"k8s.io/client-go/tools/clientcmd/api"
clientcmdapi
"k8s.io/client-go/tools/clientcmd/api"
"k8s.io/kubernetes/pkg/api"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
cmdutil
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
)
)
...
@@ -897,7 +897,7 @@ func (test configCommandTest) run(t *testing.T) string {
...
@@ -897,7 +897,7 @@ func (test configCommandTest) run(t *testing.T) string {
testSetNilMapsToEmpties
(
reflect
.
ValueOf
(
&
actualConfig
))
testSetNilMapsToEmpties
(
reflect
.
ValueOf
(
&
actualConfig
))
testClearLocationOfOrigin
(
&
actualConfig
)
testClearLocationOfOrigin
(
&
actualConfig
)
if
!
api
.
Semantic
.
DeepEqual
(
test
.
expectedConfig
,
actualConfig
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
test
.
expectedConfig
,
actualConfig
)
{
t
.
Errorf
(
"diff: %v"
,
diff
.
ObjectDiff
(
test
.
expectedConfig
,
actualConfig
))
t
.
Errorf
(
"diff: %v"
,
diff
.
ObjectDiff
(
test
.
expectedConfig
,
actualConfig
))
t
.
Errorf
(
"expected: %#v
\n
actual: %#v"
,
test
.
expectedConfig
,
actualConfig
)
t
.
Errorf
(
"expected: %#v
\n
actual: %#v"
,
test
.
expectedConfig
,
actualConfig
)
}
}
...
...
pkg/kubectl/cmd/get_test.go
View file @
79adb99a
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"strings"
"strings"
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
...
@@ -280,7 +281,7 @@ func verifyObjects(t *testing.T, expected, actual []runtime.Object) {
...
@@ -280,7 +281,7 @@ func verifyObjects(t *testing.T, expected, actual []runtime.Object) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
expected
[
i
],
actualObj
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
[
i
],
actualObj
)
{
t
.
Errorf
(
"unexpected object:
\n
%#v
\n
%#v"
,
expected
[
i
],
actualObj
)
t
.
Errorf
(
"unexpected object:
\n
%#v
\n
%#v"
,
expected
[
i
],
actualObj
)
}
}
}
}
...
...
pkg/kubectl/describe_test.go
View file @
79adb99a
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/federation/apis/federation"
"k8s.io/kubernetes/federation/apis/federation"
...
@@ -563,7 +564,7 @@ func TestGetPodsTotalRequests(t *testing.T) {
...
@@ -563,7 +564,7 @@ func TestGetPodsTotalRequests(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error %v"
,
err
)
t
.
Errorf
(
"Unexpected error %v"
,
err
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
reqs
,
testCase
.
expectedReqs
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
reqs
,
testCase
.
expectedReqs
)
{
t
.
Errorf
(
"Expected %v, got %v"
,
testCase
.
expectedReqs
,
reqs
)
t
.
Errorf
(
"Expected %v, got %v"
,
testCase
.
expectedReqs
,
reqs
)
}
}
}
}
...
...
pkg/kubectl/resource/builder_test.go
View file @
79adb99a
...
@@ -31,6 +31,7 @@ import (
...
@@ -31,6 +31,7 @@ import (
"github.com/ghodss/yaml"
"github.com/ghodss/yaml"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -591,7 +592,7 @@ func TestMultipleResourceByTheSameName(t *testing.T) {
...
@@ -591,7 +592,7 @@ func TestMultipleResourceByTheSameName(t *testing.T) {
if
err
!=
nil
||
singleItemImplied
||
len
(
test
.
Infos
)
!=
4
{
if
err
!=
nil
||
singleItemImplied
||
len
(
test
.
Infos
)
!=
4
{
t
.
Fatalf
(
"unexpected response: %v %t %#v"
,
err
,
singleItemImplied
,
test
.
Infos
)
t
.
Fatalf
(
"unexpected response: %v %t %#v"
,
err
,
singleItemImplied
,
test
.
Infos
)
}
}
if
!
api
.
Semantic
.
DeepDerivative
([]
runtime
.
Object
{
&
pods
.
Items
[
0
],
&
pods
.
Items
[
1
],
&
svcs
.
Items
[
0
],
&
svcs
.
Items
[
0
]},
test
.
Objects
())
{
if
!
api
equality
.
Semantic
.
DeepDerivative
([]
runtime
.
Object
{
&
pods
.
Items
[
0
],
&
pods
.
Items
[
1
],
&
svcs
.
Items
[
0
],
&
svcs
.
Items
[
0
]},
test
.
Objects
())
{
t
.
Errorf
(
"unexpected visited objects: %#v"
,
test
.
Objects
())
t
.
Errorf
(
"unexpected visited objects: %#v"
,
test
.
Objects
())
}
}
...
@@ -734,7 +735,7 @@ func TestSelector(t *testing.T) {
...
@@ -734,7 +735,7 @@ func TestSelector(t *testing.T) {
if
err
!=
nil
||
singleItemImplied
||
len
(
test
.
Infos
)
!=
3
{
if
err
!=
nil
||
singleItemImplied
||
len
(
test
.
Infos
)
!=
3
{
t
.
Fatalf
(
"unexpected response: %v %t %#v"
,
err
,
singleItemImplied
,
test
.
Infos
)
t
.
Fatalf
(
"unexpected response: %v %t %#v"
,
err
,
singleItemImplied
,
test
.
Infos
)
}
}
if
!
api
.
Semantic
.
DeepDerivative
([]
runtime
.
Object
{
&
pods
.
Items
[
0
],
&
pods
.
Items
[
1
],
&
svc
.
Items
[
0
]},
test
.
Objects
())
{
if
!
api
equality
.
Semantic
.
DeepDerivative
([]
runtime
.
Object
{
&
pods
.
Items
[
0
],
&
pods
.
Items
[
1
],
&
svc
.
Items
[
0
]},
test
.
Objects
())
{
t
.
Errorf
(
"unexpected visited objects: %#v"
,
test
.
Objects
())
t
.
Errorf
(
"unexpected visited objects: %#v"
,
test
.
Objects
())
}
}
...
@@ -866,7 +867,7 @@ func TestStream(t *testing.T) {
...
@@ -866,7 +867,7 @@ func TestStream(t *testing.T) {
if
err
!=
nil
||
singleItemImplied
||
len
(
test
.
Infos
)
!=
3
{
if
err
!=
nil
||
singleItemImplied
||
len
(
test
.
Infos
)
!=
3
{
t
.
Fatalf
(
"unexpected response: %v %t %#v"
,
err
,
singleItemImplied
,
test
.
Infos
)
t
.
Fatalf
(
"unexpected response: %v %t %#v"
,
err
,
singleItemImplied
,
test
.
Infos
)
}
}
if
!
api
.
Semantic
.
DeepDerivative
([]
runtime
.
Object
{
&
pods
.
Items
[
0
],
&
pods
.
Items
[
1
],
&
rc
.
Items
[
0
]},
test
.
Objects
())
{
if
!
api
equality
.
Semantic
.
DeepDerivative
([]
runtime
.
Object
{
&
pods
.
Items
[
0
],
&
pods
.
Items
[
1
],
&
rc
.
Items
[
0
]},
test
.
Objects
())
{
t
.
Errorf
(
"unexpected visited objects: %#v"
,
test
.
Objects
())
t
.
Errorf
(
"unexpected visited objects: %#v"
,
test
.
Objects
())
}
}
}
}
...
@@ -883,7 +884,7 @@ func TestYAMLStream(t *testing.T) {
...
@@ -883,7 +884,7 @@ func TestYAMLStream(t *testing.T) {
if
err
!=
nil
||
singleItemImplied
||
len
(
test
.
Infos
)
!=
3
{
if
err
!=
nil
||
singleItemImplied
||
len
(
test
.
Infos
)
!=
3
{
t
.
Fatalf
(
"unexpected response: %v %t %#v"
,
err
,
singleItemImplied
,
test
.
Infos
)
t
.
Fatalf
(
"unexpected response: %v %t %#v"
,
err
,
singleItemImplied
,
test
.
Infos
)
}
}
if
!
api
.
Semantic
.
DeepDerivative
([]
runtime
.
Object
{
&
pods
.
Items
[
0
],
&
pods
.
Items
[
1
],
&
rc
.
Items
[
0
]},
test
.
Objects
())
{
if
!
api
equality
.
Semantic
.
DeepDerivative
([]
runtime
.
Object
{
&
pods
.
Items
[
0
],
&
pods
.
Items
[
1
],
&
rc
.
Items
[
0
]},
test
.
Objects
())
{
t
.
Errorf
(
"unexpected visited objects: %#v"
,
test
.
Objects
())
t
.
Errorf
(
"unexpected visited objects: %#v"
,
test
.
Objects
())
}
}
}
}
...
@@ -905,7 +906,7 @@ func TestMultipleObject(t *testing.T) {
...
@@ -905,7 +906,7 @@ func TestMultipleObject(t *testing.T) {
&
svc
.
Items
[
0
],
&
svc
.
Items
[
0
],
},
},
}
}
if
!
api
.
Semantic
.
DeepDerivative
(
expected
,
obj
)
{
if
!
api
equality
.
Semantic
.
DeepDerivative
(
expected
,
obj
)
{
t
.
Errorf
(
"unexpected visited objects: %#v"
,
obj
)
t
.
Errorf
(
"unexpected visited objects: %#v"
,
obj
)
}
}
}
}
...
@@ -1136,7 +1137,7 @@ func TestLatest(t *testing.T) {
...
@@ -1136,7 +1137,7 @@ func TestLatest(t *testing.T) {
if
err
!=
nil
||
singleItemImplied
||
len
(
test
.
Infos
)
!=
3
{
if
err
!=
nil
||
singleItemImplied
||
len
(
test
.
Infos
)
!=
3
{
t
.
Fatalf
(
"unexpected response: %v %t %#v"
,
err
,
singleItemImplied
,
test
.
Infos
)
t
.
Fatalf
(
"unexpected response: %v %t %#v"
,
err
,
singleItemImplied
,
test
.
Infos
)
}
}
if
!
api
.
Semantic
.
DeepDerivative
([]
runtime
.
Object
{
newPod
,
newPod2
,
newSvc
},
test
.
Objects
())
{
if
!
api
equality
.
Semantic
.
DeepDerivative
([]
runtime
.
Object
{
newPod
,
newPod2
,
newSvc
},
test
.
Objects
())
{
t
.
Errorf
(
"unexpected visited objects: %#v"
,
test
.
Objects
())
t
.
Errorf
(
"unexpected visited objects: %#v"
,
test
.
Objects
())
}
}
}
}
...
...
pkg/kubelet/config/apiserver_test.go
View file @
79adb99a
...
@@ -19,11 +19,11 @@ package config
...
@@ -19,11 +19,11 @@ package config
import
(
import
(
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/cache"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
)
)
...
@@ -71,7 +71,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
...
@@ -71,7 +71,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
}
}
update
:=
got
.
(
kubetypes
.
PodUpdate
)
update
:=
got
.
(
kubetypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod1v1
)
expected
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod1v1
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
update
)
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
update
)
}
}
...
@@ -86,7 +86,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
...
@@ -86,7 +86,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
expectedA
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod1v1
,
pod2
)
expectedA
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod1v1
,
pod2
)
expectedB
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod2
,
pod1v1
)
expectedB
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod2
,
pod1v1
)
if
!
api
.
Semantic
.
DeepEqual
(
expectedA
,
update
)
&&
!
api
.
Semantic
.
DeepEqual
(
expectedB
,
update
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expectedA
,
update
)
&&
!
apiequality
.
Semantic
.
DeepEqual
(
expectedB
,
update
)
{
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
update
)
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
update
)
}
}
...
@@ -100,7 +100,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
...
@@ -100,7 +100,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
expectedA
=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod1v2
,
pod2
)
expectedA
=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod1v2
,
pod2
)
expectedB
=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod2
,
pod1v2
)
expectedB
=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod2
,
pod1v2
)
if
!
api
.
Semantic
.
DeepEqual
(
expectedA
,
update
)
&&
!
api
.
Semantic
.
DeepEqual
(
expectedB
,
update
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expectedA
,
update
)
&&
!
apiequality
.
Semantic
.
DeepEqual
(
expectedB
,
update
)
{
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
update
)
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
update
)
}
}
...
@@ -112,7 +112,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
...
@@ -112,7 +112,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
}
}
update
=
got
.
(
kubetypes
.
PodUpdate
)
update
=
got
.
(
kubetypes
.
PodUpdate
)
expected
=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod2
)
expected
=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod2
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
update
)
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
update
)
}
}
...
@@ -124,7 +124,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
...
@@ -124,7 +124,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
}
}
update
=
got
.
(
kubetypes
.
PodUpdate
)
update
=
got
.
(
kubetypes
.
PodUpdate
)
expected
=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
)
expected
=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
update
)
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
update
)
}
}
}
}
...
@@ -188,7 +188,7 @@ func TestNewSourceApiserverInitialEmptySendsEmptyPodUpdate(t *testing.T) {
...
@@ -188,7 +188,7 @@ func TestNewSourceApiserverInitialEmptySendsEmptyPodUpdate(t *testing.T) {
}
}
update
:=
got
.
(
kubetypes
.
PodUpdate
)
update
:=
got
.
(
kubetypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
)
expected
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
update
)
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
update
)
}
}
}
}
pkg/kubelet/config/config_test.go
View file @
79adb99a
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
...
@@ -101,7 +102,7 @@ func expectPodUpdate(t *testing.T, ch <-chan kubetypes.PodUpdate, expected ...ku
...
@@ -101,7 +102,7 @@ func expectPodUpdate(t *testing.T, ch <-chan kubetypes.PodUpdate, expected ...ku
// except for "Pods", which are compared separately below.
// except for "Pods", which are compared separately below.
expectedCopy
,
updateCopy
:=
expected
[
i
],
update
expectedCopy
,
updateCopy
:=
expected
[
i
],
update
expectedCopy
.
Pods
,
updateCopy
.
Pods
=
nil
,
nil
expectedCopy
.
Pods
,
updateCopy
.
Pods
=
nil
,
nil
if
!
api
.
Semantic
.
DeepEqual
(
expectedCopy
,
updateCopy
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expectedCopy
,
updateCopy
)
{
t
.
Fatalf
(
"Expected %#v, Got %#v"
,
expectedCopy
,
updateCopy
)
t
.
Fatalf
(
"Expected %#v, Got %#v"
,
expectedCopy
,
updateCopy
)
}
}
...
...
pkg/kubelet/config/file_linux_test.go
View file @
79adb99a
...
@@ -29,6 +29,7 @@ import (
...
@@ -29,6 +29,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
...
@@ -58,7 +59,7 @@ func TestUpdateOnNonExistentFile(t *testing.T) {
...
@@ -58,7 +59,7 @@ func TestUpdateOnNonExistentFile(t *testing.T) {
case
got
:=
<-
ch
:
case
got
:=
<-
ch
:
update
:=
got
.
(
kubetypes
.
PodUpdate
)
update
:=
got
.
(
kubetypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
FileSource
)
expected
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
FileSource
)
if
!
api
.
Semantic
.
DeepDerivative
(
expected
,
update
)
{
if
!
api
equality
.
Semantic
.
DeepDerivative
(
expected
,
update
)
{
t
.
Fatalf
(
"expected %#v, Got %#v"
,
expected
,
update
)
t
.
Fatalf
(
"expected %#v, Got %#v"
,
expected
,
update
)
}
}
...
@@ -95,7 +96,7 @@ func TestReadPodsFromFileExistAlready(t *testing.T) {
...
@@ -95,7 +96,7 @@ func TestReadPodsFromFileExistAlready(t *testing.T) {
t
.
Fatalf
(
"%s: Invalid pod %#v, %#v"
,
testCase
.
desc
,
internalPod
,
errs
)
t
.
Fatalf
(
"%s: Invalid pod %#v, %#v"
,
testCase
.
desc
,
internalPod
,
errs
)
}
}
}
}
if
!
api
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
t
.
Fatalf
(
"%s: Expected %#v, Got %#v"
,
testCase
.
desc
,
testCase
.
expected
,
update
)
t
.
Fatalf
(
"%s: Expected %#v, Got %#v"
,
testCase
.
desc
,
testCase
.
expected
,
update
)
}
}
case
<-
time
.
After
(
wait
.
ForeverTestTimeout
)
:
case
<-
time
.
After
(
wait
.
ForeverTestTimeout
)
:
...
@@ -159,7 +160,7 @@ func TestExtractFromEmptyDir(t *testing.T) {
...
@@ -159,7 +160,7 @@ func TestExtractFromEmptyDir(t *testing.T) {
update
:=
(
<-
ch
)
.
(
kubetypes
.
PodUpdate
)
update
:=
(
<-
ch
)
.
(
kubetypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
FileSource
)
expected
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
FileSource
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Fatalf
(
"expected %#v, Got %#v"
,
expected
,
update
)
t
.
Fatalf
(
"expected %#v, Got %#v"
,
expected
,
update
)
}
}
}
}
...
@@ -375,7 +376,7 @@ func expectUpdate(t *testing.T, ch chan interface{}, testCase *testCase) {
...
@@ -375,7 +376,7 @@ func expectUpdate(t *testing.T, ch chan interface{}, testCase *testCase) {
}
}
}
}
if
!
api
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
t
.
Fatalf
(
"%s: Expected: %#v, Got: %#v"
,
testCase
.
desc
,
testCase
.
expected
,
update
)
t
.
Fatalf
(
"%s: Expected: %#v, Got: %#v"
,
testCase
.
desc
,
testCase
.
expected
,
update
)
}
}
return
return
...
...
pkg/kubelet/config/http_test.go
View file @
79adb99a
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
...
@@ -309,7 +310,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
...
@@ -309,7 +310,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
}
}
update
:=
(
<-
ch
)
.
(
kubetypes
.
PodUpdate
)
update
:=
(
<-
ch
)
.
(
kubetypes
.
PodUpdate
)
if
!
api
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
t
.
Errorf
(
"%s: Expected: %#v, Got: %#v"
,
testCase
.
desc
,
testCase
.
expected
,
update
)
t
.
Errorf
(
"%s: Expected: %#v, Got: %#v"
,
testCase
.
desc
,
testCase
.
expected
,
update
)
}
}
for
_
,
pod
:=
range
update
.
Pods
{
for
_
,
pod
:=
range
update
.
Pods
{
...
...
pkg/kubelet/dockertools/docker_manager_test.go
View file @
79adb99a
...
@@ -37,13 +37,13 @@ import (
...
@@ -37,13 +37,13 @@ import (
"github.com/golang/mock/gomock"
"github.com/golang/mock/gomock"
cadvisorapi
"github.com/google/cadvisor/info/v1"
cadvisorapi
"github.com/google/cadvisor/info/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
kubetypes
"k8s.io/apimachinery/pkg/types"
kubetypes
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/util/clock"
"k8s.io/client-go/util/clock"
"k8s.io/client-go/util/flowcontrol"
"k8s.io/client-go/util/flowcontrol"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/componentconfig"
"k8s.io/kubernetes/pkg/apis/componentconfig"
...
@@ -327,10 +327,10 @@ func TestSetEntrypointAndCommand(t *testing.T) {
...
@@ -327,10 +327,10 @@ func TestSetEntrypointAndCommand(t *testing.T) {
}
}
setEntrypointAndCommand
(
tc
.
container
,
opts
,
actualOpts
)
setEntrypointAndCommand
(
tc
.
container
,
opts
,
actualOpts
)
if
e
,
a
:=
tc
.
expected
.
Config
.
Entrypoint
,
actualOpts
.
Config
.
Entrypoint
;
!
api
.
Semantic
.
DeepEqual
(
e
,
a
)
{
if
e
,
a
:=
tc
.
expected
.
Config
.
Entrypoint
,
actualOpts
.
Config
.
Entrypoint
;
!
api
equality
.
Semantic
.
DeepEqual
(
e
,
a
)
{
t
.
Errorf
(
"%v: unexpected entrypoint: expected %v, got %v"
,
tc
.
name
,
e
,
a
)
t
.
Errorf
(
"%v: unexpected entrypoint: expected %v, got %v"
,
tc
.
name
,
e
,
a
)
}
}
if
e
,
a
:=
tc
.
expected
.
Config
.
Cmd
,
actualOpts
.
Config
.
Cmd
;
!
api
.
Semantic
.
DeepEqual
(
e
,
a
)
{
if
e
,
a
:=
tc
.
expected
.
Config
.
Cmd
,
actualOpts
.
Config
.
Cmd
;
!
api
equality
.
Semantic
.
DeepEqual
(
e
,
a
)
{
t
.
Errorf
(
"%v: unexpected command: expected %v, got %v"
,
tc
.
name
,
e
,
a
)
t
.
Errorf
(
"%v: unexpected command: expected %v, got %v"
,
tc
.
name
,
e
,
a
)
}
}
}
}
...
...
pkg/kubelet/kubelet_node_status_test.go
View file @
79adb99a
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
cadvisorapi
"github.com/google/cadvisor/info/v1"
cadvisorapi
"github.com/google/cadvisor/info/v1"
cadvisorapiv2
"github.com/google/cadvisor/info/v2"
cadvisorapiv2
"github.com/google/cadvisor/info/v2"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -38,7 +39,6 @@ import (
...
@@ -38,7 +39,6 @@ import (
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
core
"k8s.io/client-go/testing"
core
"k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
...
@@ -245,7 +245,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
...
@@ -245,7 +245,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
if
maxImagesInNodeStatus
!=
len
(
updatedNode
.
Status
.
Images
)
{
if
maxImagesInNodeStatus
!=
len
(
updatedNode
.
Status
.
Images
)
{
t
.
Errorf
(
"unexpected image list length in node status, expected: %v, got: %v"
,
maxImagesInNodeStatus
,
len
(
updatedNode
.
Status
.
Images
))
t
.
Errorf
(
"unexpected image list length in node status, expected: %v, got: %v"
,
maxImagesInNodeStatus
,
len
(
updatedNode
.
Status
.
Images
))
}
else
{
}
else
{
if
!
api
.
Semantic
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
t
.
Errorf
(
"unexpected objects: %s"
,
diff
.
ObjectDiff
(
expectedNode
,
updatedNode
))
t
.
Errorf
(
"unexpected objects: %s"
,
diff
.
ObjectDiff
(
expectedNode
,
updatedNode
))
}
}
}
}
...
@@ -519,7 +519,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
...
@@ -519,7 +519,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
t
.
Errorf
(
"unexpected node condition order. NodeReady should be last."
)
t
.
Errorf
(
"unexpected node condition order. NodeReady should be last."
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
t
.
Errorf
(
"unexpected objects: %s"
,
diff
.
ObjectDiff
(
expectedNode
,
updatedNode
))
t
.
Errorf
(
"unexpected objects: %s"
,
diff
.
ObjectDiff
(
expectedNode
,
updatedNode
))
}
}
}
}
...
@@ -829,7 +829,7 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) {
...
@@ -829,7 +829,7 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) {
LastHeartbeatTime
:
metav1
.
Time
{},
LastHeartbeatTime
:
metav1
.
Time
{},
LastTransitionTime
:
metav1
.
Time
{},
LastTransitionTime
:
metav1
.
Time
{},
}
}
if
!
api
.
Semantic
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
t
.
Errorf
(
"unexpected objects: %s"
,
diff
.
ObjectDiff
(
expectedNode
,
updatedNode
))
t
.
Errorf
(
"unexpected objects: %s"
,
diff
.
ObjectDiff
(
expectedNode
,
updatedNode
))
}
}
}
}
...
...
pkg/kubelet/kubelet_resources_test.go
View file @
79adb99a
...
@@ -23,8 +23,8 @@ import (
...
@@ -23,8 +23,8 @@ import (
cadvisorapi
"github.com/google/cadvisor/info/v1"
cadvisorapi
"github.com/google/cadvisor/info/v1"
cadvisorapiv2
"github.com/google/cadvisor/info/v2"
cadvisorapiv2
"github.com/google/cadvisor/info/v2"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
)
)
...
@@ -78,7 +78,7 @@ func TestPodResourceLimitsDefaulting(t *testing.T) {
...
@@ -78,7 +78,7 @@ func TestPodResourceLimitsDefaulting(t *testing.T) {
for
idx
,
tc
:=
range
cases
{
for
idx
,
tc
:=
range
cases
{
actual
,
_
,
err
:=
tk
.
kubelet
.
defaultPodLimitsForDownwardApi
(
tc
.
pod
,
nil
)
actual
,
_
,
err
:=
tk
.
kubelet
.
defaultPodLimitsForDownwardApi
(
tc
.
pod
,
nil
)
as
.
Nil
(
err
,
"failed to default pod limits: %v"
,
err
)
as
.
Nil
(
err
,
"failed to default pod limits: %v"
,
err
)
if
!
api
.
Semantic
.
DeepEqual
(
tc
.
expected
,
actual
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
tc
.
expected
,
actual
)
{
as
.
Fail
(
"test case [%d] failed. Expected: %+v, Got: %+v"
,
idx
,
tc
.
expected
,
actual
)
as
.
Fail
(
"test case [%d] failed. Expected: %+v, Got: %+v"
,
idx
,
tc
.
expected
,
actual
)
}
}
}
}
...
...
pkg/kubelet/status/status_manager.go
View file @
79adb99a
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
"github.com/golang/glog"
"github.com/golang/glog"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
...
@@ -116,7 +117,7 @@ func NewManager(kubeClient clientset.Interface, podManager kubepod.Manager) Mana
...
@@ -116,7 +117,7 @@ func NewManager(kubeClient clientset.Interface, podManager kubepod.Manager) Mana
// This method normalizes the status before comparing so as to make sure that meaningless
// This method normalizes the status before comparing so as to make sure that meaningless
// changes will be ignored.
// changes will be ignored.
func
isStatusEqual
(
oldStatus
,
status
*
v1
.
PodStatus
)
bool
{
func
isStatusEqual
(
oldStatus
,
status
*
v1
.
PodStatus
)
bool
{
return
api
.
Semantic
.
DeepEqual
(
status
,
oldStatus
)
return
api
equality
.
Semantic
.
DeepEqual
(
status
,
oldStatus
)
}
}
func
(
m
*
manager
)
Start
()
{
func
(
m
*
manager
)
Start
()
{
...
...
pkg/proxy/config/api_test.go
View file @
79adb99a
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/apimachinery/pkg/watch"
...
@@ -69,7 +70,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
...
@@ -69,7 +70,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
t
.
Errorf
(
"Unable to read from channel when expected"
)
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
}
expected
:=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{}}
expected
:=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{}}
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
got
)
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
got
)
}
}
...
@@ -80,7 +81,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
...
@@ -80,7 +81,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
t
.
Errorf
(
"Unable to read from channel when expected"
)
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
}
expected
=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{
*
service1v1
}}
expected
=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{
*
service1v1
}}
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
got
)
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
got
)
}
}
...
@@ -94,7 +95,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
...
@@ -94,7 +95,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
expectedA
:=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{
*
service1v1
,
*
service2
}}
expectedA
:=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{
*
service1v1
,
*
service2
}}
expectedB
:=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{
*
service2
,
*
service1v1
}}
expectedB
:=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{
*
service2
,
*
service1v1
}}
if
!
api
.
Semantic
.
DeepEqual
(
expectedA
,
got
)
&&
!
api
.
Semantic
.
DeepEqual
(
expectedB
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expectedA
,
got
)
&&
!
apiequality
.
Semantic
.
DeepEqual
(
expectedB
,
got
)
{
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
got
)
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
got
)
}
}
...
@@ -107,7 +108,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
...
@@ -107,7 +108,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
expectedA
=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{
*
service1v2
,
*
service2
}}
expectedA
=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{
*
service1v2
,
*
service2
}}
expectedB
=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{
*
service2
,
*
service1v2
}}
expectedB
=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{
*
service2
,
*
service1v2
}}
if
!
api
.
Semantic
.
DeepEqual
(
expectedA
,
got
)
&&
!
api
.
Semantic
.
DeepEqual
(
expectedB
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expectedA
,
got
)
&&
!
apiequality
.
Semantic
.
DeepEqual
(
expectedB
,
got
)
{
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
got
)
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
got
)
}
}
...
@@ -118,7 +119,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
...
@@ -118,7 +119,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
t
.
Errorf
(
"Unable to read from channel when expected"
)
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
}
expected
=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{
*
service2
}}
expected
=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{
*
service2
}}
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
got
)
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
got
)
}
}
...
@@ -129,7 +130,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
...
@@ -129,7 +130,7 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
t
.
Errorf
(
"Unable to read from channel when expected"
)
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
}
expected
=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{}}
expected
=
ServiceUpdate
{
Op
:
SET
,
Services
:
[]
api
.
Service
{}}
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
got
)
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
got
)
}
}
}
}
...
@@ -180,7 +181,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
...
@@ -180,7 +181,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
t
.
Errorf
(
"Unable to read from channel when expected"
)
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
}
expected
:=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{}}
expected
:=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{}}
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
got
)
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
got
)
}
}
...
@@ -191,7 +192,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
...
@@ -191,7 +192,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
t
.
Errorf
(
"Unable to read from channel when expected"
)
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
}
expected
=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{
*
endpoints1v1
}}
expected
=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{
*
endpoints1v1
}}
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
got
)
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
got
)
}
}
...
@@ -205,7 +206,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
...
@@ -205,7 +206,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
expectedA
:=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{
*
endpoints1v1
,
*
endpoints2
}}
expectedA
:=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{
*
endpoints1v1
,
*
endpoints2
}}
expectedB
:=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{
*
endpoints2
,
*
endpoints1v1
}}
expectedB
:=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{
*
endpoints2
,
*
endpoints1v1
}}
if
!
api
.
Semantic
.
DeepEqual
(
expectedA
,
got
)
&&
!
api
.
Semantic
.
DeepEqual
(
expectedB
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expectedA
,
got
)
&&
!
apiequality
.
Semantic
.
DeepEqual
(
expectedB
,
got
)
{
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
got
)
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
got
)
}
}
...
@@ -218,7 +219,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
...
@@ -218,7 +219,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
expectedA
=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{
*
endpoints1v2
,
*
endpoints2
}}
expectedA
=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{
*
endpoints1v2
,
*
endpoints2
}}
expectedB
=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{
*
endpoints2
,
*
endpoints1v2
}}
expectedB
=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{
*
endpoints2
,
*
endpoints1v2
}}
if
!
api
.
Semantic
.
DeepEqual
(
expectedA
,
got
)
&&
!
api
.
Semantic
.
DeepEqual
(
expectedB
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expectedA
,
got
)
&&
!
apiequality
.
Semantic
.
DeepEqual
(
expectedB
,
got
)
{
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
got
)
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
got
)
}
}
...
@@ -229,7 +230,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
...
@@ -229,7 +230,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
t
.
Errorf
(
"Unable to read from channel when expected"
)
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
}
expected
=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{
*
endpoints2
}}
expected
=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{
*
endpoints2
}}
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
got
)
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
got
)
}
}
...
@@ -240,7 +241,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
...
@@ -240,7 +241,7 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
t
.
Errorf
(
"Unable to read from channel when expected"
)
t
.
Errorf
(
"Unable to read from channel when expected"
)
}
}
expected
=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{}}
expected
=
EndpointsUpdate
{
Op
:
SET
,
Endpoints
:
[]
api
.
Endpoints
{}}
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
got
)
{
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
got
)
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
got
)
}
}
}
}
pkg/registry/core/persistentvolume/storage/storage_test.go
View file @
79adb99a
...
@@ -19,6 +19,7 @@ package storage
...
@@ -19,6 +19,7 @@ package storage
import
(
import
(
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
...
@@ -190,7 +191,7 @@ func TestUpdateStatus(t *testing.T) {
...
@@ -190,7 +191,7 @@ func TestUpdateStatus(t *testing.T) {
}
}
pvOut
:=
obj
.
(
*
api
.
PersistentVolume
)
pvOut
:=
obj
.
(
*
api
.
PersistentVolume
)
// only compare the relevant change b/c metadata will differ
// only compare the relevant change b/c metadata will differ
if
!
api
.
Semantic
.
DeepEqual
(
pvIn
.
Status
,
pvOut
.
Status
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
pvIn
.
Status
,
pvOut
.
Status
)
{
t
.
Errorf
(
"unexpected object: %s"
,
diff
.
ObjectDiff
(
pvIn
.
Status
,
pvOut
.
Status
))
t
.
Errorf
(
"unexpected object: %s"
,
diff
.
ObjectDiff
(
pvIn
.
Status
,
pvOut
.
Status
))
}
}
}
}
pkg/registry/core/persistentvolumeclaim/storage/storage_test.go
View file @
79adb99a
...
@@ -19,6 +19,7 @@ package storage
...
@@ -19,6 +19,7 @@ package storage
import
(
import
(
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
...
@@ -187,7 +188,7 @@ func TestUpdateStatus(t *testing.T) {
...
@@ -187,7 +188,7 @@ func TestUpdateStatus(t *testing.T) {
}
}
pvcOut
:=
obj
.
(
*
api
.
PersistentVolumeClaim
)
pvcOut
:=
obj
.
(
*
api
.
PersistentVolumeClaim
)
// only compare relevant changes b/c of difference in metadata
// only compare relevant changes b/c of difference in metadata
if
!
api
.
Semantic
.
DeepEqual
(
pvc
.
Status
,
pvcOut
.
Status
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
pvc
.
Status
,
pvcOut
.
Status
)
{
t
.
Errorf
(
"unexpected object: %s"
,
diff
.
ObjectDiff
(
pvc
.
Status
,
pvcOut
.
Status
))
t
.
Errorf
(
"unexpected object: %s"
,
diff
.
ObjectDiff
(
pvc
.
Status
,
pvcOut
.
Status
))
}
}
}
}
pkg/registry/core/pod/storage/storage_test.go
View file @
79adb99a
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"testing"
"testing"
"golang.org/x/net/context"
"golang.org/x/net/context"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
...
@@ -634,7 +635,7 @@ func TestEtcdUpdateNotScheduled(t *testing.T) {
...
@@ -634,7 +635,7 @@ func TestEtcdUpdateNotScheduled(t *testing.T) {
}
}
podOut
:=
obj
.
(
*
api
.
Pod
)
podOut
:=
obj
.
(
*
api
.
Pod
)
// validChangedPod only changes the Labels, so were checking the update was valid
// validChangedPod only changes the Labels, so were checking the update was valid
if
!
api
.
Semantic
.
DeepEqual
(
podIn
.
Labels
,
podOut
.
Labels
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
podIn
.
Labels
,
podOut
.
Labels
)
{
t
.
Errorf
(
"objects differ: %v"
,
diff
.
ObjectDiff
(
podOut
,
podIn
))
t
.
Errorf
(
"objects differ: %v"
,
diff
.
ObjectDiff
(
podOut
,
podIn
))
}
}
}
}
...
@@ -705,7 +706,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
...
@@ -705,7 +706,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
}
}
podOut
:=
obj
.
(
*
api
.
Pod
)
podOut
:=
obj
.
(
*
api
.
Pod
)
// Check to verify the Spec and Label updates match from change above. Those are the fields changed.
// 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
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
podOut
.
Spec
,
podIn
.
Spec
)
||
!
apiequality
.
Semantic
.
DeepEqual
(
podOut
.
Labels
,
podIn
.
Labels
)
{
t
.
Errorf
(
"objects differ: %v"
,
diff
.
ObjectDiff
(
podOut
,
podIn
))
t
.
Errorf
(
"objects differ: %v"
,
diff
.
ObjectDiff
(
podOut
,
podIn
))
}
}
...
@@ -788,9 +789,9 @@ func TestEtcdUpdateStatus(t *testing.T) {
...
@@ -788,9 +789,9 @@ func TestEtcdUpdateStatus(t *testing.T) {
}
}
podOut
:=
obj
.
(
*
api
.
Pod
)
podOut
:=
obj
.
(
*
api
.
Pod
)
// Check to verify the Label, and Status updates match from change above. Those are the fields changed.
// Check to verify the Label, and Status updates match from change above. Those are the fields changed.
if
!
api
.
Semantic
.
DeepEqual
(
podOut
.
Spec
,
expected
.
Spec
)
||
if
!
api
equality
.
Semantic
.
DeepEqual
(
podOut
.
Spec
,
expected
.
Spec
)
||
!
api
.
Semantic
.
DeepEqual
(
podOut
.
Labels
,
expected
.
Labels
)
||
!
api
equality
.
Semantic
.
DeepEqual
(
podOut
.
Labels
,
expected
.
Labels
)
||
!
api
.
Semantic
.
DeepEqual
(
podOut
.
Status
,
expected
.
Status
)
{
!
api
equality
.
Semantic
.
DeepEqual
(
podOut
.
Status
,
expected
.
Status
)
{
t
.
Errorf
(
"objects differ: %v"
,
diff
.
ObjectDiff
(
podOut
,
expected
))
t
.
Errorf
(
"objects differ: %v"
,
diff
.
ObjectDiff
(
podOut
,
expected
))
}
}
}
}
pkg/registry/core/replicationcontroller/storage/storage_test.go
View file @
79adb99a
...
@@ -19,6 +19,7 @@ package storage
...
@@ -19,6 +19,7 @@ package storage
import
(
import
(
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
...
@@ -284,7 +285,7 @@ func TestScaleGet(t *testing.T) {
...
@@ -284,7 +285,7 @@ func TestScaleGet(t *testing.T) {
t
.
Fatalf
(
"error fetching scale for %s: %v"
,
name
,
err
)
t
.
Fatalf
(
"error fetching scale for %s: %v"
,
name
,
err
)
}
}
got
:=
obj
.
(
*
autoscaling
.
Scale
)
got
:=
obj
.
(
*
autoscaling
.
Scale
)
if
!
api
.
Semantic
.
DeepEqual
(
want
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
want
,
got
)
{
t
.
Errorf
(
"unexpected scale: %s"
,
diff
.
ObjectDiff
(
want
,
got
))
t
.
Errorf
(
"unexpected scale: %s"
,
diff
.
ObjectDiff
(
want
,
got
))
}
}
}
}
...
...
pkg/registry/core/resourcequota/storage/storage_test.go
View file @
79adb99a
...
@@ -19,6 +19,7 @@ package storage
...
@@ -19,6 +19,7 @@ package storage
import
(
import
(
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
...
@@ -197,7 +198,7 @@ func TestUpdateStatus(t *testing.T) {
...
@@ -197,7 +198,7 @@ func TestUpdateStatus(t *testing.T) {
obj
,
err
:=
storage
.
Get
(
ctx
,
"foo"
,
&
metav1
.
GetOptions
{})
obj
,
err
:=
storage
.
Get
(
ctx
,
"foo"
,
&
metav1
.
GetOptions
{})
rqOut
:=
obj
.
(
*
api
.
ResourceQuota
)
rqOut
:=
obj
.
(
*
api
.
ResourceQuota
)
// only compare the meaningful update b/c we can't compare due to metadata
// only compare the meaningful update b/c we can't compare due to metadata
if
!
api
.
Semantic
.
DeepEqual
(
resourcequotaIn
.
Status
,
rqOut
.
Status
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
resourcequotaIn
.
Status
,
rqOut
.
Status
)
{
t
.
Errorf
(
"unexpected object: %s"
,
diff
.
ObjectDiff
(
resourcequotaIn
,
rqOut
))
t
.
Errorf
(
"unexpected object: %s"
,
diff
.
ObjectDiff
(
resourcequotaIn
,
rqOut
))
}
}
}
}
pkg/registry/extensions/deployment/storage/storage_test.go
View file @
79adb99a
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"reflect"
"reflect"
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
...
@@ -226,7 +227,7 @@ func TestScaleGet(t *testing.T) {
...
@@ -226,7 +227,7 @@ func TestScaleGet(t *testing.T) {
t
.
Fatalf
(
"error fetching scale for %s: %v"
,
name
,
err
)
t
.
Fatalf
(
"error fetching scale for %s: %v"
,
name
,
err
)
}
}
got
:=
obj
.
(
*
extensions
.
Scale
)
got
:=
obj
.
(
*
extensions
.
Scale
)
if
!
api
.
Semantic
.
DeepEqual
(
want
,
got
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
want
,
got
)
{
t
.
Errorf
(
"unexpected scale: %s"
,
diff
.
ObjectDiff
(
want
,
got
))
t
.
Errorf
(
"unexpected scale: %s"
,
diff
.
ObjectDiff
(
want
,
got
))
}
}
}
}
...
...
pkg/registry/extensions/replicaset/storage/storage_test.go
View file @
79adb99a
...
@@ -19,6 +19,7 @@ package storage
...
@@ -19,6 +19,7 @@ package storage
import
(
import
(
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
...
@@ -281,7 +282,7 @@ func TestScaleGet(t *testing.T) {
...
@@ -281,7 +282,7 @@ func TestScaleGet(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"error fetching scale for %s: %v"
,
name
,
err
)
t
.
Fatalf
(
"error fetching scale for %s: %v"
,
name
,
err
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
got
,
want
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
got
,
want
)
{
t
.
Errorf
(
"unexpected scale: %s"
,
diff
.
ObjectDiff
(
got
,
want
))
t
.
Errorf
(
"unexpected scale: %s"
,
diff
.
ObjectDiff
(
got
,
want
))
}
}
}
}
...
...
pkg/storage/cacher_test.go
View file @
79adb99a
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -282,7 +283,7 @@ func verifyWatchEvent(t *testing.T, w watch.Interface, eventType watch.EventType
...
@@ -282,7 +283,7 @@ func verifyWatchEvent(t *testing.T, w watch.Interface, eventType watch.EventType
t
.
Logf
(
"(called from line %d)"
,
line
)
t
.
Logf
(
"(called from line %d)"
,
line
)
t
.
Errorf
(
"Expected: %s, got: %s"
,
eventType
,
event
.
Type
)
t
.
Errorf
(
"Expected: %s, got: %s"
,
eventType
,
event
.
Type
)
}
}
if
e
,
a
:=
eventObject
,
event
.
Object
;
!
api
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
if
e
,
a
:=
eventObject
,
event
.
Object
;
!
api
equality
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
t
.
Logf
(
"(called from line %d)"
,
line
)
t
.
Logf
(
"(called from line %d)"
,
line
)
t
.
Errorf
(
"Expected (%s): %#v, got: %#v"
,
eventType
,
e
,
a
)
t
.
Errorf
(
"Expected (%s): %#v, got: %#v"
,
eventType
,
e
,
a
)
}
}
...
...
pkg/storage/etcd/etcd_watcher_test.go
View file @
79adb99a
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
rt
"runtime"
rt
"runtime"
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/apimachinery/pkg/watch"
...
@@ -139,7 +140,7 @@ func TestWatchInterpretations(t *testing.T) {
...
@@ -139,7 +140,7 @@ func TestWatchInterpretations(t *testing.T) {
if
e
,
a
:=
item
.
expectType
,
event
.
Type
;
e
!=
a
{
if
e
,
a
:=
item
.
expectType
,
event
.
Type
;
e
!=
a
{
t
.
Errorf
(
"'%v - %v': expected %v, got %v"
,
name
,
action
,
e
,
a
)
t
.
Errorf
(
"'%v - %v': expected %v, got %v"
,
name
,
action
,
e
,
a
)
}
}
if
e
,
a
:=
item
.
expectObject
,
event
.
Object
;
!
api
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
if
e
,
a
:=
item
.
expectObject
,
event
.
Object
;
!
api
equality
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
t
.
Errorf
(
"'%v - %v': expected %v, got %v"
,
name
,
action
,
e
,
a
)
t
.
Errorf
(
"'%v - %v': expected %v, got %v"
,
name
,
action
,
e
,
a
)
}
}
}
}
...
@@ -311,7 +312,7 @@ func TestWatch(t *testing.T) {
...
@@ -311,7 +312,7 @@ func TestWatch(t *testing.T) {
if
e
,
a
:=
watch
.
Added
,
event
.
Type
;
e
!=
a
{
if
e
,
a
:=
watch
.
Added
,
event
.
Type
;
e
!=
a
{
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
}
}
if
e
,
a
:=
pod
,
event
.
Object
;
!
api
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
if
e
,
a
:=
pod
,
event
.
Object
;
!
api
equality
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
}
}
...
@@ -391,7 +392,7 @@ func TestWatchEtcdState(t *testing.T) {
...
@@ -391,7 +392,7 @@ func TestWatchEtcdState(t *testing.T) {
t
.
Errorf
(
"Unexpected event %#v"
,
event
)
t
.
Errorf
(
"Unexpected event %#v"
,
event
)
}
}
if
e
,
a
:=
endpoint
,
event
.
Object
;
!
api
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
if
e
,
a
:=
endpoint
,
event
.
Object
;
!
api
equality
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
t
.
Errorf
(
"Unexpected error: expected %#v, got %#v"
,
e
,
a
)
t
.
Errorf
(
"Unexpected error: expected %#v, got %#v"
,
e
,
a
)
}
}
}
}
...
@@ -464,7 +465,7 @@ func TestWatchFromZeroIndex(t *testing.T) {
...
@@ -464,7 +465,7 @@ func TestWatchFromZeroIndex(t *testing.T) {
t
.
Errorf
(
"Unexpected event %#v"
,
event
)
t
.
Errorf
(
"Unexpected event %#v"
,
event
)
}
}
if
e
,
a
:=
pod
,
event
.
Object
;
a
==
nil
||
!
api
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
if
e
,
a
:=
pod
,
event
.
Object
;
a
==
nil
||
!
api
equality
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
t
.
Errorf
(
"Unexpected error: expected %#v, got %#v"
,
e
,
a
)
t
.
Errorf
(
"Unexpected error: expected %#v, got %#v"
,
e
,
a
)
}
}
}
}
...
@@ -494,7 +495,7 @@ func TestWatchListFromZeroIndex(t *testing.T) {
...
@@ -494,7 +495,7 @@ func TestWatchListFromZeroIndex(t *testing.T) {
t
.
Errorf
(
"Unexpected event %#v"
,
event
)
t
.
Errorf
(
"Unexpected event %#v"
,
event
)
}
}
if
e
,
a
:=
pod
,
event
.
Object
;
!
api
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
if
e
,
a
:=
pod
,
event
.
Object
;
!
api
equality
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
t
.
Errorf
(
"Unexpected error: expected %v, got %v"
,
e
,
a
)
t
.
Errorf
(
"Unexpected error: expected %v, got %v"
,
e
,
a
)
}
}
}
}
...
...
pkg/storage/watch_cache_test.go
View file @
79adb99a
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
...
@@ -68,7 +69,7 @@ func TestWatchCacheBasic(t *testing.T) {
...
@@ -68,7 +69,7 @@ func TestWatchCacheBasic(t *testing.T) {
if
item
,
ok
,
_
:=
store
.
Get
(
pod1
);
!
ok
{
if
item
,
ok
,
_
:=
store
.
Get
(
pod1
);
!
ok
{
t
.
Errorf
(
"didn't find pod"
)
t
.
Errorf
(
"didn't find pod"
)
}
else
{
}
else
{
if
!
api
.
Semantic
.
DeepEqual
(
&
storeElement
{
Key
:
"prefix/ns/pod"
,
Object
:
pod1
},
item
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
&
storeElement
{
Key
:
"prefix/ns/pod"
,
Object
:
pod1
},
item
)
{
t
.
Errorf
(
"expected %v, got %v"
,
pod1
,
item
)
t
.
Errorf
(
"expected %v, got %v"
,
pod1
,
item
)
}
}
}
}
...
@@ -79,7 +80,7 @@ func TestWatchCacheBasic(t *testing.T) {
...
@@ -79,7 +80,7 @@ func TestWatchCacheBasic(t *testing.T) {
if
item
,
ok
,
_
:=
store
.
Get
(
pod2
);
!
ok
{
if
item
,
ok
,
_
:=
store
.
Get
(
pod2
);
!
ok
{
t
.
Errorf
(
"didn't find pod"
)
t
.
Errorf
(
"didn't find pod"
)
}
else
{
}
else
{
if
!
api
.
Semantic
.
DeepEqual
(
&
storeElement
{
Key
:
"prefix/ns/pod"
,
Object
:
pod2
},
item
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
&
storeElement
{
Key
:
"prefix/ns/pod"
,
Object
:
pod2
},
item
)
{
t
.
Errorf
(
"expected %v, got %v"
,
pod1
,
item
)
t
.
Errorf
(
"expected %v, got %v"
,
pod1
,
item
)
}
}
}
}
...
@@ -154,7 +155,7 @@ func TestEvents(t *testing.T) {
...
@@ -154,7 +155,7 @@ func TestEvents(t *testing.T) {
t
.
Errorf
(
"unexpected event type: %v"
,
result
[
0
]
.
Type
)
t
.
Errorf
(
"unexpected event type: %v"
,
result
[
0
]
.
Type
)
}
}
pod
:=
makeTestPod
(
"pod"
,
uint64
(
3
))
pod
:=
makeTestPod
(
"pod"
,
uint64
(
3
))
if
!
api
.
Semantic
.
DeepEqual
(
pod
,
result
[
0
]
.
Object
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
pod
,
result
[
0
]
.
Object
)
{
t
.
Errorf
(
"unexpected item: %v, expected: %v"
,
result
[
0
]
.
Object
,
pod
)
t
.
Errorf
(
"unexpected item: %v, expected: %v"
,
result
[
0
]
.
Object
,
pod
)
}
}
if
result
[
0
]
.
PrevObject
!=
nil
{
if
result
[
0
]
.
PrevObject
!=
nil
{
...
@@ -185,11 +186,11 @@ func TestEvents(t *testing.T) {
...
@@ -185,11 +186,11 @@ func TestEvents(t *testing.T) {
t
.
Errorf
(
"unexpected event type: %v"
,
result
[
i
]
.
Type
)
t
.
Errorf
(
"unexpected event type: %v"
,
result
[
i
]
.
Type
)
}
}
pod
:=
makeTestPod
(
"pod"
,
uint64
(
i
+
4
))
pod
:=
makeTestPod
(
"pod"
,
uint64
(
i
+
4
))
if
!
api
.
Semantic
.
DeepEqual
(
pod
,
result
[
i
]
.
Object
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
pod
,
result
[
i
]
.
Object
)
{
t
.
Errorf
(
"unexpected item: %v, expected: %v"
,
result
[
i
]
.
Object
,
pod
)
t
.
Errorf
(
"unexpected item: %v, expected: %v"
,
result
[
i
]
.
Object
,
pod
)
}
}
prevPod
:=
makeTestPod
(
"pod"
,
uint64
(
i
+
3
))
prevPod
:=
makeTestPod
(
"pod"
,
uint64
(
i
+
3
))
if
!
api
.
Semantic
.
DeepEqual
(
prevPod
,
result
[
i
]
.
PrevObject
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
prevPod
,
result
[
i
]
.
PrevObject
)
{
t
.
Errorf
(
"unexpected item: %v, expected: %v"
,
result
[
i
]
.
PrevObject
,
prevPod
)
t
.
Errorf
(
"unexpected item: %v, expected: %v"
,
result
[
i
]
.
PrevObject
,
prevPod
)
}
}
}
}
...
@@ -216,7 +217,7 @@ func TestEvents(t *testing.T) {
...
@@ -216,7 +217,7 @@ func TestEvents(t *testing.T) {
}
}
for
i
:=
0
;
i
<
5
;
i
++
{
for
i
:=
0
;
i
<
5
;
i
++
{
pod
:=
makeTestPod
(
"pod"
,
uint64
(
i
+
5
))
pod
:=
makeTestPod
(
"pod"
,
uint64
(
i
+
5
))
if
!
api
.
Semantic
.
DeepEqual
(
pod
,
result
[
i
]
.
Object
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
pod
,
result
[
i
]
.
Object
)
{
t
.
Errorf
(
"unexpected item: %v, expected: %v"
,
result
[
i
]
.
Object
,
pod
)
t
.
Errorf
(
"unexpected item: %v, expected: %v"
,
result
[
i
]
.
Object
,
pod
)
}
}
}
}
...
@@ -237,11 +238,11 @@ func TestEvents(t *testing.T) {
...
@@ -237,11 +238,11 @@ func TestEvents(t *testing.T) {
t
.
Errorf
(
"unexpected event type: %v"
,
result
[
0
]
.
Type
)
t
.
Errorf
(
"unexpected event type: %v"
,
result
[
0
]
.
Type
)
}
}
pod
:=
makeTestPod
(
"pod"
,
uint64
(
10
))
pod
:=
makeTestPod
(
"pod"
,
uint64
(
10
))
if
!
api
.
Semantic
.
DeepEqual
(
pod
,
result
[
0
]
.
Object
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
pod
,
result
[
0
]
.
Object
)
{
t
.
Errorf
(
"unexpected item: %v, expected: %v"
,
result
[
0
]
.
Object
,
pod
)
t
.
Errorf
(
"unexpected item: %v, expected: %v"
,
result
[
0
]
.
Object
,
pod
)
}
}
prevPod
:=
makeTestPod
(
"pod"
,
uint64
(
9
))
prevPod
:=
makeTestPod
(
"pod"
,
uint64
(
9
))
if
!
api
.
Semantic
.
DeepEqual
(
prevPod
,
result
[
0
]
.
PrevObject
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
prevPod
,
result
[
0
]
.
PrevObject
)
{
t
.
Errorf
(
"unexpected item: %v, expected: %v"
,
result
[
0
]
.
PrevObject
,
prevPod
)
t
.
Errorf
(
"unexpected item: %v, expected: %v"
,
result
[
0
]
.
PrevObject
,
prevPod
)
}
}
}
}
...
@@ -287,7 +288,7 @@ func TestWaitUntilFreshAndGet(t *testing.T) {
...
@@ -287,7 +288,7 @@ func TestWaitUntilFreshAndGet(t *testing.T) {
if
!
exists
{
if
!
exists
{
t
.
Fatalf
(
"no results returned: %#v"
,
obj
)
t
.
Fatalf
(
"no results returned: %#v"
,
obj
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
&
storeElement
{
Key
:
"prefix/ns/bar"
,
Object
:
makeTestPod
(
"bar"
,
5
)},
obj
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
&
storeElement
{
Key
:
"prefix/ns/bar"
,
Object
:
makeTestPod
(
"bar"
,
5
)},
obj
)
{
t
.
Errorf
(
"unexpected element returned: %#v"
,
obj
)
t
.
Errorf
(
"unexpected element returned: %#v"
,
obj
)
}
}
}
}
...
...
pkg/util/io/io_test.go
View file @
79adb99a
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"testing"
"testing"
"github.com/pborman/uuid"
"github.com/pborman/uuid"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
utiltesting
"k8s.io/client-go/util/testing"
utiltesting
"k8s.io/client-go/util/testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
...
@@ -49,7 +50,7 @@ func TestSavePodToFile(t *testing.T) {
...
@@ -49,7 +50,7 @@ func TestSavePodToFile(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"failed to load pod from file: %v"
,
err
)
t
.
Fatalf
(
"failed to load pod from file: %v"
,
err
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
pod
,
podFromFile
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
pod
,
podFromFile
)
{
t
.
Errorf
(
"
\n
expected %#v
\n
got %#v
\n
"
,
pod
,
podFromFile
)
t
.
Errorf
(
"
\n
expected %#v
\n
got %#v
\n
"
,
pod
,
podFromFile
)
}
}
}
}
plugin/pkg/admission/gc/gc_admission.go
View file @
79adb99a
...
@@ -20,11 +20,11 @@ import (
...
@@ -20,11 +20,11 @@ import (
"fmt"
"fmt"
"io"
"io"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/authorization/authorizer"
"k8s.io/apiserver/pkg/authorization/authorizer"
"k8s.io/kubernetes/pkg/api"
)
)
func
init
()
{
func
init
()
{
...
@@ -91,7 +91,7 @@ func isChangingOwnerReference(newObj, oldObj runtime.Object) bool {
...
@@ -91,7 +91,7 @@ func isChangingOwnerReference(newObj, oldObj runtime.Object) bool {
return
true
return
true
}
}
for
i
:=
range
oldOwners
{
for
i
:=
range
oldOwners
{
if
!
api
.
Semantic
.
DeepEqual
(
oldOwners
[
i
],
newOwners
[
i
])
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
oldOwners
[
i
],
newOwners
[
i
])
{
return
true
return
true
}
}
}
}
...
...
plugin/pkg/admission/limitranger/admission_test.go
View file @
79adb99a
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
...
@@ -166,7 +167,7 @@ func TestDefaultContainerResourceRequirements(t *testing.T) {
...
@@ -166,7 +167,7 @@ func TestDefaultContainerResourceRequirements(t *testing.T) {
}
}
actual
:=
defaultContainerResourceRequirements
(
&
limitRange
)
actual
:=
defaultContainerResourceRequirements
(
&
limitRange
)
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
actual
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
actual
)
{
t
.
Errorf
(
"actual.Limits != expected.Limits; %v != %v"
,
actual
.
Limits
,
expected
.
Limits
)
t
.
Errorf
(
"actual.Limits != expected.Limits; %v != %v"
,
actual
.
Limits
,
expected
.
Limits
)
t
.
Errorf
(
"actual.Requests != expected.Requests; %v != %v"
,
actual
.
Requests
,
expected
.
Requests
)
t
.
Errorf
(
"actual.Requests != expected.Requests; %v != %v"
,
actual
.
Requests
,
expected
.
Requests
)
t
.
Errorf
(
"expected != actual; %v != %v"
,
expected
,
actual
)
t
.
Errorf
(
"expected != actual; %v != %v"
,
expected
,
actual
)
...
@@ -199,7 +200,7 @@ func TestMergePodResourceRequirements(t *testing.T) {
...
@@ -199,7 +200,7 @@ func TestMergePodResourceRequirements(t *testing.T) {
mergePodResourceRequirements
(
&
pod
,
&
defaultRequirements
)
mergePodResourceRequirements
(
&
pod
,
&
defaultRequirements
)
for
i
:=
range
pod
.
Spec
.
Containers
{
for
i
:=
range
pod
.
Spec
.
Containers
{
actual
:=
pod
.
Spec
.
Containers
[
i
]
.
Resources
actual
:=
pod
.
Spec
.
Containers
[
i
]
.
Resources
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
actual
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
actual
)
{
t
.
Errorf
(
"pod %v, expected != actual; %v != %v"
,
pod
.
Name
,
expected
,
actual
)
t
.
Errorf
(
"pod %v, expected != actual; %v != %v"
,
pod
.
Name
,
expected
,
actual
)
}
}
}
}
...
@@ -218,13 +219,13 @@ func TestMergePodResourceRequirements(t *testing.T) {
...
@@ -218,13 +219,13 @@ func TestMergePodResourceRequirements(t *testing.T) {
mergePodResourceRequirements
(
&
pod
,
&
defaultRequirements
)
mergePodResourceRequirements
(
&
pod
,
&
defaultRequirements
)
for
i
:=
range
pod
.
Spec
.
Containers
{
for
i
:=
range
pod
.
Spec
.
Containers
{
actual
:=
pod
.
Spec
.
Containers
[
i
]
.
Resources
actual
:=
pod
.
Spec
.
Containers
[
i
]
.
Resources
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
actual
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
actual
)
{
t
.
Errorf
(
"pod %v, expected != actual; %v != %v"
,
pod
.
Name
,
expected
,
actual
)
t
.
Errorf
(
"pod %v, expected != actual; %v != %v"
,
pod
.
Name
,
expected
,
actual
)
}
}
}
}
for
i
:=
range
pod
.
Spec
.
InitContainers
{
for
i
:=
range
pod
.
Spec
.
InitContainers
{
actual
:=
pod
.
Spec
.
InitContainers
[
i
]
.
Resources
actual
:=
pod
.
Spec
.
InitContainers
[
i
]
.
Resources
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
actual
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
actual
)
{
t
.
Errorf
(
"pod %v, expected != actual; %v != %v"
,
pod
.
Name
,
expected
,
actual
)
t
.
Errorf
(
"pod %v, expected != actual; %v != %v"
,
pod
.
Name
,
expected
,
actual
)
}
}
}
}
...
@@ -238,13 +239,13 @@ func TestMergePodResourceRequirements(t *testing.T) {
...
@@ -238,13 +239,13 @@ func TestMergePodResourceRequirements(t *testing.T) {
mergePodResourceRequirements
(
&
pod
,
&
defaultRequirements
)
mergePodResourceRequirements
(
&
pod
,
&
defaultRequirements
)
for
i
:=
range
pod
.
Spec
.
Containers
{
for
i
:=
range
pod
.
Spec
.
Containers
{
actual
:=
pod
.
Spec
.
Containers
[
i
]
.
Resources
actual
:=
pod
.
Spec
.
Containers
[
i
]
.
Resources
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
actual
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
expected
,
actual
)
{
t
.
Errorf
(
"pod %v, expected != actual; %v != %v"
,
pod
.
Name
,
expected
,
actual
)
t
.
Errorf
(
"pod %v, expected != actual; %v != %v"
,
pod
.
Name
,
expected
,
actual
)
}
}
}
}
for
i
:=
range
pod
.
Spec
.
InitContainers
{
for
i
:=
range
pod
.
Spec
.
InitContainers
{
actual
:=
pod
.
Spec
.
InitContainers
[
i
]
.
Resources
actual
:=
pod
.
Spec
.
InitContainers
[
i
]
.
Resources
if
!
api
.
Semantic
.
DeepEqual
(
initInputs
[
i
],
actual
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
initInputs
[
i
],
actual
)
{
t
.
Errorf
(
"pod %v, expected != actual; %v != %v"
,
pod
.
Name
,
initInputs
[
i
],
actual
)
t
.
Errorf
(
"pod %v, expected != actual; %v != %v"
,
pod
.
Name
,
initInputs
[
i
],
actual
)
}
}
}
}
...
...
staging/src/k8s.io/apimachinery/pkg/api/equality/semantic.go
0 → 100644
View file @
79adb99a
/*
Copyright 2014 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
equality
import
(
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
)
// Semantic can do semantic deep equality checks for api objects.
// Example: apiequality.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true
var
Semantic
=
conversion
.
EqualitiesOrDie
(
func
(
a
,
b
resource
.
Quantity
)
bool
{
// Ignore formatting, only care that numeric value stayed the same.
// TODO: if we decide it's important, it should be safe to start comparing the format.
//
// Uninitialized quantities are equivalent to 0 quantities.
return
a
.
Cmp
(
b
)
==
0
},
func
(
a
,
b
metav1
.
Time
)
bool
{
return
a
.
UTC
()
==
b
.
UTC
()
},
func
(
a
,
b
labels
.
Selector
)
bool
{
return
a
.
String
()
==
b
.
String
()
},
func
(
a
,
b
fields
.
Selector
)
bool
{
return
a
.
String
()
==
b
.
String
()
},
)
staging/src/k8s.io/client-go/pkg/api/helpers.go
View file @
79adb99a
...
@@ -67,7 +67,7 @@ func NonConvertibleFields(annotations map[string]string) map[string]string {
...
@@ -67,7 +67,7 @@ func NonConvertibleFields(annotations map[string]string) map[string]string {
}
}
// Semantic can do semantic deep equality checks for api objects.
// Semantic can do semantic deep equality checks for api objects.
// Example: api.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true
// Example: api
equality
.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true
var
Semantic
=
conversion
.
EqualitiesOrDie
(
var
Semantic
=
conversion
.
EqualitiesOrDie
(
func
(
a
,
b
resource
.
Quantity
)
bool
{
func
(
a
,
b
resource
.
Quantity
)
bool
{
// Ignore formatting, only care that numeric value stayed the same.
// Ignore formatting, only care that numeric value stayed the same.
...
...
staging/src/k8s.io/client-go/rest/request_test.go
View file @
79adb99a
...
@@ -50,6 +50,7 @@ import (
...
@@ -50,6 +50,7 @@ import (
"k8s.io/client-go/util/clock"
"k8s.io/client-go/util/clock"
"k8s.io/client-go/util/flowcontrol"
"k8s.io/client-go/util/flowcontrol"
utiltesting
"k8s.io/client-go/util/testing"
utiltesting
"k8s.io/client-go/util/testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
_
"k8s.io/client-go/pkg/api/install"
_
"k8s.io/client-go/pkg/api/install"
)
)
...
@@ -415,7 +416,7 @@ func TestTransformResponse(t *testing.T) {
...
@@ -415,7 +416,7 @@ func TestTransformResponse(t *testing.T) {
if
test
.
ErrFn
!=
nil
&&
!
test
.
ErrFn
(
err
)
{
if
test
.
ErrFn
!=
nil
&&
!
test
.
ErrFn
(
err
)
{
t
.
Errorf
(
"%d: error function did not match: %v"
,
i
,
err
)
t
.
Errorf
(
"%d: error function did not match: %v"
,
i
,
err
)
}
}
if
!
(
test
.
Data
==
nil
&&
response
==
nil
)
&&
!
api
.
Semantic
.
DeepDerivative
(
test
.
Data
,
response
)
{
if
!
(
test
.
Data
==
nil
&&
response
==
nil
)
&&
!
api
equality
.
Semantic
.
DeepDerivative
(
test
.
Data
,
response
)
{
t
.
Errorf
(
"%d: unexpected response: %#v %#v"
,
i
,
test
.
Data
,
response
)
t
.
Errorf
(
"%d: unexpected response: %#v %#v"
,
i
,
test
.
Data
,
response
)
}
}
if
test
.
Created
!=
created
{
if
test
.
Created
!=
created
{
...
@@ -1043,7 +1044,7 @@ func TestDoRequestNewWay(t *testing.T) {
...
@@ -1043,7 +1044,7 @@ func TestDoRequestNewWay(t *testing.T) {
}
}
if
obj
==
nil
{
if
obj
==
nil
{
t
.
Error
(
"nil obj"
)
t
.
Error
(
"nil obj"
)
}
else
if
!
api
.
Semantic
.
DeepDerivative
(
expectedObj
,
obj
)
{
}
else
if
!
api
equality
.
Semantic
.
DeepDerivative
(
expectedObj
,
obj
)
{
t
.
Errorf
(
"Expected: %#v, got %#v"
,
expectedObj
,
obj
)
t
.
Errorf
(
"Expected: %#v, got %#v"
,
expectedObj
,
obj
)
}
}
requestURL
:=
defaultResourcePathWithPrefix
(
"foo/bar"
,
""
,
""
,
"baz"
)
requestURL
:=
defaultResourcePathWithPrefix
(
"foo/bar"
,
""
,
""
,
"baz"
)
...
@@ -1276,7 +1277,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
...
@@ -1276,7 +1277,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
}
}
if
obj
==
nil
{
if
obj
==
nil
{
t
.
Error
(
"nil obj"
)
t
.
Error
(
"nil obj"
)
}
else
if
!
api
.
Semantic
.
DeepDerivative
(
expectedObj
,
obj
)
{
}
else
if
!
api
equality
.
Semantic
.
DeepDerivative
(
expectedObj
,
obj
)
{
t
.
Errorf
(
"Expected: %#v, got %#v"
,
expectedObj
,
obj
)
t
.
Errorf
(
"Expected: %#v, got %#v"
,
expectedObj
,
obj
)
}
}
tmpStr
:=
string
(
reqBodyExpected
)
tmpStr
:=
string
(
reqBodyExpected
)
...
@@ -1316,7 +1317,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
...
@@ -1316,7 +1317,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
}
}
if
obj
==
nil
{
if
obj
==
nil
{
t
.
Error
(
"nil obj"
)
t
.
Error
(
"nil obj"
)
}
else
if
!
api
.
Semantic
.
DeepDerivative
(
expectedObj
,
obj
)
{
}
else
if
!
api
equality
.
Semantic
.
DeepDerivative
(
expectedObj
,
obj
)
{
t
.
Errorf
(
"Expected: %#v, got %#v"
,
expectedObj
,
obj
)
t
.
Errorf
(
"Expected: %#v, got %#v"
,
expectedObj
,
obj
)
}
}
tmpStr
:=
string
(
reqBodyExpected
)
tmpStr
:=
string
(
reqBodyExpected
)
...
@@ -1370,7 +1371,7 @@ func TestDoRequestNewWayFile(t *testing.T) {
...
@@ -1370,7 +1371,7 @@ func TestDoRequestNewWayFile(t *testing.T) {
}
}
if
obj
==
nil
{
if
obj
==
nil
{
t
.
Error
(
"nil obj"
)
t
.
Error
(
"nil obj"
)
}
else
if
!
api
.
Semantic
.
DeepDerivative
(
expectedObj
,
obj
)
{
}
else
if
!
api
equality
.
Semantic
.
DeepDerivative
(
expectedObj
,
obj
)
{
t
.
Errorf
(
"Expected: %#v, got %#v"
,
expectedObj
,
obj
)
t
.
Errorf
(
"Expected: %#v, got %#v"
,
expectedObj
,
obj
)
}
}
if
wasCreated
{
if
wasCreated
{
...
@@ -1415,7 +1416,7 @@ func TestWasCreated(t *testing.T) {
...
@@ -1415,7 +1416,7 @@ func TestWasCreated(t *testing.T) {
}
}
if
obj
==
nil
{
if
obj
==
nil
{
t
.
Error
(
"nil obj"
)
t
.
Error
(
"nil obj"
)
}
else
if
!
api
.
Semantic
.
DeepDerivative
(
expectedObj
,
obj
)
{
}
else
if
!
api
equality
.
Semantic
.
DeepDerivative
(
expectedObj
,
obj
)
{
t
.
Errorf
(
"Expected: %#v, got %#v"
,
expectedObj
,
obj
)
t
.
Errorf
(
"Expected: %#v, got %#v"
,
expectedObj
,
obj
)
}
}
if
!
wasCreated
{
if
!
wasCreated
{
...
@@ -1623,7 +1624,7 @@ func TestWatch(t *testing.T) {
...
@@ -1623,7 +1624,7 @@ func TestWatch(t *testing.T) {
if
e
,
a
:=
item
.
t
,
got
.
Type
;
e
!=
a
{
if
e
,
a
:=
item
.
t
,
got
.
Type
;
e
!=
a
{
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
}
}
if
e
,
a
:=
item
.
obj
,
got
.
Object
;
!
api
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
if
e
,
a
:=
item
.
obj
,
got
.
Object
;
!
api
equality
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
}
}
}
}
...
...
staging/src/k8s.io/client-go/rest/watch/decoder_test.go
View file @
79adb99a
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/api/v1"
restclientwatch
"k8s.io/client-go/rest/watch"
restclientwatch
"k8s.io/client-go/rest/watch"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
_
"k8s.io/client-go/pkg/api/install"
_
"k8s.io/client-go/pkg/api/install"
)
)
...
@@ -68,7 +69,7 @@ func TestDecoder(t *testing.T) {
...
@@ -68,7 +69,7 @@ func TestDecoder(t *testing.T) {
if
e
,
a
:=
eventType
,
action
;
e
!=
a
{
if
e
,
a
:=
eventType
,
action
;
e
!=
a
{
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
}
}
if
e
,
a
:=
expect
,
got
;
!
api
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
if
e
,
a
:=
expect
,
got
;
!
api
equality
.
Semantic
.
DeepDerivative
(
e
,
a
)
{
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
}
}
t
.
Logf
(
"Exited read"
)
t
.
Logf
(
"Exited read"
)
...
...
staging/src/k8s.io/client-go/rest/watch/encoder_test.go
View file @
79adb99a
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"io/ioutil"
"io/ioutil"
"testing"
"testing"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
...
@@ -71,7 +72,7 @@ func TestEncodeDecodeRoundTrip(t *testing.T) {
...
@@ -71,7 +72,7 @@ func TestEncodeDecodeRoundTrip(t *testing.T) {
t
.
Errorf
(
"%d: unexpected error: %v"
,
i
,
err
)
t
.
Errorf
(
"%d: unexpected error: %v"
,
i
,
err
)
continue
continue
}
}
if
!
api
.
Semantic
.
DeepDerivative
(
testCase
.
Object
,
obj
)
{
if
!
api
equality
.
Semantic
.
DeepDerivative
(
testCase
.
Object
,
obj
)
{
t
.
Errorf
(
"%d: expected %#v, got %#v"
,
i
,
testCase
.
Object
,
obj
)
t
.
Errorf
(
"%d: expected %#v, got %#v"
,
i
,
testCase
.
Object
,
obj
)
}
}
if
event
!=
testCase
.
Type
{
if
event
!=
testCase
.
Type
{
...
...
test/integration/serviceaccount/service_account_test.go
View file @
79adb99a
...
@@ -31,6 +31,7 @@ import (
...
@@ -31,6 +31,7 @@ import (
"testing"
"testing"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
...
@@ -259,13 +260,13 @@ func TestServiceAccountTokenAutoMount(t *testing.T) {
...
@@ -259,13 +260,13 @@ func TestServiceAccountTokenAutoMount(t *testing.T) {
if
createdPod
.
Spec
.
ServiceAccountName
!=
expectedServiceAccount
{
if
createdPod
.
Spec
.
ServiceAccountName
!=
expectedServiceAccount
{
t
.
Fatalf
(
"Expected %s, got %s"
,
expectedServiceAccount
,
createdPod
.
Spec
.
ServiceAccountName
)
t
.
Fatalf
(
"Expected %s, got %s"
,
expectedServiceAccount
,
createdPod
.
Spec
.
ServiceAccountName
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
&
expectedVolumes
,
&
createdPod
.
Spec
.
Volumes
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
&
expectedVolumes
,
&
createdPod
.
Spec
.
Volumes
)
{
t
.
Fatalf
(
"Expected
\n\t
%#v
\n\t
got
\n\t
%#v"
,
expectedVolumes
,
createdPod
.
Spec
.
Volumes
)
t
.
Fatalf
(
"Expected
\n\t
%#v
\n\t
got
\n\t
%#v"
,
expectedVolumes
,
createdPod
.
Spec
.
Volumes
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
&
expectedContainer1VolumeMounts
,
&
createdPod
.
Spec
.
Containers
[
0
]
.
VolumeMounts
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
&
expectedContainer1VolumeMounts
,
&
createdPod
.
Spec
.
Containers
[
0
]
.
VolumeMounts
)
{
t
.
Fatalf
(
"Expected
\n\t
%#v
\n\t
got
\n\t
%#v"
,
expectedContainer1VolumeMounts
,
createdPod
.
Spec
.
Containers
[
0
]
.
VolumeMounts
)
t
.
Fatalf
(
"Expected
\n\t
%#v
\n\t
got
\n\t
%#v"
,
expectedContainer1VolumeMounts
,
createdPod
.
Spec
.
Containers
[
0
]
.
VolumeMounts
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
&
expectedContainer2VolumeMounts
,
&
createdPod
.
Spec
.
Containers
[
1
]
.
VolumeMounts
)
{
if
!
api
equality
.
Semantic
.
DeepEqual
(
&
expectedContainer2VolumeMounts
,
&
createdPod
.
Spec
.
Containers
[
1
]
.
VolumeMounts
)
{
t
.
Fatalf
(
"Expected
\n\t
%#v
\n\t
got
\n\t
%#v"
,
expectedContainer2VolumeMounts
,
createdPod
.
Spec
.
Containers
[
1
]
.
VolumeMounts
)
t
.
Fatalf
(
"Expected
\n\t
%#v
\n\t
got
\n\t
%#v"
,
expectedContainer2VolumeMounts
,
createdPod
.
Spec
.
Containers
[
1
]
.
VolumeMounts
)
}
}
}
}
...
...
test/utils/runners.go
View file @
79adb99a
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"sync"
"sync"
"time"
"time"
apiequality
"k8s.io/apimachinery/pkg/api/equality"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
@@ -845,7 +846,7 @@ func DoCleanupNode(client clientset.Interface, nodeName string, strategy Prepare
...
@@ -845,7 +846,7 @@ func DoCleanupNode(client clientset.Interface, nodeName string, strategy Prepare
return
fmt
.
Errorf
(
"Skipping cleanup of Node: failed to get Node %v: %v"
,
nodeName
,
err
)
return
fmt
.
Errorf
(
"Skipping cleanup of Node: failed to get Node %v: %v"
,
nodeName
,
err
)
}
}
updatedNode
:=
strategy
.
CleanupNode
(
node
)
updatedNode
:=
strategy
.
CleanupNode
(
node
)
if
api
.
Semantic
.
DeepEqual
(
node
,
updatedNode
)
{
if
api
equality
.
Semantic
.
DeepEqual
(
node
,
updatedNode
)
{
return
nil
return
nil
}
}
if
_
,
err
=
client
.
Core
()
.
Nodes
()
.
Update
(
updatedNode
);
err
==
nil
{
if
_
,
err
=
client
.
Core
()
.
Nodes
()
.
Update
(
updatedNode
);
err
==
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment