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
7797ff2e
Commit
7797ff2e
authored
Jul 29, 2016
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 29451
parent
ed3a29bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
38 deletions
+40
-38
replicaset_test.go
test/integration/replicaset/replicaset_test.go
+20
-19
replicationcontroller_test.go
...ation/replicationcontroller/replicationcontroller_test.go
+20
-19
No files found.
test/integration/replicaset/replicaset_test.go
View file @
7797ff2e
...
@@ -157,6 +157,22 @@ func rmSetup(t *testing.T, enableGarbageCollector bool) (*httptest.Server, *repl
...
@@ -157,6 +157,22 @@ func rmSetup(t *testing.T, enableGarbageCollector bool) (*httptest.Server, *repl
return
s
,
rm
,
podInformer
,
clientSet
return
s
,
rm
,
podInformer
,
clientSet
}
}
// wait for the podInformer to observe the pods. Call this function before
// running the RS controller to prevent the rc manager from creating new pods
// rather than adopting the existing ones.
func
waitToObservePods
(
t
*
testing
.
T
,
podInformer
controllerframwork
.
SharedIndexInformer
,
podNum
int
)
{
if
err
:=
wait
.
Poll
(
10
*
time
.
Second
,
60
*
time
.
Second
,
func
()
(
bool
,
error
)
{
objects
:=
podInformer
.
GetIndexer
()
.
List
()
if
len
(
objects
)
==
podNum
{
return
true
,
nil
}
else
{
return
false
,
nil
}
});
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
TestAdoption
(
t
*
testing
.
T
)
{
func
TestAdoption
(
t
*
testing
.
T
)
{
var
trueVar
=
true
var
trueVar
=
true
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
...
@@ -229,23 +245,7 @@ func TestAdoption(t *testing.T) {
...
@@ -229,23 +245,7 @@ func TestAdoption(t *testing.T) {
stopCh
:=
make
(
chan
struct
{})
stopCh
:=
make
(
chan
struct
{})
go
podInformer
.
Run
(
stopCh
)
go
podInformer
.
Run
(
stopCh
)
// wait for the podInformer to observe the pod, otherwise the rs controller
waitToObservePods
(
t
,
podInformer
,
1
)
// will try to create a new pod rather than adopting the existing one.
if
err
:=
wait
.
Poll
(
10
*
time
.
Second
,
60
*
time
.
Second
,
func
()
(
bool
,
error
)
{
objects
:=
podInformer
.
GetIndexer
()
.
List
()
for
_
,
object
:=
range
objects
{
pod
,
ok
:=
object
.
(
*
api
.
Pod
)
if
!
ok
{
t
.
Fatal
(
"expect object to be a pod"
)
}
if
pod
.
Name
==
podName
{
return
true
,
nil
}
}
return
false
,
nil
});
err
!=
nil
{
t
.
Fatal
(
err
)
}
go
rm
.
Run
(
5
,
stopCh
)
go
rm
.
Run
(
5
,
stopCh
)
if
err
:=
wait
.
Poll
(
10
*
time
.
Second
,
60
*
time
.
Second
,
func
()
(
bool
,
error
)
{
if
err
:=
wait
.
Poll
(
10
*
time
.
Second
,
60
*
time
.
Second
,
func
()
(
bool
,
error
)
{
updatedPod
,
err
:=
podClient
.
Get
(
pod
.
Name
)
updatedPod
,
err
:=
podClient
.
Get
(
pod
.
Name
)
...
@@ -316,6 +316,7 @@ func TestUpdateSelectorToAdopt(t *testing.T) {
...
@@ -316,6 +316,7 @@ func TestUpdateSelectorToAdopt(t *testing.T) {
stopCh
:=
make
(
chan
struct
{})
stopCh
:=
make
(
chan
struct
{})
go
podInformer
.
Run
(
stopCh
)
go
podInformer
.
Run
(
stopCh
)
waitToObservePods
(
t
,
podInformer
,
2
)
go
rm
.
Run
(
5
,
stopCh
)
go
rm
.
Run
(
5
,
stopCh
)
waitRSStable
(
t
,
clientSet
,
rs
,
ns
.
Name
)
waitRSStable
(
t
,
clientSet
,
rs
,
ns
.
Name
)
...
@@ -383,7 +384,7 @@ func TestUpdateSelectorToRemoveControllerRef(t *testing.T) {
...
@@ -383,7 +384,7 @@ func TestUpdateSelectorToRemoveControllerRef(t *testing.T) {
func
TestUpdateLabelToRemoveControllerRef
(
t
*
testing
.
T
)
{
func
TestUpdateLabelToRemoveControllerRef
(
t
*
testing
.
T
)
{
// We have pod1, pod2 and rs. rs.spec.replicas=2. At first rs.Selector
// We have pod1, pod2 and rs. rs.spec.replicas=2. At first rs.Selector
// matches pod1 and pod2; change pod2's lab
le
s to non-matching. Verify
// matches pod1 and pod2; change pod2's lab
el
s to non-matching. Verify
// that rs creates one more pod, so there are 3 pods. Also verify that
// that rs creates one more pod, so there are 3 pods. Also verify that
// pod2's controllerRef is cleared.
// pod2's controllerRef is cleared.
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
...
@@ -425,7 +426,7 @@ func TestUpdateLabelToRemoveControllerRef(t *testing.T) {
...
@@ -425,7 +426,7 @@ func TestUpdateLabelToRemoveControllerRef(t *testing.T) {
func
TestUpdateLabelToBeAdopted
(
t
*
testing
.
T
)
{
func
TestUpdateLabelToBeAdopted
(
t
*
testing
.
T
)
{
// We have pod1, pod2 and rs. rs.spec.replicas=1. At first rs.Selector
// We have pod1, pod2 and rs. rs.spec.replicas=1. At first rs.Selector
// matches pod1 only; change pod2's lab
le
s to be matching. Verify the RS
// matches pod1 only; change pod2's lab
el
s to be matching. Verify the RS
// controller adopts pod2 and delete one of them, so there is only 1 pod
// controller adopts pod2 and delete one of them, so there is only 1 pod
// left.
// left.
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
...
...
test/integration/replicationcontroller/replicationcontroller_test.go
View file @
7797ff2e
...
@@ -154,6 +154,22 @@ func rmSetup(t *testing.T, enableGarbageCollector bool) (*httptest.Server, *repl
...
@@ -154,6 +154,22 @@ func rmSetup(t *testing.T, enableGarbageCollector bool) (*httptest.Server, *repl
return
s
,
rm
,
podInformer
,
clientSet
return
s
,
rm
,
podInformer
,
clientSet
}
}
// wait for the podInformer to observe the pods. Call this function before
// running the RC manager to prevent the rc manager from creating new pods
// rather than adopting the existing ones.
func
waitToObservePods
(
t
*
testing
.
T
,
podInformer
controllerframwork
.
SharedIndexInformer
,
podNum
int
)
{
if
err
:=
wait
.
Poll
(
10
*
time
.
Second
,
60
*
time
.
Second
,
func
()
(
bool
,
error
)
{
objects
:=
podInformer
.
GetIndexer
()
.
List
()
if
len
(
objects
)
==
podNum
{
return
true
,
nil
}
else
{
return
false
,
nil
}
});
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
TestAdoption
(
t
*
testing
.
T
)
{
func
TestAdoption
(
t
*
testing
.
T
)
{
var
trueVar
=
true
var
trueVar
=
true
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
...
@@ -226,23 +242,7 @@ func TestAdoption(t *testing.T) {
...
@@ -226,23 +242,7 @@ func TestAdoption(t *testing.T) {
stopCh
:=
make
(
chan
struct
{})
stopCh
:=
make
(
chan
struct
{})
go
podInformer
.
Run
(
stopCh
)
go
podInformer
.
Run
(
stopCh
)
// wait for the podInformer to observe the pod, otherwise the rc manager
waitToObservePods
(
t
,
podInformer
,
1
)
// will try to create a new pod rather than adopting the existing one.
if
err
:=
wait
.
Poll
(
10
*
time
.
Second
,
60
*
time
.
Second
,
func
()
(
bool
,
error
)
{
objects
:=
podInformer
.
GetIndexer
()
.
List
()
for
_
,
object
:=
range
objects
{
pod
,
ok
:=
object
.
(
*
api
.
Pod
)
if
!
ok
{
t
.
Fatal
(
"expect object to be a pod"
)
}
if
pod
.
Name
==
podName
{
return
true
,
nil
}
}
return
false
,
nil
});
err
!=
nil
{
t
.
Fatal
(
err
)
}
go
rm
.
Run
(
5
,
stopCh
)
go
rm
.
Run
(
5
,
stopCh
)
if
err
:=
wait
.
Poll
(
10
*
time
.
Second
,
60
*
time
.
Second
,
func
()
(
bool
,
error
)
{
if
err
:=
wait
.
Poll
(
10
*
time
.
Second
,
60
*
time
.
Second
,
func
()
(
bool
,
error
)
{
updatedPod
,
err
:=
podClient
.
Get
(
pod
.
Name
)
updatedPod
,
err
:=
podClient
.
Get
(
pod
.
Name
)
...
@@ -350,6 +350,7 @@ func TestUpdateSelectorToRemoveControllerRef(t *testing.T) {
...
@@ -350,6 +350,7 @@ func TestUpdateSelectorToRemoveControllerRef(t *testing.T) {
stopCh
:=
make
(
chan
struct
{})
stopCh
:=
make
(
chan
struct
{})
go
podInformer
.
Run
(
stopCh
)
go
podInformer
.
Run
(
stopCh
)
waitToObservePods
(
t
,
podInformer
,
2
)
go
rm
.
Run
(
5
,
stopCh
)
go
rm
.
Run
(
5
,
stopCh
)
waitRCStable
(
t
,
clientSet
,
rc
,
ns
.
Name
)
waitRCStable
(
t
,
clientSet
,
rc
,
ns
.
Name
)
...
@@ -380,7 +381,7 @@ func TestUpdateSelectorToRemoveControllerRef(t *testing.T) {
...
@@ -380,7 +381,7 @@ func TestUpdateSelectorToRemoveControllerRef(t *testing.T) {
func
TestUpdateLabelToRemoveControllerRef
(
t
*
testing
.
T
)
{
func
TestUpdateLabelToRemoveControllerRef
(
t
*
testing
.
T
)
{
// We have pod1, pod2 and rc. rc.spec.replicas=2. At first rc.Selector
// We have pod1, pod2 and rc. rc.spec.replicas=2. At first rc.Selector
// matches pod1 and pod2; change pod2's lab
le
s to non-matching. Verify
// matches pod1 and pod2; change pod2's lab
el
s to non-matching. Verify
// that rc creates one more pod, so there are 3 pods. Also verify that
// that rc creates one more pod, so there are 3 pods. Also verify that
// pod2's controllerRef is cleared.
// pod2's controllerRef is cleared.
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
...
@@ -422,7 +423,7 @@ func TestUpdateLabelToRemoveControllerRef(t *testing.T) {
...
@@ -422,7 +423,7 @@ func TestUpdateLabelToRemoveControllerRef(t *testing.T) {
func
TestUpdateLabelToBeAdopted
(
t
*
testing
.
T
)
{
func
TestUpdateLabelToBeAdopted
(
t
*
testing
.
T
)
{
// We have pod1, pod2 and rc. rc.spec.replicas=1. At first rc.Selector
// We have pod1, pod2 and rc. rc.spec.replicas=1. At first rc.Selector
// matches pod1 only; change pod2's lab
le
s to be matching. Verify the RC
// matches pod1 only; change pod2's lab
el
s to be matching. Verify the RC
// controller adopts pod2 and delete one of them, so there is only 1 pod
// controller adopts pod2 and delete one of them, so there is only 1 pod
// left.
// left.
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
s
,
rm
,
podInformer
,
clientSet
:=
rmSetup
(
t
,
true
)
...
...
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