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
08562057
Unverified
Commit
08562057
authored
Apr 09, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Apr 09, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #76324 from SataQiu/refactor-e2e-framework-20190409
Refactor and clean up e2e/framework/exec_util.go
parents
701d28f6
55b322e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
exec_util.go
test/e2e/framework/exec_util.go
+8
-11
No files found.
test/e2e/framework/exec_util.go
View file @
08562057
...
@@ -33,12 +33,10 @@ import (
...
@@ -33,12 +33,10 @@ import (
// ExecOptions passed to ExecWithOptions
// ExecOptions passed to ExecWithOptions
type
ExecOptions
struct
{
type
ExecOptions
struct
{
Command
[]
string
Command
[]
string
Namespace
string
Namespace
string
PodName
string
PodName
string
ContainerName
string
ContainerName
string
Stdin
io
.
Reader
Stdin
io
.
Reader
CaptureStdout
bool
CaptureStdout
bool
CaptureStderr
bool
CaptureStderr
bool
...
@@ -85,11 +83,10 @@ func (f *Framework) ExecWithOptions(options ExecOptions) (string, string, error)
...
@@ -85,11 +83,10 @@ func (f *Framework) ExecWithOptions(options ExecOptions) (string, string, error)
// specified container and return stdout, stderr and error
// specified container and return stdout, stderr and error
func
(
f
*
Framework
)
ExecCommandInContainerWithFullOutput
(
podName
,
containerName
string
,
cmd
...
string
)
(
string
,
string
,
error
)
{
func
(
f
*
Framework
)
ExecCommandInContainerWithFullOutput
(
podName
,
containerName
string
,
cmd
...
string
)
(
string
,
string
,
error
)
{
return
f
.
ExecWithOptions
(
ExecOptions
{
return
f
.
ExecWithOptions
(
ExecOptions
{
Command
:
cmd
,
Command
:
cmd
,
Namespace
:
f
.
Namespace
.
Name
,
Namespace
:
f
.
Namespace
.
Name
,
PodName
:
podName
,
PodName
:
podName
,
ContainerName
:
containerName
,
ContainerName
:
containerName
,
Stdin
:
nil
,
Stdin
:
nil
,
CaptureStdout
:
true
,
CaptureStdout
:
true
,
CaptureStderr
:
true
,
CaptureStderr
:
true
,
...
@@ -114,14 +111,14 @@ func (f *Framework) ExecShellInContainer(podName, containerName string, cmd stri
...
@@ -114,14 +111,14 @@ func (f *Framework) ExecShellInContainer(podName, containerName string, cmd stri
func
(
f
*
Framework
)
execCommandInPod
(
podName
string
,
cmd
...
string
)
string
{
func
(
f
*
Framework
)
execCommandInPod
(
podName
string
,
cmd
...
string
)
string
{
pod
,
err
:=
f
.
PodClient
()
.
Get
(
podName
,
metav1
.
GetOptions
{})
pod
,
err
:=
f
.
PodClient
()
.
Get
(
podName
,
metav1
.
GetOptions
{})
ExpectNoError
(
err
,
"failed to get pod
"
)
ExpectNoError
(
err
,
"failed to get pod
%v"
,
podName
)
gomega
.
Expect
(
pod
.
Spec
.
Containers
)
.
NotTo
(
gomega
.
BeEmpty
())
gomega
.
Expect
(
pod
.
Spec
.
Containers
)
.
NotTo
(
gomega
.
BeEmpty
())
return
f
.
ExecCommandInContainer
(
podName
,
pod
.
Spec
.
Containers
[
0
]
.
Name
,
cmd
...
)
return
f
.
ExecCommandInContainer
(
podName
,
pod
.
Spec
.
Containers
[
0
]
.
Name
,
cmd
...
)
}
}
func
(
f
*
Framework
)
execCommandInPodWithFullOutput
(
podName
string
,
cmd
...
string
)
(
string
,
string
,
error
)
{
func
(
f
*
Framework
)
execCommandInPodWithFullOutput
(
podName
string
,
cmd
...
string
)
(
string
,
string
,
error
)
{
pod
,
err
:=
f
.
PodClient
()
.
Get
(
podName
,
metav1
.
GetOptions
{})
pod
,
err
:=
f
.
PodClient
()
.
Get
(
podName
,
metav1
.
GetOptions
{})
ExpectNoError
(
err
,
"failed to get pod
"
)
ExpectNoError
(
err
,
"failed to get pod
%v"
,
podName
)
gomega
.
Expect
(
pod
.
Spec
.
Containers
)
.
NotTo
(
gomega
.
BeEmpty
())
gomega
.
Expect
(
pod
.
Spec
.
Containers
)
.
NotTo
(
gomega
.
BeEmpty
())
return
f
.
ExecCommandInContainerWithFullOutput
(
podName
,
pod
.
Spec
.
Containers
[
0
]
.
Name
,
cmd
...
)
return
f
.
ExecCommandInContainerWithFullOutput
(
podName
,
pod
.
Spec
.
Containers
[
0
]
.
Name
,
cmd
...
)
}
}
...
@@ -131,7 +128,7 @@ func (f *Framework) ExecShellInPod(podName string, cmd string) string {
...
@@ -131,7 +128,7 @@ func (f *Framework) ExecShellInPod(podName string, cmd string) string {
return
f
.
execCommandInPod
(
podName
,
"/bin/sh"
,
"-c"
,
cmd
)
return
f
.
execCommandInPod
(
podName
,
"/bin/sh"
,
"-c"
,
cmd
)
}
}
// ExecShellInPodWithFullOutput executes the specified command on the
pod with returing return
stdout, stderr and error.
// ExecShellInPodWithFullOutput executes the specified command on the
Pod and returns
stdout, stderr and error.
func
(
f
*
Framework
)
ExecShellInPodWithFullOutput
(
podName
string
,
cmd
string
)
(
string
,
string
,
error
)
{
func
(
f
*
Framework
)
ExecShellInPodWithFullOutput
(
podName
string
,
cmd
string
)
(
string
,
string
,
error
)
{
return
f
.
execCommandInPodWithFullOutput
(
podName
,
"/bin/sh"
,
"-c"
,
cmd
)
return
f
.
execCommandInPodWithFullOutput
(
podName
,
"/bin/sh"
,
"-c"
,
cmd
)
}
}
...
...
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