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
e4542e2c
Commit
e4542e2c
authored
Dec 06, 2016
by
Michael Fraenkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wait for the port to be ready before starting
- wait until the port is ready - verify the container terminated
parent
aa08702d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
9 deletions
+34
-9
portforward.go
test/e2e/portforward.go
+34
-9
No files found.
test/e2e/portforward.go
View file @
e4542e2c
...
...
@@ -32,6 +32,7 @@ import (
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/version"
"k8s.io/kubernetes/test/e2e/framework"
testutils
"k8s.io/kubernetes/test/utils"
.
"github.com/onsi/ginkgo"
)
...
...
@@ -55,6 +56,21 @@ func pfPod(expectedClientData, chunks, chunkSize, chunkIntervalMillis string) *v
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
Name
:
"readiness"
,
Image
:
"gcr.io/google_containers/netexec:1.7"
,
ReadinessProbe
:
&
v1
.
Probe
{
Handler
:
v1
.
Handler
{
Exec
:
&
v1
.
ExecAction
{
Command
:
[]
string
{
"sh"
,
"-c"
,
"netstat -na | grep LISTEN | grep -v 8080 | grep 80"
,
}},
},
InitialDelaySeconds
:
5
,
TimeoutSeconds
:
60
,
PeriodSeconds
:
1
,
},
},
{
Name
:
"portforwardtester"
,
Image
:
"gcr.io/google_containers/portforwardtester:1.2"
,
Env
:
[]
v1
.
EnvVar
{
...
...
@@ -86,6 +102,15 @@ func pfPod(expectedClientData, chunks, chunkSize, chunkIntervalMillis string) *v
}
}
func
WaitForTerminatedContainer
(
f
*
framework
.
Framework
,
pod
*
v1
.
Pod
,
containerName
string
)
error
{
return
framework
.
WaitForPodCondition
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"container terminated"
,
framework
.
PodStartTimeout
,
func
(
pod
*
v1
.
Pod
)
(
bool
,
error
)
{
if
len
(
testutils
.
TerminatedContainers
(
pod
)[
containerName
])
>
0
{
return
true
,
nil
}
return
false
,
nil
})
}
type
portForwardCommand
struct
{
cmd
*
exec
.
Cmd
port
int
...
...
@@ -180,7 +205,7 @@ var _ = framework.KubeDescribe("Port forwarding", func() {
if
_
,
err
:=
f
.
ClientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
.
Create
(
pod
);
err
!=
nil
{
framework
.
Failf
(
"Couldn't create pod: %v"
,
err
)
}
if
err
:=
f
.
WaitForPodR
unning
(
pod
.
Name
);
err
!=
nil
{
if
err
:=
f
.
WaitForPodR
eady
(
pod
.
Name
);
err
!=
nil
{
framework
.
Failf
(
"Pod did not start running: %v"
,
err
)
}
defer
func
()
{
...
...
@@ -206,8 +231,8 @@ var _ = framework.KubeDescribe("Port forwarding", func() {
conn
.
Close
()
By
(
"Waiting for the target pod to stop running"
)
if
err
:=
f
.
WaitForPodNoLongerRunning
(
pod
.
Name
);
err
!=
nil
{
framework
.
Failf
(
"
Pod did not stop running
: %v"
,
err
)
if
err
:=
WaitForTerminatedContainer
(
f
,
pod
,
"portforwardtester"
);
err
!=
nil
{
framework
.
Failf
(
"
Container did not terminate
: %v"
,
err
)
}
By
(
"Verifying logs"
)
...
...
@@ -225,7 +250,7 @@ var _ = framework.KubeDescribe("Port forwarding", func() {
if
_
,
err
:=
f
.
ClientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
.
Create
(
pod
);
err
!=
nil
{
framework
.
Failf
(
"Couldn't create pod: %v"
,
err
)
}
if
err
:=
f
.
WaitForPodR
unning
(
pod
.
Name
);
err
!=
nil
{
if
err
:=
f
.
WaitForPodR
eady
(
pod
.
Name
);
err
!=
nil
{
framework
.
Failf
(
"Pod did not start running: %v"
,
err
)
}
defer
func
()
{
...
...
@@ -272,8 +297,8 @@ var _ = framework.KubeDescribe("Port forwarding", func() {
}
By
(
"Waiting for the target pod to stop running"
)
if
err
:=
f
.
WaitForPodNoLongerRunning
(
pod
.
Name
);
err
!=
nil
{
framework
.
Failf
(
"
Pod did not stop running
: %v"
,
err
)
if
err
:=
WaitForTerminatedContainer
(
f
,
pod
,
"portforwardtester"
);
err
!=
nil
{
framework
.
Failf
(
"
Container did not terminate
: %v"
,
err
)
}
By
(
"Verifying logs"
)
...
...
@@ -293,7 +318,7 @@ var _ = framework.KubeDescribe("Port forwarding", func() {
if
_
,
err
:=
f
.
ClientSet
.
Core
()
.
Pods
(
f
.
Namespace
.
Name
)
.
Create
(
pod
);
err
!=
nil
{
framework
.
Failf
(
"Couldn't create pod: %v"
,
err
)
}
if
err
:=
f
.
WaitForPodR
unning
(
pod
.
Name
);
err
!=
nil
{
if
err
:=
f
.
WaitForPodR
eady
(
pod
.
Name
);
err
!=
nil
{
framework
.
Failf
(
"Pod did not start running: %v"
,
err
)
}
defer
func
()
{
...
...
@@ -330,8 +355,8 @@ var _ = framework.KubeDescribe("Port forwarding", func() {
}
By
(
"Waiting for the target pod to stop running"
)
if
err
:=
f
.
WaitForPodNoLongerRunning
(
pod
.
Name
);
err
!=
nil
{
framework
.
Failf
(
"
Pod did not stop running
: %v"
,
err
)
if
err
:=
WaitForTerminatedContainer
(
f
,
pod
,
"portforwardtester"
);
err
!=
nil
{
framework
.
Failf
(
"
Container did not terminate
: %v"
,
err
)
}
By
(
"Verifying logs"
)
...
...
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