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
f1b6158a
Commit
f1b6158a
authored
Oct 11, 2015
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let port forwarding e2e tests timeout on kubectl calls
parent
8e25b7c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
portforward.go
test/e2e/portforward.go
+19
-3
No files found.
test/e2e/portforward.go
View file @
f1b6158a
...
@@ -24,8 +24,10 @@ import (
...
@@ -24,8 +24,10 @@ import (
"regexp"
"regexp"
"strconv"
"strconv"
"strings"
"strings"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
)
)
...
@@ -110,6 +112,20 @@ func runPortForward(ns, podName string, port int) (*exec.Cmd, int) {
...
@@ -110,6 +112,20 @@ func runPortForward(ns, podName string, port int) (*exec.Cmd, int) {
return
cmd
,
listenPort
return
cmd
,
listenPort
}
}
func
runKubectlWithTimeout
(
timeout
time
.
Duration
,
args
...
string
)
string
{
logOutput
:=
make
(
chan
string
)
go
func
()
{
logOutput
<-
runKubectl
(
args
...
)
}()
select
{
case
<-
time
.
After
(
timeout
)
:
Failf
(
"kubectl timed out"
)
return
""
case
o
:=
<-
logOutput
:
return
o
}
}
var
_
=
Describe
(
"Port forwarding"
,
func
()
{
var
_
=
Describe
(
"Port forwarding"
,
func
()
{
framework
:=
NewFramework
(
"port-forwarding"
)
framework
:=
NewFramework
(
"port-forwarding"
)
...
@@ -133,7 +149,7 @@ var _ = Describe("Port forwarding", func() {
...
@@ -133,7 +149,7 @@ var _ = Describe("Port forwarding", func() {
By
(
"Closing the connection to the local port"
)
By
(
"Closing the connection to the local port"
)
conn
.
Close
()
conn
.
Close
()
logOutput
:=
runKubectl
(
"logs"
,
fmt
.
Sprintf
(
"--namespace=%v"
,
framework
.
Namespace
.
Name
),
"-f"
,
podName
)
logOutput
:=
runKubectl
WithTimeout
(
util
.
ForeverTestTimeout
,
"logs"
,
fmt
.
Sprintf
(
"--namespace=%v"
,
framework
.
Namespace
.
Name
),
"-f"
,
podName
)
verifyLogMessage
(
logOutput
,
"Accepted client connection"
)
verifyLogMessage
(
logOutput
,
"Accepted client connection"
)
verifyLogMessage
(
logOutput
,
"Expected to read 3 bytes from client, but got 0 instead"
)
verifyLogMessage
(
logOutput
,
"Expected to read 3 bytes from client, but got 0 instead"
)
})
})
...
@@ -178,7 +194,7 @@ var _ = Describe("Port forwarding", func() {
...
@@ -178,7 +194,7 @@ var _ = Describe("Port forwarding", func() {
Failf
(
"Expected %q from server, got %q"
,
e
,
a
)
Failf
(
"Expected %q from server, got %q"
,
e
,
a
)
}
}
logOutput
:=
runKubectl
(
"logs"
,
fmt
.
Sprintf
(
"--namespace=%v"
,
framework
.
Namespace
.
Name
),
"-f"
,
podName
)
logOutput
:=
runKubectl
WithTimeout
(
util
.
ForeverTestTimeout
,
"logs"
,
fmt
.
Sprintf
(
"--namespace=%v"
,
framework
.
Namespace
.
Name
),
"-f"
,
podName
)
verifyLogMessage
(
logOutput
,
"^Accepted client connection$"
)
verifyLogMessage
(
logOutput
,
"^Accepted client connection$"
)
verifyLogMessage
(
logOutput
,
"^Received expected client data$"
)
verifyLogMessage
(
logOutput
,
"^Received expected client data$"
)
verifyLogMessage
(
logOutput
,
"^Done$"
)
verifyLogMessage
(
logOutput
,
"^Done$"
)
...
@@ -215,7 +231,7 @@ var _ = Describe("Port forwarding", func() {
...
@@ -215,7 +231,7 @@ var _ = Describe("Port forwarding", func() {
Failf
(
"Expected %q from server, got %q"
,
e
,
a
)
Failf
(
"Expected %q from server, got %q"
,
e
,
a
)
}
}
logOutput
:=
runKubectl
(
"logs"
,
fmt
.
Sprintf
(
"--namespace=%v"
,
framework
.
Namespace
.
Name
),
"-f"
,
podName
)
logOutput
:=
runKubectl
WithTimeout
(
util
.
ForeverTestTimeout
,
"logs"
,
fmt
.
Sprintf
(
"--namespace=%v"
,
framework
.
Namespace
.
Name
),
"-f"
,
podName
)
verifyLogMessage
(
logOutput
,
"Accepted client connection"
)
verifyLogMessage
(
logOutput
,
"Accepted client connection"
)
verifyLogMessage
(
logOutput
,
"Done"
)
verifyLogMessage
(
logOutput
,
"Done"
)
})
})
...
...
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