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
71bbabc3
Unverified
Commit
71bbabc3
authored
May 08, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 08, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77486 from jiatongw/logf/kubectl
Modify e2e/kubectl tests to import e2elog.Logf
parents
19431e01
3b5bedd7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
32 deletions
+35
-32
BUILD
test/e2e/kubectl/BUILD
+1
-0
kubectl.go
test/e2e/kubectl/kubectl.go
+26
-25
portforward.go
test/e2e/kubectl/portforward.go
+8
-7
No files found.
test/e2e/kubectl/BUILD
View file @
71bbabc3
...
@@ -33,6 +33,7 @@ go_library(
...
@@ -33,6 +33,7 @@ go_library(
"//test/e2e/framework:go_default_library",
"//test/e2e/framework:go_default_library",
"//test/e2e/framework/auth:go_default_library",
"//test/e2e/framework/auth:go_default_library",
"//test/e2e/framework/job:go_default_library",
"//test/e2e/framework/job:go_default_library",
"//test/e2e/framework/log:go_default_library",
"//test/e2e/framework/testfiles:go_default_library",
"//test/e2e/framework/testfiles:go_default_library",
"//test/e2e/scheduling:go_default_library",
"//test/e2e/scheduling:go_default_library",
"//test/utils:go_default_library",
"//test/utils:go_default_library",
...
...
test/e2e/kubectl/kubectl.go
View file @
71bbabc3
...
@@ -60,6 +60,7 @@ import (
...
@@ -60,6 +60,7 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework/auth"
"k8s.io/kubernetes/test/e2e/framework/auth"
jobutil
"k8s.io/kubernetes/test/e2e/framework/job"
jobutil
"k8s.io/kubernetes/test/e2e/framework/job"
e2elog
"k8s.io/kubernetes/test/e2e/framework/log"
"k8s.io/kubernetes/test/e2e/framework/testfiles"
"k8s.io/kubernetes/test/e2e/framework/testfiles"
"k8s.io/kubernetes/test/e2e/scheduling"
"k8s.io/kubernetes/test/e2e/scheduling"
testutils
"k8s.io/kubernetes/test/utils"
testutils
"k8s.io/kubernetes/test/utils"
...
@@ -140,7 +141,7 @@ func runKubectlRetryOrDie(args ...string) string {
...
@@ -140,7 +141,7 @@ func runKubectlRetryOrDie(args ...string) string {
}
}
// Expect no errors to be present after retries are finished
// Expect no errors to be present after retries are finished
// Copied from framework #ExecOrDie
// Copied from framework #ExecOrDie
framework
.
Logf
(
"stdout: %q"
,
output
)
e2elog
.
Logf
(
"stdout: %q"
,
output
)
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
return
output
return
output
}
}
...
@@ -234,7 +235,7 @@ var _ = SIGDescribe("Kubectl client", func() {
...
@@ -234,7 +235,7 @@ var _ = SIGDescribe("Kubectl client", func() {
debugDiscovery
:=
func
()
{
debugDiscovery
:=
func
()
{
home
:=
os
.
Getenv
(
"HOME"
)
home
:=
os
.
Getenv
(
"HOME"
)
if
len
(
home
)
==
0
{
if
len
(
home
)
==
0
{
framework
.
Logf
(
"no $HOME envvar set"
)
e2elog
.
Logf
(
"no $HOME envvar set"
)
return
return
}
}
...
@@ -250,17 +251,17 @@ var _ = SIGDescribe("Kubectl client", func() {
...
@@ -250,17 +251,17 @@ var _ = SIGDescribe("Kubectl client", func() {
if
len
(
parts
)
!=
3
||
parts
[
1
]
!=
"v1"
||
parts
[
2
]
!=
"serverresources.json"
{
if
len
(
parts
)
!=
3
||
parts
[
1
]
!=
"v1"
||
parts
[
2
]
!=
"serverresources.json"
{
return
nil
return
nil
}
}
framework
.
Logf
(
"%s modified at %s (current time: %s)"
,
path
,
info
.
ModTime
(),
time
.
Now
())
e2elog
.
Logf
(
"%s modified at %s (current time: %s)"
,
path
,
info
.
ModTime
(),
time
.
Now
())
data
,
readError
:=
ioutil
.
ReadFile
(
path
)
data
,
readError
:=
ioutil
.
ReadFile
(
path
)
if
readError
!=
nil
{
if
readError
!=
nil
{
framework
.
Logf
(
"%s error: %v"
,
path
,
readError
)
e2elog
.
Logf
(
"%s error: %v"
,
path
,
readError
)
}
else
{
}
else
{
framework
.
Logf
(
"%s content: %s"
,
path
,
string
(
data
))
e2elog
.
Logf
(
"%s content: %s"
,
path
,
string
(
data
))
}
}
return
nil
return
nil
})
})
framework
.
Logf
(
"scanned %s for discovery docs: %v"
,
home
,
err
)
e2elog
.
Logf
(
"scanned %s for discovery docs: %v"
,
home
,
err
)
}
}
framework
.
KubeDescribe
(
"Update Demo"
,
func
()
{
framework
.
KubeDescribe
(
"Update Demo"
,
func
()
{
...
@@ -348,7 +349,7 @@ var _ = SIGDescribe("Kubectl client", func() {
...
@@ -348,7 +349,7 @@ var _ = SIGDescribe("Kubectl client", func() {
})
})
ginkgo
.
By
(
"creating all guestbook components"
)
ginkgo
.
By
(
"creating all guestbook components"
)
forEachGBFile
(
func
(
contents
string
)
{
forEachGBFile
(
func
(
contents
string
)
{
framework
.
Logf
(
contents
)
e2elog
.
Logf
(
contents
)
framework
.
RunKubectlOrDieInput
(
contents
,
"create"
,
"-f"
,
"-"
,
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
))
framework
.
RunKubectlOrDieInput
(
contents
,
"create"
,
"-f"
,
"-"
,
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
))
})
})
...
@@ -604,7 +605,7 @@ var _ = SIGDescribe("Kubectl client", func() {
...
@@ -604,7 +605,7 @@ var _ = SIGDescribe("Kubectl client", func() {
ginkgo
.
By
(
"curling local port output"
)
ginkgo
.
By
(
"curling local port output"
)
localAddr
:=
fmt
.
Sprintf
(
"http://localhost:%d"
,
cmd
.
port
)
localAddr
:=
fmt
.
Sprintf
(
"http://localhost:%d"
,
cmd
.
port
)
body
,
err
:=
curl
(
localAddr
)
body
,
err
:=
curl
(
localAddr
)
framework
.
Logf
(
"got: %s"
,
body
)
e2elog
.
Logf
(
"got: %s"
,
body
)
if
err
!=
nil
{
if
err
!=
nil
{
framework
.
Failf
(
"Failed http.Get of forwarded port (%s): %v"
,
localAddr
,
err
)
framework
.
Failf
(
"Failed http.Get of forwarded port (%s): %v"
,
localAddr
,
err
)
}
}
...
@@ -639,7 +640,7 @@ var _ = SIGDescribe("Kubectl client", func() {
...
@@ -639,7 +640,7 @@ var _ = SIGDescribe("Kubectl client", func() {
inClusterHost
:=
strings
.
TrimSpace
(
framework
.
RunHostCmdOrDie
(
ns
,
simplePodName
,
"printenv KUBERNETES_SERVICE_HOST"
))
inClusterHost
:=
strings
.
TrimSpace
(
framework
.
RunHostCmdOrDie
(
ns
,
simplePodName
,
"printenv KUBERNETES_SERVICE_HOST"
))
inClusterPort
:=
strings
.
TrimSpace
(
framework
.
RunHostCmdOrDie
(
ns
,
simplePodName
,
"printenv KUBERNETES_SERVICE_PORT"
))
inClusterPort
:=
strings
.
TrimSpace
(
framework
.
RunHostCmdOrDie
(
ns
,
simplePodName
,
"printenv KUBERNETES_SERVICE_PORT"
))
framework
.
Logf
(
"copying %s to the %s pod"
,
kubectlPath
,
simplePodName
)
e2elog
.
Logf
(
"copying %s to the %s pod"
,
kubectlPath
,
simplePodName
)
framework
.
RunKubectlOrDie
(
"cp"
,
kubectlPath
,
ns
+
"/"
+
simplePodName
+
":/tmp/"
)
framework
.
RunKubectlOrDie
(
"cp"
,
kubectlPath
,
ns
+
"/"
+
simplePodName
+
":/tmp/"
)
// Build a kubeconfig file that will make use of the injected ca and token,
// Build a kubeconfig file that will make use of the injected ca and token,
...
@@ -669,7 +670,7 @@ users:
...
@@ -669,7 +670,7 @@ users:
user:
user:
tokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
tokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
`
),
os
.
FileMode
(
0755
)))
`
),
os
.
FileMode
(
0755
)))
framework
.
Logf
(
"copying override kubeconfig to the %s pod"
,
simplePodName
)
e2elog
.
Logf
(
"copying override kubeconfig to the %s pod"
,
simplePodName
)
framework
.
RunKubectlOrDie
(
"cp"
,
filepath
.
Join
(
tmpDir
,
overrideKubeconfigName
),
ns
+
"/"
+
simplePodName
+
":/tmp/"
)
framework
.
RunKubectlOrDie
(
"cp"
,
filepath
.
Join
(
tmpDir
,
overrideKubeconfigName
),
ns
+
"/"
+
simplePodName
+
":/tmp/"
)
framework
.
ExpectNoError
(
ioutil
.
WriteFile
(
filepath
.
Join
(
tmpDir
,
"invalid-configmap-with-namespace.yaml"
),
[]
byte
(
`
framework
.
ExpectNoError
(
ioutil
.
WriteFile
(
filepath
.
Join
(
tmpDir
,
"invalid-configmap-with-namespace.yaml"
),
[]
byte
(
`
...
@@ -685,7 +686,7 @@ apiVersion: v1
...
@@ -685,7 +686,7 @@ apiVersion: v1
metadata:
metadata:
name: "configmap without namespace and invalid name"
name: "configmap without namespace and invalid name"
`
),
os
.
FileMode
(
0755
)))
`
),
os
.
FileMode
(
0755
)))
framework
.
Logf
(
"copying configmap manifests to the %s pod"
,
simplePodName
)
e2elog
.
Logf
(
"copying configmap manifests to the %s pod"
,
simplePodName
)
framework
.
RunKubectlOrDie
(
"cp"
,
filepath
.
Join
(
tmpDir
,
"invalid-configmap-with-namespace.yaml"
),
ns
+
"/"
+
simplePodName
+
":/tmp/"
)
framework
.
RunKubectlOrDie
(
"cp"
,
filepath
.
Join
(
tmpDir
,
"invalid-configmap-with-namespace.yaml"
),
ns
+
"/"
+
simplePodName
+
":/tmp/"
)
framework
.
RunKubectlOrDie
(
"cp"
,
filepath
.
Join
(
tmpDir
,
"invalid-configmap-without-namespace.yaml"
),
ns
+
"/"
+
simplePodName
+
":/tmp/"
)
framework
.
RunKubectlOrDie
(
"cp"
,
filepath
.
Join
(
tmpDir
,
"invalid-configmap-without-namespace.yaml"
),
ns
+
"/"
+
simplePodName
+
":/tmp/"
)
...
@@ -709,7 +710,7 @@ metadata:
...
@@ -709,7 +710,7 @@ metadata:
ginkgo
.
By
(
"trying to use kubectl with invalid token"
)
ginkgo
.
By
(
"trying to use kubectl with invalid token"
)
_
,
err
=
framework
.
RunHostCmd
(
ns
,
simplePodName
,
"/tmp/kubectl get pods --token=invalid --v=7 2>&1"
)
_
,
err
=
framework
.
RunHostCmd
(
ns
,
simplePodName
,
"/tmp/kubectl get pods --token=invalid --v=7 2>&1"
)
framework
.
Logf
(
"got err %v"
,
err
)
e2elog
.
Logf
(
"got err %v"
,
err
)
gomega
.
Expect
(
err
)
.
To
(
gomega
.
HaveOccurred
())
gomega
.
Expect
(
err
)
.
To
(
gomega
.
HaveOccurred
())
gomega
.
Expect
(
err
)
.
To
(
gomega
.
ContainSubstring
(
"Using in-cluster namespace"
))
gomega
.
Expect
(
err
)
.
To
(
gomega
.
ContainSubstring
(
"Using in-cluster namespace"
))
gomega
.
Expect
(
err
)
.
To
(
gomega
.
ContainSubstring
(
"Using in-cluster configuration"
))
gomega
.
Expect
(
err
)
.
To
(
gomega
.
ContainSubstring
(
"Using in-cluster configuration"
))
...
@@ -718,7 +719,7 @@ metadata:
...
@@ -718,7 +719,7 @@ metadata:
ginkgo
.
By
(
"trying to use kubectl with invalid server"
)
ginkgo
.
By
(
"trying to use kubectl with invalid server"
)
_
,
err
=
framework
.
RunHostCmd
(
ns
,
simplePodName
,
"/tmp/kubectl get pods --server=invalid --v=6 2>&1"
)
_
,
err
=
framework
.
RunHostCmd
(
ns
,
simplePodName
,
"/tmp/kubectl get pods --server=invalid --v=6 2>&1"
)
framework
.
Logf
(
"got err %v"
,
err
)
e2elog
.
Logf
(
"got err %v"
,
err
)
gomega
.
Expect
(
err
)
.
To
(
gomega
.
HaveOccurred
())
gomega
.
Expect
(
err
)
.
To
(
gomega
.
HaveOccurred
())
gomega
.
Expect
(
err
)
.
To
(
gomega
.
ContainSubstring
(
"Unable to connect to the server"
))
gomega
.
Expect
(
err
)
.
To
(
gomega
.
ContainSubstring
(
"Unable to connect to the server"
))
gomega
.
Expect
(
err
)
.
To
(
gomega
.
ContainSubstring
(
"GET http://invalid/api"
))
gomega
.
Expect
(
err
)
.
To
(
gomega
.
ContainSubstring
(
"GET http://invalid/api"
))
...
@@ -1059,14 +1060,14 @@ metadata:
...
@@ -1059,14 +1060,14 @@ metadata:
ginkgo
.
By
(
"creating Redis RC"
)
ginkgo
.
By
(
"creating Redis RC"
)
framework
.
Logf
(
"namespace %v"
,
ns
)
e2elog
.
Logf
(
"namespace %v"
,
ns
)
framework
.
RunKubectlOrDieInput
(
controllerJSON
,
"create"
,
"-f"
,
"-"
,
nsFlag
)
framework
.
RunKubectlOrDieInput
(
controllerJSON
,
"create"
,
"-f"
,
"-"
,
nsFlag
)
// It may take a while for the pods to get registered in some cases, wait to be sure.
// It may take a while for the pods to get registered in some cases, wait to be sure.
ginkgo
.
By
(
"Waiting for Redis master to start."
)
ginkgo
.
By
(
"Waiting for Redis master to start."
)
waitForOrFailWithDebug
(
1
)
waitForOrFailWithDebug
(
1
)
forEachPod
(
func
(
pod
v1
.
Pod
)
{
forEachPod
(
func
(
pod
v1
.
Pod
)
{
framework
.
Logf
(
"wait on redis-master startup in %v "
,
ns
)
e2elog
.
Logf
(
"wait on redis-master startup in %v "
,
ns
)
framework
.
LookForStringInLog
(
ns
,
pod
.
Name
,
"redis-master"
,
"The server is now ready to accept connections"
,
framework
.
PodStartTimeout
)
framework
.
LookForStringInLog
(
ns
,
pod
.
Name
,
"redis-master"
,
"The server is now ready to accept connections"
,
framework
.
PodStartTimeout
)
})
})
validateService
:=
func
(
name
string
,
servicePort
int
,
timeout
time
.
Duration
)
{
validateService
:=
func
(
name
string
,
servicePort
int
,
timeout
time
.
Duration
)
{
...
@@ -1074,7 +1075,7 @@ metadata:
...
@@ -1074,7 +1075,7 @@ metadata:
endpoints
,
err
:=
c
.
CoreV1
()
.
Endpoints
(
ns
)
.
Get
(
name
,
metav1
.
GetOptions
{})
endpoints
,
err
:=
c
.
CoreV1
()
.
Endpoints
(
ns
)
.
Get
(
name
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
if
err
!=
nil
{
// log the real error
// log the real error
framework
.
Logf
(
"Get endpoints failed (interval %v): %v"
,
framework
.
Poll
,
err
)
e2elog
.
Logf
(
"Get endpoints failed (interval %v): %v"
,
framework
.
Poll
,
err
)
// if the error is API not found or could not find default credentials or TLS handshake timeout, try again
// if the error is API not found or could not find default credentials or TLS handshake timeout, try again
if
apierrs
.
IsNotFound
(
err
)
||
if
apierrs
.
IsNotFound
(
err
)
||
...
@@ -1087,7 +1088,7 @@ metadata:
...
@@ -1087,7 +1088,7 @@ metadata:
uidToPort
:=
framework
.
GetContainerPortsByPodUID
(
endpoints
)
uidToPort
:=
framework
.
GetContainerPortsByPodUID
(
endpoints
)
if
len
(
uidToPort
)
==
0
{
if
len
(
uidToPort
)
==
0
{
framework
.
Logf
(
"No endpoint found, retrying"
)
e2elog
.
Logf
(
"No endpoint found, retrying"
)
return
false
,
nil
return
false
,
nil
}
}
if
len
(
uidToPort
)
>
1
{
if
len
(
uidToPort
)
>
1
{
...
@@ -2070,21 +2071,21 @@ func curl(url string) (string, error) {
...
@@ -2070,21 +2071,21 @@ func curl(url string) (string, error) {
}
}
func
validateGuestbookApp
(
c
clientset
.
Interface
,
ns
string
)
{
func
validateGuestbookApp
(
c
clientset
.
Interface
,
ns
string
)
{
framework
.
Logf
(
"Waiting for all frontend pods to be Running."
)
e2elog
.
Logf
(
"Waiting for all frontend pods to be Running."
)
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"tier"
:
"frontend"
,
"app"
:
"guestbook"
}))
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"tier"
:
"frontend"
,
"app"
:
"guestbook"
}))
err
:=
testutils
.
WaitForPodsWithLabelRunning
(
c
,
ns
,
label
)
err
:=
testutils
.
WaitForPodsWithLabelRunning
(
c
,
ns
,
label
)
framework
.
ExpectNoError
(
err
)
framework
.
ExpectNoError
(
err
)
framework
.
Logf
(
"Waiting for frontend to serve content."
)
e2elog
.
Logf
(
"Waiting for frontend to serve content."
)
if
!
waitForGuestbookResponse
(
c
,
"get"
,
""
,
`{"data": ""}`
,
guestbookStartupTimeout
,
ns
)
{
if
!
waitForGuestbookResponse
(
c
,
"get"
,
""
,
`{"data": ""}`
,
guestbookStartupTimeout
,
ns
)
{
framework
.
Failf
(
"Frontend service did not start serving content in %v seconds."
,
guestbookStartupTimeout
.
Seconds
())
framework
.
Failf
(
"Frontend service did not start serving content in %v seconds."
,
guestbookStartupTimeout
.
Seconds
())
}
}
framework
.
Logf
(
"Trying to add a new entry to the guestbook."
)
e2elog
.
Logf
(
"Trying to add a new entry to the guestbook."
)
if
!
waitForGuestbookResponse
(
c
,
"set"
,
"TestEntry"
,
`{"message": "Updated"}`
,
guestbookResponseTimeout
,
ns
)
{
if
!
waitForGuestbookResponse
(
c
,
"set"
,
"TestEntry"
,
`{"message": "Updated"}`
,
guestbookResponseTimeout
,
ns
)
{
framework
.
Failf
(
"Cannot added new entry in %v seconds."
,
guestbookResponseTimeout
.
Seconds
())
framework
.
Failf
(
"Cannot added new entry in %v seconds."
,
guestbookResponseTimeout
.
Seconds
())
}
}
framework
.
Logf
(
"Verifying that added entry can be retrieved."
)
e2elog
.
Logf
(
"Verifying that added entry can be retrieved."
)
if
!
waitForGuestbookResponse
(
c
,
"get"
,
""
,
`{"data": "TestEntry"}`
,
guestbookResponseTimeout
,
ns
)
{
if
!
waitForGuestbookResponse
(
c
,
"get"
,
""
,
`{"data": "TestEntry"}`
,
guestbookResponseTimeout
,
ns
)
{
framework
.
Failf
(
"Entry to guestbook wasn't correctly added in %v seconds."
,
guestbookResponseTimeout
.
Seconds
())
framework
.
Failf
(
"Entry to guestbook wasn't correctly added in %v seconds."
,
guestbookResponseTimeout
.
Seconds
())
}
}
...
@@ -2097,7 +2098,7 @@ func waitForGuestbookResponse(c clientset.Interface, cmd, arg, expectedResponse
...
@@ -2097,7 +2098,7 @@ func waitForGuestbookResponse(c clientset.Interface, cmd, arg, expectedResponse
if
err
==
nil
&&
res
==
expectedResponse
{
if
err
==
nil
&&
res
==
expectedResponse
{
return
true
return
true
}
}
framework
.
Logf
(
"Failed to get response from guestbook. err: %v, response: %s"
,
err
,
res
)
e2elog
.
Logf
(
"Failed to get response from guestbook. err: %v, response: %s"
,
err
,
res
)
}
}
return
false
return
false
}
}
...
@@ -2192,7 +2193,7 @@ func getUDData(jpgExpected string, ns string) func(clientset.Interface, string)
...
@@ -2192,7 +2193,7 @@ func getUDData(jpgExpected string, ns string) func(clientset.Interface, string)
// getUDData validates data.json in the update-demo (returns nil if data is ok).
// getUDData validates data.json in the update-demo (returns nil if data is ok).
return
func
(
c
clientset
.
Interface
,
podID
string
)
error
{
return
func
(
c
clientset
.
Interface
,
podID
string
)
error
{
framework
.
Logf
(
"validating pod %s"
,
podID
)
e2elog
.
Logf
(
"validating pod %s"
,
podID
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
framework
.
SingleCallTimeout
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
framework
.
SingleCallTimeout
)
defer
cancel
()
defer
cancel
()
...
@@ -2212,12 +2213,12 @@ func getUDData(jpgExpected string, ns string) func(clientset.Interface, string)
...
@@ -2212,12 +2213,12 @@ func getUDData(jpgExpected string, ns string) func(clientset.Interface, string)
}
}
return
err
return
err
}
}
framework
.
Logf
(
"got data: %s"
,
body
)
e2elog
.
Logf
(
"got data: %s"
,
body
)
var
data
updateDemoData
var
data
updateDemoData
if
err
:=
json
.
Unmarshal
(
body
,
&
data
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
body
,
&
data
);
err
!=
nil
{
return
err
return
err
}
}
framework
.
Logf
(
"Unmarshalled json jpg/img => %s , expecting %s ."
,
data
,
jpgExpected
)
e2elog
.
Logf
(
"Unmarshalled json jpg/img => %s , expecting %s ."
,
data
,
jpgExpected
)
if
strings
.
Contains
(
data
.
Image
,
jpgExpected
)
{
if
strings
.
Contains
(
data
.
Image
,
jpgExpected
)
{
return
nil
return
nil
}
}
...
...
test/e2e/kubectl/portforward.go
View file @
71bbabc3
...
@@ -32,10 +32,11 @@ import (
...
@@ -32,10 +32,11 @@ import (
"time"
"time"
"golang.org/x/net/websocket"
"golang.org/x/net/websocket"
"k8s.io/api/core/v1"
v1
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
e2elog
"k8s.io/kubernetes/test/e2e/framework/log"
testutils
"k8s.io/kubernetes/test/utils"
testutils
"k8s.io/kubernetes/test/utils"
imageutils
"k8s.io/kubernetes/test/utils/image"
imageutils
"k8s.io/kubernetes/test/utils/image"
...
@@ -136,7 +137,7 @@ type portForwardCommand struct {
...
@@ -136,7 +137,7 @@ type portForwardCommand struct {
func
(
c
*
portForwardCommand
)
Stop
()
{
func
(
c
*
portForwardCommand
)
Stop
()
{
// SIGINT signals that kubectl port-forward should gracefully terminate
// SIGINT signals that kubectl port-forward should gracefully terminate
if
err
:=
c
.
cmd
.
Process
.
Signal
(
syscall
.
SIGINT
);
err
!=
nil
{
if
err
:=
c
.
cmd
.
Process
.
Signal
(
syscall
.
SIGINT
);
err
!=
nil
{
framework
.
Logf
(
"error sending SIGINT to kubectl port-forward: %v"
,
err
)
e2elog
.
Logf
(
"error sending SIGINT to kubectl port-forward: %v"
,
err
)
}
}
// try to wait for a clean exit
// try to wait for a clean exit
...
@@ -154,12 +155,12 @@ func (c *portForwardCommand) Stop() {
...
@@ -154,12 +155,12 @@ func (c *portForwardCommand) Stop() {
// success
// success
return
return
}
}
framework
.
Logf
(
"error waiting for kubectl port-forward to exit: %v"
,
err
)
e2elog
.
Logf
(
"error waiting for kubectl port-forward to exit: %v"
,
err
)
case
<-
expired
.
C
:
case
<-
expired
.
C
:
framework
.
Logf
(
"timed out waiting for kubectl port-forward to exit"
)
e2elog
.
Logf
(
"timed out waiting for kubectl port-forward to exit"
)
}
}
framework
.
Logf
(
"trying to forcibly kill kubectl port-forward"
)
e2elog
.
Logf
(
"trying to forcibly kill kubectl port-forward"
)
framework
.
TryKill
(
c
.
cmd
)
framework
.
TryKill
(
c
.
cmd
)
}
}
...
@@ -169,7 +170,7 @@ func runPortForward(ns, podName string, port int) *portForwardCommand {
...
@@ -169,7 +170,7 @@ func runPortForward(ns, podName string, port int) *portForwardCommand {
// This is somewhat ugly but is the only way to retrieve the port that was picked
// This is somewhat ugly but is the only way to retrieve the port that was picked
// by the port-forward command. We don't want to hard code the port as we have no
// by the port-forward command. We don't want to hard code the port as we have no
// way of guaranteeing we can pick one that isn't in use, particularly on Jenkins.
// way of guaranteeing we can pick one that isn't in use, particularly on Jenkins.
framework
.
Logf
(
"starting port-forward command and streaming output"
)
e2elog
.
Logf
(
"starting port-forward command and streaming output"
)
portOutput
,
_
,
err
:=
framework
.
StartCmdAndStreamOutput
(
cmd
)
portOutput
,
_
,
err
:=
framework
.
StartCmdAndStreamOutput
(
cmd
)
if
err
!=
nil
{
if
err
!=
nil
{
framework
.
Failf
(
"Failed to start port-forward command: %v"
,
err
)
framework
.
Failf
(
"Failed to start port-forward command: %v"
,
err
)
...
@@ -178,7 +179,7 @@ func runPortForward(ns, podName string, port int) *portForwardCommand {
...
@@ -178,7 +179,7 @@ func runPortForward(ns, podName string, port int) *portForwardCommand {
buf
:=
make
([]
byte
,
128
)
buf
:=
make
([]
byte
,
128
)
var
n
int
var
n
int
framework
.
Logf
(
"reading from `kubectl port-forward` command's stdout"
)
e2elog
.
Logf
(
"reading from `kubectl port-forward` command's stdout"
)
if
n
,
err
=
portOutput
.
Read
(
buf
);
err
!=
nil
{
if
n
,
err
=
portOutput
.
Read
(
buf
);
err
!=
nil
{
framework
.
Failf
(
"Failed to read from kubectl port-forward stdout: %v"
,
err
)
framework
.
Failf
(
"Failed to read from kubectl port-forward stdout: %v"
,
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