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
3c9b6869
Commit
3c9b6869
authored
Jul 05, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate scheduler integration tests
parent
13b2387c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
34 deletions
+67
-34
nodes.go
pkg/client/unversioned/nodes.go
+11
-0
fake_nodes.go
pkg/client/unversioned/testclient/fake_nodes.go
+5
-0
extender_test.go
test/integration/extender_test.go
+12
-8
scheduler_test.go
test/integration/scheduler_test.go
+39
-26
No files found.
pkg/client/unversioned/nodes.go
View file @
3c9b6869
...
@@ -30,6 +30,7 @@ type NodeInterface interface {
...
@@ -30,6 +30,7 @@ type NodeInterface interface {
Create
(
node
*
api
.
Node
)
(
*
api
.
Node
,
error
)
Create
(
node
*
api
.
Node
)
(
*
api
.
Node
,
error
)
List
(
opts
api
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
List
(
opts
api
.
ListOptions
)
(
*
api
.
NodeList
,
error
)
Delete
(
name
string
)
error
Delete
(
name
string
)
error
DeleteCollection
(
options
*
api
.
DeleteOptions
,
listOptions
api
.
ListOptions
)
error
Update
(
*
api
.
Node
)
(
*
api
.
Node
,
error
)
Update
(
*
api
.
Node
)
(
*
api
.
Node
,
error
)
UpdateStatus
(
*
api
.
Node
)
(
*
api
.
Node
,
error
)
UpdateStatus
(
*
api
.
Node
)
(
*
api
.
Node
,
error
)
Watch
(
opts
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
Watch
(
opts
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
...
@@ -76,6 +77,16 @@ func (c *nodes) Delete(name string) error {
...
@@ -76,6 +77,16 @@ func (c *nodes) Delete(name string) error {
return
c
.
r
.
Delete
()
.
Resource
(
c
.
resourceName
())
.
Name
(
name
)
.
Do
()
.
Error
()
return
c
.
r
.
Delete
()
.
Resource
(
c
.
resourceName
())
.
Name
(
name
)
.
Do
()
.
Error
()
}
}
// DeleteCollection deletes a collection of nodes.
func
(
c
*
nodes
)
DeleteCollection
(
options
*
api
.
DeleteOptions
,
listOptions
api
.
ListOptions
)
error
{
return
c
.
r
.
Delete
()
.
Resource
(
c
.
resourceName
())
.
VersionedParams
(
&
listOptions
,
api
.
ParameterCodec
)
.
Body
(
options
)
.
Do
()
.
Error
()
}
// Update updates an existing node.
// Update updates an existing node.
func
(
c
*
nodes
)
Update
(
node
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
func
(
c
*
nodes
)
Update
(
node
*
api
.
Node
)
(
*
api
.
Node
,
error
)
{
result
:=
&
api
.
Node
{}
result
:=
&
api
.
Node
{}
...
...
pkg/client/unversioned/testclient/fake_nodes.go
View file @
3c9b6869
...
@@ -68,6 +68,11 @@ func (c *FakeNodes) Delete(name string) error {
...
@@ -68,6 +68,11 @@ func (c *FakeNodes) Delete(name string) error {
return
err
return
err
}
}
func
(
c
*
FakeNodes
)
DeleteCollection
(
options
*
api
.
DeleteOptions
,
listOptions
api
.
ListOptions
)
error
{
_
,
err
:=
c
.
Fake
.
Invokes
(
NewRootDeleteCollectionAction
(
"nodes"
,
listOptions
),
&
api
.
NodeList
{})
return
err
}
func
(
c
*
FakeNodes
)
Watch
(
opts
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
func
(
c
*
FakeNodes
)
Watch
(
opts
api
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
return
c
.
Fake
.
InvokesWatch
(
NewRootWatchAction
(
"nodes"
,
opts
))
return
c
.
Fake
.
InvokesWatch
(
NewRootWatchAction
(
"nodes"
,
opts
))
}
}
...
...
test/integration/extender_test.go
View file @
3c9b6869
...
@@ -185,12 +185,12 @@ func machine_3_Prioritizer(pod *api.Pod, nodes *api.NodeList) (*schedulerapi.Hos
...
@@ -185,12 +185,12 @@ func machine_3_Prioritizer(pod *api.Pod, nodes *api.NodeList) (*schedulerapi.Hos
}
}
func
TestSchedulerExtender
(
t
*
testing
.
T
)
{
func
TestSchedulerExtender
(
t
*
testing
.
T
)
{
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework
.
DeleteAllEtcdKeys
()
_
,
s
:=
framework
.
RunAMaster
(
nil
)
_
,
s
:=
framework
.
RunAMaster
(
nil
)
defer
s
.
Close
()
defer
s
.
Close
()
ns
:=
framework
.
CreateTestingNamespace
(
"scheduler-extender"
,
s
,
t
)
defer
framework
.
DeleteTestingNamespace
(
ns
,
s
,
t
)
restClient
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
restClient
:=
client
.
NewOrDie
(
&
restclient
.
Config
{
Host
:
s
.
URL
,
ContentConfig
:
restclient
.
ContentConfig
{
GroupVersion
:
testapi
.
Default
.
GroupVersion
()}})
extender1
:=
&
Extender
{
extender1
:=
&
Extender
{
...
@@ -240,15 +240,19 @@ func TestSchedulerExtender(t *testing.T) {
...
@@ -240,15 +240,19 @@ func TestSchedulerExtender(t *testing.T) {
}
}
eventBroadcaster
:=
record
.
NewBroadcaster
()
eventBroadcaster
:=
record
.
NewBroadcaster
()
schedulerConfig
.
Recorder
=
eventBroadcaster
.
NewRecorder
(
api
.
EventSource
{
Component
:
api
.
DefaultSchedulerName
})
schedulerConfig
.
Recorder
=
eventBroadcaster
.
NewRecorder
(
api
.
EventSource
{
Component
:
api
.
DefaultSchedulerName
})
eventBroadcaster
.
StartRecordingToSink
(
restClient
.
Events
(
""
))
eventBroadcaster
.
StartRecordingToSink
(
restClient
.
Events
(
ns
.
Name
))
scheduler
.
New
(
schedulerConfig
)
.
Run
()
scheduler
.
New
(
schedulerConfig
)
.
Run
()
defer
close
(
schedulerConfig
.
StopEverything
)
defer
close
(
schedulerConfig
.
StopEverything
)
DoTestPodScheduling
(
t
,
restClient
)
DoTestPodScheduling
(
ns
,
t
,
restClient
)
}
}
func
DoTestPodScheduling
(
t
*
testing
.
T
,
restClient
*
client
.
Client
)
{
func
DoTestPodScheduling
(
ns
*
api
.
Namespace
,
t
*
testing
.
T
,
restClient
*
client
.
Client
)
{
// NOTE: This test cannot run in parallel, because it is creating and deleting
// non-namespaced objects (Nodes).
defer
restClient
.
Nodes
()
.
DeleteCollection
(
nil
,
api
.
ListOptions
{})
goodCondition
:=
api
.
NodeCondition
{
goodCondition
:=
api
.
NodeCondition
{
Type
:
api
.
NodeReady
,
Type
:
api
.
NodeReady
,
Status
:
api
.
ConditionTrue
,
Status
:
api
.
ConditionTrue
,
...
@@ -279,7 +283,7 @@ func DoTestPodScheduling(t *testing.T, restClient *client.Client) {
...
@@ -279,7 +283,7 @@ func DoTestPodScheduling(t *testing.T, restClient *client.Client) {
},
},
}
}
myPod
,
err
:=
restClient
.
Pods
(
api
.
NamespaceDefault
)
.
Create
(
pod
)
myPod
,
err
:=
restClient
.
Pods
(
ns
.
Name
)
.
Create
(
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to create pod: %v"
,
err
)
t
.
Fatalf
(
"Failed to create pod: %v"
,
err
)
}
}
...
@@ -289,7 +293,7 @@ func DoTestPodScheduling(t *testing.T, restClient *client.Client) {
...
@@ -289,7 +293,7 @@ func DoTestPodScheduling(t *testing.T, restClient *client.Client) {
t
.
Fatalf
(
"Failed to schedule pod: %v"
,
err
)
t
.
Fatalf
(
"Failed to schedule pod: %v"
,
err
)
}
}
if
myPod
,
err
:=
restClient
.
Pods
(
api
.
NamespaceDefault
)
.
Get
(
myPod
.
Name
);
err
!=
nil
{
if
myPod
,
err
:=
restClient
.
Pods
(
ns
.
Name
)
.
Get
(
myPod
.
Name
);
err
!=
nil
{
t
.
Fatalf
(
"Failed to get pod: %v"
,
err
)
t
.
Fatalf
(
"Failed to get pod: %v"
,
err
)
}
else
if
myPod
.
Spec
.
NodeName
!=
"machine3"
{
}
else
if
myPod
.
Spec
.
NodeName
!=
"machine3"
{
t
.
Fatalf
(
"Failed to schedule using extender, expected machine3, got %v"
,
myPod
.
Spec
.
NodeName
)
t
.
Fatalf
(
"Failed to schedule using extender, expected machine3, got %v"
,
myPod
.
Spec
.
NodeName
)
...
...
test/integration/scheduler_test.go
View file @
3c9b6869
This diff is collapsed.
Click to expand it.
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