Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
9b9dcebe
Unverified
Commit
9b9dcebe
authored
Oct 09, 2019
by
Matthew Fisher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(kube): watch events from a matching pod
Signed-off-by:
Matthew Fisher
<
matt.fisher@microsoft.com
>
parent
91356c81
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
client.go
pkg/kube/client.go
+1
-1
environment.go
pkg/releasetesting/environment.go
+7
-3
environment_test.go
pkg/releasetesting/environment_test.go
+10
-0
No files found.
pkg/kube/client.go
View file @
9b9dcebe
...
...
@@ -935,7 +935,7 @@ func (c *Client) WaitAndGetCompletedPodPhase(namespace string, reader io.Reader,
}
func
(
c
*
Client
)
watchPodUntilComplete
(
timeout
time
.
Duration
,
info
*
resource
.
Info
)
error
{
lw
:=
cachetools
.
NewListWatchFromClient
(
info
.
Client
,
info
.
Mapping
.
Resource
.
Resource
,
info
.
Namespace
,
fields
.
Everything
(
))
lw
:=
cachetools
.
NewListWatchFromClient
(
info
.
Client
,
info
.
Mapping
.
Resource
.
Resource
,
info
.
Namespace
,
fields
.
ParseSelectorOrDie
(
fmt
.
Sprintf
(
"metadata.name=%s"
,
info
.
Name
)
))
c
.
Log
(
"Watching pod %s for completion with timeout of %v"
,
info
.
Name
,
timeout
)
ctx
,
cancel
:=
watchtools
.
ContextWithOptionalTimeout
(
context
.
Background
(),
timeout
)
...
...
pkg/releasetesting/environment.go
View file @
9b9dcebe
...
...
@@ -21,6 +21,7 @@ import (
"fmt"
"io/ioutil"
"log"
"strings"
"sync"
"time"
...
...
@@ -31,6 +32,9 @@ import (
"k8s.io/helm/pkg/tiller/environment"
)
// logEscaper is necessary for escaping control characters found in the log stream.
var
logEscaper
=
strings
.
NewReplacer
(
"%"
,
"%%"
)
// Environment encapsulates information about where test suite executes and returns results
type
Environment
struct
{
Namespace
string
...
...
@@ -136,7 +140,7 @@ func (env *Environment) GetLogs(testManifests []string) {
env
.
streamError
(
err
.
Error
())
continue
}
if
len
(
infos
)
<
1
{
if
len
(
infos
)
==
0
{
env
.
streamError
(
fmt
.
Sprint
(
"Pod manifest is invalid. Unable to obtain the logs"
))
continue
}
...
...
@@ -151,7 +155,7 @@ func (env *Environment) GetLogs(testManifests []string) {
env
.
streamError
(
err
.
Error
())
continue
}
msg
:=
fmt
.
Sprintf
(
"
\n
POD LOGS: %s
\n
%s"
,
podName
,
log
s
)
env
.
streamMessage
(
msg
,
release
.
TestRun_
UNKNOWN
)
msg
:=
fmt
.
Sprintf
(
"
\n
POD LOGS: %s
\n
%s"
,
podName
,
log
Escaper
.
Replace
(
string
(
logs
))
)
env
.
streamMessage
(
msg
,
release
.
TestRun_
RUNNING
)
}
}
pkg/releasetesting/environment_test.go
View file @
9b9dcebe
...
...
@@ -95,6 +95,16 @@ func TestGetTestPodLogs(t *testing.T) {
mockTestEnv
.
KubeClient
=
newGetLogKubeClient
()
mockTestEnv
.
GetLogs
(
mockTestSuite
.
TestManifests
)
expectedMessage
:=
"ERROR: Pod manifest is invalid. Unable to obtain the logs"
stream
:=
mockTestEnv
.
Stream
.
(
*
mockStream
)
if
len
(
stream
.
messages
)
!=
1
{
t
.
Errorf
(
"Expected 1 message, got: %v"
,
len
(
stream
.
messages
))
}
if
stream
.
messages
[
0
]
.
Msg
!=
expectedMessage
{
t
.
Errorf
(
"Expected message '%s', got: %v"
,
expectedMessage
,
stream
.
messages
[
0
]
.
Msg
)
}
}
func
TestStreamMessage
(
t
*
testing
.
T
)
{
...
...
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