ref(pkg/tiller): add flag to enable tilling logging in tests

`go test ./pkg/tiller -test.log`
pull/3989/head
Adam Reese 7 years ago
parent a06d14ae00
commit 03ea683b9a
No known key found for this signature in database
GPG Key ID: 06F35E60A7A18DD6

@ -23,7 +23,7 @@ import (
)
func TestGetReleaseContent(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
if err := rs.Releases.Create(rel); err != nil {
t.Fatalf("Could not store mock release: %s", err)

@ -67,7 +67,7 @@ func TestGetHistory_WithRevisions(t *testing.T) {
mk("angry-bird", 1, rpb.StatusSuperseded),
}
srv := rsFixture()
srv := rsFixture(t)
for _, rls := range hist {
if err := srv.Releases.Create(rls); err != nil {
t.Fatalf("Failed to create release: %s", err)
@ -99,7 +99,7 @@ func TestGetHistory_WithNoRevisions(t *testing.T) {
// create release 'sad-panda' with no revision history
rls := namedReleaseStub("sad-panda", rpb.StatusDeployed)
srv := rsFixture()
srv := rsFixture(t)
srv.Releases.Create(rls)
for _, tt := range tests {

@ -26,7 +26,7 @@ import (
)
func TestInstallRelease(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
req := installRequest()
res, err := rs.InstallRelease(req)
@ -79,7 +79,7 @@ func TestInstallRelease(t *testing.T) {
}
func TestInstallRelease_WithNotes(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
req := installRequest(
withChart(withNotes(notesText)),
@ -138,7 +138,7 @@ func TestInstallRelease_WithNotes(t *testing.T) {
}
func TestInstallRelease_WithNotesRendered(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
req := installRequest(
withChart(withNotes(notesText + " {{.Release.Name}}")),
@ -198,7 +198,7 @@ func TestInstallRelease_WithNotesRendered(t *testing.T) {
}
func TestInstallRelease_WithChartAndDependencyNotes(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
req := installRequest(withChart(
withNotes(notesText),
@ -229,7 +229,7 @@ func TestInstallRelease_WithChartAndDependencyNotes(t *testing.T) {
}
func TestInstallRelease_DryRun(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
req := installRequest(withDryRun(),
withChart(withSampleTemplates()),
@ -280,7 +280,7 @@ func TestInstallRelease_DryRun(t *testing.T) {
}
func TestInstallRelease_NoHooks(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rs.Releases.Create(releaseStub())
req := installRequest(withDisabledHooks())
@ -295,7 +295,7 @@ func TestInstallRelease_NoHooks(t *testing.T) {
}
func TestInstallRelease_FailedHooks(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rs.Releases.Create(releaseStub())
rs.KubeClient = newHookFailingKubeClient()
@ -311,7 +311,7 @@ func TestInstallRelease_FailedHooks(t *testing.T) {
}
func TestInstallRelease_ReuseName(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rs.Log = t.Logf
rel := releaseStub()
rel.Info.Status = release.StatusDeleted
@ -341,7 +341,7 @@ func TestInstallRelease_ReuseName(t *testing.T) {
}
func TestInstallRelease_KubeVersion(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
req := installRequest(
withChart(withKube(">=0.0.0")),
@ -353,7 +353,7 @@ func TestInstallRelease_KubeVersion(t *testing.T) {
}
func TestInstallRelease_WrongKubeVersion(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
req := installRequest(
withChart(withKube(">=5.0.0")),

@ -25,7 +25,7 @@ import (
)
func TestListReleases(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
num := 7
for i := 0; i < num; i++ {
rel := releaseStub()
@ -46,7 +46,7 @@ func TestListReleases(t *testing.T) {
}
func TestListReleasesByStatus(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
stubs := []*release.Release{
namedReleaseStub("kamal", release.StatusDeployed),
namedReleaseStub("astrolabe", release.StatusDeleted),
@ -111,7 +111,7 @@ func TestListReleasesByStatus(t *testing.T) {
}
func TestListReleasesSort(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
// Put them in by reverse order so that the mock doesn't "accidentally"
// sort.
@ -148,7 +148,7 @@ func TestListReleasesSort(t *testing.T) {
}
func TestListReleasesFilter(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
names := []string{
"axon",
"dendrite",

@ -25,7 +25,7 @@ import (
)
func TestRollbackRelease(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
rs.Releases.Create(rel)
upgradedRel := upgradeReleaseVersion(rel)
@ -135,7 +135,7 @@ func TestRollbackRelease(t *testing.T) {
}
func TestRollbackWithReleaseVersion(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel2 := releaseStub()
rel2.Name = "other"
rs.Releases.Create(rel2)
@ -180,7 +180,7 @@ func TestRollbackWithReleaseVersion(t *testing.T) {
}
func TestRollbackReleaseNoHooks(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
rel.Hooks = []*release.Hook{
{
@ -215,7 +215,7 @@ func TestRollbackReleaseNoHooks(t *testing.T) {
}
func TestRollbackReleaseFailure(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
rs.Releases.Create(rel)
upgradedRel := upgradeReleaseVersion(rel)

@ -18,6 +18,7 @@ package tiller
import (
"errors"
"flag"
"fmt"
"io"
"io/ioutil"
@ -39,6 +40,8 @@ import (
"k8s.io/helm/pkg/tiller/environment"
)
var verbose = flag.Bool("test.log", false, "enable tiller logging")
const notesText = "my notes here"
var manifestWithHook = `kind: ConfigMap
@ -87,11 +90,20 @@ data:
name: value
`
func rsFixture() *ReleaseServer {
func rsFixture(t *testing.T) *ReleaseServer {
t.Helper()
env := environment.New()
dc := fake.NewSimpleClientset().Discovery()
kc := &environment.PrintingKubeClient{Out: ioutil.Discard}
return NewReleaseServer(env, dc, kc)
rs := NewReleaseServer(env, dc, kc)
rs.Log = func(format string, v ...interface{}) {
t.Helper()
if *verbose {
t.Logf(format, v...)
}
}
return rs
}
type chartOptions struct {
@ -292,7 +304,7 @@ func TestValidName(t *testing.T) {
}
func TestGetVersionSet(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
vs, err := GetVersionSet(rs.discovery)
if err != nil {
t.Error(err)
@ -306,7 +318,7 @@ func TestGetVersionSet(t *testing.T) {
}
func TestUniqName(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel1 := releaseStub()
rel2 := releaseStub()

@ -24,7 +24,7 @@ import (
)
func TestGetReleaseStatus(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
if err := rs.Releases.Create(rel); err != nil {
t.Fatalf("Could not store mock release: %s", err)
@ -44,7 +44,7 @@ func TestGetReleaseStatus(t *testing.T) {
}
func TestGetReleaseStatusDeleted(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
rel.Info.Status = release.StatusDeleted
if err := rs.Releases.Create(rel); err != nil {

@ -25,7 +25,7 @@ import (
)
func TestUninstallRelease(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rs.Releases.Create(releaseStub())
req := &hapi.UninstallReleaseRequest{
@ -59,7 +59,7 @@ func TestUninstallRelease(t *testing.T) {
}
func TestUninstallPurgeRelease(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
rs.Releases.Create(rel)
upgradedRel := upgradeReleaseVersion(rel)
@ -97,7 +97,7 @@ func TestUninstallPurgeRelease(t *testing.T) {
}
func TestUninstallPurgeDeleteRelease(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rs.Releases.Create(releaseStub())
req := &hapi.UninstallReleaseRequest{
@ -121,7 +121,7 @@ func TestUninstallPurgeDeleteRelease(t *testing.T) {
}
func TestUninstallReleaseWithKeepPolicy(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
name := "angry-bunny"
rs.Releases.Create(releaseWithKeepStub(name))
@ -152,7 +152,7 @@ func TestUninstallReleaseWithKeepPolicy(t *testing.T) {
}
func TestUninstallReleaseNoHooks(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rs.Releases.Create(releaseStub())
req := &hapi.UninstallReleaseRequest{

@ -28,7 +28,7 @@ import (
)
func TestUpdateRelease(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
rs.Releases.Create(rel)
@ -100,7 +100,7 @@ func TestUpdateRelease(t *testing.T) {
}
}
func TestUpdateRelease_ResetValues(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
rs.Releases.Create(rel)
@ -127,7 +127,7 @@ func TestUpdateRelease_ResetValues(t *testing.T) {
// This is a regression test for bug found in issue #3655
func TestUpdateRelease_ComplexReuseValues(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
installReq := &hapi.InstallReleaseRequest{
Namespace: "spaced",
@ -223,7 +223,7 @@ func TestUpdateRelease_ComplexReuseValues(t *testing.T) {
}
func TestUpdateRelease_ReuseValues(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
rs.Releases.Create(rel)
@ -260,7 +260,7 @@ func TestUpdateRelease_ReuseValues(t *testing.T) {
func TestUpdateRelease_ResetReuseValues(t *testing.T) {
// This verifies that when both reset and reuse are set, reset wins.
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
rs.Releases.Create(rel)
@ -288,7 +288,7 @@ func TestUpdateRelease_ResetReuseValues(t *testing.T) {
}
func TestUpdateReleaseFailure(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
rs.Releases.Create(rel)
rs.KubeClient = newUpdateFailingKubeClient()
@ -330,7 +330,7 @@ func TestUpdateReleaseFailure(t *testing.T) {
}
func TestUpdateReleaseFailure_Force(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := namedReleaseStub("forceful-luke", release.StatusFailed)
rs.Releases.Create(rel)
@ -372,7 +372,7 @@ func TestUpdateReleaseFailure_Force(t *testing.T) {
}
func TestUpdateReleaseNoHooks(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
rs.Releases.Create(rel)
@ -400,7 +400,7 @@ func TestUpdateReleaseNoHooks(t *testing.T) {
}
func TestUpdateReleaseNoChanges(t *testing.T) {
rs := rsFixture()
rs := rsFixture(t)
rel := releaseStub()
rs.Releases.Create(rel)

Loading…
Cancel
Save