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
ac8184df
Commit
ac8184df
authored
Nov 28, 2016
by
Marcin Wielgus
Committed by
Marcin
Dec 02, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ingress test fixes
parent
c7785fb1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
ingress_controller_test.go
.../federation-controller/ingress/ingress_controller_test.go
+0
-0
test_helper.go
...ration/pkg/federation-controller/util/test/test_helper.go
+16
-2
No files found.
federation/pkg/federation-controller/ingress/ingress_controller_test.go
View file @
ac8184df
This diff is collapsed.
Click to expand it.
federation/pkg/federation-controller/util/test/test_helper.go
View file @
ac8184df
...
...
@@ -36,6 +36,10 @@ import (
"github.com/golang/glog"
)
const
(
pushTimeout
=
5
*
time
.
Second
)
// A structure that distributes eventes to multiple watchers.
type
WatcherDispatcher
struct
{
sync
.
Mutex
...
...
@@ -58,6 +62,7 @@ func (wd *WatcherDispatcher) Stop() {
wd
.
Lock
()
defer
wd
.
Unlock
()
close
(
wd
.
stopChan
)
glog
.
Infof
(
"Stopping WatcherDispatcher"
)
for
_
,
watcher
:=
range
wd
.
watchers
{
watcher
.
Stop
()
}
...
...
@@ -141,7 +146,7 @@ func RegisterFakeWatch(resource string, client *core.Fake) *WatcherDispatcher {
dispatcher
:=
&
WatcherDispatcher
{
watchers
:
make
([]
*
watch
.
RaceFreeFakeWatcher
,
0
),
eventsSoFar
:
make
([]
*
watch
.
Event
,
0
),
orderExecution
:
make
(
chan
func
()),
orderExecution
:
make
(
chan
func
()
,
100
),
stopChan
:
make
(
chan
struct
{}),
}
go
func
()
{
...
...
@@ -199,13 +204,22 @@ func RegisterFakeCopyOnUpdate(resource string, client *core.Fake, watcher *Watch
client
.
AddReactor
(
"update"
,
resource
,
func
(
action
core
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
updateAction
:=
action
.
(
core
.
UpdateAction
)
originalObj
:=
updateAction
.
GetObject
()
glog
.
V
(
7
)
.
Infof
(
"Updating %s: %v"
,
resource
,
updateAction
.
GetObject
())
// Create a copy of the object here to prevent data races while reading the object in go routine.
obj
:=
copy
(
originalObj
)
watcher
.
orderExecution
<-
func
()
{
operation
:=
func
()
{
glog
.
V
(
4
)
.
Infof
(
"Object updated. Writing to channel: %v"
,
obj
)
watcher
.
Modify
(
obj
)
objChan
<-
obj
}
select
{
case
watcher
.
orderExecution
<-
operation
:
break
case
<-
time
.
After
(
pushTimeout
)
:
glog
.
Errorf
(
"Fake client execution channel blocked"
)
glog
.
Errorf
(
"Tried to push %v"
,
updateAction
)
}
return
true
,
originalObj
,
nil
})
return
objChan
...
...
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