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
ac068cd1
Commit
ac068cd1
authored
Mar 11, 2016
by
Brian Grant
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #22727 from mml/racey
Guarantee we finish writing to the test log before the test exits.
parents
1a1a77d0
547c3b44
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
1 deletion
+29
-1
scheduler_test.go
plugin/pkg/scheduler/scheduler_test.go
+29
-1
No files found.
plugin/pkg/scheduler/scheduler_test.go
View file @
ac068cd1
...
@@ -18,8 +18,10 @@ package scheduler
...
@@ -18,8 +18,10 @@ package scheduler
import
(
import
(
"errors"
"errors"
"fmt"
"math/rand"
"math/rand"
"reflect"
"reflect"
"sync"
"testing"
"testing"
"time"
"time"
...
@@ -158,8 +160,34 @@ func TestScheduler(t *testing.T) {
...
@@ -158,8 +160,34 @@ func TestScheduler(t *testing.T) {
}
}
func
TestSchedulerForgetAssumedPodAfterDelete
(
t
*
testing
.
T
)
{
func
TestSchedulerForgetAssumedPodAfterDelete
(
t
*
testing
.
T
)
{
// Set up a channel through which we'll funnel log messages from the watcher.
// This way, we can guarantee that when the test ends no thread will still be
// trying to write to t.Logf (which it would if we handed t.Logf directly to
// StartLogging).
ch
:=
make
(
chan
string
)
done
:=
make
(
chan
struct
{})
var
wg
sync
.
WaitGroup
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
for
{
select
{
case
msg
:=
<-
ch
:
t
.
Log
(
msg
)
case
<-
done
:
return
}
}
}()
eventBroadcaster
:=
record
.
NewBroadcaster
()
eventBroadcaster
:=
record
.
NewBroadcaster
()
defer
eventBroadcaster
.
StartLogging
(
t
.
Logf
)
.
Stop
()
watcher
:=
eventBroadcaster
.
StartLogging
(
func
(
format
string
,
args
...
interface
{})
{
ch
<-
fmt
.
Sprintf
(
format
,
args
...
)
})
defer
func
()
{
watcher
.
Stop
()
close
(
done
)
wg
.
Wait
()
}()
// Setup modeler so we control the contents of all 3 stores: assumed,
// Setup modeler so we control the contents of all 3 stores: assumed,
// scheduled and queued
// scheduled and queued
...
...
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