Made NamespaceManager.Run indempotent and added graceful shutdown
This commit is contained in:
@@ -18,8 +18,10 @@ package namespace
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
)
|
||||
@@ -131,3 +133,25 @@ func TestSyncNamespaceThatIsActive(t *testing.T) {
|
||||
t.Errorf("Expected no action from controller, but got: %v", actionSet)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunStop(t *testing.T) {
|
||||
o := testclient.NewObjects(api.Scheme)
|
||||
client := &testclient.Fake{ReactFn: testclient.ObjectReaction(o, latest.RESTMapper)}
|
||||
nsMgr := NewNamespaceManager(client, 1*time.Second)
|
||||
|
||||
if nsMgr.StopEverything != nil {
|
||||
t.Errorf("Non-running manager should not have a stop channel. Got %v", nsMgr.StopEverything)
|
||||
}
|
||||
|
||||
nsMgr.Run()
|
||||
|
||||
if nsMgr.StopEverything == nil {
|
||||
t.Errorf("Running manager should have a stop channel. Got nil")
|
||||
}
|
||||
|
||||
nsMgr.Stop()
|
||||
|
||||
if nsMgr.StopEverything != nil {
|
||||
t.Errorf("Non-running manager should not have a stop channel. Got %v", nsMgr.StopEverything)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user