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
6c36b611
Commit
6c36b611
authored
Jan 13, 2016
by
Random-Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add lock in density test
parent
1df76bc6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
density.go
test/e2e/density.go
+22
-6
No files found.
test/e2e/density.go
View file @
6c36b611
...
@@ -229,6 +229,8 @@ var _ = Describe("Density [Skipped]", func() {
...
@@ -229,6 +229,8 @@ var _ = Describe("Density [Skipped]", func() {
}
}
// Create a listener for events.
// Create a listener for events.
// eLock is a lock protects the events
var
eLock
sync
.
Mutex
events
:=
make
([](
*
api
.
Event
),
0
)
events
:=
make
([](
*
api
.
Event
),
0
)
_
,
controller
:=
controllerframework
.
NewInformer
(
_
,
controller
:=
controllerframework
.
NewInformer
(
&
cache
.
ListWatch
{
&
cache
.
ListWatch
{
...
@@ -243,6 +245,8 @@ var _ = Describe("Density [Skipped]", func() {
...
@@ -243,6 +245,8 @@ var _ = Describe("Density [Skipped]", func() {
0
,
0
,
controllerframework
.
ResourceEventHandlerFuncs
{
controllerframework
.
ResourceEventHandlerFuncs
{
AddFunc
:
func
(
obj
interface
{})
{
AddFunc
:
func
(
obj
interface
{})
{
eLock
.
Lock
()
defer
eLock
.
Unlock
()
events
=
append
(
events
,
obj
.
(
*
api
.
Event
))
events
=
append
(
events
,
obj
.
(
*
api
.
Event
))
},
},
},
},
...
@@ -251,6 +255,8 @@ var _ = Describe("Density [Skipped]", func() {
...
@@ -251,6 +255,8 @@ var _ = Describe("Density [Skipped]", func() {
go
controller
.
Run
(
stop
)
go
controller
.
Run
(
stop
)
// Create a listener for api updates
// Create a listener for api updates
// uLock is a lock protects the updateCount
var
uLock
sync
.
Mutex
updateCount
:=
0
updateCount
:=
0
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
RCName
}))
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"name"
:
RCName
}))
_
,
updateController
:=
controllerframework
.
NewInformer
(
_
,
updateController
:=
controllerframework
.
NewInformer
(
...
@@ -268,6 +274,8 @@ var _ = Describe("Density [Skipped]", func() {
...
@@ -268,6 +274,8 @@ var _ = Describe("Density [Skipped]", func() {
0
,
0
,
controllerframework
.
ResourceEventHandlerFuncs
{
controllerframework
.
ResourceEventHandlerFuncs
{
UpdateFunc
:
func
(
_
,
_
interface
{})
{
UpdateFunc
:
func
(
_
,
_
interface
{})
{
uLock
.
Lock
()
defer
uLock
.
Unlock
()
updateCount
++
updateCount
++
},
},
},
},
...
@@ -287,10 +295,18 @@ var _ = Describe("Density [Skipped]", func() {
...
@@ -287,10 +295,18 @@ var _ = Describe("Density [Skipped]", func() {
currentCount
:=
updateCount
currentCount
:=
updateCount
timeout
:=
10
*
time
.
Minute
timeout
:=
10
*
time
.
Minute
for
start
:=
time
.
Now
();
(
last
<
current
||
lastCount
<
currentCount
)
&&
time
.
Since
(
start
)
<
timeout
;
time
.
Sleep
(
10
*
time
.
Second
)
{
for
start
:=
time
.
Now
();
(
last
<
current
||
lastCount
<
currentCount
)
&&
time
.
Since
(
start
)
<
timeout
;
time
.
Sleep
(
10
*
time
.
Second
)
{
last
=
current
func
()
{
current
=
len
(
events
)
eLock
.
Lock
()
lastCount
=
currentCount
defer
eLock
.
Unlock
()
currentCount
=
updateCount
last
=
current
current
=
len
(
events
)
}()
func
()
{
uLock
.
Lock
()
defer
uLock
.
Unlock
()
lastCount
=
currentCount
currentCount
=
updateCount
}()
}
}
close
(
stop
)
close
(
stop
)
...
@@ -298,10 +314,10 @@ var _ = Describe("Density [Skipped]", func() {
...
@@ -298,10 +314,10 @@ var _ = Describe("Density [Skipped]", func() {
Logf
(
"Warning: Not all events were recorded after waiting %.2f minutes"
,
timeout
.
Minutes
())
Logf
(
"Warning: Not all events were recorded after waiting %.2f minutes"
,
timeout
.
Minutes
())
}
}
Logf
(
"Found %d events"
,
current
)
Logf
(
"Found %d events"
,
current
)
if
updateCount
!=
curren
tCount
{
if
currentCount
!=
las
tCount
{
Logf
(
"Warning: Not all updates were recorded after waiting %.2f minutes"
,
timeout
.
Minutes
())
Logf
(
"Warning: Not all updates were recorded after waiting %.2f minutes"
,
timeout
.
Minutes
())
}
}
Logf
(
"Found %d updates"
,
update
Count
)
Logf
(
"Found %d updates"
,
current
Count
)
// Tune the threshold for allowed failures.
// Tune the threshold for allowed failures.
badEvents
:=
BadEvents
(
events
)
badEvents
:=
BadEvents
(
events
)
...
...
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