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
5c338988
Unverified
Commit
5c338988
authored
Sep 19, 2018
by
Maciej Szulik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wait for events instead of just checking them in cronjob e2e
parent
191949da
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
20 deletions
+22
-20
cronjob.go
test/e2e/apps/cronjob.go
+22
-20
No files found.
test/e2e/apps/cronjob.go
View file @
5c338988
...
...
@@ -180,8 +180,8 @@ var _ = SIGDescribe("CronJob", func() {
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"Ensuring no unexpected event has happened"
)
err
=
checkNo
EventWithReason
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
cronJob
.
Name
,
[]
string
{
"MissingJob"
,
"UnexpectedJob"
})
Expect
(
err
)
.
Not
To
(
HaveOccurred
())
err
=
waitFor
EventWithReason
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
cronJob
.
Name
,
[]
string
{
"MissingJob"
,
"UnexpectedJob"
})
Expect
(
err
)
.
To
(
HaveOccurred
())
By
(
"Removing cronjob"
)
err
=
deleteCronJob
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
cronJob
.
Name
)
...
...
@@ -219,8 +219,8 @@ var _ = SIGDescribe("CronJob", func() {
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"Ensuring MissingJob event has occurred"
)
err
=
checkNo
EventWithReason
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
cronJob
.
Name
,
[]
string
{
"MissingJob"
})
Expect
(
err
)
.
To
(
HaveOccurred
())
err
=
waitFor
EventWithReason
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
cronJob
.
Name
,
[]
string
{
"MissingJob"
})
Expect
(
err
)
.
Not
To
(
HaveOccurred
())
By
(
"Removing cronjob"
)
err
=
deleteCronJob
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
cronJob
.
Name
)
...
...
@@ -426,24 +426,26 @@ func waitForAnyFinishedJob(c clientset.Interface, ns string) error {
})
}
// checkNoEventWithReason checks no events with a reason within a list has occurred
func
checkNoEventWithReason
(
c
clientset
.
Interface
,
ns
,
cronJobName
string
,
reasons
[]
string
)
error
{
sj
,
err
:=
c
.
BatchV1beta1
()
.
CronJobs
(
ns
)
.
Get
(
cronJobName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error in getting cronjob %s/%s: %v"
,
ns
,
cronJobName
,
err
)
}
events
,
err
:=
c
.
CoreV1
()
.
Events
(
ns
)
.
Search
(
legacyscheme
.
Scheme
,
sj
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error in listing events: %s"
,
err
)
}
for
_
,
e
:=
range
events
.
Items
{
for
_
,
reason
:=
range
reasons
{
if
e
.
Reason
==
reason
{
return
fmt
.
Errorf
(
"Found event with reason %s: %#v"
,
reason
,
e
)
// waitForEventWithReason waits for events with a reason within a list has occurred
func
waitForEventWithReason
(
c
clientset
.
Interface
,
ns
,
cronJobName
string
,
reasons
[]
string
)
error
{
return
wait
.
Poll
(
framework
.
Poll
,
30
*
time
.
Second
,
func
()
(
bool
,
error
)
{
sj
,
err
:=
c
.
BatchV1beta1
()
.
CronJobs
(
ns
)
.
Get
(
cronJobName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
false
,
err
}
events
,
err
:=
c
.
CoreV1
()
.
Events
(
ns
)
.
Search
(
legacyscheme
.
Scheme
,
sj
)
if
err
!=
nil
{
return
false
,
err
}
for
_
,
e
:=
range
events
.
Items
{
for
_
,
reason
:=
range
reasons
{
if
e
.
Reason
==
reason
{
return
true
,
nil
}
}
}
}
return
nil
return
false
,
nil
})
}
// filterNotDeletedJobs returns the job list without any jobs that are pending
...
...
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