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
7361f751
Commit
7361f751
authored
May 15, 2015
by
Robert Rati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a config struct for RunRC and allow polling interval to be
configurable. #7572
parent
9e06132e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
18 deletions
+64
-18
density.go
test/e2e/density.go
+16
-5
load.go
test/e2e/load.go
+7
-1
scale.go
test/e2e/scale.go
+9
-1
util.go
test/e2e/util.go
+32
-11
No files found.
test/e2e/density.go
View file @
7361f751
...
@@ -96,16 +96,18 @@ var _ = Describe("Density", func() {
...
@@ -96,16 +96,18 @@ var _ = Describe("Density", func() {
type
Density
struct
{
type
Density
struct
{
skip
bool
skip
bool
podsPerMinion
int
podsPerMinion
int
/* Controls how often the apiserver is polled for pods */
interval
int
}
}
densityTests
:=
[]
Density
{
densityTests
:=
[]
Density
{
// This test should always run, even if larger densities are skipped.
// This test should always run, even if larger densities are skipped.
{
podsPerMinion
:
3
,
skip
:
false
},
{
podsPerMinion
:
3
,
skip
:
false
,
interval
:
10
},
{
podsPerMinion
:
30
,
skip
:
false
},
{
podsPerMinion
:
30
,
skip
:
false
,
interval
:
10
},
// More than 30 pods per node is outside our v1.0 goals.
// More than 30 pods per node is outside our v1.0 goals.
// We might want to enable those tests in the future.
// We might want to enable those tests in the future.
{
podsPerMinion
:
50
,
skip
:
true
},
{
podsPerMinion
:
50
,
skip
:
true
,
interval
:
10
},
{
podsPerMinion
:
100
,
skip
:
true
},
{
podsPerMinion
:
100
,
skip
:
true
,
interval
:
1
},
}
}
for
_
,
testArg
:=
range
densityTests
{
for
_
,
testArg
:=
range
densityTests
{
...
@@ -124,6 +126,15 @@ var _ = Describe("Density", func() {
...
@@ -124,6 +126,15 @@ var _ = Describe("Density", func() {
expectNoError
(
err
)
expectNoError
(
err
)
defer
fileHndl
.
Close
()
defer
fileHndl
.
Close
()
config
:=
RCConfig
{
Client
:
c
,
Image
:
"gcr.io/google_containers/pause:go"
,
Name
:
RCName
,
Namespace
:
ns
,
PollInterval
:
itArg
.
interval
,
PodStatusFile
:
fileHndl
,
Replicas
:
totalPods
,
}
// Create a listener for events.
// Create a listener for events.
events
:=
make
([](
*
api
.
Event
),
0
)
events
:=
make
([](
*
api
.
Event
),
0
)
_
,
controller
:=
framework
.
NewInformer
(
_
,
controller
:=
framework
.
NewInformer
(
...
@@ -148,7 +159,7 @@ var _ = Describe("Density", func() {
...
@@ -148,7 +159,7 @@ var _ = Describe("Density", func() {
// Start the replication controller.
// Start the replication controller.
startTime
:=
time
.
Now
()
startTime
:=
time
.
Now
()
expectNoError
(
RunRC
(
c
,
RCName
,
ns
,
"gcr.io/google_containers/pause:go"
,
totalPods
,
fileHndl
))
expectNoError
(
RunRC
(
c
onfig
))
e2eStartupTime
:=
time
.
Now
()
.
Sub
(
startTime
)
e2eStartupTime
:=
time
.
Now
()
.
Sub
(
startTime
)
Logf
(
"E2E startup time for %d pods: %v"
,
totalPods
,
e2eStartupTime
)
Logf
(
"E2E startup time for %d pods: %v"
,
totalPods
,
e2eStartupTime
)
...
...
test/e2e/load.go
View file @
7361f751
...
@@ -120,7 +120,13 @@ func playWithRC(c *client.Client, wg *sync.WaitGroup, ns, name string, size int)
...
@@ -120,7 +120,13 @@ func playWithRC(c *client.Client, wg *sync.WaitGroup, ns, name string, size int)
// Once every 1-2 minutes perform resize of RC.
// Once every 1-2 minutes perform resize of RC.
for
start
:=
time
.
Now
();
time
.
Since
(
start
)
<
simulationTime
;
time
.
Sleep
(
time
.
Duration
(
60
+
rand
.
Intn
(
60
))
*
time
.
Second
)
{
for
start
:=
time
.
Now
();
time
.
Since
(
start
)
<
simulationTime
;
time
.
Sleep
(
time
.
Duration
(
60
+
rand
.
Intn
(
60
))
*
time
.
Second
)
{
if
!
rcExist
{
if
!
rcExist
{
expectNoError
(
RunRC
(
c
,
name
,
ns
,
image
,
size
,
nil
),
fmt
.
Sprintf
(
"creating rc %s in namespace %s"
,
name
,
ns
))
config
:=
RCConfig
{
Client
:
c
,
Name
:
name
,
Namespace
:
ns
,
Image
:
image
,
Replicas
:
size
,
}
expectNoError
(
RunRC
(
config
),
fmt
.
Sprintf
(
"creating rc %s in namespace %s"
,
name
,
ns
))
rcExist
=
true
rcExist
=
true
}
}
// Resize RC to a random size between 0.5x and 1.5x of the original size.
// Resize RC to a random size between 0.5x and 1.5x of the original size.
...
...
test/e2e/scale.go
View file @
7361f751
...
@@ -107,7 +107,15 @@ var _ = Describe("Scale", func() {
...
@@ -107,7 +107,15 @@ var _ = Describe("Scale", func() {
for
i
:=
0
;
i
<
itArg
.
rcsPerThread
;
i
++
{
for
i
:=
0
;
i
<
itArg
.
rcsPerThread
;
i
++
{
name
:=
"my-short-lived-pod"
+
string
(
util
.
NewUUID
())
name
:=
"my-short-lived-pod"
+
string
(
util
.
NewUUID
())
n
:=
itArg
.
podsPerMinion
*
minionCount
n
:=
itArg
.
podsPerMinion
*
minionCount
expectNoError
(
RunRC
(
c
,
name
,
ns
,
"gcr.io/google_containers/pause:go"
,
n
,
nil
))
config
:=
RCConfig
{
Client
:
c
,
Name
:
name
,
Namespace
:
ns
,
Image
:
"gcr.io/google_containers/pause:go"
,
Replicas
:
n
,
}
expectNoError
(
RunRC
(
config
))
podsLaunched
+=
n
podsLaunched
+=
n
Logf
(
"Launched %v pods so far..."
,
podsLaunched
)
Logf
(
"Launched %v pods so far..."
,
podsLaunched
)
err
:=
DeleteRC
(
c
,
ns
,
name
)
err
:=
DeleteRC
(
c
,
ns
,
name
)
...
...
test/e2e/util.go
View file @
7361f751
...
@@ -75,6 +75,16 @@ type ContainerFailures struct {
...
@@ -75,6 +75,16 @@ type ContainerFailures struct {
restarts
int
restarts
int
}
}
type
RCConfig
struct
{
Client
*
client
.
Client
Image
string
Name
string
Namespace
string
PollInterval
int
PodStatusFile
*
os
.
File
Replicas
int
}
func
Logf
(
format
string
,
a
...
interface
{})
{
func
Logf
(
format
string
,
a
...
interface
{})
{
fmt
.
Fprintf
(
GinkgoWriter
,
"INFO: "
+
format
+
"
\n
"
,
a
...
)
fmt
.
Fprintf
(
GinkgoWriter
,
"INFO: "
+
format
+
"
\n
"
,
a
...
)
}
}
...
@@ -475,8 +485,14 @@ func Diff(oldPods []api.Pod, curPods []api.Pod) PodDiff {
...
@@ -475,8 +485,14 @@ func Diff(oldPods []api.Pod, curPods []api.Pod) PodDiff {
// It will waits for all pods it spawns to become "Running".
// It will waits for all pods it spawns to become "Running".
// It's the caller's responsibility to clean up externally (i.e. use the
// It's the caller's responsibility to clean up externally (i.e. use the
// namespace lifecycle for handling cleanup).
// namespace lifecycle for handling cleanup).
func
RunRC
(
c
*
client
.
Client
,
name
string
,
ns
,
image
string
,
replicas
int
,
podStatusFile
*
os
.
File
)
error
{
func
RunRC
(
c
onfig
RCConfig
)
error
{
var
last
int
var
last
int
c
:=
config
.
Client
name
:=
config
.
Name
ns
:=
config
.
Namespace
image
:=
config
.
Image
replicas
:=
config
.
Replicas
interval
:=
config
.
PollInterval
maxContainerFailures
:=
int
(
math
.
Max
(
1.0
,
float64
(
replicas
)
*
.01
))
maxContainerFailures
:=
int
(
math
.
Max
(
1.0
,
float64
(
replicas
)
*
.01
))
current
:=
0
current
:=
0
...
@@ -518,7 +534,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int, podSta
...
@@ -518,7 +534,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int, podSta
// Create a routine to query for the list of pods
// Create a routine to query for the list of pods
stop
:=
make
(
chan
struct
{})
stop
:=
make
(
chan
struct
{})
go
func
(
stop
<-
chan
struct
{},
n
string
,
ns
string
,
l
labels
.
Selector
)
{
go
func
(
stop
<-
chan
struct
{},
n
string
,
ns
string
,
l
labels
.
Selector
,
i
int
)
{
for
{
for
{
select
{
select
{
case
<-
stop
:
case
<-
stop
:
...
@@ -530,16 +546,19 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int, podSta
...
@@ -530,16 +546,19 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int, podSta
}
else
{
}
else
{
podLists
.
Push
(
p
.
Items
)
podLists
.
Push
(
p
.
Items
)
}
}
time
.
Sleep
(
1
*
time
.
Second
)
time
.
Sleep
(
time
.
Duration
(
i
)
*
time
.
Second
)
}
}
}
}
}(
stop
,
name
,
ns
,
label
)
}(
stop
,
name
,
ns
,
label
,
interval
)
defer
close
(
stop
)
defer
close
(
stop
)
By
(
fmt
.
Sprintf
(
"Making sure all %d replicas of rc %s in namespace %s exist"
,
replicas
,
name
,
ns
))
By
(
fmt
.
Sprintf
(
"Making sure all %d replicas of rc %s in namespace %s exist"
,
replicas
,
name
,
ns
))
failCount
:=
5
failCount
:=
int
(
25
/
interval
)
for
same
<
failCount
&&
current
<
replicas
{
for
same
<
failCount
&&
current
<
replicas
{
time
.
Sleep
(
2
*
time
.
Second
)
time
.
Sleep
(
time
.
Duration
(
interval
*
2
)
*
time
.
Second
)
// Greedily read all existing entries in the queue until
// all pods are found submitted or the queue is empty
for
podLists
.
Len
()
>
0
&&
current
<
replicas
{
for
podLists
.
Len
()
>
0
&&
current
<
replicas
{
item
:=
podLists
.
Pop
()
item
:=
podLists
.
Pop
()
pods
:=
item
.
value
.
([]
api
.
Pod
)
pods
:=
item
.
value
.
([]
api
.
Pod
)
...
@@ -568,13 +587,16 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int, podSta
...
@@ -568,13 +587,16 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int, podSta
By
(
fmt
.
Sprintf
(
"Waiting for all %d replicas to be running with a max container failures of %d"
,
replicas
,
maxContainerFailures
))
By
(
fmt
.
Sprintf
(
"Waiting for all %d replicas to be running with a max container failures of %d"
,
replicas
,
maxContainerFailures
))
same
=
0
same
=
0
last
=
0
last
=
0
failCount
=
10
failCount
=
int
(
100
/
interval
)
current
=
0
current
=
0
var
oldPods
[]
api
.
Pod
var
oldPods
[]
api
.
Pod
podLists
.
Reset
()
podLists
.
Reset
()
foundAllPods
:=
false
foundAllPods
:=
false
for
same
<
failCount
&&
current
<
replicas
{
for
same
<
failCount
&&
current
<
replicas
{
time
.
Sleep
(
2
*
time
.
Second
)
time
.
Sleep
(
time
.
Duration
(
interval
*
2
)
*
time
.
Second
)
// Greedily read all existing entries in the queue until
// either all pods are running or the queue is empty
for
podLists
.
Len
()
>
0
&&
current
<
replicas
{
for
podLists
.
Len
()
>
0
&&
current
<
replicas
{
item
:=
podLists
.
Pop
()
item
:=
podLists
.
Pop
()
current
=
0
current
=
0
...
@@ -603,8 +625,8 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int, podSta
...
@@ -603,8 +625,8 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int, podSta
}
}
}
}
Logf
(
"Pod States: %d running, %d pending, %d waiting, %d inactive, %d unknown "
,
current
,
pending
,
waiting
,
inactive
,
unknown
)
Logf
(
"Pod States: %d running, %d pending, %d waiting, %d inactive, %d unknown "
,
current
,
pending
,
waiting
,
inactive
,
unknown
)
if
p
odStatusFile
!=
nil
{
if
config
.
P
odStatusFile
!=
nil
{
fmt
.
Fprintf
(
p
odStatusFile
,
"%s, %d, running, %d, pending, %d, waiting, %d, inactive, %d, unknown
\n
"
,
item
.
createTime
,
current
,
pending
,
waiting
,
inactive
,
unknown
)
fmt
.
Fprintf
(
config
.
P
odStatusFile
,
"%s, %d, running, %d, pending, %d, waiting, %d, inactive, %d, unknown
\n
"
,
item
.
createTime
,
current
,
pending
,
waiting
,
inactive
,
unknown
)
}
}
if
foundAllPods
&&
len
(
currentPods
)
!=
len
(
oldPods
)
{
if
foundAllPods
&&
len
(
currentPods
)
!=
len
(
oldPods
)
{
...
@@ -652,7 +674,6 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int, podSta
...
@@ -652,7 +674,6 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int, podSta
}
}
}
}
}
}
close
(
stop
)
if
current
!=
replicas
{
if
current
!=
replicas
{
return
fmt
.
Errorf
(
"Only %d pods started out of %d"
,
current
,
replicas
)
return
fmt
.
Errorf
(
"Only %d pods started out of %d"
,
current
,
replicas
)
}
}
...
...
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