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
9df172b0
Commit
9df172b0
authored
Sep 21, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14246 from mvdan/fix-race-lifecycle
Auto commit by PR queue bot
parents
2e5a3cfb
80a37fbc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
admission_test.go
plugin/pkg/admission/namespace/lifecycle/admission_test.go
+8
-0
No files found.
plugin/pkg/admission/namespace/lifecycle/admission_test.go
View file @
9df172b0
...
...
@@ -18,6 +18,7 @@ package lifecycle
import
(
"fmt"
"sync"
"testing"
"k8s.io/kubernetes/pkg/admission"
...
...
@@ -39,6 +40,7 @@ func TestAdmission(t *testing.T) {
Phase
:
api
.
NamespaceActive
,
},
}
var
namespaceLock
sync
.
RWMutex
store
:=
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)
store
.
Add
(
namespaceObj
)
...
...
@@ -46,12 +48,16 @@ func TestAdmission(t *testing.T) {
mockClient
:=
&
testclient
.
Fake
{}
mockClient
.
AddWatchReactor
(
"*"
,
testclient
.
DefaultWatchReactor
(
fakeWatch
,
nil
))
mockClient
.
AddReactor
(
"get"
,
"namespaces"
,
func
(
action
testclient
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
namespaceLock
.
RLock
()
defer
namespaceLock
.
RUnlock
()
if
getAction
,
ok
:=
action
.
(
testclient
.
GetAction
);
ok
&&
getAction
.
GetName
()
==
namespaceObj
.
Name
{
return
true
,
namespaceObj
,
nil
}
return
true
,
nil
,
fmt
.
Errorf
(
"No result for action %v"
,
action
)
})
mockClient
.
AddReactor
(
"list"
,
"namespaces"
,
func
(
action
testclient
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
namespaceLock
.
RLock
()
defer
namespaceLock
.
RUnlock
()
return
true
,
&
api
.
NamespaceList
{
Items
:
[]
api
.
Namespace
{
*
namespaceObj
}},
nil
})
...
...
@@ -78,7 +84,9 @@ func TestAdmission(t *testing.T) {
}
// change namespace state to terminating
namespaceLock
.
Lock
()
namespaceObj
.
Status
.
Phase
=
api
.
NamespaceTerminating
namespaceLock
.
Unlock
()
store
.
Add
(
namespaceObj
)
// verify create operations in the namespace cause an error
...
...
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