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
1ec6b02e
Commit
1ec6b02e
authored
Apr 13, 2015
by
Daniel Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tests flaky due to timeouts
parent
a0fa592b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
21 deletions
+22
-21
controller_test.go
pkg/controller/framework/controller_test.go
+22
-21
No files found.
pkg/controller/framework/controller_test.go
View file @
1ec6b02e
...
...
@@ -45,8 +45,7 @@ func Example() {
fifo
:=
cache
.
NewDeltaFIFO
(
cache
.
MetaNamespaceKeyFunc
,
nil
,
downstream
)
// Let's do threadsafe output to get predictable test results.
outputSetLock
:=
sync
.
Mutex
{}
outputSet
:=
util
.
StringSet
{}
deletionCounter
:=
make
(
chan
string
,
1000
)
cfg
:=
&
framework
.
Config
{
Queue
:
fifo
,
...
...
@@ -68,6 +67,7 @@ func Example() {
return
err
}
// Delete this object.
source
.
Delete
(
newest
.
Object
.
(
runtime
.
Object
))
}
else
{
// Update our downstream store.
...
...
@@ -83,10 +83,8 @@ func Example() {
return
err
}
// Record some output.
outputSetLock
.
Lock
()
defer
outputSetLock
.
Unlock
()
outputSet
.
Insert
(
key
)
// Report this deletion.
deletionCounter
<-
key
}
return
nil
},
...
...
@@ -94,20 +92,23 @@ func Example() {
// Create the controller and run it until we close stop.
stop
:=
make
(
chan
struct
{})
defer
close
(
stop
)
go
framework
.
New
(
cfg
)
.
Run
(
stop
)
// Let's add a few objects to the source.
for
_
,
name
:=
range
[]
string
{
"a-hello"
,
"b-controller"
,
"c-framework"
}
{
testIDs
:=
[]
string
{
"a-hello"
,
"b-controller"
,
"c-framework"
}
for
_
,
name
:=
range
testIDs
{
// Note that these pods are not valid-- the fake source doesn't
// call validation or anything.
source
.
Add
(
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
}})
}
// Let's wait for the controller to process the things we just added.
time
.
Sleep
(
500
*
time
.
Millisecond
)
close
(
stop
)
outputSet
:=
util
.
StringSet
{}
for
i
:=
0
;
i
<
len
(
testIDs
);
i
++
{
outputSet
.
Insert
(
<-
deletionCounter
)
}
outputSetLock
.
Lock
()
for
_
,
key
:=
range
outputSet
.
List
()
{
fmt
.
Println
(
key
)
}
...
...
@@ -122,8 +123,7 @@ func ExampleInformer() {
source
:=
framework
.
NewFakeControllerSource
()
// Let's do threadsafe output to get predictable test results.
outputSetLock
:=
sync
.
Mutex
{}
outputSet
:=
util
.
StringSet
{}
deletionCounter
:=
make
(
chan
string
,
1000
)
// Make a controller that immediately deletes anything added to it, and
// logs anything deleted.
...
...
@@ -141,30 +141,31 @@ func ExampleInformer() {
key
=
"oops something went wrong with the key"
}
// Record some output when items are deleted.
outputSetLock
.
Lock
()
defer
outputSetLock
.
Unlock
()
outputSet
.
Insert
(
key
)
// Report this deletion.
deletionCounter
<-
key
},
},
)
// Run the controller and run it until we close stop.
stop
:=
make
(
chan
struct
{})
defer
close
(
stop
)
go
controller
.
Run
(
stop
)
// Let's add a few objects to the source.
for
_
,
name
:=
range
[]
string
{
"a-hello"
,
"b-controller"
,
"c-framework"
}
{
testIDs
:=
[]
string
{
"a-hello"
,
"b-controller"
,
"c-framework"
}
for
_
,
name
:=
range
testIDs
{
// Note that these pods are not valid-- the fake source doesn't
// call validation or
perform any other check
ing.
// call validation or
anyth
ing.
source
.
Add
(
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
}})
}
// Let's wait for the controller to process the things we just added.
time
.
Sleep
(
500
*
time
.
Millisecond
)
close
(
stop
)
outputSet
:=
util
.
StringSet
{}
for
i
:=
0
;
i
<
len
(
testIDs
);
i
++
{
outputSet
.
Insert
(
<-
deletionCounter
)
}
outputSetLock
.
Lock
()
for
_
,
key
:=
range
outputSet
.
List
()
{
fmt
.
Println
(
key
)
}
...
...
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