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
4f847cb4
Commit
4f847cb4
authored
Mar 14, 2017
by
Connor Doyle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move e2e sched event predicates to new file.
parent
442e9200
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
25 deletions
+50
-25
BUILD
test/e2e/scheduling/BUILD
+1
-0
events.go
test/e2e/scheduling/events.go
+41
-0
opaque_resource.go
test/e2e/scheduling/opaque_resource.go
+8
-25
No files found.
test/e2e/scheduling/BUILD
View file @
4f847cb4
...
...
@@ -10,6 +10,7 @@ load(
go_library(
name = "go_default_library",
srcs = [
"events.go",
"opaque_resource.go",
"predicates.go",
"rescheduler.go",
...
...
test/e2e/scheduling/events.go
0 → 100644
View file @
4f847cb4
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
scheduling
import
(
"fmt"
"strings"
"k8s.io/kubernetes/pkg/api/v1"
)
func
scheduleSuccessEvent
(
podName
,
nodeName
string
)
func
(
*
v1
.
Event
)
bool
{
return
func
(
e
*
v1
.
Event
)
bool
{
return
e
.
Type
==
v1
.
EventTypeNormal
&&
e
.
Reason
==
"Scheduled"
&&
strings
.
HasPrefix
(
e
.
Name
,
podName
)
&&
strings
.
Contains
(
e
.
Message
,
fmt
.
Sprintf
(
"Successfully assigned %v to %v"
,
podName
,
nodeName
))
}
}
func
scheduleFailureEvent
(
podName
string
)
func
(
*
v1
.
Event
)
bool
{
return
func
(
e
*
v1
.
Event
)
bool
{
return
strings
.
HasPrefix
(
e
.
Name
,
podName
)
&&
e
.
Type
==
"Warning"
&&
e
.
Reason
==
"FailedScheduling"
}
}
test/e2e/scheduling/opaque_resource.go
View file @
4f847cb4
...
...
@@ -78,7 +78,7 @@ var _ = framework.KubeDescribe("Opaque resources [Feature:OpaqueResources]", fun
}
// Here we don't check for the bound node name since it can land on
// any one (this pod doesn't require any of the opaque resource.)
predicate
:=
scheduleSuccess
(
pod
.
Name
,
""
)
predicate
:=
scheduleSuccess
Event
(
pod
.
Name
,
""
)
success
,
err
:=
common
.
ObserveEventAfterAction
(
f
,
predicate
,
action
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
success
)
.
To
(
Equal
(
true
))
...
...
@@ -103,7 +103,7 @@ var _ = framework.KubeDescribe("Opaque resources [Feature:OpaqueResources]", fun
_
,
err
:=
f
.
ClientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
.
Create
(
pod
)
return
err
}
predicate
:=
scheduleSuccess
(
pod
.
Name
,
node
.
Name
)
predicate
:=
scheduleSuccess
Event
(
pod
.
Name
,
node
.
Name
)
success
,
err
:=
common
.
ObserveEventAfterAction
(
f
,
predicate
,
action
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
success
)
.
To
(
Equal
(
true
))
...
...
@@ -121,7 +121,7 @@ var _ = framework.KubeDescribe("Opaque resources [Feature:OpaqueResources]", fun
_
,
err
:=
f
.
ClientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
.
Create
(
f
.
NewTestPod
(
"over-max-oir"
,
requests
,
limits
))
return
err
}
predicate
:=
scheduleFailure
(
"over-max-oir"
)
predicate
:=
scheduleFailure
Event
(
"over-max-oir"
)
success
,
err
:=
common
.
ObserveEventAfterAction
(
f
,
predicate
,
action
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
success
)
.
To
(
Equal
(
true
))
...
...
@@ -166,7 +166,7 @@ var _ = framework.KubeDescribe("Opaque resources [Feature:OpaqueResources]", fun
_
,
err
:=
f
.
ClientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
.
Create
(
pod
)
return
err
}
predicate
:=
scheduleSuccess
(
pod
.
Name
,
node
.
Name
)
predicate
:=
scheduleSuccess
Event
(
pod
.
Name
,
node
.
Name
)
success
,
err
:=
common
.
ObserveEventAfterAction
(
f
,
predicate
,
action
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
success
)
.
To
(
Equal
(
true
))
...
...
@@ -206,7 +206,7 @@ var _ = framework.KubeDescribe("Opaque resources [Feature:OpaqueResources]", fun
_
,
err
=
f
.
ClientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
.
Create
(
pod
)
return
err
}
predicate
=
scheduleFailure
(
pod
.
Name
)
predicate
=
scheduleFailure
Event
(
pod
.
Name
)
success
,
err
=
common
.
ObserveEventAfterAction
(
f
,
predicate
,
action
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
success
)
.
To
(
Equal
(
true
))
...
...
@@ -232,7 +232,7 @@ var _ = framework.KubeDescribe("Opaque resources [Feature:OpaqueResources]", fun
_
,
err
:=
f
.
ClientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
.
Create
(
pod1
)
return
err
}
predicate
:=
scheduleSuccess
(
pod1
.
Name
,
node
.
Name
)
predicate
:=
scheduleSuccess
Event
(
pod1
.
Name
,
node
.
Name
)
success
,
err
:=
common
.
ObserveEventAfterAction
(
f
,
predicate
,
action
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
success
)
.
To
(
Equal
(
true
))
...
...
@@ -242,7 +242,7 @@ var _ = framework.KubeDescribe("Opaque resources [Feature:OpaqueResources]", fun
_
,
err
:=
f
.
ClientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
.
Create
(
pod2
)
return
err
}
predicate
=
scheduleFailure
(
pod2
.
Name
)
predicate
=
scheduleFailure
Event
(
pod2
.
Name
)
success
,
err
=
common
.
ObserveEventAfterAction
(
f
,
predicate
,
action
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
success
)
.
To
(
Equal
(
true
))
...
...
@@ -252,7 +252,7 @@ var _ = framework.KubeDescribe("Opaque resources [Feature:OpaqueResources]", fun
err
:=
f
.
ClientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
.
Delete
(
pod1
.
Name
,
nil
)
return
err
}
predicate
=
scheduleSuccess
(
pod2
.
Name
,
node
.
Name
)
predicate
=
scheduleSuccess
Event
(
pod2
.
Name
,
node
.
Name
)
success
,
err
=
common
.
ObserveEventAfterAction
(
f
,
predicate
,
action
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
success
)
.
To
(
Equal
(
true
))
...
...
@@ -302,20 +302,3 @@ func escapeForJSONPatch(resName v1.ResourceName) string {
// See https://tools.ietf.org/html/rfc6901#section-3
return
strings
.
Replace
(
string
(
resName
),
"/"
,
"~1"
,
-
1
)
}
func
scheduleSuccess
(
podName
,
nodeName
string
)
func
(
*
v1
.
Event
)
bool
{
return
func
(
e
*
v1
.
Event
)
bool
{
return
e
.
Type
==
v1
.
EventTypeNormal
&&
e
.
Reason
==
"Scheduled"
&&
strings
.
HasPrefix
(
e
.
Name
,
podName
)
&&
strings
.
Contains
(
e
.
Message
,
fmt
.
Sprintf
(
"Successfully assigned %v to %v"
,
podName
,
nodeName
))
}
}
func
scheduleFailure
(
podName
string
)
func
(
*
v1
.
Event
)
bool
{
return
func
(
e
*
v1
.
Event
)
bool
{
return
strings
.
HasPrefix
(
e
.
Name
,
podName
)
&&
e
.
Type
==
"Warning"
&&
e
.
Reason
==
"FailedScheduling"
}
}
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