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
562ea716
Commit
562ea716
authored
Oct 02, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14664 from deads2k/fix-prepend
Auto commit by PR queue bot
parents
ff85f0ba
4cc63313
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
17 deletions
+21
-17
testclient.go
pkg/client/unversioned/testclient/testclient.go
+13
-3
controller_test.go
pkg/controller/job/controller_test.go
+4
-4
replication_controller_test.go
pkg/controller/replication/replication_controller_test.go
+1
-4
admission_test.go
plugin/pkg/admission/namespace/lifecycle/admission_test.go
+3
-6
No files found.
pkg/client/unversioned/testclient/testclient.go
View file @
562ea716
...
@@ -42,6 +42,8 @@ func NewSimpleFake(objects ...runtime.Object) *Fake {
...
@@ -42,6 +42,8 @@ func NewSimpleFake(objects ...runtime.Object) *Fake {
fakeClient
:=
&
Fake
{}
fakeClient
:=
&
Fake
{}
fakeClient
.
AddReactor
(
"*"
,
"*"
,
ObjectReaction
(
o
,
api
.
RESTMapper
))
fakeClient
.
AddReactor
(
"*"
,
"*"
,
ObjectReaction
(
o
,
api
.
RESTMapper
))
fakeClient
.
AddWatchReactor
(
"*"
,
DefaultWatchReactor
(
watch
.
NewFake
(),
nil
))
return
fakeClient
return
fakeClient
}
}
...
@@ -102,9 +104,7 @@ func (c *Fake) AddReactor(verb, resource string, reaction ReactionFunc) {
...
@@ -102,9 +104,7 @@ func (c *Fake) AddReactor(verb, resource string, reaction ReactionFunc) {
// PrependReactor adds a reactor to the beginning of the chain
// PrependReactor adds a reactor to the beginning of the chain
func
(
c
*
Fake
)
PrependReactor
(
verb
,
resource
string
,
reaction
ReactionFunc
)
{
func
(
c
*
Fake
)
PrependReactor
(
verb
,
resource
string
,
reaction
ReactionFunc
)
{
newChain
:=
make
([]
Reactor
,
0
,
len
(
c
.
ReactionChain
)
+
1
)
c
.
ReactionChain
=
append
([]
Reactor
{
&
SimpleReactor
{
verb
,
resource
,
reaction
}},
c
.
ReactionChain
...
)
newChain
[
0
]
=
&
SimpleReactor
{
verb
,
resource
,
reaction
}
newChain
=
append
(
newChain
,
c
.
ReactionChain
...
)
}
}
// AddWatchReactor appends a reactor to the end of the chain
// AddWatchReactor appends a reactor to the end of the chain
...
@@ -112,11 +112,21 @@ func (c *Fake) AddWatchReactor(resource string, reaction WatchReactionFunc) {
...
@@ -112,11 +112,21 @@ func (c *Fake) AddWatchReactor(resource string, reaction WatchReactionFunc) {
c
.
WatchReactionChain
=
append
(
c
.
WatchReactionChain
,
&
SimpleWatchReactor
{
resource
,
reaction
})
c
.
WatchReactionChain
=
append
(
c
.
WatchReactionChain
,
&
SimpleWatchReactor
{
resource
,
reaction
})
}
}
// PrependWatchReactor adds a reactor to the beginning of the chain
func
(
c
*
Fake
)
PrependWatchReactor
(
resource
string
,
reaction
WatchReactionFunc
)
{
c
.
WatchReactionChain
=
append
([]
WatchReactor
{
&
SimpleWatchReactor
{
resource
,
reaction
}},
c
.
WatchReactionChain
...
)
}
// AddProxyReactor appends a reactor to the end of the chain
// AddProxyReactor appends a reactor to the end of the chain
func
(
c
*
Fake
)
AddProxyReactor
(
resource
string
,
reaction
ProxyReactionFunc
)
{
func
(
c
*
Fake
)
AddProxyReactor
(
resource
string
,
reaction
ProxyReactionFunc
)
{
c
.
ProxyReactionChain
=
append
(
c
.
ProxyReactionChain
,
&
SimpleProxyReactor
{
resource
,
reaction
})
c
.
ProxyReactionChain
=
append
(
c
.
ProxyReactionChain
,
&
SimpleProxyReactor
{
resource
,
reaction
})
}
}
// PrependProxyReactor adds a reactor to the beginning of the chain
func
(
c
*
Fake
)
PrependProxyReactor
(
resource
string
,
reaction
ProxyReactionFunc
)
{
c
.
ProxyReactionChain
=
append
([]
ProxyReactor
{
&
SimpleProxyReactor
{
resource
,
reaction
}},
c
.
ProxyReactionChain
...
)
}
// Invokes records the provided Action and then invokes the ReactFn (if provided).
// Invokes records the provided Action and then invokes the ReactFn (if provided).
// defaultReturnObj is expected to be of the same type a normal call would return.
// defaultReturnObj is expected to be of the same type a normal call would return.
func
(
c
*
Fake
)
Invokes
(
action
Action
,
defaultReturnObj
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
func
(
c
*
Fake
)
Invokes
(
action
Action
,
defaultReturnObj
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
...
...
pkg/controller/job/controller_test.go
View file @
562ea716
...
@@ -395,9 +395,9 @@ type FakeWatcher struct {
...
@@ -395,9 +395,9 @@ type FakeWatcher struct {
}
}
func
TestWatchJobs
(
t
*
testing
.
T
)
{
func
TestWatchJobs
(
t
*
testing
.
T
)
{
client
:=
testclient
.
NewSimpleFake
()
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
:=
watch
.
NewFake
()
client
:=
&
testclient
.
Fake
{}
client
.
PrependWatchReactor
(
"*"
,
testclient
.
DefaultWatchReactor
(
fakeWatch
,
nil
))
client
.
AddWatchReactor
(
"*"
,
testclient
.
DefaultWatchReactor
(
fakeWatch
,
nil
))
manager
:=
NewJobController
(
client
)
manager
:=
NewJobController
(
client
)
manager
.
podStoreSynced
=
alwaysReady
manager
.
podStoreSynced
=
alwaysReady
...
@@ -458,9 +458,9 @@ func TestWatchJobs(t *testing.T) {
...
@@ -458,9 +458,9 @@ func TestWatchJobs(t *testing.T) {
}
}
func
TestWatchPods
(
t
*
testing
.
T
)
{
func
TestWatchPods
(
t
*
testing
.
T
)
{
client
:=
testclient
.
NewSimpleFake
()
fakeWatch
:=
watch
.
NewFake
()
fakeWatch
:=
watch
.
NewFake
()
client
:=
&
testclient
.
Fake
{}
client
.
PrependWatchReactor
(
"*"
,
testclient
.
DefaultWatchReactor
(
fakeWatch
,
nil
))
client
.
AddWatchReactor
(
"*"
,
testclient
.
DefaultWatchReactor
(
fakeWatch
,
nil
))
manager
:=
NewJobController
(
client
)
manager
:=
NewJobController
(
client
)
manager
.
podStoreSynced
=
alwaysReady
manager
.
podStoreSynced
=
alwaysReady
...
...
pkg/controller/replication/replication_controller_test.go
View file @
562ea716
...
@@ -502,10 +502,7 @@ func TestWatchPods(t *testing.T) {
...
@@ -502,10 +502,7 @@ func TestWatchPods(t *testing.T) {
}
}
func
TestUpdatePods
(
t
*
testing
.
T
)
{
func
TestUpdatePods
(
t
*
testing
.
T
)
{
fakeWatch
:=
watch
.
NewFake
()
manager
:=
NewReplicationManager
(
testclient
.
NewSimpleFake
(),
BurstReplicas
)
client
:=
&
testclient
.
Fake
{}
client
.
AddWatchReactor
(
"*"
,
testclient
.
DefaultWatchReactor
(
fakeWatch
,
nil
))
manager
:=
NewReplicationManager
(
client
,
BurstReplicas
)
manager
.
podStoreSynced
=
alwaysReady
manager
.
podStoreSynced
=
alwaysReady
received
:=
make
(
chan
string
)
received
:=
make
(
chan
string
)
...
...
plugin/pkg/admission/namespace/lifecycle/admission_test.go
View file @
562ea716
...
@@ -26,7 +26,6 @@ import (
...
@@ -26,7 +26,6 @@ import (
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
)
)
// TestAdmission
// TestAdmission
...
@@ -44,10 +43,8 @@ func TestAdmission(t *testing.T) {
...
@@ -44,10 +43,8 @@ func TestAdmission(t *testing.T) {
store
:=
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)
store
:=
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)
store
.
Add
(
namespaceObj
)
store
.
Add
(
namespaceObj
)
fakeWatch
:=
watch
.
NewFake
()
mockClient
:=
testclient
.
NewSimpleFake
()
mockClient
:=
&
testclient
.
Fake
{}
mockClient
.
PrependReactor
(
"get"
,
"namespaces"
,
func
(
action
testclient
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
mockClient
.
AddWatchReactor
(
"*"
,
testclient
.
DefaultWatchReactor
(
fakeWatch
,
nil
))
mockClient
.
AddReactor
(
"get"
,
"namespaces"
,
func
(
action
testclient
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
namespaceLock
.
RLock
()
namespaceLock
.
RLock
()
defer
namespaceLock
.
RUnlock
()
defer
namespaceLock
.
RUnlock
()
if
getAction
,
ok
:=
action
.
(
testclient
.
GetAction
);
ok
&&
getAction
.
GetName
()
==
namespaceObj
.
Name
{
if
getAction
,
ok
:=
action
.
(
testclient
.
GetAction
);
ok
&&
getAction
.
GetName
()
==
namespaceObj
.
Name
{
...
@@ -55,7 +52,7 @@ func TestAdmission(t *testing.T) {
...
@@ -55,7 +52,7 @@ func TestAdmission(t *testing.T) {
}
}
return
true
,
nil
,
fmt
.
Errorf
(
"No result for action %v"
,
action
)
return
true
,
nil
,
fmt
.
Errorf
(
"No result for action %v"
,
action
)
})
})
mockClient
.
Ad
dReactor
(
"list"
,
"namespaces"
,
func
(
action
testclient
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
mockClient
.
Prepen
dReactor
(
"list"
,
"namespaces"
,
func
(
action
testclient
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
namespaceLock
.
RLock
()
namespaceLock
.
RLock
()
defer
namespaceLock
.
RUnlock
()
defer
namespaceLock
.
RUnlock
()
return
true
,
&
api
.
NamespaceList
{
Items
:
[]
api
.
Namespace
{
*
namespaceObj
}},
nil
return
true
,
&
api
.
NamespaceList
{
Items
:
[]
api
.
Namespace
{
*
namespaceObj
}},
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