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
0e484f25
Commit
0e484f25
authored
Mar 06, 2015
by
Prashanth Balasubramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly reap replication controllers in e2e test
parent
b650e481
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
20 deletions
+24
-20
stop.go
pkg/kubectl/stop.go
+9
-6
stop_test.go
pkg/kubectl/stop_test.go
+2
-2
networking.go
test/e2e/networking.go
+6
-5
rc.go
test/e2e/rc.go
+7
-7
No files found.
pkg/kubectl/stop.go
View file @
0e484f25
...
...
@@ -26,8 +26,9 @@ import (
)
const
(
interval
=
time
.
Second
*
3
timeout
=
time
.
Minute
*
5
shortInterval
=
time
.
Millisecond
*
100
interval
=
time
.
Second
*
3
timeout
=
time
.
Minute
*
5
)
// A Reaper handles terminating an object as gracefully as possible.
...
...
@@ -69,10 +70,12 @@ func (reaper *ReplicationControllerReaper) Stop(namespace, name string) (string,
if
err
!=
nil
{
return
""
,
err
}
controller
.
Spec
.
Replicas
=
0
// TODO: do retry on 409 errors here?
if
_
,
err
:=
rc
.
Update
(
controller
);
err
!=
nil
{
resizer
,
err
:=
ResizerFor
(
"ReplicationController"
,
*
reaper
)
if
err
!=
nil
{
return
""
,
err
}
cond
:=
ResizeCondition
(
resizer
,
&
ResizePrecondition
{
-
1
,
""
},
namespace
,
name
,
0
)
if
err
=
wait
.
Poll
(
shortInterval
,
reaper
.
timeout
,
cond
);
err
!=
nil
{
return
""
,
err
}
if
err
:=
wait
.
Poll
(
reaper
.
pollInterval
,
reaper
.
timeout
,
...
...
pkg/kubectl/stop_test.go
View file @
0e484f25
...
...
@@ -43,10 +43,10 @@ func TestReplicationControllerStop(t *testing.T) {
if
s
!=
expected
{
t
.
Errorf
(
"expected %s, got %s"
,
expected
,
s
)
}
if
len
(
fake
.
Actions
)
!=
4
{
if
len
(
fake
.
Actions
)
!=
5
{
t
.
Errorf
(
"unexpected actions: %v, expected 4 actions (get, update, get, delete)"
,
fake
.
Actions
)
}
for
i
,
action
:=
range
[]
string
{
"get"
,
"update"
,
"get"
,
"delete"
}
{
for
i
,
action
:=
range
[]
string
{
"get"
,
"
get"
,
"
update"
,
"get"
,
"delete"
}
{
if
fake
.
Actions
[
i
]
.
Action
!=
action
+
"-controller"
{
t
.
Errorf
(
"unexpected action: %v, expected %s-controller"
,
fake
.
Actions
[
i
],
action
)
}
...
...
test/e2e/networking.go
View file @
0e484f25
...
...
@@ -23,6 +23,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
.
"github.com/onsi/ginkgo"
...
...
@@ -123,13 +124,13 @@ var _ = Describe("Networking", func() {
defer
func
()
{
defer
GinkgoRecover
()
By
(
"Cleaning up the replication controller"
)
rc
.
Spec
.
Replicas
=
0
rc
,
err
=
c
.
ReplicationControllers
(
ns
)
.
Update
(
r
c
)
// Resize the replication controller to zero to get rid of pods.
rc
Reaper
,
err
:=
kubectl
.
ReaperFor
(
"ReplicationController"
,
c
)
if
err
!=
nil
{
Fail
(
fmt
.
Sprintf
(
"unable to
modify replica count for
rc %v: %v"
,
rc
.
Name
,
err
))
Fail
(
fmt
.
Sprintf
(
"unable to
stop
rc %v: %v"
,
rc
.
Name
,
err
))
}
if
err
=
c
.
ReplicationControllers
(
ns
)
.
Delete
(
rc
.
Name
);
err
!=
nil
{
Fail
(
fmt
.
Sprintf
(
"unable to
delete
rc %v: %v"
,
rc
.
Name
,
err
))
if
_
,
err
=
rcReaper
.
Stop
(
ns
,
rc
.
Name
);
err
!=
nil
{
Fail
(
fmt
.
Sprintf
(
"unable to
stop
rc %v: %v"
,
rc
.
Name
,
err
))
}
}()
...
...
test/e2e/rc.go
View file @
0e484f25
...
...
@@ -24,6 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
...
...
@@ -97,14 +98,13 @@ func ServeImageOrFail(c *client.Client, test string, image string) {
// Cleanup the replication controller when we are done.
defer
func
()
{
// Resize the replication controller to zero to get rid of pods.
controller
.
Spec
.
Replicas
=
0
if
_
,
err
=
c
.
ReplicationControllers
(
ns
)
.
Update
(
controller
);
err
!=
nil
{
Logf
(
"Failed to resize replication controller %s to zero: %v"
,
name
,
err
)
By
(
"Cleaning up the replication controller"
)
rcReaper
,
err
:=
kubectl
.
ReaperFor
(
"ReplicationController"
,
c
)
if
err
!=
nil
{
Logf
(
"Failed to cleanup replication controller %v: %v."
,
controller
.
Name
,
err
)
}
// Delete the replication controller.
if
err
=
c
.
ReplicationControllers
(
ns
)
.
Delete
(
name
);
err
!=
nil
{
Logf
(
"Failed to delete replication controller %s: %v"
,
name
,
err
)
if
_
,
err
=
rcReaper
.
Stop
(
ns
,
controller
.
Name
);
err
!=
nil
{
Logf
(
"Failed to stop replication controller %v: %v."
,
controller
.
Name
,
err
)
}
}()
...
...
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