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
c9a31e49
Unverified
Commit
c9a31e49
authored
Nov 16, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 16, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #71048 from m1kola/e2e_portforward_log_polling
Fixes flaky tests for kubectl port-forward
parents
54ee58b2
9cc47e3b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
68 deletions
+30
-68
portforward.go
test/e2e/kubectl/portforward.go
+30
-68
No files found.
test/e2e/kubectl/portforward.go
View file @
c9a31e49
...
@@ -47,6 +47,11 @@ const (
...
@@ -47,6 +47,11 @@ const (
podName
=
"pfpod"
podName
=
"pfpod"
)
)
const
(
podCheckInterval
=
1
*
time
.
Second
postStartWaitTimeout
=
2
*
time
.
Minute
)
// TODO support other ports besides 80
// TODO support other ports besides 80
var
(
var
(
portForwardRegexp
=
regexp
.
MustCompile
(
"Forwarding from (127.0.0.1|
\\
[::1
\\
]):([0-9]+) -> 80"
)
portForwardRegexp
=
regexp
.
MustCompile
(
"Forwarding from (127.0.0.1|
\\
[::1
\\
]):([0-9]+) -> 80"
)
...
@@ -202,14 +207,6 @@ func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
...
@@ -202,14 +207,6 @@ func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
if
err
:=
f
.
WaitForPodReady
(
pod
.
Name
);
err
!=
nil
{
if
err
:=
f
.
WaitForPodReady
(
pod
.
Name
);
err
!=
nil
{
framework
.
Failf
(
"Pod did not start running: %v"
,
err
)
framework
.
Failf
(
"Pod did not start running: %v"
,
err
)
}
}
defer
func
()
{
logs
,
err
:=
framework
.
GetPodLogs
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"portforwardtester"
)
if
err
!=
nil
{
framework
.
Logf
(
"Error getting pod log: %v"
,
err
)
}
else
{
framework
.
Logf
(
"Pod log:
\n
%s"
,
logs
)
}
}()
By
(
"Running 'kubectl port-forward'"
)
By
(
"Running 'kubectl port-forward'"
)
cmd
:=
runPortForward
(
f
.
Namespace
.
Name
,
pod
.
Name
,
80
)
cmd
:=
runPortForward
(
f
.
Namespace
.
Name
,
pod
.
Name
,
80
)
...
@@ -241,12 +238,12 @@ func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
...
@@ -241,12 +238,12 @@ func doTestConnectSendDisconnect(bindAddress string, f *framework.Framework) {
}
}
By
(
"Verifying logs"
)
By
(
"Verifying logs"
)
logOutput
,
err
:=
framework
.
GetPodLogs
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"portforwardtester"
)
Eventually
(
func
()
(
string
,
error
)
{
if
err
!=
nil
{
return
framework
.
GetPodLogs
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"portforwardtester"
)
framework
.
Failf
(
"Error retrieving pod logs: %v"
,
err
)
},
postStartWaitTimeout
,
podCheckInterval
)
.
Should
(
SatisfyAll
(
}
ContainSubstring
(
"Accepted client connection"
),
verifyLogMessage
(
logOutput
,
"Accepted client connection"
)
ContainSubstring
(
"Done"
),
verifyLogMessage
(
logOutput
,
"Done"
)
)
)
}
}
func
doTestMustConnectSendNothing
(
bindAddress
string
,
f
*
framework
.
Framework
)
{
func
doTestMustConnectSendNothing
(
bindAddress
string
,
f
*
framework
.
Framework
)
{
...
@@ -258,14 +255,6 @@ func doTestMustConnectSendNothing(bindAddress string, f *framework.Framework) {
...
@@ -258,14 +255,6 @@ func doTestMustConnectSendNothing(bindAddress string, f *framework.Framework) {
if
err
:=
f
.
WaitForPodReady
(
pod
.
Name
);
err
!=
nil
{
if
err
:=
f
.
WaitForPodReady
(
pod
.
Name
);
err
!=
nil
{
framework
.
Failf
(
"Pod did not start running: %v"
,
err
)
framework
.
Failf
(
"Pod did not start running: %v"
,
err
)
}
}
defer
func
()
{
logs
,
err
:=
framework
.
GetPodLogs
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"portforwardtester"
)
if
err
!=
nil
{
framework
.
Logf
(
"Error getting pod log: %v"
,
err
)
}
else
{
framework
.
Logf
(
"Pod log:
\n
%s"
,
logs
)
}
}()
By
(
"Running 'kubectl port-forward'"
)
By
(
"Running 'kubectl port-forward'"
)
cmd
:=
runPortForward
(
f
.
Namespace
.
Name
,
pod
.
Name
,
80
)
cmd
:=
runPortForward
(
f
.
Namespace
.
Name
,
pod
.
Name
,
80
)
...
@@ -286,12 +275,12 @@ func doTestMustConnectSendNothing(bindAddress string, f *framework.Framework) {
...
@@ -286,12 +275,12 @@ func doTestMustConnectSendNothing(bindAddress string, f *framework.Framework) {
}
}
By
(
"Verifying logs"
)
By
(
"Verifying logs"
)
logOutput
,
err
:=
framework
.
GetPodLogs
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"portforwardtester"
)
Eventually
(
func
()
(
string
,
error
)
{
if
err
!=
nil
{
return
framework
.
GetPodLogs
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"portforwardtester"
)
framework
.
Failf
(
"Error retrieving pod logs: %v"
,
err
)
},
postStartWaitTimeout
,
podCheckInterval
)
.
Should
(
SatisfyAll
(
}
ContainSubstring
(
"Accepted client connection"
),
verifyLogMessage
(
logOutput
,
"Accepted client connection"
)
ContainSubstring
(
"Expected to read 3 bytes from client, but got 0 instead"
),
verifyLogMessage
(
logOutput
,
"Expected to read 3 bytes from client, but got 0 instead"
)
)
)
}
}
func
doTestMustConnectSendDisconnect
(
bindAddress
string
,
f
*
framework
.
Framework
)
{
func
doTestMustConnectSendDisconnect
(
bindAddress
string
,
f
*
framework
.
Framework
)
{
...
@@ -303,14 +292,6 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
...
@@ -303,14 +292,6 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
if
err
:=
f
.
WaitForPodReady
(
pod
.
Name
);
err
!=
nil
{
if
err
:=
f
.
WaitForPodReady
(
pod
.
Name
);
err
!=
nil
{
framework
.
Failf
(
"Pod did not start running: %v"
,
err
)
framework
.
Failf
(
"Pod did not start running: %v"
,
err
)
}
}
defer
func
()
{
logs
,
err
:=
framework
.
GetPodLogs
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"portforwardtester"
)
if
err
!=
nil
{
framework
.
Logf
(
"Error getting pod log: %v"
,
err
)
}
else
{
framework
.
Logf
(
"Pod log:
\n
%s"
,
logs
)
}
}()
By
(
"Running 'kubectl port-forward'"
)
By
(
"Running 'kubectl port-forward'"
)
cmd
:=
runPortForward
(
f
.
Namespace
.
Name
,
pod
.
Name
,
80
)
cmd
:=
runPortForward
(
f
.
Namespace
.
Name
,
pod
.
Name
,
80
)
...
@@ -352,13 +333,13 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
...
@@ -352,13 +333,13 @@ func doTestMustConnectSendDisconnect(bindAddress string, f *framework.Framework)
}
}
By
(
"Verifying logs"
)
By
(
"Verifying logs"
)
logOutput
,
err
:=
framework
.
GetPodLogs
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"portforwardtester"
)
Eventually
(
func
()
(
string
,
error
)
{
if
err
!=
nil
{
return
framework
.
GetPodLogs
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"portforwardtester"
)
framework
.
Failf
(
"Error retrieving pod logs: %v"
,
err
)
},
postStartWaitTimeout
,
podCheckInterval
)
.
Should
(
SatisfyAll
(
}
ContainSubstring
(
"Accepted client connection"
),
verifyLogMessage
(
logOutput
,
"^Accepted client connection$"
)
ContainSubstring
(
"Received expected client data"
),
verifyLogMessage
(
logOutput
,
"^Received expected client data$"
)
ContainSubstring
(
"Done"
),
verifyLogMessage
(
logOutput
,
"^Done$"
)
)
)
}
}
func
doTestOverWebSockets
(
bindAddress
string
,
f
*
framework
.
Framework
)
{
func
doTestOverWebSockets
(
bindAddress
string
,
f
*
framework
.
Framework
)
{
...
@@ -373,14 +354,6 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
...
@@ -373,14 +354,6 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
if
err
:=
f
.
WaitForPodReady
(
pod
.
Name
);
err
!=
nil
{
if
err
:=
f
.
WaitForPodReady
(
pod
.
Name
);
err
!=
nil
{
framework
.
Failf
(
"Pod did not start running: %v"
,
err
)
framework
.
Failf
(
"Pod did not start running: %v"
,
err
)
}
}
defer
func
()
{
logs
,
err
:=
framework
.
GetPodLogs
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"portforwardtester"
)
if
err
!=
nil
{
framework
.
Logf
(
"Error getting pod log: %v"
,
err
)
}
else
{
framework
.
Logf
(
"Pod log:
\n
%s"
,
logs
)
}
}()
req
:=
f
.
ClientSet
.
CoreV1
()
.
RESTClient
()
.
Get
()
.
req
:=
f
.
ClientSet
.
CoreV1
()
.
RESTClient
()
.
Get
()
.
Namespace
(
f
.
Namespace
.
Name
)
.
Namespace
(
f
.
Namespace
.
Name
)
.
...
@@ -449,12 +422,12 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
...
@@ -449,12 +422,12 @@ func doTestOverWebSockets(bindAddress string, f *framework.Framework) {
},
time
.
Minute
,
10
*
time
.
Second
)
.
Should
(
BeNil
())
},
time
.
Minute
,
10
*
time
.
Second
)
.
Should
(
BeNil
())
By
(
"Verifying logs"
)
By
(
"Verifying logs"
)
logOutput
,
err
:=
framework
.
GetPodLogs
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"portforwardtester"
)
Eventually
(
func
()
(
string
,
error
)
{
if
err
!=
nil
{
return
framework
.
GetPodLogs
(
f
.
ClientSet
,
f
.
Namespace
.
Name
,
pod
.
Name
,
"portforwardtester"
)
framework
.
Failf
(
"Error retrieving pod logs: %v"
,
err
)
},
postStartWaitTimeout
,
podCheckInterval
)
.
Should
(
SatisfyAll
(
}
ContainSubstring
(
"Accepted client connection"
),
verifyLogMessage
(
logOutput
,
"^Accepted client connection$"
)
ContainSubstring
(
"Received expected client data"
),
verifyLogMessage
(
logOutput
,
"^Received expected client data$"
)
)
)
}
}
var
_
=
SIGDescribe
(
"Kubectl Port forwarding"
,
func
()
{
var
_
=
SIGDescribe
(
"Kubectl Port forwarding"
,
func
()
{
...
@@ -504,17 +477,6 @@ var _ = SIGDescribe("Kubectl Port forwarding", func() {
...
@@ -504,17 +477,6 @@ var _ = SIGDescribe("Kubectl Port forwarding", func() {
})
})
})
})
func
verifyLogMessage
(
log
,
expected
string
)
{
re
:=
regexp
.
MustCompile
(
expected
)
lines
:=
strings
.
Split
(
log
,
"
\n
"
)
for
i
:=
range
lines
{
if
re
.
MatchString
(
lines
[
i
])
{
return
}
}
framework
.
Failf
(
"Missing %q from log: %s"
,
expected
,
log
)
}
func
wsRead
(
conn
*
websocket
.
Conn
)
(
byte
,
[]
byte
,
error
)
{
func
wsRead
(
conn
*
websocket
.
Conn
)
(
byte
,
[]
byte
,
error
)
{
for
{
for
{
var
data
[]
byte
var
data
[]
byte
...
...
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