mirror of https://github.com/k3s-io/k3s
commit
ac63290ff5
|
@ -31,6 +31,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/storage"
|
||||
etcdstorage "k8s.io/kubernetes/pkg/storage/etcd"
|
||||
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/sets"
|
||||
|
@ -39,6 +40,12 @@ import (
|
|||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func newEtcdTestStorage(t *testing.T, codec runtime.Codec, prefix string) (*etcdtesting.EtcdTestServer, storage.Interface) {
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
storage := etcdstorage.NewEtcdStorage(server.Client, codec, prefix)
|
||||
return server, storage
|
||||
}
|
||||
|
||||
func newTestCacher(s storage.Interface) *storage.Cacher {
|
||||
prefix := "pods"
|
||||
config := storage.CacherConfig{
|
||||
|
@ -82,7 +89,7 @@ func updatePod(t *testing.T, s storage.Interface, obj, old *api.Pod) *api.Pod {
|
|||
}
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
server, etcdStorage := etcdstorage.NewEtcdTestStorage(t, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
server, etcdStorage := newEtcdTestStorage(t, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
defer server.Terminate(t)
|
||||
cacher := newTestCacher(etcdStorage)
|
||||
|
||||
|
@ -158,7 +165,7 @@ func verifyWatchEvent(t *testing.T, w watch.Interface, eventType watch.EventType
|
|||
}
|
||||
|
||||
func TestWatch(t *testing.T) {
|
||||
server, etcdStorage := etcdstorage.NewEtcdTestStorage(t, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
server, etcdStorage := newEtcdTestStorage(t, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
defer server.Terminate(t)
|
||||
cacher := newTestCacher(etcdStorage)
|
||||
|
||||
|
@ -217,7 +224,7 @@ func TestWatch(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFiltering(t *testing.T) {
|
||||
server, etcdStorage := etcdstorage.NewEtcdTestStorage(t, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
server, etcdStorage := newEtcdTestStorage(t, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
defer server.Terminate(t)
|
||||
cacher := newTestCacher(etcdStorage)
|
||||
|
||||
|
@ -269,7 +276,7 @@ func TestFiltering(t *testing.T) {
|
|||
* and the watch *never returns.* I would like to still keep this test here and re-enable
|
||||
* with the new 2.2+ client library.
|
||||
func TestStorageError(t *testing.T) {
|
||||
server, etcdStorage := etcdstorage.NewEtcdTestStorage(t, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
server, etcdStorage := newEtcdTestStorage(t, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
cacher := newTestCacher(etcdStorage)
|
||||
|
||||
watcher, err := cacher.Watch(context.TODO(), "pods/ns/foo", 1, storage.Everything)
|
||||
|
|
|
@ -38,6 +38,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/conversion"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/storage"
|
||||
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing"
|
||||
storagetesting "k8s.io/kubernetes/pkg/storage/testing"
|
||||
|
||||
// TODO: once fakeClient has been purged move utils
|
||||
|
@ -109,10 +110,10 @@ func createPodList(t *testing.T, helper etcdHelper, list *api.PodList) error {
|
|||
}
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
key := etcdtest.AddPrefix("/some/key")
|
||||
helper := newEtcdHelper(server.client, testapi.Default.Codec(), key)
|
||||
helper := newEtcdHelper(server.Client, testapi.Default.Codec(), key)
|
||||
|
||||
list := api.PodList{
|
||||
Items: []api.Pod{
|
||||
|
@ -145,10 +146,10 @@ func TestList(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestListFiltered(t *testing.T) {
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
key := etcdtest.AddPrefix("/some/key")
|
||||
helper := newEtcdHelper(server.client, testapi.Default.Codec(), key)
|
||||
helper := newEtcdHelper(server.Client, testapi.Default.Codec(), key)
|
||||
|
||||
list := api.PodList{
|
||||
Items: []api.Pod{
|
||||
|
@ -186,15 +187,15 @@ func TestListFiltered(t *testing.T) {
|
|||
|
||||
// TestListAcrossDirectories ensures that the client excludes directories and flattens tree-response - simulates cross-namespace query
|
||||
func TestListAcrossDirectories(t *testing.T) {
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
rootkey := etcdtest.AddPrefix("/some/key")
|
||||
key1 := etcdtest.AddPrefix("/some/key/directory1")
|
||||
key2 := etcdtest.AddPrefix("/some/key/directory2")
|
||||
|
||||
roothelper := newEtcdHelper(server.client, testapi.Default.Codec(), rootkey)
|
||||
helper1 := newEtcdHelper(server.client, testapi.Default.Codec(), key1)
|
||||
helper2 := newEtcdHelper(server.client, testapi.Default.Codec(), key2)
|
||||
roothelper := newEtcdHelper(server.Client, testapi.Default.Codec(), rootkey)
|
||||
helper1 := newEtcdHelper(server.Client, testapi.Default.Codec(), key1)
|
||||
helper2 := newEtcdHelper(server.Client, testapi.Default.Codec(), key2)
|
||||
|
||||
list := api.PodList{
|
||||
Items: []api.Pod{
|
||||
|
@ -234,10 +235,10 @@ func TestListAcrossDirectories(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
key := etcdtest.AddPrefix("/some/key")
|
||||
helper := newEtcdHelper(server.client, testapi.Default.Codec(), key)
|
||||
helper := newEtcdHelper(server.Client, testapi.Default.Codec(), key)
|
||||
expect := api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Spec: apitesting.DeepEqualSafePodSpec(),
|
||||
|
@ -256,11 +257,11 @@ func TestGet(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetNotFoundErr(t *testing.T) {
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
key := etcdtest.AddPrefix("/some/key")
|
||||
boguskey := etcdtest.AddPrefix("/some/boguskey")
|
||||
helper := newEtcdHelper(server.client, testapi.Default.Codec(), key)
|
||||
helper := newEtcdHelper(server.Client, testapi.Default.Codec(), key)
|
||||
|
||||
var got api.Pod
|
||||
err := helper.Get(context.TODO(), boguskey, &got, false)
|
||||
|
@ -271,9 +272,9 @@ func TestGetNotFoundErr(t *testing.T) {
|
|||
|
||||
func TestCreate(t *testing.T) {
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
helper := newEtcdHelper(server.client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
helper := newEtcdHelper(server.Client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
returnedObj := &api.Pod{}
|
||||
err := helper.Create(context.TODO(), "/some/key", obj, returnedObj, 5)
|
||||
if err != nil {
|
||||
|
@ -298,9 +299,9 @@ func TestCreate(t *testing.T) {
|
|||
|
||||
func TestCreateNilOutParam(t *testing.T) {
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
helper := newEtcdHelper(server.client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
helper := newEtcdHelper(server.Client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
err := helper.Create(context.TODO(), "/some/key", obj, nil, 5)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error %#v", err)
|
||||
|
@ -309,9 +310,9 @@ func TestCreateNilOutParam(t *testing.T) {
|
|||
|
||||
func TestSet(t *testing.T) {
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
helper := newEtcdHelper(server.client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
helper := newEtcdHelper(server.Client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
returnedObj := &api.Pod{}
|
||||
err := helper.Set(context.TODO(), "/some/key", obj, returnedObj, 5)
|
||||
if err != nil {
|
||||
|
@ -334,9 +335,9 @@ func TestSet(t *testing.T) {
|
|||
|
||||
func TestSetFailCAS(t *testing.T) {
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"}}
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
helper := newEtcdHelper(server.client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
helper := newEtcdHelper(server.Client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
err := helper.Set(context.TODO(), "/some/key", obj, nil, 5)
|
||||
if err == nil {
|
||||
t.Errorf("Expecting error.")
|
||||
|
@ -345,9 +346,9 @@ func TestSetFailCAS(t *testing.T) {
|
|||
|
||||
func TestSetWithVersion(t *testing.T) {
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
helper := newEtcdHelper(server.client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
helper := newEtcdHelper(server.Client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
|
||||
returnedObj := &api.Pod{}
|
||||
err := helper.Set(context.TODO(), "/some/key", obj, returnedObj, 7)
|
||||
|
@ -368,9 +369,9 @@ func TestSetWithVersion(t *testing.T) {
|
|||
|
||||
func TestSetWithoutResourceVersioner(t *testing.T) {
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
helper := newEtcdHelper(server.client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
helper := newEtcdHelper(server.Client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
helper.versioner = nil
|
||||
returnedObj := &api.Pod{}
|
||||
err := helper.Set(context.TODO(), "/some/key", obj, returnedObj, 3)
|
||||
|
@ -384,9 +385,9 @@ func TestSetWithoutResourceVersioner(t *testing.T) {
|
|||
|
||||
func TestSetNilOutParam(t *testing.T) {
|
||||
obj := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
helper := newEtcdHelper(server.client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
helper := newEtcdHelper(server.Client, testapi.Default.Codec(), etcdtest.PathPrefix())
|
||||
helper.versioner = nil
|
||||
err := helper.Set(context.TODO(), "/some/key", obj, nil, 3)
|
||||
if err != nil {
|
||||
|
@ -395,10 +396,10 @@ func TestSetNilOutParam(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGuaranteedUpdate(t *testing.T) {
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
key := etcdtest.AddPrefix("/some/key")
|
||||
helper := newEtcdHelper(server.client, codec, key)
|
||||
helper := newEtcdHelper(server.Client, codec, key)
|
||||
|
||||
obj := &storagetesting.TestResource{ObjectMeta: api.ObjectMeta{Name: "foo"}, Value: 1}
|
||||
err := helper.GuaranteedUpdate(context.TODO(), key, &storagetesting.TestResource{}, true, storage.SimpleUpdate(func(in runtime.Object) (runtime.Object, error) {
|
||||
|
@ -436,10 +437,10 @@ func TestGuaranteedUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGuaranteedUpdateNoChange(t *testing.T) {
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
key := etcdtest.AddPrefix("/some/key")
|
||||
helper := newEtcdHelper(server.client, codec, key)
|
||||
helper := newEtcdHelper(server.Client, codec, key)
|
||||
|
||||
obj := &storagetesting.TestResource{ObjectMeta: api.ObjectMeta{Name: "foo"}, Value: 1}
|
||||
err := helper.GuaranteedUpdate(context.TODO(), key, &storagetesting.TestResource{}, true, storage.SimpleUpdate(func(in runtime.Object) (runtime.Object, error) {
|
||||
|
@ -465,10 +466,10 @@ func TestGuaranteedUpdateNoChange(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGuaranteedUpdateKeyNotFound(t *testing.T) {
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
key := etcdtest.AddPrefix("/some/key")
|
||||
helper := newEtcdHelper(server.client, codec, key)
|
||||
helper := newEtcdHelper(server.Client, codec, key)
|
||||
|
||||
// Create a new node.
|
||||
obj := &storagetesting.TestResource{ObjectMeta: api.ObjectMeta{Name: "foo"}, Value: 1}
|
||||
|
@ -491,10 +492,10 @@ func TestGuaranteedUpdateKeyNotFound(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGuaranteedUpdate_CreateCollision(t *testing.T) {
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
key := etcdtest.AddPrefix("/some/key")
|
||||
helper := newEtcdHelper(server.client, codec, etcdtest.PathPrefix())
|
||||
helper := newEtcdHelper(server.Client, codec, etcdtest.PathPrefix())
|
||||
|
||||
const concurrency = 10
|
||||
var wgDone sync.WaitGroup
|
||||
|
@ -586,10 +587,10 @@ func TestGetEtcdVersion_NotListening(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPrefixEtcdKey(t *testing.T) {
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
prefix := path.Join("/", etcdtest.PathPrefix())
|
||||
helper := newEtcdHelper(server.client, testapi.Default.Codec(), prefix)
|
||||
helper := newEtcdHelper(server.Client, testapi.Default.Codec(), prefix)
|
||||
|
||||
baseKey := "/some/key"
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/storage"
|
||||
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/tools/etcdtest"
|
||||
"k8s.io/kubernetes/pkg/watch"
|
||||
|
||||
|
@ -220,8 +221,8 @@ func TestWatchInterpretation_ResponseBadData(t *testing.T) {
|
|||
* with the new 2.2+ client library.
|
||||
func TestWatchEtcdError(t *testing.T) {
|
||||
codec := testapi.Default.Codec()
|
||||
server := NewEtcdTestClientServer(t)
|
||||
h := newEtcdHelper(server.client, codec, etcdtest.PathPrefix())
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
h := newEtcdHelper(server.Client, codec, etcdtest.PathPrefix())
|
||||
watching, err := h.Watch(context.TODO(), "/some/key", 4, storage.Everything)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
|
@ -237,10 +238,10 @@ func TestWatchEtcdError(t *testing.T) {
|
|||
|
||||
func TestWatch(t *testing.T) {
|
||||
codec := testapi.Default.Codec()
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
key := "/some/key"
|
||||
h := newEtcdHelper(server.client, codec, etcdtest.PathPrefix())
|
||||
h := newEtcdHelper(server.Client, codec, etcdtest.PathPrefix())
|
||||
|
||||
watching, err := h.Watch(context.TODO(), key, 0, storage.Everything)
|
||||
if err != nil {
|
||||
|
@ -284,10 +285,10 @@ func makeSubsets(ip string, port int) []api.EndpointSubset {
|
|||
func TestWatchEtcdState(t *testing.T) {
|
||||
codec := testapi.Default.Codec()
|
||||
key := etcdtest.AddPrefix("/somekey/foo")
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
|
||||
h := newEtcdHelper(server.client, codec, etcdtest.PathPrefix())
|
||||
h := newEtcdHelper(server.Client, codec, etcdtest.PathPrefix())
|
||||
watching, err := h.Watch(context.TODO(), key, 0, storage.Everything)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
|
@ -334,10 +335,10 @@ func TestWatchFromZeroIndex(t *testing.T) {
|
|||
pod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
|
||||
key := etcdtest.AddPrefix("/somekey/foo")
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
|
||||
h := newEtcdHelper(server.client, codec, etcdtest.PathPrefix())
|
||||
h := newEtcdHelper(server.Client, codec, etcdtest.PathPrefix())
|
||||
|
||||
// set before the watch and verify events
|
||||
err := h.Set(context.TODO(), key, pod, pod, 0)
|
||||
|
@ -383,9 +384,9 @@ func TestWatchFromZeroIndex(t *testing.T) {
|
|||
func TestWatchListFromZeroIndex(t *testing.T) {
|
||||
codec := testapi.Default.Codec()
|
||||
key := etcdtest.AddPrefix("/some/key")
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
h := newEtcdHelper(server.client, codec, key)
|
||||
h := newEtcdHelper(server.Client, codec, key)
|
||||
|
||||
watching, err := h.WatchList(context.TODO(), key, 0, storage.Everything)
|
||||
if err != nil {
|
||||
|
@ -415,9 +416,9 @@ func TestWatchListIgnoresRootKey(t *testing.T) {
|
|||
codec := testapi.Default.Codec()
|
||||
pod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}}
|
||||
key := etcdtest.AddPrefix("/some/key")
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
h := newEtcdHelper(server.client, codec, key)
|
||||
h := newEtcdHelper(server.Client, codec, key)
|
||||
|
||||
watching, err := h.WatchList(context.TODO(), key, 0, storage.Everything)
|
||||
if err != nil {
|
||||
|
@ -444,10 +445,10 @@ func TestWatchListIgnoresRootKey(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestWatchPurposefulShutdown(t *testing.T) {
|
||||
server := NewEtcdTestClientServer(t)
|
||||
server := etcdtesting.NewEtcdTestClientServer(t)
|
||||
defer server.Terminate(t)
|
||||
key := "/some/key"
|
||||
h := newEtcdHelper(server.client, codec, etcdtest.PathPrefix())
|
||||
h := newEtcdHelper(server.Client, codec, etcdtest.PathPrefix())
|
||||
|
||||
// Test purposeful shutdown
|
||||
watching, err := h.Watch(context.TODO(), key, 0, storage.Everything)
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package etcd
|
||||
package testing
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -26,8 +26,6 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/storage"
|
||||
"k8s.io/kubernetes/pkg/tools"
|
||||
|
||||
"github.com/coreos/etcd/etcdserver"
|
||||
|
@ -42,7 +40,7 @@ import (
|
|||
type EtcdTestServer struct {
|
||||
etcdserver.ServerConfig
|
||||
PeerListeners, ClientListeners []net.Listener
|
||||
client tools.EtcdClient
|
||||
Client tools.EtcdClient
|
||||
|
||||
raftHandler http.Handler
|
||||
s *etcdserver.EtcdServer
|
||||
|
@ -130,7 +128,7 @@ func (m *EtcdTestServer) launch(t *testing.T) error {
|
|||
|
||||
// Terminate will shutdown the running etcd server
|
||||
func (m *EtcdTestServer) Terminate(t *testing.T) {
|
||||
m.client.(*goetcd.Client).Close()
|
||||
m.Client.(*goetcd.Client).Close()
|
||||
m.s.Stop()
|
||||
for _, hs := range m.hss {
|
||||
hs.CloseClientConnections()
|
||||
|
@ -149,18 +147,11 @@ func NewEtcdTestClientServer(t *testing.T) *EtcdTestServer {
|
|||
t.Fatal("Failed to start etcd server error=%v", err)
|
||||
return nil
|
||||
}
|
||||
server.client = goetcd.NewClient(server.ClientURLs.StringSlice())
|
||||
if server.client == nil {
|
||||
server.Client = goetcd.NewClient(server.ClientURLs.StringSlice())
|
||||
if server.Client == nil {
|
||||
t.Errorf("Failed to connect to local etcd server")
|
||||
defer server.Terminate(t)
|
||||
return nil
|
||||
}
|
||||
return server
|
||||
}
|
||||
|
||||
// NewEtcdTestStorage creates a new storage.Interface and TestServer
|
||||
func NewEtcdTestStorage(t *testing.T, codec runtime.Codec, prefix string) (*EtcdTestServer, storage.Interface) {
|
||||
server := NewEtcdTestClientServer(t)
|
||||
storage := NewEtcdStorage(server.client, codec, prefix)
|
||||
return server, storage
|
||||
}
|
Loading…
Reference in New Issue