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
d9848524
Commit
d9848524
authored
Mar 09, 2015
by
Alex Mohr
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4780 from jdef/bug_4757
add unit test for #4757
parents
ee276b26
bf02d172
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
etcd_test.go
pkg/registry/pod/etcd/etcd_test.go
+36
-0
No files found.
pkg/registry/pod/etcd/etcd_test.go
View file @
d9848524
...
...
@@ -24,6 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
etcderrors
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors/etcd"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/rest/resttest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
...
...
@@ -846,6 +847,41 @@ func TestEtcdCreate(t *testing.T) {
}
}
// Ensure that when scheduler creates a binding for a pod that has already been deleted
// by the API server, API server returns not-found error.
func
TestEtcdCreateBindingNoPod
(
t
*
testing
.
T
)
{
registry
,
bindingRegistry
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
ctx
:=
api
.
NewDefaultContext
()
fakeClient
.
TestIndex
=
true
key
,
_
:=
registry
.
store
.
KeyFunc
(
ctx
,
"foo"
)
fakeClient
.
Data
[
key
]
=
tools
.
EtcdResponseWithError
{
R
:
&
etcd
.
Response
{
Node
:
nil
,
},
E
:
tools
.
EtcdErrorNotFound
,
}
// Assume that a pod has undergone the following:
// - Create (apiserver)
// - Schedule (scheduler)
// - Delete (apiserver)
_
,
err
:=
bindingRegistry
.
Create
(
ctx
,
&
api
.
Binding
{
PodID
:
"foo"
,
Host
:
"machine"
,
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
api
.
NamespaceDefault
}})
if
err
==
nil
{
t
.
Fatalf
(
"Expected not-found-error but got nothing"
)
}
if
!
errors
.
IsNotFound
(
etcderrors
.
InterpretGetError
(
err
,
"Pod"
,
"foo"
))
{
t
.
Fatalf
(
"Unexpected error returned: %#v"
,
err
)
}
_
,
err
=
registry
.
Get
(
ctx
,
"foo"
)
if
err
==
nil
{
t
.
Fatalf
(
"Expected not-found-error but got nothing"
)
}
if
!
errors
.
IsNotFound
(
etcderrors
.
InterpretGetError
(
err
,
"Pod"
,
"foo"
))
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
}
}
func
TestEtcdCreateFailsWithoutNamespace
(
t
*
testing
.
T
)
{
registry
,
_
,
_
,
fakeClient
,
_
:=
newStorage
(
t
)
fakeClient
.
TestIndex
=
true
...
...
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