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
ce4c3f51
Unverified
Commit
ce4c3f51
authored
Mar 04, 2019
by
Jacob LeGrone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(resource-policy): verify behavior of non-standard policy types
Signed-off-by:
Jacob LeGrone
<
git@jacob.work
>
parent
55fbed95
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
9 deletions
+97
-9
client_test.go
pkg/kube/client_test.go
+1
-1
resource_policy_test.go
pkg/kube/resource_policy_test.go
+72
-0
release_server_test.go
pkg/tiller/release_server_test.go
+20
-7
release_uninstall_test.go
pkg/tiller/release_uninstall_test.go
+4
-1
No files found.
pkg/kube/client_test.go
View file @
ce4c3f51
...
@@ -213,7 +213,7 @@ func TestUpdate(t *testing.T) {
...
@@ -213,7 +213,7 @@ func TestUpdate(t *testing.T) {
// Test resource policy is respected
// Test resource policy is respected
actions
=
nil
actions
=
nil
listA
.
Items
[
2
]
.
ObjectMeta
.
Annotations
=
map
[
string
]
string
{
ResourcePolicyAnno
:
KeepPolicy
}
listA
.
Items
[
2
]
.
ObjectMeta
.
Annotations
=
map
[
string
]
string
{
ResourcePolicyAnno
:
"keep"
}
if
err
:=
c
.
Update
(
v1
.
NamespaceDefault
,
objBody
(
&
listA
),
objBody
(
&
listB
),
false
,
false
,
0
,
false
);
err
!=
nil
{
if
err
:=
c
.
Update
(
v1
.
NamespaceDefault
,
objBody
(
&
listA
),
objBody
(
&
listB
),
false
,
false
,
0
,
false
);
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
...
pkg/kube/resource_policy_test.go
0 → 100644
View file @
ce4c3f51
/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
kube
import
"testing"
func
TestResourcePolicyIsKeep
(
t
*
testing
.
T
)
{
type
annotations
map
[
string
]
string
type
testcase
struct
{
annotations
keep
bool
}
cases
:=
[]
testcase
{
{
nil
,
false
},
{
annotations
{
"foo"
:
"bar"
,
},
false
,
},
{
annotations
{
ResourcePolicyAnno
:
"keep"
,
},
true
,
},
{
annotations
{
ResourcePolicyAnno
:
"KEEP "
,
},
true
,
},
{
annotations
{
ResourcePolicyAnno
:
""
,
},
true
,
},
{
annotations
{
ResourcePolicyAnno
:
"delete"
,
},
false
,
},
{
annotations
{
ResourcePolicyAnno
:
"DELETE"
,
},
true
,
},
}
for
_
,
tc
:=
range
cases
{
if
tc
.
keep
!=
ResourcePolicyIsKeep
(
tc
.
annotations
)
{
t
.
Errorf
(
"Expected function to return %t for annotations %v"
,
tc
.
keep
,
tc
.
annotations
)
}
}
}
pkg/tiller/release_server_test.go
View file @
ce4c3f51
...
@@ -89,13 +89,22 @@ spec:
...
@@ -89,13 +89,22 @@ spec:
var
manifestWithKeep
=
`kind: ConfigMap
var
manifestWithKeep
=
`kind: ConfigMap
metadata:
metadata:
name: test-cm-keep
name: test-cm-keep
-a
annotations:
annotations:
"helm.sh/resource-policy": keep
"helm.sh/resource-policy": keep
data:
data:
name: value
name: value
`
`
var
manifestWithKeepEmpty
=
`kind: ConfigMap
metadata:
name: test-cm-keep-b
annotations:
"helm.sh/resource-policy": ""
data:
name: value
`
var
manifestWithUpgradeHooks
=
`kind: ConfigMap
var
manifestWithUpgradeHooks
=
`kind: ConfigMap
metadata:
metadata:
name: test-cm
name: test-cm
...
@@ -449,23 +458,27 @@ func releaseWithKeepStub(rlsName string) *release.Release {
...
@@ -449,23 +458,27 @@ func releaseWithKeepStub(rlsName string) *release.Release {
Name
:
"bunnychart"
,
Name
:
"bunnychart"
,
},
},
Templates
:
[]
*
chart
.
Template
{
Templates
:
[]
*
chart
.
Template
{
{
Name
:
"templates/configmap"
,
Data
:
[]
byte
(
manifestWithKeep
)},
{
Name
:
"templates/configmap-keep-a"
,
Data
:
[]
byte
(
manifestWithKeep
)},
{
Name
:
"templates/configmap-keep-b"
,
Data
:
[]
byte
(
manifestWithKeepEmpty
)},
},
},
}
}
date
:=
timestamp
.
Timestamp
{
Seconds
:
242085845
,
Nanos
:
0
}
date
:=
timestamp
.
Timestamp
{
Seconds
:
242085845
,
Nanos
:
0
}
r
eturn
&
release
.
Release
{
r
l
:=
&
release
.
Release
{
Name
:
rlsName
,
Name
:
rlsName
,
Info
:
&
release
.
Info
{
Info
:
&
release
.
Info
{
FirstDeployed
:
&
date
,
FirstDeployed
:
&
date
,
LastDeployed
:
&
date
,
LastDeployed
:
&
date
,
Status
:
&
release
.
Status
{
Code
:
release
.
Status_DEPLOYED
},
Status
:
&
release
.
Status
{
Code
:
release
.
Status_DEPLOYED
},
},
},
Chart
:
ch
,
Chart
:
ch
,
Config
:
&
chart
.
Config
{
Raw
:
`name: value`
},
Config
:
&
chart
.
Config
{
Raw
:
`name: value`
},
Version
:
1
,
Version
:
1
,
Manifest
:
manifestWithKeep
,
}
}
helm
.
RenderReleaseMock
(
rl
,
false
)
return
rl
}
}
func
MockEnvironment
()
*
environment
.
Environment
{
func
MockEnvironment
()
*
environment
.
Environment
{
...
...
pkg/tiller/release_uninstall_test.go
View file @
ce4c3f51
...
@@ -150,7 +150,10 @@ func TestUninstallReleaseWithKeepPolicy(t *testing.T) {
...
@@ -150,7 +150,10 @@ func TestUninstallReleaseWithKeepPolicy(t *testing.T) {
if
res
.
Info
==
""
{
if
res
.
Info
==
""
{
t
.
Errorf
(
"Expected response info to not be empty"
)
t
.
Errorf
(
"Expected response info to not be empty"
)
}
else
{
}
else
{
if
!
strings
.
Contains
(
res
.
Info
,
"[ConfigMap] test-cm-keep"
)
{
if
!
strings
.
Contains
(
res
.
Info
,
"[ConfigMap] test-cm-keep-a"
)
{
t
.
Errorf
(
"unexpected output: %s"
,
res
.
Info
)
}
if
!
strings
.
Contains
(
res
.
Info
,
"[ConfigMap] test-cm-keep-b"
)
{
t
.
Errorf
(
"unexpected output: %s"
,
res
.
Info
)
t
.
Errorf
(
"unexpected output: %s"
,
res
.
Info
)
}
}
}
}
...
...
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