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
05696cfe
Commit
05696cfe
authored
Mar 14, 2017
by
Connor Doyle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sync barrier to event obs helper.
- This change should guarantee that in observeEventAfterAction, the action is only executed after the informer begins watching the event stream.
parent
442e9200
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
events.go
test/e2e/common/events.go
+8
-2
No files found.
test/e2e/common/events.go
View file @
05696cfe
...
...
@@ -50,10 +50,10 @@ func ObserveNodeUpdateAfterAction(f *framework.Framework, nodeName string, nodeP
return
ls
,
err
},
WatchFunc
:
func
(
options
metav1
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
// Signal parent goroutine that watching has begun.
defer
informerStartedGuard
.
Do
(
func
()
{
close
(
informerStartedChan
)
})
options
.
FieldSelector
=
nodeSelector
.
String
()
w
,
err
:=
f
.
ClientSet
.
Core
()
.
Nodes
()
.
Watch
(
options
)
// Signal parent goroutine that watching has begun.
informerStartedGuard
.
Do
(
func
()
{
close
(
informerStartedChan
)
})
return
w
,
err
},
},
...
...
@@ -96,6 +96,8 @@ func ObserveNodeUpdateAfterAction(f *framework.Framework, nodeName string, nodeP
// after performing the supplied action.
func
ObserveEventAfterAction
(
f
*
framework
.
Framework
,
eventPredicate
func
(
*
v1
.
Event
)
bool
,
action
func
()
error
)
(
bool
,
error
)
{
observedMatchingEvent
:=
false
informerStartedChan
:=
make
(
chan
struct
{})
var
informerStartedGuard
sync
.
Once
// Create an informer to list/watch events from the test framework namespace.
_
,
controller
:=
cache
.
NewInformer
(
...
...
@@ -105,6 +107,8 @@ func ObserveEventAfterAction(f *framework.Framework, eventPredicate func(*v1.Eve
return
ls
,
err
},
WatchFunc
:
func
(
options
metav1
.
ListOptions
)
(
watch
.
Interface
,
error
)
{
// Signal parent goroutine that watching has begun.
defer
informerStartedGuard
.
Do
(
func
()
{
close
(
informerStartedChan
)
})
w
,
err
:=
f
.
ClientSet
.
Core
()
.
Events
(
f
.
Namespace
.
Name
)
.
Watch
(
options
)
return
w
,
err
},
...
...
@@ -123,9 +127,11 @@ func ObserveEventAfterAction(f *framework.Framework, eventPredicate func(*v1.Eve
},
)
// Start the informer and block this goroutine waiting for the started signal.
informerStopChan
:=
make
(
chan
struct
{})
defer
func
()
{
close
(
informerStopChan
)
}()
go
controller
.
Run
(
informerStopChan
)
<-
informerStartedChan
// Invoke the action function.
err
:=
action
()
...
...
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