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
b1475b4f
Commit
b1475b4f
authored
Apr 14, 2017
by
ymqytw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
retry when checking output of kubectl describe
parent
4e172303
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
6 deletions
+31
-6
kubectl.go
test/e2e/kubectl.go
+31
-6
No files found.
test/e2e/kubectl.go
View file @
b1475b4f
...
...
@@ -787,7 +787,6 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
})
// Rc
output
:=
framework
.
RunKubectlOrDie
(
"describe"
,
"rc"
,
"redis-master"
,
nsFlag
)
requiredStrings
:=
[][]
string
{
{
"Name:"
,
"redis-master"
},
{
"Namespace:"
,
ns
},
...
...
@@ -800,10 +799,10 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
{
"Pod Template:"
},
{
"Image:"
,
redisImage
},
{
"Events:"
}}
check
Output
(
output
,
requiredStrings
)
check
KubectlOutputWithRetry
(
requiredStrings
,
"describe"
,
"rc"
,
"redis-master"
,
nsFlag
)
// Service
output
=
framework
.
RunKubectlOrDie
(
"describe"
,
"service"
,
"redis-master"
,
nsFlag
)
output
:
=
framework
.
RunKubectlOrDie
(
"describe"
,
"service"
,
"redis-master"
,
nsFlag
)
requiredStrings
=
[][]
string
{
{
"Name:"
,
"redis-master"
},
{
"Namespace:"
,
ns
},
...
...
@@ -1630,7 +1629,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
})
// Checks whether the output split by line contains the required elements.
func
checkOutput
(
output
string
,
required
[][]
string
)
{
func
checkOutput
ReturnError
(
output
string
,
required
[][]
string
)
error
{
outputLines
:=
strings
.
Split
(
output
,
"
\n
"
)
currentLine
:=
0
for
_
,
requirement
:=
range
required
{
...
...
@@ -1638,14 +1637,40 @@ func checkOutput(output string, required [][]string) {
currentLine
++
}
if
currentLine
==
len
(
outputLines
)
{
framework
.
Failf
(
"F
ailed to find %s in %s"
,
requirement
[
0
],
output
)
return
fmt
.
Errorf
(
"f
ailed to find %s in %s"
,
requirement
[
0
],
output
)
}
for
_
,
item
:=
range
requirement
[
1
:
]
{
if
!
strings
.
Contains
(
outputLines
[
currentLine
],
item
)
{
framework
.
Failf
(
"F
ailed to find %s in %s"
,
item
,
outputLines
[
currentLine
])
return
fmt
.
Errorf
(
"f
ailed to find %s in %s"
,
item
,
outputLines
[
currentLine
])
}
}
}
return
nil
}
func
checkOutput
(
output
string
,
required
[][]
string
)
{
err
:=
checkOutputReturnError
(
output
,
required
)
if
err
!=
nil
{
framework
.
Failf
(
"%v"
,
err
)
}
}
func
checkKubectlOutputWithRetry
(
required
[][]
string
,
args
...
string
)
{
var
pollErr
error
wait
.
PollImmediate
(
time
.
Second
,
time
.
Minute
,
func
()
(
bool
,
error
)
{
output
:=
framework
.
RunKubectlOrDie
(
args
...
)
err
:=
checkOutputReturnError
(
output
,
required
)
if
err
!=
nil
{
pollErr
=
err
return
false
,
nil
}
pollErr
=
nil
return
true
,
nil
})
if
pollErr
!=
nil
{
framework
.
Failf
(
"%v"
,
pollErr
)
}
return
}
func
getAPIVersions
(
apiEndpoint
string
)
(
*
metav1
.
APIVersions
,
error
)
{
...
...
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