mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
parent
53ec66caf4
commit
436790ccd1
@ -24,6 +24,7 @@ import (
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
|
||||
etcderrors "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors/etcd"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/rest/resttest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
||||
@ -846,6 +847,33 @@ func TestEtcdCreate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEtcdCreateBindingNoPod(t *testing.T) {
|
||||
registry, bindingRegistry, fakeClient, _ := newStorage(t)
|
||||
ctx := api.NewDefaultContext()
|
||||
fakeClient.TestIndex = true
|
||||
|
||||
key, _ := registry.store.KeyFunc(ctx, "foo")
|
||||
fakeClient.Data[key] = tools.EtcdResponseWithError{
|
||||
R: &etcd.Response{
|
||||
Node: nil,
|
||||
},
|
||||
E: tools.EtcdErrorNotFound,
|
||||
}
|
||||
// Assume that a pod has undergone the following:
|
||||
// - Create (apiserver)
|
||||
// - Schedule (scheduler)
|
||||
// - Delete (apiserver)
|
||||
_, err := bindingRegistry.Create(ctx, &api.Binding{PodID: "foo", Host: "machine", ObjectMeta: api.ObjectMeta{Namespace: api.NamespaceDefault}})
|
||||
if !errors.IsNotFound(etcderrors.InterpretGetError(err, "Pod", "foo")) {
|
||||
t.Fatalf("Unexpected error returned: %#v", err)
|
||||
}
|
||||
|
||||
_, err = registry.Get(ctx, "foo")
|
||||
if !errors.IsNotFound(etcderrors.InterpretGetError(err, "Pod", "foo")) {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEtcdCreateFailsWithoutNamespace(t *testing.T) {
|
||||
registry, _, _, fakeClient, _ := newStorage(t)
|
||||
fakeClient.TestIndex = true
|
||||
|
Loading…
Reference in New Issue
Block a user