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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
2 deletions
+25
-2
test-e2e.sh
cluster/test-e2e.sh
+1
-1
kubectl.go
test/e2e/kubectl.go
+4
-0
util.go
test/e2e/util.go
+20
-1
No files found.
cluster/test-e2e.sh
View file @
bc92fd6a
...
@@ -30,4 +30,4 @@ TEST_ARGS="$@"
...
@@ -30,4 +30,4 @@ TEST_ARGS="$@"
echo
"Running e2e tests:"
1>&2
echo
"Running e2e tests:"
1>&2
echo
"./hack/ginkgo-e2e.sh
${
TEST_ARGS
}
"
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 (
...
@@ -70,6 +70,7 @@ const (
simplePodName
=
"nginx"
simplePodName
=
"nginx"
nginxDefaultOutput
=
"Welcome to nginx!"
nginxDefaultOutput
=
"Welcome to nginx!"
simplePodPort
=
80
simplePodPort
=
80
runJobTimeout
=
5
*
time
.
Minute
)
)
var
proxyRegexp
=
regexp
.
MustCompile
(
"Starting to serve on 127.0.0.1:([0-9]+)"
)
var
proxyRegexp
=
regexp
.
MustCompile
(
"Starting to serve on 127.0.0.1:([0-9]+)"
)
...
@@ -911,8 +912,11 @@ var _ = Describe("Kubectl client", func() {
...
@@ -911,8 +912,11 @@ var _ = Describe("Kubectl client", func() {
It
(
"should create a job from an image, then delete the job [Conformance]"
,
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"
)
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'"
)
.
runOutput
:=
newKubectlCommand
(
nsFlag
,
"run"
,
jobName
,
"--image=busybox"
,
"--rm=true"
,
"--restart=Never"
,
"--attach=true"
,
"--stdin"
,
"--"
,
"sh"
,
"-c"
,
"cat && echo 'stdin closed'"
)
.
withStdinData
(
"abcd1234"
)
.
withStdinData
(
"abcd1234"
)
.
withTimeout
(
t
.
C
)
.
execOrDie
()
execOrDie
()
Expect
(
runOutput
)
.
To
(
ContainSubstring
(
"abcd1234"
))
Expect
(
runOutput
)
.
To
(
ContainSubstring
(
"abcd1234"
))
Expect
(
runOutput
)
.
To
(
ContainSubstring
(
"stdin closed"
))
Expect
(
runOutput
)
.
To
(
ContainSubstring
(
"stdin closed"
))
...
...
test/e2e/util.go
View file @
bc92fd6a
...
@@ -1190,6 +1190,7 @@ func kubectlCmd(args ...string) *exec.Cmd {
...
@@ -1190,6 +1190,7 @@ func kubectlCmd(args ...string) *exec.Cmd {
// Add more functions to customize the builder as needed.
// Add more functions to customize the builder as needed.
type
kubectlBuilder
struct
{
type
kubectlBuilder
struct
{
cmd
*
exec
.
Cmd
cmd
*
exec
.
Cmd
timeout
<-
chan
time
.
Time
}
}
func
newKubectlCommand
(
args
...
string
)
*
kubectlBuilder
{
func
newKubectlCommand
(
args
...
string
)
*
kubectlBuilder
{
...
@@ -1198,6 +1199,11 @@ func newKubectlCommand(args ...string) *kubectlBuilder {
...
@@ -1198,6 +1199,11 @@ func newKubectlCommand(args ...string) *kubectlBuilder {
return
b
return
b
}
}
func
(
b
*
kubectlBuilder
)
withTimeout
(
t
<-
chan
time
.
Time
)
*
kubectlBuilder
{
b
.
timeout
=
t
return
b
}
func
(
b
kubectlBuilder
)
withStdinData
(
data
string
)
*
kubectlBuilder
{
func
(
b
kubectlBuilder
)
withStdinData
(
data
string
)
*
kubectlBuilder
{
b
.
cmd
.
Stdin
=
strings
.
NewReader
(
data
)
b
.
cmd
.
Stdin
=
strings
.
NewReader
(
data
)
return
&
b
return
&
b
...
@@ -1220,9 +1226,22 @@ func (b kubectlBuilder) exec() (string, error) {
...
@@ -1220,9 +1226,22 @@ func (b kubectlBuilder) exec() (string, error) {
cmd
.
Stdout
,
cmd
.
Stderr
=
&
stdout
,
&
stderr
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
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
{
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
)
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
(
"stdout: %q"
,
stdout
.
String
())
Logf
(
"stderr: %q"
,
stderr
.
String
())
Logf
(
"stderr: %q"
,
stderr
.
String
())
// TODO: trimspace should be unnecessary after switching to use kubectl binary directly
// TODO: trimspace should be unnecessary after switching to use kubectl binary directly
...
...
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