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
b22950c1
Commit
b22950c1
authored
May 24, 2017
by
Brian
Committed by
GitHub
May 24, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2484 from fibonacci1729/master
ref(tiller): refactor tests in logical files
parents
fcf48f43
172dbb22
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
510 additions
and
391 deletions
+510
-391
release_content_test.go
pkg/tiller/release_content_test.go
+41
-0
release_rollback_test.go
pkg/tiller/release_rollback_test.go
+193
-0
release_server_test.go
pkg/tiller/release_server_test.go
+0
-391
release_status_test.go
pkg/tiller/release_status_test.go
+64
-0
release_testing_test.go
pkg/tiller/release_testing_test.go
+35
-0
release_uninstall_test.go
pkg/tiller/release_uninstall_test.go
+177
-0
No files found.
pkg/tiller/release_content_test.go
0 → 100644
View file @
b22950c1
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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
tiller
import
(
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/services"
"testing"
)
func
TestGetReleaseContent
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
if
err
:=
rs
.
env
.
Releases
.
Create
(
rel
);
err
!=
nil
{
t
.
Fatalf
(
"Could not store mock release: %s"
,
err
)
}
res
,
err
:=
rs
.
GetReleaseContent
(
c
,
&
services
.
GetReleaseContentRequest
{
Name
:
rel
.
Name
,
Version
:
1
})
if
err
!=
nil
{
t
.
Errorf
(
"Error getting release content: %s"
,
err
)
}
if
res
.
Release
.
Chart
.
Metadata
.
Name
!=
rel
.
Chart
.
Metadata
.
Name
{
t
.
Errorf
(
"Expected %q, got %q"
,
rel
.
Chart
.
Metadata
.
Name
,
res
.
Release
.
Chart
.
Metadata
.
Name
)
}
}
pkg/tiller/release_rollback_test.go
0 → 100644
View file @
b22950c1
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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
tiller
import
(
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/proto/hapi/services"
"strings"
"testing"
)
func
TestRollbackRelease
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rs
.
env
.
Releases
.
Create
(
rel
)
upgradedRel
:=
upgradeReleaseVersion
(
rel
)
upgradedRel
.
Hooks
=
[]
*
release
.
Hook
{
{
Name
:
"test-cm"
,
Kind
:
"ConfigMap"
,
Path
:
"test-cm"
,
Manifest
:
manifestWithRollbackHooks
,
Events
:
[]
release
.
Hook_Event
{
release
.
Hook_PRE_ROLLBACK
,
release
.
Hook_POST_ROLLBACK
,
},
},
}
upgradedRel
.
Manifest
=
"hello world"
rs
.
env
.
Releases
.
Update
(
rel
)
rs
.
env
.
Releases
.
Create
(
upgradedRel
)
req
:=
&
services
.
RollbackReleaseRequest
{
Name
:
rel
.
Name
,
}
res
,
err
:=
rs
.
RollbackRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed rollback: %s"
,
err
)
}
if
res
.
Release
.
Name
==
""
{
t
.
Errorf
(
"Expected release name."
)
}
if
res
.
Release
.
Name
!=
rel
.
Name
{
t
.
Errorf
(
"Updated release name does not match previous release name. Expected %s, got %s"
,
rel
.
Name
,
res
.
Release
.
Name
)
}
if
res
.
Release
.
Namespace
!=
rel
.
Namespace
{
t
.
Errorf
(
"Expected release namespace '%s', got '%s'."
,
rel
.
Namespace
,
res
.
Release
.
Namespace
)
}
if
res
.
Release
.
Version
!=
3
{
t
.
Errorf
(
"Expected release version to be %v, got %v"
,
3
,
res
.
Release
.
Version
)
}
updated
,
err
:=
rs
.
env
.
Releases
.
Get
(
res
.
Release
.
Name
,
res
.
Release
.
Version
)
if
err
!=
nil
{
t
.
Errorf
(
"Expected release for %s (%v)."
,
res
.
Release
.
Name
,
rs
.
env
.
Releases
)
}
if
len
(
updated
.
Hooks
)
!=
2
{
t
.
Fatalf
(
"Expected 2 hooks, got %d"
,
len
(
updated
.
Hooks
))
}
if
updated
.
Hooks
[
0
]
.
Manifest
!=
manifestWithHook
{
t
.
Errorf
(
"Unexpected manifest: %v"
,
updated
.
Hooks
[
0
]
.
Manifest
)
}
anotherUpgradedRelease
:=
upgradeReleaseVersion
(
upgradedRel
)
rs
.
env
.
Releases
.
Update
(
upgradedRel
)
rs
.
env
.
Releases
.
Create
(
anotherUpgradedRelease
)
res
,
err
=
rs
.
RollbackRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed rollback: %s"
,
err
)
}
updated
,
err
=
rs
.
env
.
Releases
.
Get
(
res
.
Release
.
Name
,
res
.
Release
.
Version
)
if
err
!=
nil
{
t
.
Errorf
(
"Expected release for %s (%v)."
,
res
.
Release
.
Name
,
rs
.
env
.
Releases
)
}
if
len
(
updated
.
Hooks
)
!=
1
{
t
.
Fatalf
(
"Expected 1 hook, got %d"
,
len
(
updated
.
Hooks
))
}
if
updated
.
Hooks
[
0
]
.
Manifest
!=
manifestWithRollbackHooks
{
t
.
Errorf
(
"Unexpected manifest: %v"
,
updated
.
Hooks
[
0
]
.
Manifest
)
}
if
res
.
Release
.
Version
!=
4
{
t
.
Errorf
(
"Expected release version to be %v, got %v"
,
3
,
res
.
Release
.
Version
)
}
if
updated
.
Hooks
[
0
]
.
Events
[
0
]
!=
release
.
Hook_PRE_ROLLBACK
{
t
.
Errorf
(
"Expected event 0 to be pre rollback"
)
}
if
updated
.
Hooks
[
0
]
.
Events
[
1
]
!=
release
.
Hook_POST_ROLLBACK
{
t
.
Errorf
(
"Expected event 1 to be post rollback"
)
}
if
len
(
res
.
Release
.
Manifest
)
==
0
{
t
.
Errorf
(
"No manifest returned: %v"
,
res
.
Release
)
}
if
len
(
updated
.
Manifest
)
==
0
{
t
.
Errorf
(
"Expected manifest in %v"
,
res
)
}
if
!
strings
.
Contains
(
updated
.
Manifest
,
"hello world"
)
{
t
.
Errorf
(
"unexpected output: %s"
,
rel
.
Manifest
)
}
if
res
.
Release
.
Info
.
Description
!=
"Rollback to 2"
{
t
.
Errorf
(
"Expected rollback to 2, got %q"
,
res
.
Release
.
Info
.
Description
)
}
}
func
TestRollbackWithReleaseVersion
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rs
.
env
.
Releases
.
Create
(
rel
)
upgradedRel
:=
upgradeReleaseVersion
(
rel
)
rs
.
env
.
Releases
.
Update
(
rel
)
rs
.
env
.
Releases
.
Create
(
upgradedRel
)
req
:=
&
services
.
RollbackReleaseRequest
{
Name
:
rel
.
Name
,
DisableHooks
:
true
,
Version
:
1
,
}
_
,
err
:=
rs
.
RollbackRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed rollback: %s"
,
err
)
}
}
func
TestRollbackReleaseNoHooks
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rel
.
Hooks
=
[]
*
release
.
Hook
{
{
Name
:
"test-cm"
,
Kind
:
"ConfigMap"
,
Path
:
"test-cm"
,
Manifest
:
manifestWithRollbackHooks
,
Events
:
[]
release
.
Hook_Event
{
release
.
Hook_PRE_ROLLBACK
,
release
.
Hook_POST_ROLLBACK
,
},
},
}
rs
.
env
.
Releases
.
Create
(
rel
)
upgradedRel
:=
upgradeReleaseVersion
(
rel
)
rs
.
env
.
Releases
.
Update
(
rel
)
rs
.
env
.
Releases
.
Create
(
upgradedRel
)
req
:=
&
services
.
RollbackReleaseRequest
{
Name
:
rel
.
Name
,
DisableHooks
:
true
,
}
res
,
err
:=
rs
.
RollbackRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed rollback: %s"
,
err
)
}
if
hl
:=
res
.
Release
.
Hooks
[
0
]
.
LastRun
;
hl
!=
nil
{
t
.
Errorf
(
"Expected that no hooks were run. Got %d"
,
hl
)
}
}
pkg/tiller/release_server_test.go
View file @
b22950c1
...
...
@@ -985,306 +985,6 @@ func TestUpdateReleaseNoChanges(t *testing.T) {
}
}
func
TestRollbackReleaseNoHooks
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rel
.
Hooks
=
[]
*
release
.
Hook
{
{
Name
:
"test-cm"
,
Kind
:
"ConfigMap"
,
Path
:
"test-cm"
,
Manifest
:
manifestWithRollbackHooks
,
Events
:
[]
release
.
Hook_Event
{
release
.
Hook_PRE_ROLLBACK
,
release
.
Hook_POST_ROLLBACK
,
},
},
}
rs
.
env
.
Releases
.
Create
(
rel
)
upgradedRel
:=
upgradeReleaseVersion
(
rel
)
rs
.
env
.
Releases
.
Update
(
rel
)
rs
.
env
.
Releases
.
Create
(
upgradedRel
)
req
:=
&
services
.
RollbackReleaseRequest
{
Name
:
rel
.
Name
,
DisableHooks
:
true
,
}
res
,
err
:=
rs
.
RollbackRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed rollback: %s"
,
err
)
}
if
hl
:=
res
.
Release
.
Hooks
[
0
]
.
LastRun
;
hl
!=
nil
{
t
.
Errorf
(
"Expected that no hooks were run. Got %d"
,
hl
)
}
}
func
TestRollbackWithReleaseVersion
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rs
.
env
.
Releases
.
Create
(
rel
)
upgradedRel
:=
upgradeReleaseVersion
(
rel
)
rs
.
env
.
Releases
.
Update
(
rel
)
rs
.
env
.
Releases
.
Create
(
upgradedRel
)
req
:=
&
services
.
RollbackReleaseRequest
{
Name
:
rel
.
Name
,
DisableHooks
:
true
,
Version
:
1
,
}
_
,
err
:=
rs
.
RollbackRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed rollback: %s"
,
err
)
}
}
func
TestRollbackRelease
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rs
.
env
.
Releases
.
Create
(
rel
)
upgradedRel
:=
upgradeReleaseVersion
(
rel
)
upgradedRel
.
Hooks
=
[]
*
release
.
Hook
{
{
Name
:
"test-cm"
,
Kind
:
"ConfigMap"
,
Path
:
"test-cm"
,
Manifest
:
manifestWithRollbackHooks
,
Events
:
[]
release
.
Hook_Event
{
release
.
Hook_PRE_ROLLBACK
,
release
.
Hook_POST_ROLLBACK
,
},
},
}
upgradedRel
.
Manifest
=
"hello world"
rs
.
env
.
Releases
.
Update
(
rel
)
rs
.
env
.
Releases
.
Create
(
upgradedRel
)
req
:=
&
services
.
RollbackReleaseRequest
{
Name
:
rel
.
Name
,
}
res
,
err
:=
rs
.
RollbackRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed rollback: %s"
,
err
)
}
if
res
.
Release
.
Name
==
""
{
t
.
Errorf
(
"Expected release name."
)
}
if
res
.
Release
.
Name
!=
rel
.
Name
{
t
.
Errorf
(
"Updated release name does not match previous release name. Expected %s, got %s"
,
rel
.
Name
,
res
.
Release
.
Name
)
}
if
res
.
Release
.
Namespace
!=
rel
.
Namespace
{
t
.
Errorf
(
"Expected release namespace '%s', got '%s'."
,
rel
.
Namespace
,
res
.
Release
.
Namespace
)
}
if
res
.
Release
.
Version
!=
3
{
t
.
Errorf
(
"Expected release version to be %v, got %v"
,
3
,
res
.
Release
.
Version
)
}
updated
,
err
:=
rs
.
env
.
Releases
.
Get
(
res
.
Release
.
Name
,
res
.
Release
.
Version
)
if
err
!=
nil
{
t
.
Errorf
(
"Expected release for %s (%v)."
,
res
.
Release
.
Name
,
rs
.
env
.
Releases
)
}
if
len
(
updated
.
Hooks
)
!=
2
{
t
.
Fatalf
(
"Expected 2 hooks, got %d"
,
len
(
updated
.
Hooks
))
}
if
updated
.
Hooks
[
0
]
.
Manifest
!=
manifestWithHook
{
t
.
Errorf
(
"Unexpected manifest: %v"
,
updated
.
Hooks
[
0
]
.
Manifest
)
}
anotherUpgradedRelease
:=
upgradeReleaseVersion
(
upgradedRel
)
rs
.
env
.
Releases
.
Update
(
upgradedRel
)
rs
.
env
.
Releases
.
Create
(
anotherUpgradedRelease
)
res
,
err
=
rs
.
RollbackRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed rollback: %s"
,
err
)
}
updated
,
err
=
rs
.
env
.
Releases
.
Get
(
res
.
Release
.
Name
,
res
.
Release
.
Version
)
if
err
!=
nil
{
t
.
Errorf
(
"Expected release for %s (%v)."
,
res
.
Release
.
Name
,
rs
.
env
.
Releases
)
}
if
len
(
updated
.
Hooks
)
!=
1
{
t
.
Fatalf
(
"Expected 1 hook, got %d"
,
len
(
updated
.
Hooks
))
}
if
updated
.
Hooks
[
0
]
.
Manifest
!=
manifestWithRollbackHooks
{
t
.
Errorf
(
"Unexpected manifest: %v"
,
updated
.
Hooks
[
0
]
.
Manifest
)
}
if
res
.
Release
.
Version
!=
4
{
t
.
Errorf
(
"Expected release version to be %v, got %v"
,
3
,
res
.
Release
.
Version
)
}
if
updated
.
Hooks
[
0
]
.
Events
[
0
]
!=
release
.
Hook_PRE_ROLLBACK
{
t
.
Errorf
(
"Expected event 0 to be pre rollback"
)
}
if
updated
.
Hooks
[
0
]
.
Events
[
1
]
!=
release
.
Hook_POST_ROLLBACK
{
t
.
Errorf
(
"Expected event 1 to be post rollback"
)
}
if
len
(
res
.
Release
.
Manifest
)
==
0
{
t
.
Errorf
(
"No manifest returned: %v"
,
res
.
Release
)
}
if
len
(
updated
.
Manifest
)
==
0
{
t
.
Errorf
(
"Expected manifest in %v"
,
res
)
}
if
!
strings
.
Contains
(
updated
.
Manifest
,
"hello world"
)
{
t
.
Errorf
(
"unexpected output: %s"
,
rel
.
Manifest
)
}
if
res
.
Release
.
Info
.
Description
!=
"Rollback to 2"
{
t
.
Errorf
(
"Expected rollback to 2, got %q"
,
res
.
Release
.
Info
.
Description
)
}
}
func
TestUninstallRelease
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rs
.
env
.
Releases
.
Create
(
releaseStub
())
req
:=
&
services
.
UninstallReleaseRequest
{
Name
:
"angry-panda"
,
}
res
,
err
:=
rs
.
UninstallRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed uninstall: %s"
,
err
)
}
if
res
.
Release
.
Name
!=
"angry-panda"
{
t
.
Errorf
(
"Expected angry-panda, got %q"
,
res
.
Release
.
Name
)
}
if
res
.
Release
.
Info
.
Status
.
Code
!=
release
.
Status_DELETED
{
t
.
Errorf
(
"Expected status code to be DELETED, got %d"
,
res
.
Release
.
Info
.
Status
.
Code
)
}
if
res
.
Release
.
Hooks
[
0
]
.
LastRun
.
Seconds
==
0
{
t
.
Error
(
"Expected LastRun to be greater than zero."
)
}
if
res
.
Release
.
Info
.
Deleted
.
Seconds
<=
0
{
t
.
Errorf
(
"Expected valid UNIX date, got %d"
,
res
.
Release
.
Info
.
Deleted
.
Seconds
)
}
if
res
.
Release
.
Info
.
Description
!=
"Deletion complete"
{
t
.
Errorf
(
"Expected Deletion complete, got %q"
,
res
.
Release
.
Info
.
Description
)
}
}
func
TestUninstallPurgeRelease
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rs
.
env
.
Releases
.
Create
(
rel
)
upgradedRel
:=
upgradeReleaseVersion
(
rel
)
rs
.
env
.
Releases
.
Update
(
rel
)
rs
.
env
.
Releases
.
Create
(
upgradedRel
)
req
:=
&
services
.
UninstallReleaseRequest
{
Name
:
"angry-panda"
,
Purge
:
true
,
}
res
,
err
:=
rs
.
UninstallRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed uninstall: %s"
,
err
)
}
if
res
.
Release
.
Name
!=
"angry-panda"
{
t
.
Errorf
(
"Expected angry-panda, got %q"
,
res
.
Release
.
Name
)
}
if
res
.
Release
.
Info
.
Status
.
Code
!=
release
.
Status_DELETED
{
t
.
Errorf
(
"Expected status code to be DELETED, got %d"
,
res
.
Release
.
Info
.
Status
.
Code
)
}
if
res
.
Release
.
Info
.
Deleted
.
Seconds
<=
0
{
t
.
Errorf
(
"Expected valid UNIX date, got %d"
,
res
.
Release
.
Info
.
Deleted
.
Seconds
)
}
rels
,
err
:=
rs
.
GetHistory
(
helm
.
NewContext
(),
&
services
.
GetHistoryRequest
{
Name
:
"angry-panda"
})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
rels
.
Releases
)
!=
0
{
t
.
Errorf
(
"Expected no releases in storage, got %d"
,
len
(
rels
.
Releases
))
}
}
func
TestUninstallPurgeDeleteRelease
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rs
.
env
.
Releases
.
Create
(
releaseStub
())
req
:=
&
services
.
UninstallReleaseRequest
{
Name
:
"angry-panda"
,
}
_
,
err
:=
rs
.
UninstallRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed uninstall: %s"
,
err
)
}
req2
:=
&
services
.
UninstallReleaseRequest
{
Name
:
"angry-panda"
,
Purge
:
true
,
}
_
,
err2
:=
rs
.
UninstallRelease
(
c
,
req2
)
if
err2
!=
nil
&&
err2
.
Error
()
!=
"'angry-panda' has no deployed releases"
{
t
.
Errorf
(
"Failed uninstall: %s"
,
err2
)
}
}
func
TestUninstallReleaseWithKeepPolicy
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
name
:=
"angry-bunny"
rs
.
env
.
Releases
.
Create
(
releaseWithKeepStub
(
name
))
req
:=
&
services
.
UninstallReleaseRequest
{
Name
:
name
,
}
res
,
err
:=
rs
.
UninstallRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed uninstall: %s"
,
err
)
}
if
res
.
Release
.
Name
!=
name
{
t
.
Errorf
(
"Expected angry-bunny, got %q"
,
res
.
Release
.
Name
)
}
if
res
.
Release
.
Info
.
Status
.
Code
!=
release
.
Status_DELETED
{
t
.
Errorf
(
"Expected status code to be DELETED, got %d"
,
res
.
Release
.
Info
.
Status
.
Code
)
}
if
res
.
Info
==
""
{
t
.
Errorf
(
"Expected response info to not be empty"
)
}
else
{
if
!
strings
.
Contains
(
res
.
Info
,
"[ConfigMap] test-cm-keep"
)
{
t
.
Errorf
(
"unexpected output: %s"
,
res
.
Info
)
}
}
}
func
releaseWithKeepStub
(
rlsName
string
)
*
release
.
Release
{
ch
:=
&
chart
.
Chart
{
Metadata
:
&
chart
.
Metadata
{
...
...
@@ -1310,85 +1010,6 @@ func releaseWithKeepStub(rlsName string) *release.Release {
}
}
func
TestUninstallReleaseNoHooks
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rs
.
env
.
Releases
.
Create
(
releaseStub
())
req
:=
&
services
.
UninstallReleaseRequest
{
Name
:
"angry-panda"
,
DisableHooks
:
true
,
}
res
,
err
:=
rs
.
UninstallRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed uninstall: %s"
,
err
)
}
// The default value for a protobuf timestamp is nil.
if
res
.
Release
.
Hooks
[
0
]
.
LastRun
!=
nil
{
t
.
Errorf
(
"Expected LastRun to be zero, got %d."
,
res
.
Release
.
Hooks
[
0
]
.
LastRun
.
Seconds
)
}
}
func
TestGetReleaseContent
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
if
err
:=
rs
.
env
.
Releases
.
Create
(
rel
);
err
!=
nil
{
t
.
Fatalf
(
"Could not store mock release: %s"
,
err
)
}
res
,
err
:=
rs
.
GetReleaseContent
(
c
,
&
services
.
GetReleaseContentRequest
{
Name
:
rel
.
Name
,
Version
:
1
})
if
err
!=
nil
{
t
.
Errorf
(
"Error getting release content: %s"
,
err
)
}
if
res
.
Release
.
Chart
.
Metadata
.
Name
!=
rel
.
Chart
.
Metadata
.
Name
{
t
.
Errorf
(
"Expected %q, got %q"
,
rel
.
Chart
.
Metadata
.
Name
,
res
.
Release
.
Chart
.
Metadata
.
Name
)
}
}
func
TestGetReleaseStatus
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
if
err
:=
rs
.
env
.
Releases
.
Create
(
rel
);
err
!=
nil
{
t
.
Fatalf
(
"Could not store mock release: %s"
,
err
)
}
res
,
err
:=
rs
.
GetReleaseStatus
(
c
,
&
services
.
GetReleaseStatusRequest
{
Name
:
rel
.
Name
,
Version
:
1
})
if
err
!=
nil
{
t
.
Errorf
(
"Error getting release content: %s"
,
err
)
}
if
res
.
Name
!=
rel
.
Name
{
t
.
Errorf
(
"Expected name %q, got %q"
,
rel
.
Name
,
res
.
Name
)
}
if
res
.
Info
.
Status
.
Code
!=
release
.
Status_DEPLOYED
{
t
.
Errorf
(
"Expected %d, got %d"
,
release
.
Status_DEPLOYED
,
res
.
Info
.
Status
.
Code
)
}
}
func
TestGetReleaseStatusDeleted
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rel
.
Info
.
Status
.
Code
=
release
.
Status_DELETED
if
err
:=
rs
.
env
.
Releases
.
Create
(
rel
);
err
!=
nil
{
t
.
Fatalf
(
"Could not store mock release: %s"
,
err
)
}
res
,
err
:=
rs
.
GetReleaseStatus
(
c
,
&
services
.
GetReleaseStatusRequest
{
Name
:
rel
.
Name
,
Version
:
1
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error getting release content: %s"
,
err
)
}
if
res
.
Info
.
Status
.
Code
!=
release
.
Status_DELETED
{
t
.
Errorf
(
"Expected %d, got %d"
,
release
.
Status_DELETED
,
res
.
Info
.
Status
.
Code
)
}
}
func
TestListReleases
(
t
*
testing
.
T
)
{
rs
:=
rsFixture
()
num
:=
7
...
...
@@ -1597,18 +1218,6 @@ func TestReleasesNamespace(t *testing.T) {
}
}
func
TestRunReleaseTest
(
t
*
testing
.
T
)
{
rs
:=
rsFixture
()
rel
:=
namedReleaseStub
(
"nemo"
,
release
.
Status_DEPLOYED
)
rs
.
env
.
Releases
.
Create
(
rel
)
req
:=
&
services
.
TestReleaseRequest
{
Name
:
"nemo"
,
Timeout
:
2
}
err
:=
rs
.
RunReleaseTest
(
req
,
mockRunReleaseTestServer
{})
if
err
!=
nil
{
t
.
Fatalf
(
"failed to run release tests on %s: %s"
,
rel
.
Name
,
err
)
}
}
func
MockEnvironment
()
*
environment
.
Environment
{
e
:=
environment
.
New
()
e
.
Releases
=
storage
.
Init
(
driver
.
NewMemory
())
...
...
pkg/tiller/release_status_test.go
0 → 100644
View file @
b22950c1
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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
tiller
import
(
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/proto/hapi/services"
"testing"
)
func
TestGetReleaseStatus
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
if
err
:=
rs
.
env
.
Releases
.
Create
(
rel
);
err
!=
nil
{
t
.
Fatalf
(
"Could not store mock release: %s"
,
err
)
}
res
,
err
:=
rs
.
GetReleaseStatus
(
c
,
&
services
.
GetReleaseStatusRequest
{
Name
:
rel
.
Name
,
Version
:
1
})
if
err
!=
nil
{
t
.
Errorf
(
"Error getting release content: %s"
,
err
)
}
if
res
.
Name
!=
rel
.
Name
{
t
.
Errorf
(
"Expected name %q, got %q"
,
rel
.
Name
,
res
.
Name
)
}
if
res
.
Info
.
Status
.
Code
!=
release
.
Status_DEPLOYED
{
t
.
Errorf
(
"Expected %d, got %d"
,
release
.
Status_DEPLOYED
,
res
.
Info
.
Status
.
Code
)
}
}
func
TestGetReleaseStatusDeleted
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rel
.
Info
.
Status
.
Code
=
release
.
Status_DELETED
if
err
:=
rs
.
env
.
Releases
.
Create
(
rel
);
err
!=
nil
{
t
.
Fatalf
(
"Could not store mock release: %s"
,
err
)
}
res
,
err
:=
rs
.
GetReleaseStatus
(
c
,
&
services
.
GetReleaseStatusRequest
{
Name
:
rel
.
Name
,
Version
:
1
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error getting release content: %s"
,
err
)
}
if
res
.
Info
.
Status
.
Code
!=
release
.
Status_DELETED
{
t
.
Errorf
(
"Expected %d, got %d"
,
release
.
Status_DELETED
,
res
.
Info
.
Status
.
Code
)
}
}
pkg/tiller/release_testing_test.go
0 → 100644
View file @
b22950c1
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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
tiller
import
(
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/proto/hapi/services"
"testing"
)
func
TestRunReleaseTest
(
t
*
testing
.
T
)
{
rs
:=
rsFixture
()
rel
:=
namedReleaseStub
(
"nemo"
,
release
.
Status_DEPLOYED
)
rs
.
env
.
Releases
.
Create
(
rel
)
req
:=
&
services
.
TestReleaseRequest
{
Name
:
"nemo"
,
Timeout
:
2
}
err
:=
rs
.
RunReleaseTest
(
req
,
mockRunReleaseTestServer
{})
if
err
!=
nil
{
t
.
Fatalf
(
"failed to run release tests on %s: %s"
,
rel
.
Name
,
err
)
}
}
pkg/tiller/release_uninstall_test.go
0 → 100644
View file @
b22950c1
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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
tiller
import
(
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/proto/hapi/services"
"strings"
"testing"
)
func
TestUninstallRelease
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rs
.
env
.
Releases
.
Create
(
releaseStub
())
req
:=
&
services
.
UninstallReleaseRequest
{
Name
:
"angry-panda"
,
}
res
,
err
:=
rs
.
UninstallRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed uninstall: %s"
,
err
)
}
if
res
.
Release
.
Name
!=
"angry-panda"
{
t
.
Errorf
(
"Expected angry-panda, got %q"
,
res
.
Release
.
Name
)
}
if
res
.
Release
.
Info
.
Status
.
Code
!=
release
.
Status_DELETED
{
t
.
Errorf
(
"Expected status code to be DELETED, got %d"
,
res
.
Release
.
Info
.
Status
.
Code
)
}
if
res
.
Release
.
Hooks
[
0
]
.
LastRun
.
Seconds
==
0
{
t
.
Error
(
"Expected LastRun to be greater than zero."
)
}
if
res
.
Release
.
Info
.
Deleted
.
Seconds
<=
0
{
t
.
Errorf
(
"Expected valid UNIX date, got %d"
,
res
.
Release
.
Info
.
Deleted
.
Seconds
)
}
if
res
.
Release
.
Info
.
Description
!=
"Deletion complete"
{
t
.
Errorf
(
"Expected Deletion complete, got %q"
,
res
.
Release
.
Info
.
Description
)
}
}
func
TestUninstallPurgeRelease
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rel
:=
releaseStub
()
rs
.
env
.
Releases
.
Create
(
rel
)
upgradedRel
:=
upgradeReleaseVersion
(
rel
)
rs
.
env
.
Releases
.
Update
(
rel
)
rs
.
env
.
Releases
.
Create
(
upgradedRel
)
req
:=
&
services
.
UninstallReleaseRequest
{
Name
:
"angry-panda"
,
Purge
:
true
,
}
res
,
err
:=
rs
.
UninstallRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed uninstall: %s"
,
err
)
}
if
res
.
Release
.
Name
!=
"angry-panda"
{
t
.
Errorf
(
"Expected angry-panda, got %q"
,
res
.
Release
.
Name
)
}
if
res
.
Release
.
Info
.
Status
.
Code
!=
release
.
Status_DELETED
{
t
.
Errorf
(
"Expected status code to be DELETED, got %d"
,
res
.
Release
.
Info
.
Status
.
Code
)
}
if
res
.
Release
.
Info
.
Deleted
.
Seconds
<=
0
{
t
.
Errorf
(
"Expected valid UNIX date, got %d"
,
res
.
Release
.
Info
.
Deleted
.
Seconds
)
}
rels
,
err
:=
rs
.
GetHistory
(
helm
.
NewContext
(),
&
services
.
GetHistoryRequest
{
Name
:
"angry-panda"
})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
rels
.
Releases
)
!=
0
{
t
.
Errorf
(
"Expected no releases in storage, got %d"
,
len
(
rels
.
Releases
))
}
}
func
TestUninstallPurgeDeleteRelease
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rs
.
env
.
Releases
.
Create
(
releaseStub
())
req
:=
&
services
.
UninstallReleaseRequest
{
Name
:
"angry-panda"
,
}
_
,
err
:=
rs
.
UninstallRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed uninstall: %s"
,
err
)
}
req2
:=
&
services
.
UninstallReleaseRequest
{
Name
:
"angry-panda"
,
Purge
:
true
,
}
_
,
err2
:=
rs
.
UninstallRelease
(
c
,
req2
)
if
err2
!=
nil
&&
err2
.
Error
()
!=
"'angry-panda' has no deployed releases"
{
t
.
Errorf
(
"Failed uninstall: %s"
,
err2
)
}
}
func
TestUninstallReleaseWithKeepPolicy
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
name
:=
"angry-bunny"
rs
.
env
.
Releases
.
Create
(
releaseWithKeepStub
(
name
))
req
:=
&
services
.
UninstallReleaseRequest
{
Name
:
name
,
}
res
,
err
:=
rs
.
UninstallRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed uninstall: %s"
,
err
)
}
if
res
.
Release
.
Name
!=
name
{
t
.
Errorf
(
"Expected angry-bunny, got %q"
,
res
.
Release
.
Name
)
}
if
res
.
Release
.
Info
.
Status
.
Code
!=
release
.
Status_DELETED
{
t
.
Errorf
(
"Expected status code to be DELETED, got %d"
,
res
.
Release
.
Info
.
Status
.
Code
)
}
if
res
.
Info
==
""
{
t
.
Errorf
(
"Expected response info to not be empty"
)
}
else
{
if
!
strings
.
Contains
(
res
.
Info
,
"[ConfigMap] test-cm-keep"
)
{
t
.
Errorf
(
"unexpected output: %s"
,
res
.
Info
)
}
}
}
func
TestUninstallReleaseNoHooks
(
t
*
testing
.
T
)
{
c
:=
helm
.
NewContext
()
rs
:=
rsFixture
()
rs
.
env
.
Releases
.
Create
(
releaseStub
())
req
:=
&
services
.
UninstallReleaseRequest
{
Name
:
"angry-panda"
,
DisableHooks
:
true
,
}
res
,
err
:=
rs
.
UninstallRelease
(
c
,
req
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed uninstall: %s"
,
err
)
}
// The default value for a protobuf timestamp is nil.
if
res
.
Release
.
Hooks
[
0
]
.
LastRun
!=
nil
{
t
.
Errorf
(
"Expected LastRun to be zero, got %d."
,
res
.
Release
.
Hooks
[
0
]
.
LastRun
.
Seconds
)
}
}
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