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
b50367cb
Commit
b50367cb
authored
Nov 19, 2016
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove v1.Semantics
parent
aad6831a
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
68 additions
and
143 deletions
+68
-143
helpers.go
pkg/api/v1/helpers.go
+0
-24
helpers_test.go
pkg/api/v1/helpers_test.go
+2
-64
controller_utils_test.go
pkg/controller/controller_utils_test.go
+2
-1
deployment_controller.go
pkg/controller/deployment/deployment_controller.go
+2
-1
deployment_util.go
pkg/controller/deployment/util/deployment_util.go
+1
-1
deployment_util_test.go
pkg/controller/deployment/util/deployment_util_test.go
+1
-1
jobcontroller_test.go
pkg/controller/job/jobcontroller_test.go
+3
-2
nodecontroller.go
pkg/controller/node/nodecontroller.go
+1
-1
nodecontroller_test.go
pkg/controller/node/nodecontroller_test.go
+3
-2
replica_set_test.go
pkg/controller/replicaset/replica_set_test.go
+3
-2
replication_controller_test.go
pkg/controller/replication/replication_controller_test.go
+4
-3
resource_quota_controller.go
pkg/controller/resourcequota/resource_quota_controller.go
+2
-2
apiserver_test.go
pkg/kubelet/config/apiserver_test.go
+7
-6
config_test.go
pkg/kubelet/config/config_test.go
+2
-1
file_linux_test.go
pkg/kubelet/config/file_linux_test.go
+11
-11
http_test.go
pkg/kubelet/config/http_test.go
+8
-8
docker_manager_test.go
pkg/kubelet/dockertools/docker_manager_test.go
+4
-4
kubelet_node_status_test.go
pkg/kubelet/kubelet_node_status_test.go
+4
-3
kubelet_resources_test.go
pkg/kubelet/kubelet_resources_test.go
+2
-1
status_manager.go
pkg/kubelet/status/status_manager.go
+1
-1
service_account_test.go
test/integration/serviceaccount/service_account_test.go
+4
-3
runners.go
test/utils/runners.go
+1
-1
No files found.
pkg/api/v1/helpers.go
View file @
b50367cb
...
...
@@ -22,9 +22,6 @@ import (
"strings"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/conversion"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/selection"
...
...
@@ -32,27 +29,6 @@ import (
"k8s.io/kubernetes/pkg/util/sets"
)
// Semantic can do semantic deep equality checks for api objects.
// Example: api.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
unversioned
.
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
()
},
)
// IsOpaqueIntResourceName returns true if the resource name has the opaque
// integer resource prefix.
func
IsOpaqueIntResourceName
(
name
ResourceName
)
bool
{
...
...
pkg/api/v1/helpers_test.go
View file @
b50367cb
...
...
@@ -18,74 +18,12 @@ package v1
import
(
"reflect"
"strings"
"testing"
"k8s.io/kubernetes/pkg/api
/resource
"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/labels"
)
func
TestConversionError
(
t
*
testing
.
T
)
{
var
i
int
var
s
string
i
=
3
s
=
"foo"
c
:=
ConversionError
{
In
:
&
i
,
Out
:
&
s
,
Message
:
"Can't make x into y, silly"
,
}
var
e
error
e
=
&
c
// ensure it implements error
msg
:=
e
.
Error
()
t
.
Logf
(
"Message is %v"
,
msg
)
for
_
,
part
:=
range
[]
string
{
"3"
,
"int"
,
"string"
,
"Can't"
}
{
if
!
strings
.
Contains
(
msg
,
part
)
{
t
.
Errorf
(
"didn't find %v"
,
part
)
}
}
}
func
TestSemantic
(
t
*
testing
.
T
)
{
table
:=
[]
struct
{
a
,
b
interface
{}
shouldEqual
bool
}{
{
resource
.
MustParse
(
"0"
),
resource
.
Quantity
{},
true
},
{
resource
.
Quantity
{},
resource
.
MustParse
(
"0"
),
true
},
{
resource
.
Quantity
{},
resource
.
MustParse
(
"1m"
),
false
},
{
resource
.
NewQuantity
(
5
,
resource
.
BinarySI
),
resource
.
NewQuantity
(
5
,
resource
.
DecimalSI
),
true
,
},
{
resource
.
MustParse
(
"2m"
),
resource
.
MustParse
(
"1m"
),
false
},
}
for
index
,
item
:=
range
table
{
if
e
,
a
:=
item
.
shouldEqual
,
Semantic
.
DeepEqual
(
item
.
a
,
item
.
b
);
e
!=
a
{
t
.
Errorf
(
"case[%d], expected %v, got %v."
,
index
,
e
,
a
)
}
}
}
func
TestIsStandardResource
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
input
string
output
bool
}{
{
"cpu"
,
true
},
{
"memory"
,
true
},
{
"disk"
,
false
},
{
"blah"
,
false
},
{
"x.y.z"
,
false
},
}
for
i
,
tc
:=
range
testCases
{
if
IsStandardResourceName
(
tc
.
input
)
!=
tc
.
output
{
t
.
Errorf
(
"case[%d], expected: %t, got: %t"
,
i
,
tc
.
output
,
!
tc
.
output
)
}
}
}
func
TestAddToNodeAddresses
(
t
*
testing
.
T
)
{
testCases
:=
[]
struct
{
existing
[]
NodeAddress
...
...
@@ -137,7 +75,7 @@ func TestAddToNodeAddresses(t *testing.T) {
for
i
,
tc
:=
range
testCases
{
AddToNodeAddresses
(
&
tc
.
existing
,
tc
.
toAdd
...
)
if
!
Semantic
.
DeepEqual
(
tc
.
expected
,
tc
.
existing
)
{
if
!
api
.
Semantic
.
DeepEqual
(
tc
.
expected
,
tc
.
existing
)
{
t
.
Errorf
(
"case[%d], expected: %v, got: %v"
,
i
,
tc
.
expected
,
tc
.
existing
)
}
}
...
...
pkg/controller/controller_utils_test.go
View file @
b50367cb
...
...
@@ -27,6 +27,7 @@ import (
"testing"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
...
...
@@ -273,7 +274,7 @@ func TestCreatePods(t *testing.T) {
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
if
!
v1
.
Semantic
.
DeepDerivative
(
&
expectedPod
,
actualPod
)
{
if
!
api
.
Semantic
.
DeepDerivative
(
&
expectedPod
,
actualPod
)
{
t
.
Logf
(
"Body: %s"
,
fakeHandler
.
RequestBody
)
t
.
Errorf
(
"Unexpected mismatch. Expected
\n
%#v,
\n
Got:
\n
%#v"
,
&
expectedPod
,
actualPod
)
}
...
...
pkg/controller/deployment/deployment_controller.go
View file @
b50367cb
...
...
@@ -27,6 +27,7 @@ import (
"time"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
extensions
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
...
...
@@ -220,7 +221,7 @@ func (dc *DeploymentController) updateReplicaSet(old, cur interface{}) {
}
// A number of things could affect the old deployment: labels changing,
// pod template changing, etc.
if
!
v1
.
Semantic
.
DeepEqual
(
oldRS
,
curRS
)
{
if
!
api
.
Semantic
.
DeepEqual
(
oldRS
,
curRS
)
{
if
oldD
:=
dc
.
getDeploymentForReplicaSet
(
oldRS
);
oldD
!=
nil
{
dc
.
enqueueDeployment
(
oldD
)
}
...
...
pkg/controller/deployment/util/deployment_util.go
View file @
b50367cb
...
...
@@ -611,7 +611,7 @@ func equalIgnoreHash(template1, template2 v1.PodTemplateSpec) (bool, error) {
// Then, compare the templates without comparing their labels
template1
.
Labels
,
template2
.
Labels
=
nil
,
nil
result
:=
v1
.
Semantic
.
DeepEqual
(
template1
,
template2
)
result
:=
api
.
Semantic
.
DeepEqual
(
template1
,
template2
)
return
result
,
nil
}
...
...
pkg/controller/deployment/util/deployment_util_test.go
View file @
b50367cb
...
...
@@ -255,7 +255,7 @@ func TestGetNewRC(t *testing.T) {
if
err
!=
nil
{
t
.
Errorf
(
"In test case %s, got unexpected error %v"
,
test
.
test
,
err
)
}
if
!
v1
.
Semantic
.
DeepEqual
(
rs
,
test
.
expected
)
{
if
!
api
.
Semantic
.
DeepEqual
(
rs
,
test
.
expected
)
{
t
.
Errorf
(
"In test case %s, expected %#v, got %#v"
,
test
.
test
,
test
.
expected
,
rs
)
}
}
...
...
pkg/controller/job/jobcontroller_test.go
View file @
b50367cb
...
...
@@ -21,6 +21,7 @@ import (
"testing"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apimachinery/registered"
...
...
@@ -656,7 +657,7 @@ func TestWatchJobs(t *testing.T) {
t
.
Errorf
(
"Expected to find job under key %v: %v"
,
key
,
err
)
return
nil
}
if
!
v1
.
Semantic
.
DeepDerivative
(
*
job
,
testJob
)
{
if
!
api
.
Semantic
.
DeepDerivative
(
*
job
,
testJob
)
{
t
.
Errorf
(
"Expected %#v, but got %#v"
,
testJob
,
*
job
)
}
return
nil
...
...
@@ -699,7 +700,7 @@ func TestWatchPods(t *testing.T) {
if
err
!=
nil
{
t
.
Errorf
(
"Expected to find job under key %v: %v"
,
key
,
err
)
}
if
!
v1
.
Semantic
.
DeepDerivative
(
job
,
testJob
)
{
if
!
api
.
Semantic
.
DeepDerivative
(
job
,
testJob
)
{
t
.
Errorf
(
"
\n
Expected %#v,
\n
but got %#v"
,
testJob
,
job
)
close
(
received
)
return
nil
...
...
pkg/controller/node/nodecontroller.go
View file @
b50367cb
...
...
@@ -773,7 +773,7 @@ func (nc *NodeController) tryUpdateNodeStatus(node *v1.Node) (time.Duration, v1.
}
_
,
currentCondition
:=
v1
.
GetNodeCondition
(
&
node
.
Status
,
v1
.
NodeReady
)
if
!
v1
.
Semantic
.
DeepEqual
(
currentCondition
,
&
observedReadyCondition
)
{
if
!
api
.
Semantic
.
DeepEqual
(
currentCondition
,
&
observedReadyCondition
)
{
if
_
,
err
=
nc
.
kubeClient
.
Core
()
.
Nodes
()
.
UpdateStatus
(
node
);
err
!=
nil
{
glog
.
Errorf
(
"Error updating node %s: %v"
,
node
.
Name
,
err
)
return
gracePeriod
,
observedReadyCondition
,
currentReadyCondition
,
err
...
...
pkg/controller/node/nodecontroller_test.go
View file @
b50367cb
...
...
@@ -22,6 +22,7 @@ import (
"testing"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
...
...
@@ -1483,10 +1484,10 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
if
item
.
expectedRequestCount
!=
item
.
fakeNodeHandler
.
RequestCount
{
t
.
Errorf
(
"expected %v call, but got %v."
,
item
.
expectedRequestCount
,
item
.
fakeNodeHandler
.
RequestCount
)
}
if
len
(
item
.
fakeNodeHandler
.
UpdatedNodes
)
>
0
&&
!
v1
.
Semantic
.
DeepEqual
(
item
.
expectedNodes
,
item
.
fakeNodeHandler
.
UpdatedNodes
)
{
if
len
(
item
.
fakeNodeHandler
.
UpdatedNodes
)
>
0
&&
!
api
.
Semantic
.
DeepEqual
(
item
.
expectedNodes
,
item
.
fakeNodeHandler
.
UpdatedNodes
)
{
t
.
Errorf
(
"Case[%d] unexpected nodes: %s"
,
i
,
diff
.
ObjectDiff
(
item
.
expectedNodes
[
0
],
item
.
fakeNodeHandler
.
UpdatedNodes
[
0
]))
}
if
len
(
item
.
fakeNodeHandler
.
UpdatedNodeStatuses
)
>
0
&&
!
v1
.
Semantic
.
DeepEqual
(
item
.
expectedNodes
,
item
.
fakeNodeHandler
.
UpdatedNodeStatuses
)
{
if
len
(
item
.
fakeNodeHandler
.
UpdatedNodeStatuses
)
>
0
&&
!
api
.
Semantic
.
DeepEqual
(
item
.
expectedNodes
,
item
.
fakeNodeHandler
.
UpdatedNodeStatuses
)
{
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 @
b50367cb
...
...
@@ -28,6 +28,7 @@ import (
"testing"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
...
...
@@ -540,7 +541,7 @@ func TestWatchControllers(t *testing.T) {
t
.
Errorf
(
"Expected to find replica set under key %v"
,
key
)
}
rsSpec
:=
*
obj
.
(
*
extensions
.
ReplicaSet
)
if
!
v1
.
Semantic
.
DeepDerivative
(
rsSpec
,
testRSSpec
)
{
if
!
api
.
Semantic
.
DeepDerivative
(
rsSpec
,
testRSSpec
)
{
t
.
Errorf
(
"Expected %#v, but got %#v"
,
testRSSpec
,
rsSpec
)
}
close
(
received
)
...
...
@@ -582,7 +583,7 @@ func TestWatchPods(t *testing.T) {
t
.
Errorf
(
"Expected to find replica set under key %v"
,
key
)
}
rsSpec
:=
obj
.
(
*
extensions
.
ReplicaSet
)
if
!
v1
.
Semantic
.
DeepDerivative
(
rsSpec
,
testRSSpec
)
{
if
!
api
.
Semantic
.
DeepDerivative
(
rsSpec
,
testRSSpec
)
{
t
.
Errorf
(
"
\n
Expected %#v,
\n
but got %#v"
,
testRSSpec
,
rsSpec
)
}
close
(
received
)
...
...
pkg/controller/replication/replication_controller_test.go
View file @
b50367cb
...
...
@@ -27,6 +27,7 @@ import (
"testing"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
...
...
@@ -465,7 +466,7 @@ func TestWatchControllers(t *testing.T) {
t
.
Errorf
(
"Expected to find controller under key %v"
,
key
)
}
controllerSpec
:=
*
obj
.
(
*
v1
.
ReplicationController
)
if
!
v1
.
Semantic
.
DeepDerivative
(
controllerSpec
,
testControllerSpec
)
{
if
!
api
.
Semantic
.
DeepDerivative
(
controllerSpec
,
testControllerSpec
)
{
t
.
Errorf
(
"Expected %#v, but got %#v"
,
testControllerSpec
,
controllerSpec
)
}
close
(
received
)
...
...
@@ -508,7 +509,7 @@ func TestWatchPods(t *testing.T) {
t
.
Errorf
(
"Expected to find controller under key %v"
,
key
)
}
controllerSpec
:=
obj
.
(
*
v1
.
ReplicationController
)
if
!
v1
.
Semantic
.
DeepDerivative
(
controllerSpec
,
testControllerSpec
)
{
if
!
api
.
Semantic
.
DeepDerivative
(
controllerSpec
,
testControllerSpec
)
{
t
.
Errorf
(
"
\n
Expected %#v,
\n
but got %#v"
,
testControllerSpec
,
controllerSpec
)
}
close
(
received
)
...
...
@@ -702,7 +703,7 @@ func doTestControllerBurstReplicas(t *testing.T, burstReplicas, numReplicas int)
// Size up the controller, then size it down, and confirm the expected create/delete pattern
for
_
,
replicas
:=
range
[]
int
{
numReplicas
,
0
}
{
*
(
controllerSpec
.
Spec
.
Replicas
)
=
int32
(
replicas
)
*
(
controllerSpec
.
Spec
.
Replicas
)
=
int32
(
replicas
)
manager
.
rcStore
.
Indexer
.
Add
(
controllerSpec
)
for
i
:=
0
;
i
<
numReplicas
;
i
+=
burstReplicas
{
...
...
pkg/controller/resourcequota/resource_quota_controller.go
View file @
b50367cb
...
...
@@ -173,7 +173,7 @@ func (rq *ResourceQuotaController) addQuota(obj interface{}) {
resourceQuota
:=
obj
.
(
*
v1
.
ResourceQuota
)
// if we declared an intent that is not yet captured in status (prioritize it)
if
!
v1
.
Semantic
.
DeepEqual
(
resourceQuota
.
Spec
.
Hard
,
resourceQuota
.
Status
.
Hard
)
{
if
!
api
.
Semantic
.
DeepEqual
(
resourceQuota
.
Spec
.
Hard
,
resourceQuota
.
Status
.
Hard
)
{
rq
.
missingUsageQueue
.
Add
(
key
)
return
}
...
...
@@ -268,7 +268,7 @@ func (rq *ResourceQuotaController) syncResourceQuotaFromKey(key string) (err err
// syncResourceQuota runs a complete sync of resource quota status across all known kinds
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
dirty
:=
!
v1
.
Semantic
.
DeepEqual
(
v1ResourceQuota
.
Spec
.
Hard
,
v1ResourceQuota
.
Status
.
Hard
)
dirty
:=
!
api
.
Semantic
.
DeepEqual
(
v1ResourceQuota
.
Spec
.
Hard
,
v1ResourceQuota
.
Status
.
Hard
)
resourceQuota
:=
api
.
ResourceQuota
{}
if
err
:=
v1
.
Convert_v1_ResourceQuota_To_api_ResourceQuota
(
&
v1ResourceQuota
,
&
resourceQuota
,
nil
);
err
!=
nil
{
...
...
pkg/kubelet/config/apiserver_test.go
View file @
b50367cb
...
...
@@ -19,6 +19,7 @@ package config
import
(
"testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/cache"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
...
...
@@ -69,7 +70,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
}
update
:=
got
.
(
kubetypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod1v1
)
if
!
v1
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
update
)
}
...
...
@@ -84,7 +85,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
expectedA
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod1v1
,
pod2
)
expectedB
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod2
,
pod1v1
)
if
!
v1
.
Semantic
.
DeepEqual
(
expectedA
,
update
)
&&
!
v1
.
Semantic
.
DeepEqual
(
expectedB
,
update
)
{
if
!
api
.
Semantic
.
DeepEqual
(
expectedA
,
update
)
&&
!
api
.
Semantic
.
DeepEqual
(
expectedB
,
update
)
{
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
update
)
}
...
...
@@ -98,7 +99,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
expectedA
=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod1v2
,
pod2
)
expectedB
=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod2
,
pod1v2
)
if
!
v1
.
Semantic
.
DeepEqual
(
expectedA
,
update
)
&&
!
v1
.
Semantic
.
DeepEqual
(
expectedB
,
update
)
{
if
!
api
.
Semantic
.
DeepEqual
(
expectedA
,
update
)
&&
!
api
.
Semantic
.
DeepEqual
(
expectedB
,
update
)
{
t
.
Errorf
(
"Expected %#v or %#v, Got %#v"
,
expectedA
,
expectedB
,
update
)
}
...
...
@@ -110,7 +111,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
}
update
=
got
.
(
kubetypes
.
PodUpdate
)
expected
=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
,
pod2
)
if
!
v1
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
update
)
}
...
...
@@ -122,7 +123,7 @@ func TestNewSourceApiserver_UpdatesAndMultiplePods(t *testing.T) {
}
update
=
got
.
(
kubetypes
.
PodUpdate
)
expected
=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
)
if
!
v1
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v, Got %#v"
,
expected
,
update
)
}
}
...
...
@@ -186,7 +187,7 @@ func TestNewSourceApiserverInitialEmptySendsEmptyPodUpdate(t *testing.T) {
}
update
:=
got
.
(
kubetypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
ApiserverSource
)
if
!
v1
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Errorf
(
"Expected %#v; Got %#v"
,
expected
,
update
)
}
}
pkg/kubelet/config/config_test.go
View file @
b50367cb
...
...
@@ -24,6 +24,7 @@ import (
"testing"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/client/record"
...
...
@@ -100,7 +101,7 @@ func expectPodUpdate(t *testing.T, ch <-chan kubetypes.PodUpdate, expected ...ku
// except for "Pods", which are compared separately below.
expectedCopy
,
updateCopy
:=
expected
[
i
],
update
expectedCopy
.
Pods
,
updateCopy
.
Pods
=
nil
,
nil
if
!
v1
.
Semantic
.
DeepEqual
(
expectedCopy
,
updateCopy
)
{
if
!
api
.
Semantic
.
DeepEqual
(
expectedCopy
,
updateCopy
)
{
t
.
Fatalf
(
"Expected %#v, Got %#v"
,
expectedCopy
,
updateCopy
)
}
...
...
pkg/kubelet/config/file_linux_test.go
View file @
b50367cb
...
...
@@ -29,10 +29,10 @@ import (
"testing"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/validation"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/runtime"
...
...
@@ -58,7 +58,7 @@ func TestUpdateOnNonExistentFile(t *testing.T) {
case
got
:=
<-
ch
:
update
:=
got
.
(
kubetypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
FileSource
)
if
!
v1
.
Semantic
.
DeepDerivative
(
expected
,
update
)
{
if
!
api
.
Semantic
.
DeepDerivative
(
expected
,
update
)
{
t
.
Fatalf
(
"expected %#v, Got %#v"
,
expected
,
update
)
}
...
...
@@ -87,15 +87,15 @@ func TestReadPodsFromFileExistAlready(t *testing.T) {
update
:=
got
.
(
kubetypes
.
PodUpdate
)
for
_
,
pod
:=
range
update
.
Pods
{
// TODO: remove the conversion when validation is performed on versioned objects.
internalPod
:=
&
api
.
Pod
{}
if
err
:=
v1
.
Convert_v1_Pod_To_api_Pod
(
pod
,
internalPod
,
nil
);
err
!=
nil
{
t
.
Fatalf
(
"%s: Cannot convert pod %#v, %#v"
,
testCase
.
desc
,
pod
,
err
)
}
if
errs
:=
validation
.
ValidatePod
(
internalPod
);
len
(
errs
)
>
0
{
internalPod
:=
&
api
.
Pod
{}
if
err
:=
v1
.
Convert_v1_Pod_To_api_Pod
(
pod
,
internalPod
,
nil
);
err
!=
nil
{
t
.
Fatalf
(
"%s: Cannot convert pod %#v, %#v"
,
testCase
.
desc
,
pod
,
err
)
}
if
errs
:=
validation
.
ValidatePod
(
internalPod
);
len
(
errs
)
>
0
{
t
.
Fatalf
(
"%s: Invalid pod %#v, %#v"
,
testCase
.
desc
,
internalPod
,
errs
)
}
}
if
!
v1
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
if
!
api
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
t
.
Fatalf
(
"%s: Expected %#v, Got %#v"
,
testCase
.
desc
,
testCase
.
expected
,
update
)
}
case
<-
time
.
After
(
wait
.
ForeverTestTimeout
)
:
...
...
@@ -159,7 +159,7 @@ func TestExtractFromEmptyDir(t *testing.T) {
update
:=
(
<-
ch
)
.
(
kubetypes
.
PodUpdate
)
expected
:=
CreatePodUpdate
(
kubetypes
.
SET
,
kubetypes
.
FileSource
)
if
!
v1
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
if
!
api
.
Semantic
.
DeepEqual
(
expected
,
update
)
{
t
.
Fatalf
(
"expected %#v, Got %#v"
,
expected
,
update
)
}
}
...
...
@@ -371,7 +371,7 @@ func expectUpdate(t *testing.T, ch chan interface{}, testCase *testCase) {
}
}
if
!
v1
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
if
!
api
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
t
.
Fatalf
(
"%s: Expected: %#v, Got: %#v"
,
testCase
.
desc
,
testCase
.
expected
,
update
)
}
return
...
...
pkg/kubelet/config/http_test.go
View file @
b50367cb
...
...
@@ -23,10 +23,10 @@ import (
"testing"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/apimachinery/registered"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
...
...
@@ -301,16 +301,16 @@ func TestExtractPodsFromHTTP(t *testing.T) {
}
update
:=
(
<-
ch
)
.
(
kubetypes
.
PodUpdate
)
if
!
v1
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
if
!
api
.
Semantic
.
DeepEqual
(
testCase
.
expected
,
update
)
{
t
.
Errorf
(
"%s: Expected: %#v, Got: %#v"
,
testCase
.
desc
,
testCase
.
expected
,
update
)
}
for
_
,
pod
:=
range
update
.
Pods
{
// TODO: remove the conversion when validation is performed on versioned objects.
internalPod
:=
&
api
.
Pod
{}
if
err
:=
v1
.
Convert_v1_Pod_To_api_Pod
(
pod
,
internalPod
,
nil
);
err
!=
nil
{
t
.
Fatalf
(
"%s: Cannot convert pod %#v, %#v"
,
testCase
.
desc
,
pod
,
err
)
}
if
errs
:=
validation
.
ValidatePod
(
internalPod
);
len
(
errs
)
!=
0
{
internalPod
:=
&
api
.
Pod
{}
if
err
:=
v1
.
Convert_v1_Pod_To_api_Pod
(
pod
,
internalPod
,
nil
);
err
!=
nil
{
t
.
Fatalf
(
"%s: Cannot convert pod %#v, %#v"
,
testCase
.
desc
,
pod
,
err
)
}
if
errs
:=
validation
.
ValidatePod
(
internalPod
);
len
(
errs
)
!=
0
{
t
.
Errorf
(
"%s: Expected no validation errors on %#v, Got %v"
,
testCase
.
desc
,
pod
,
errs
.
ToAggregate
())
}
}
...
...
pkg/kubelet/dockertools/docker_manager_test.go
View file @
b50367cb
...
...
@@ -38,6 +38,7 @@ import (
"github.com/golang/mock/gomock"
cadvisorapi
"github.com/google/cadvisor/info/v1"
"github.com/stretchr/testify/assert"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/componentconfig"
...
...
@@ -314,10 +315,10 @@ func TestSetEntrypointAndCommand(t *testing.T) {
}
setEntrypointAndCommand
(
tc
.
container
,
opts
,
actualOpts
)
if
e
,
a
:=
tc
.
expected
.
Config
.
Entrypoint
,
actualOpts
.
Config
.
Entrypoint
;
!
v1
.
Semantic
.
DeepEqual
(
e
,
a
)
{
if
e
,
a
:=
tc
.
expected
.
Config
.
Entrypoint
,
actualOpts
.
Config
.
Entrypoint
;
!
api
.
Semantic
.
DeepEqual
(
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
;
!
v1
.
Semantic
.
DeepEqual
(
e
,
a
)
{
if
e
,
a
:=
tc
.
expected
.
Config
.
Cmd
,
actualOpts
.
Config
.
Cmd
;
!
api
.
Semantic
.
DeepEqual
(
e
,
a
)
{
t
.
Errorf
(
"%v: unexpected command: expected %v, got %v"
,
tc
.
name
,
e
,
a
)
}
}
...
...
@@ -1302,8 +1303,7 @@ func TestSyncPodWithHostNetwork(t *testing.T) {
Containers
:
[]
v1
.
Container
{
{
Name
:
"bar"
},
},
HostNetwork
:
true
,
HostNetwork
:
true
,
})
runSyncPod
(
t
,
dm
,
fakeDocker
,
pod
,
nil
,
false
)
...
...
pkg/kubelet/kubelet_node_status_test.go
View file @
b50367cb
...
...
@@ -27,6 +27,7 @@ import (
cadvisorapi
"github.com/google/cadvisor/info/v1"
cadvisorapiv2
"github.com/google/cadvisor/info/v2"
"k8s.io/kubernetes/pkg/api"
apierrors
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/unversioned"
...
...
@@ -225,7 +226,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
if
maxImagesInNodeStatus
!=
len
(
updatedNode
.
Status
.
Images
)
{
t
.
Errorf
(
"unexpected image list length in node status, expected: %v, got: %v"
,
maxImagesInNodeStatus
,
len
(
updatedNode
.
Status
.
Images
))
}
else
{
if
!
v1
.
Semantic
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
if
!
api
.
Semantic
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
t
.
Errorf
(
"unexpected objects: %s"
,
diff
.
ObjectDiff
(
expectedNode
,
updatedNode
))
}
}
...
...
@@ -498,7 +499,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
t
.
Errorf
(
"unexpected node condition order. NodeReady should be last."
)
}
if
!
v1
.
Semantic
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
if
!
api
.
Semantic
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
t
.
Errorf
(
"unexpected objects: %s"
,
diff
.
ObjectDiff
(
expectedNode
,
updatedNode
))
}
}
...
...
@@ -806,7 +807,7 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) {
LastHeartbeatTime
:
unversioned
.
Time
{},
LastTransitionTime
:
unversioned
.
Time
{},
}
if
!
v1
.
Semantic
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
if
!
api
.
Semantic
.
DeepEqual
(
expectedNode
,
updatedNode
)
{
t
.
Errorf
(
"unexpected objects: %s"
,
diff
.
ObjectDiff
(
expectedNode
,
updatedNode
))
}
}
...
...
pkg/kubelet/kubelet_resources_test.go
View file @
b50367cb
...
...
@@ -23,6 +23,7 @@ import (
cadvisorapi
"github.com/google/cadvisor/info/v1"
cadvisorapiv2
"github.com/google/cadvisor/info/v2"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/v1"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
...
...
@@ -76,7 +77,7 @@ func TestPodResourceLimitsDefaulting(t *testing.T) {
for
idx
,
tc
:=
range
cases
{
actual
,
_
,
err
:=
tk
.
kubelet
.
defaultPodLimitsForDownwardApi
(
tc
.
pod
,
nil
)
as
.
Nil
(
err
,
"failed to default pod limits: %v"
,
err
)
if
!
v1
.
Semantic
.
DeepEqual
(
tc
.
expected
,
actual
)
{
if
!
api
.
Semantic
.
DeepEqual
(
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 @
b50367cb
...
...
@@ -116,7 +116,7 @@ func NewManager(kubeClient clientset.Interface, podManager kubepod.Manager) Mana
// This method normalizes the status before comparing so as to make sure that meaningless
// changes will be ignored.
func
isStatusEqual
(
oldStatus
,
status
*
v1
.
PodStatus
)
bool
{
return
v1
.
Semantic
.
DeepEqual
(
status
,
oldStatus
)
return
api
.
Semantic
.
DeepEqual
(
status
,
oldStatus
)
}
func
(
m
*
manager
)
Start
()
{
...
...
test/integration/serviceaccount/service_account_test.go
View file @
b50367cb
...
...
@@ -31,6 +31,7 @@ import (
"testing"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apimachinery/registered"
...
...
@@ -262,13 +263,13 @@ func TestServiceAccountTokenAutoMount(t *testing.T) {
if
createdPod
.
Spec
.
ServiceAccountName
!=
expectedServiceAccount
{
t
.
Fatalf
(
"Expected %s, got %s"
,
expectedServiceAccount
,
createdPod
.
Spec
.
ServiceAccountName
)
}
if
!
v1
.
Semantic
.
DeepEqual
(
&
expectedVolumes
,
&
createdPod
.
Spec
.
Volumes
)
{
if
!
api
.
Semantic
.
DeepEqual
(
&
expectedVolumes
,
&
createdPod
.
Spec
.
Volumes
)
{
t
.
Fatalf
(
"Expected
\n\t
%#v
\n\t
got
\n\t
%#v"
,
expectedVolumes
,
createdPod
.
Spec
.
Volumes
)
}
if
!
v1
.
Semantic
.
DeepEqual
(
&
expectedContainer1VolumeMounts
,
&
createdPod
.
Spec
.
Containers
[
0
]
.
VolumeMounts
)
{
if
!
api
.
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
)
}
if
!
v1
.
Semantic
.
DeepEqual
(
&
expectedContainer2VolumeMounts
,
&
createdPod
.
Spec
.
Containers
[
1
]
.
VolumeMounts
)
{
if
!
api
.
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
)
}
}
...
...
test/utils/runners.go
View file @
b50367cb
...
...
@@ -696,7 +696,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
)
}
updatedNode
:=
strategy
.
CleanupNode
(
node
)
if
v1
.
Semantic
.
DeepEqual
(
node
,
updatedNode
)
{
if
api
.
Semantic
.
DeepEqual
(
node
,
updatedNode
)
{
return
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