diff --git a/pkg/kubecfg/kubecfg.go b/pkg/kubecfg/kubecfg.go index 2e9b73b3453..0cdd866056d 100644 --- a/pkg/kubecfg/kubecfg.go +++ b/pkg/kubecfg/kubecfg.go @@ -107,6 +107,12 @@ func SaveNamespaceInfo(path string, ns *NamespaceInfo) error { return err } +// extracted for test speed +var ( + updatePollInterval = 5 * time.Second + updatePollTimeout = 300 * time.Second +) + // Update performs a rolling update of a collection of pods. // 'name' points to a replication controller. // 'client' is used for updating pods. @@ -149,7 +155,7 @@ func Update(ctx api.Context, name string, client client.Interface, updatePeriod } time.Sleep(updatePeriod) } - return wait.Poll(time.Second*5, time.Second*300, func() (bool, error) { + return wait.Poll(updatePollInterval, updatePollTimeout, func() (bool, error) { podList, err := client.Pods(api.Namespace(ctx)).List(s) if err != nil { return false, err diff --git a/pkg/kubecfg/kubecfg_test.go b/pkg/kubecfg/kubecfg_test.go index 196ec427094..1e0d3287b79 100644 --- a/pkg/kubecfg/kubecfg_test.go +++ b/pkg/kubecfg/kubecfg_test.go @@ -23,6 +23,7 @@ import ( "os" "reflect" "testing" + "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" @@ -35,6 +36,10 @@ func validateAction(expectedAction, actualAction client.FakeAction, t *testing.T } } +func init() { + updatePollInterval = 1 * time.Millisecond +} + func TestUpdateWithPods(t *testing.T) { fakeClient := client.Fake{ PodsList: api.PodList{