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
bc92fd6a
Commit
bc92fd6a
authored
Jan 08, 2016
by
James DeFelice
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a timeout for job runs in case something gets stuck
parent
b7438274
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
+27
-4
test-e2e.sh
cluster/test-e2e.sh
+1
-1
kubectl.go
test/e2e/kubectl.go
+4
-0
util.go
test/e2e/util.go
+22
-3
No files found.
cluster/test-e2e.sh
View file @
bc92fd6a
...
...
@@ -30,4 +30,4 @@ TEST_ARGS="$@"
echo
"Running e2e tests:"
1>&2
echo
"./hack/ginkgo-e2e.sh
${
TEST_ARGS
}
"
1>&2
exec
"
${
KUBE_ROOT
}
/hack/ginkgo-e2e.sh"
${
TEST_ARGS
}
exec
"
${
KUBE_ROOT
}
/hack/ginkgo-e2e.sh"
"
$@
"
test/e2e/kubectl.go
View file @
bc92fd6a
...
...
@@ -70,6 +70,7 @@ const (
simplePodName
=
"nginx"
nginxDefaultOutput
=
"Welcome to nginx!"
simplePodPort
=
80
runJobTimeout
=
5
*
time
.
Minute
)
var
proxyRegexp
=
regexp
.
MustCompile
(
"Starting to serve on 127.0.0.1:([0-9]+)"
)
...
...
@@ -911,8 +912,11 @@ var _ = Describe("Kubectl client", func() {
It
(
"should create a job from an image, then delete the job [Conformance]"
,
func
()
{
By
(
"executing a command with run --rm and attach with stdin"
)
t
:=
time
.
NewTimer
(
runJobTimeout
)
defer
t
.
Stop
()
runOutput
:=
newKubectlCommand
(
nsFlag
,
"run"
,
jobName
,
"--image=busybox"
,
"--rm=true"
,
"--restart=Never"
,
"--attach=true"
,
"--stdin"
,
"--"
,
"sh"
,
"-c"
,
"cat && echo 'stdin closed'"
)
.
withStdinData
(
"abcd1234"
)
.
withTimeout
(
t
.
C
)
.
execOrDie
()
Expect
(
runOutput
)
.
To
(
ContainSubstring
(
"abcd1234"
))
Expect
(
runOutput
)
.
To
(
ContainSubstring
(
"stdin closed"
))
...
...
test/e2e/util.go
View file @
bc92fd6a
...
...
@@ -1189,7 +1189,8 @@ func kubectlCmd(args ...string) *exec.Cmd {
// kubectlBuilder is used to build, custimize and execute a kubectl Command.
// Add more functions to customize the builder as needed.
type
kubectlBuilder
struct
{
cmd
*
exec
.
Cmd
cmd
*
exec
.
Cmd
timeout
<-
chan
time
.
Time
}
func
newKubectlCommand
(
args
...
string
)
*
kubectlBuilder
{
...
...
@@ -1198,6 +1199,11 @@ func newKubectlCommand(args ...string) *kubectlBuilder {
return
b
}
func
(
b
*
kubectlBuilder
)
withTimeout
(
t
<-
chan
time
.
Time
)
*
kubectlBuilder
{
b
.
timeout
=
t
return
b
}
func
(
b
kubectlBuilder
)
withStdinData
(
data
string
)
*
kubectlBuilder
{
b
.
cmd
.
Stdin
=
strings
.
NewReader
(
data
)
return
&
b
...
...
@@ -1220,8 +1226,21 @@ func (b kubectlBuilder) exec() (string, error) {
cmd
.
Stdout
,
cmd
.
Stderr
=
&
stdout
,
&
stderr
Logf
(
"Running '%s %s'"
,
cmd
.
Path
,
strings
.
Join
(
cmd
.
Args
[
1
:
],
" "
))
// skip arg[0] as it is printed separately
if
err
:=
cmd
.
Run
();
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"Error running %v:
\n
Command stdout:
\n
%v
\n
stderr:
\n
%v
\n
error:
\n
%v
\n
"
,
cmd
,
cmd
.
Stdout
,
cmd
.
Stderr
,
err
)
if
err
:=
cmd
.
Start
();
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"Error starting %v:
\n
Command stdout:
\n
%v
\n
stderr:
\n
%v
\n
error:
\n
%v
\n
"
,
cmd
,
cmd
.
Stdout
,
cmd
.
Stderr
,
err
)
}
errCh
:=
make
(
chan
error
,
1
)
go
func
()
{
errCh
<-
cmd
.
Wait
()
}()
select
{
case
err
:=
<-
errCh
:
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"Error running %v:
\n
Command stdout:
\n
%v
\n
stderr:
\n
%v
\n
error:
\n
%v
\n
"
,
cmd
,
cmd
.
Stdout
,
cmd
.
Stderr
,
err
)
}
case
<-
b
.
timeout
:
b
.
cmd
.
Process
.
Kill
()
return
""
,
fmt
.
Errorf
(
"Timed out waiting for command %v:
\n
Command stdout:
\n
%v
\n
stderr:
\n
%v
\n
"
,
cmd
,
cmd
.
Stdout
,
cmd
.
Stderr
)
}
Logf
(
"stdout: %q"
,
stdout
.
String
())
Logf
(
"stderr: %q"
,
stderr
.
String
())
...
...
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