mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #27938 from wojtek-t/integration_namespaces
Automatic merge from submit-queue Unify DeleteAllEtcdKeys in integration tests & start using namespaces in some tests Getting rid of DeleteAllEtcdKeys() and running all tests in separate namespace is necessary to run integration tests in parallel. Aside from that, this is first step of reducing amount of annoying logs in integration tests...
This commit is contained in:
commit
1b5cf22de6
@ -412,6 +412,7 @@ func getTestRequests() []struct {
|
|||||||
//
|
//
|
||||||
// TODO(etune): write a fuzz test of the REST API.
|
// TODO(etune): write a fuzz test of the REST API.
|
||||||
func TestAuthModeAlwaysAllow(t *testing.T) {
|
func TestAuthModeAlwaysAllow(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
// Set up a master
|
// Set up a master
|
||||||
@ -517,6 +518,7 @@ func getPreviousResourceVersionKey(url, id string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAuthModeAlwaysDeny(t *testing.T) {
|
func TestAuthModeAlwaysDeny(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
// Set up a master
|
// Set up a master
|
||||||
@ -571,7 +573,7 @@ func (allowAliceAuthorizer) Authorize(a authorizer.Attributes) error {
|
|||||||
// TestAliceNotForbiddenOrUnauthorized tests a user who is known to
|
// TestAliceNotForbiddenOrUnauthorized tests a user who is known to
|
||||||
// the authentication system and authorized to do any actions.
|
// the authentication system and authorized to do any actions.
|
||||||
func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
|
func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
// This file has alice and bob in it.
|
// This file has alice and bob in it.
|
||||||
@ -652,6 +654,7 @@ func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
|
|||||||
// the authentication system but not authorized to do any actions
|
// the authentication system but not authorized to do any actions
|
||||||
// should receive "Forbidden".
|
// should receive "Forbidden".
|
||||||
func TestBobIsForbidden(t *testing.T) {
|
func TestBobIsForbidden(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
// This file has alice and bob in it.
|
// This file has alice and bob in it.
|
||||||
@ -701,6 +704,7 @@ func TestBobIsForbidden(t *testing.T) {
|
|||||||
// An authorization module is installed in this scenario for integration
|
// An authorization module is installed in this scenario for integration
|
||||||
// test purposes, but requests aren't expected to reach it.
|
// test purposes, but requests aren't expected to reach it.
|
||||||
func TestUnknownUserIsUnauthorized(t *testing.T) {
|
func TestUnknownUserIsUnauthorized(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
// This file has alice and bob in it.
|
// This file has alice and bob in it.
|
||||||
@ -772,6 +776,7 @@ func (impersonateAuthorizer) Authorize(a authorizer.Attributes) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestImpersonateIsForbidden(t *testing.T) {
|
func TestImpersonateIsForbidden(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
var m *master.Master
|
var m *master.Master
|
||||||
@ -923,6 +928,7 @@ func (a *trackingAuthorizer) Authorize(attributes authorizer.Attributes) error {
|
|||||||
|
|
||||||
// TestAuthorizationAttributeDetermination tests that authorization attributes are built correctly
|
// TestAuthorizationAttributeDetermination tests that authorization attributes are built correctly
|
||||||
func TestAuthorizationAttributeDetermination(t *testing.T) {
|
func TestAuthorizationAttributeDetermination(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
trackingAuthorizer := &trackingAuthorizer{}
|
trackingAuthorizer := &trackingAuthorizer{}
|
||||||
@ -993,6 +999,7 @@ func TestAuthorizationAttributeDetermination(t *testing.T) {
|
|||||||
// TestNamespaceAuthorization tests that authorization can be controlled
|
// TestNamespaceAuthorization tests that authorization can be controlled
|
||||||
// by namespace.
|
// by namespace.
|
||||||
func TestNamespaceAuthorization(t *testing.T) {
|
func TestNamespaceAuthorization(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
// This file has alice and bob in it.
|
// This file has alice and bob in it.
|
||||||
@ -1096,6 +1103,7 @@ func TestNamespaceAuthorization(t *testing.T) {
|
|||||||
// TestKindAuthorization tests that authorization can be controlled
|
// TestKindAuthorization tests that authorization can be controlled
|
||||||
// by namespace.
|
// by namespace.
|
||||||
func TestKindAuthorization(t *testing.T) {
|
func TestKindAuthorization(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
// This file has alice and bob in it.
|
// This file has alice and bob in it.
|
||||||
@ -1189,6 +1197,7 @@ func TestKindAuthorization(t *testing.T) {
|
|||||||
// TestReadOnlyAuthorization tests that authorization can be controlled
|
// TestReadOnlyAuthorization tests that authorization can be controlled
|
||||||
// by namespace.
|
// by namespace.
|
||||||
func TestReadOnlyAuthorization(t *testing.T) {
|
func TestReadOnlyAuthorization(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
// This file has alice and bob in it.
|
// This file has alice and bob in it.
|
||||||
@ -1253,6 +1262,7 @@ func TestReadOnlyAuthorization(t *testing.T) {
|
|||||||
// authenticator to call out to a remote web server for authentication
|
// authenticator to call out to a remote web server for authentication
|
||||||
// decisions.
|
// decisions.
|
||||||
func TestWebhookTokenAuthenticator(t *testing.T) {
|
func TestWebhookTokenAuthenticator(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
var m *master.Master
|
var m *master.Master
|
||||||
|
@ -47,10 +47,11 @@ func TestClient(t *testing.T) {
|
|||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
ns := api.NamespaceDefault
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
|
ns := framework.CreateTestingNamespace("client", s, t)
|
||||||
|
defer framework.DeleteTestingNamespace(ns, s, t)
|
||||||
|
|
||||||
info, err := client.Discovery().ServerVersion()
|
info, err := client.Discovery().ServerVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
@ -59,7 +60,7 @@ func TestClient(t *testing.T) {
|
|||||||
t.Errorf("expected %#v, got %#v", e, a)
|
t.Errorf("expected %#v, got %#v", e, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
pods, err := client.Pods(ns).List(api.ListOptions{})
|
pods, err := client.Pods(ns.Name).List(api.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -71,6 +72,7 @@ func TestClient(t *testing.T) {
|
|||||||
pod := &api.Pod{
|
pod := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
GenerateName: "test",
|
GenerateName: "test",
|
||||||
|
Namespace: ns.Name,
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
@ -81,14 +83,14 @@ func TestClient(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
got, err := client.Pods(ns).Create(pod)
|
got, err := client.Pods(ns.Name).Create(pod)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("unexpected non-error: %v", got)
|
t.Fatalf("unexpected non-error: %v", got)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get a created pod
|
// get a created pod
|
||||||
pod.Spec.Containers[0].Image = "an-image"
|
pod.Spec.Containers[0].Image = "an-image"
|
||||||
got, err = client.Pods(ns).Create(pod)
|
got, err = client.Pods(ns.Name).Create(pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -97,7 +99,7 @@ func TestClient(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pod is shown, but not scheduled
|
// pod is shown, but not scheduled
|
||||||
pods, err = client.Pods(ns).List(api.ListOptions{})
|
pods, err = client.Pods(ns.Name).List(api.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -117,15 +119,18 @@ func TestAtomicPut(t *testing.T) {
|
|||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
|
ns := framework.CreateTestingNamespace("atomic-put", s, t)
|
||||||
|
defer framework.DeleteTestingNamespace(ns, s, t)
|
||||||
|
|
||||||
rcBody := api.ReplicationController{
|
rcBody := api.ReplicationController{
|
||||||
TypeMeta: unversioned.TypeMeta{
|
TypeMeta: unversioned.TypeMeta{
|
||||||
APIVersion: c.APIVersion().String(),
|
APIVersion: c.APIVersion().String(),
|
||||||
},
|
},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "atomicrc",
|
Name: "atomicrc",
|
||||||
|
Namespace: ns.Name,
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
"name": "atomicrc",
|
"name": "atomicrc",
|
||||||
},
|
},
|
||||||
@ -149,7 +154,7 @@ func TestAtomicPut(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
rcs := c.ReplicationControllers(api.NamespaceDefault)
|
rcs := c.ReplicationControllers(ns.Name)
|
||||||
rc, err := rcs.Create(&rcBody)
|
rc, err := rcs.Create(&rcBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed creating atomicRC: %v", err)
|
t.Fatalf("Failed creating atomicRC: %v", err)
|
||||||
@ -206,9 +211,11 @@ func TestPatch(t *testing.T) {
|
|||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
|
ns := framework.CreateTestingNamespace("patch", s, t)
|
||||||
|
defer framework.DeleteTestingNamespace(ns, s, t)
|
||||||
|
|
||||||
name := "patchpod"
|
name := "patchpod"
|
||||||
resource := "pods"
|
resource := "pods"
|
||||||
podBody := api.Pod{
|
podBody := api.Pod{
|
||||||
@ -216,8 +223,9 @@ func TestPatch(t *testing.T) {
|
|||||||
APIVersion: c.APIVersion().String(),
|
APIVersion: c.APIVersion().String(),
|
||||||
},
|
},
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Labels: map[string]string{},
|
Namespace: ns.Name,
|
||||||
|
Labels: map[string]string{},
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
@ -225,7 +233,7 @@ func TestPatch(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
pods := c.Pods(api.NamespaceDefault)
|
pods := c.Pods(ns.Name)
|
||||||
pod, err := pods.Create(&podBody)
|
pod, err := pods.Create(&podBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed creating patchpods: %v", err)
|
t.Fatalf("Failed creating patchpods: %v", err)
|
||||||
@ -260,7 +268,7 @@ func TestPatch(t *testing.T) {
|
|||||||
execPatch := func(pt api.PatchType, body []byte) error {
|
execPatch := func(pt api.PatchType, body []byte) error {
|
||||||
return c.Patch(pt).
|
return c.Patch(pt).
|
||||||
Resource(resource).
|
Resource(resource).
|
||||||
Namespace(api.NamespaceDefault).
|
Namespace(ns.Name).
|
||||||
Name(name).
|
Name(name).
|
||||||
Body(body).
|
Body(body).
|
||||||
Do().
|
Do().
|
||||||
@ -312,11 +320,16 @@ func TestPatchWithCreateOnUpdate(t *testing.T) {
|
|||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
|
ns := framework.CreateTestingNamespace("patch-with-create", s, t)
|
||||||
|
defer framework.DeleteTestingNamespace(ns, s, t)
|
||||||
|
|
||||||
endpointTemplate := &api.Endpoints{
|
endpointTemplate := &api.Endpoints{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "patchendpoint"},
|
ObjectMeta: api.ObjectMeta{
|
||||||
|
Name: "patchendpoint",
|
||||||
|
Namespace: ns.Name,
|
||||||
|
},
|
||||||
Subsets: []api.EndpointSubset{
|
Subsets: []api.EndpointSubset{
|
||||||
{
|
{
|
||||||
Addresses: []api.EndpointAddress{{IP: "1.2.3.4"}},
|
Addresses: []api.EndpointAddress{{IP: "1.2.3.4"}},
|
||||||
@ -326,7 +339,7 @@ func TestPatchWithCreateOnUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
patchEndpoint := func(json []byte) (runtime.Object, error) {
|
patchEndpoint := func(json []byte) (runtime.Object, error) {
|
||||||
return c.Patch(api.MergePatchType).Resource("endpoints").Namespace(api.NamespaceDefault).Name("patchendpoint").Body(json).Do().Get()
|
return c.Patch(api.MergePatchType).Resource("endpoints").Namespace(ns.Name).Name("patchendpoint").Body(json).Do().Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure patch doesn't get to CreateOnUpdate
|
// Make sure patch doesn't get to CreateOnUpdate
|
||||||
@ -341,7 +354,7 @@ func TestPatchWithCreateOnUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the endpoint (endpoints set AllowCreateOnUpdate=true) to get a UID and resource version
|
// Create the endpoint (endpoints set AllowCreateOnUpdate=true) to get a UID and resource version
|
||||||
createdEndpoint, err := c.Endpoints(api.NamespaceDefault).Update(endpointTemplate)
|
createdEndpoint, err := c.Endpoints(ns.Name).Update(endpointTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed creating endpoint: %v", err)
|
t.Fatalf("Failed creating endpoint: %v", err)
|
||||||
}
|
}
|
||||||
@ -418,7 +431,6 @@ func TestAPIVersions(t *testing.T) {
|
|||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
clientVersion := c.APIVersion().String()
|
clientVersion := c.APIVersion().String()
|
||||||
@ -441,19 +453,20 @@ func TestSingleWatch(t *testing.T) {
|
|||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
ns := "blargh"
|
ns := framework.CreateTestingNamespace("single-watch", s, t)
|
||||||
framework.DeleteAllEtcdKeys()
|
defer framework.DeleteTestingNamespace(ns, s, t)
|
||||||
|
|
||||||
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
mkEvent := func(i int) *api.Event {
|
mkEvent := func(i int) *api.Event {
|
||||||
name := fmt.Sprintf("event-%v", i)
|
name := fmt.Sprintf("event-%v", i)
|
||||||
return &api.Event{
|
return &api.Event{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Namespace: ns,
|
Namespace: ns.Name,
|
||||||
Name: name,
|
Name: name,
|
||||||
},
|
},
|
||||||
InvolvedObject: api.ObjectReference{
|
InvolvedObject: api.ObjectReference{
|
||||||
Namespace: ns,
|
Namespace: ns.Name,
|
||||||
Name: name,
|
Name: name,
|
||||||
},
|
},
|
||||||
Reason: fmt.Sprintf("event %v", i),
|
Reason: fmt.Sprintf("event %v", i),
|
||||||
@ -463,7 +476,7 @@ func TestSingleWatch(t *testing.T) {
|
|||||||
rv1 := ""
|
rv1 := ""
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
event := mkEvent(i)
|
event := mkEvent(i)
|
||||||
got, err := client.Events(ns).Create(event)
|
got, err := client.Events(ns.Name).Create(event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed creating event %#q: %v", event, err)
|
t.Fatalf("Failed creating event %#q: %v", event, err)
|
||||||
}
|
}
|
||||||
@ -478,7 +491,7 @@ func TestSingleWatch(t *testing.T) {
|
|||||||
|
|
||||||
w, err := client.Get().
|
w, err := client.Get().
|
||||||
Prefix("watch").
|
Prefix("watch").
|
||||||
NamespaceIfScoped(ns, len(ns) > 0).
|
Namespace(ns.Name).
|
||||||
Resource("events").
|
Resource("events").
|
||||||
Name("event-9").
|
Name("event-9").
|
||||||
Param("resourceVersion", rv1).
|
Param("resourceVersion", rv1).
|
||||||
@ -518,15 +531,16 @@ func TestMultiWatch(t *testing.T) {
|
|||||||
// Disable this test as long as it demonstrates a problem.
|
// Disable this test as long as it demonstrates a problem.
|
||||||
// TODO: Reenable this test when we get #6059 resolved.
|
// TODO: Reenable this test when we get #6059 resolved.
|
||||||
return
|
return
|
||||||
|
|
||||||
const watcherCount = 50
|
const watcherCount = 50
|
||||||
rt.GOMAXPROCS(watcherCount)
|
rt.GOMAXPROCS(watcherCount)
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
defer framework.DeleteAllEtcdKeys()
|
|
||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
ns := api.NamespaceDefault
|
ns := framework.CreateTestingNamespace("multi-watch", s, t)
|
||||||
|
defer framework.DeleteTestingNamespace(ns, s, t)
|
||||||
|
|
||||||
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
dummyEvent := func(i int) *api.Event {
|
dummyEvent := func(i int) *api.Event {
|
||||||
@ -534,11 +548,11 @@ func TestMultiWatch(t *testing.T) {
|
|||||||
return &api.Event{
|
return &api.Event{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: fmt.Sprintf("%v.%x", name, time.Now().UnixNano()),
|
Name: fmt.Sprintf("%v.%x", name, time.Now().UnixNano()),
|
||||||
Namespace: ns,
|
Namespace: ns.Name,
|
||||||
},
|
},
|
||||||
InvolvedObject: api.ObjectReference{
|
InvolvedObject: api.ObjectReference{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: ns,
|
Namespace: ns.Name,
|
||||||
},
|
},
|
||||||
Reason: fmt.Sprintf("unrelated change %v", i),
|
Reason: fmt.Sprintf("unrelated change %v", i),
|
||||||
}
|
}
|
||||||
@ -556,7 +570,7 @@ func TestMultiWatch(t *testing.T) {
|
|||||||
for i := 0; i < watcherCount; i++ {
|
for i := 0; i < watcherCount; i++ {
|
||||||
watchesStarted.Add(1)
|
watchesStarted.Add(1)
|
||||||
name := fmt.Sprintf("multi-watch-%v", i)
|
name := fmt.Sprintf("multi-watch-%v", i)
|
||||||
got, err := client.Pods(ns).Create(&api.Pod{
|
got, err := client.Pods(ns.Name).Create(&api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Labels: labels.Set{"watchlabel": name},
|
Labels: labels.Set{"watchlabel": name},
|
||||||
@ -577,7 +591,7 @@ func TestMultiWatch(t *testing.T) {
|
|||||||
LabelSelector: labels.Set{"watchlabel": name}.AsSelector(),
|
LabelSelector: labels.Set{"watchlabel": name}.AsSelector(),
|
||||||
ResourceVersion: rv,
|
ResourceVersion: rv,
|
||||||
}
|
}
|
||||||
w, err := client.Pods(ns).Watch(options)
|
w, err := client.Pods(ns.Name).Watch(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("watch error for %v: %v", name, err))
|
panic(fmt.Sprintf("watch error for %v: %v", name, err))
|
||||||
}
|
}
|
||||||
@ -626,7 +640,7 @@ func TestMultiWatch(t *testing.T) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, err := client.Events(ns).Create(dummyEvent(i)); err != nil {
|
if _, err := client.Events(ns.Name).Create(dummyEvent(i)); err != nil {
|
||||||
panic(fmt.Sprintf("couldn't make an event: %v", err))
|
panic(fmt.Sprintf("couldn't make an event: %v", err))
|
||||||
}
|
}
|
||||||
changeMade <- i
|
changeMade <- i
|
||||||
@ -663,7 +677,7 @@ func TestMultiWatch(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
name := fmt.Sprintf("unrelated-%v", i)
|
name := fmt.Sprintf("unrelated-%v", i)
|
||||||
_, err := client.Pods(ns).Create(&api.Pod{
|
_, err := client.Pods(ns.Name).Create(&api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
},
|
},
|
||||||
@ -697,13 +711,13 @@ func TestMultiWatch(t *testing.T) {
|
|||||||
for i := 0; i < watcherCount; i++ {
|
for i := 0; i < watcherCount; i++ {
|
||||||
go func(i int) {
|
go func(i int) {
|
||||||
name := fmt.Sprintf("multi-watch-%v", i)
|
name := fmt.Sprintf("multi-watch-%v", i)
|
||||||
pod, err := client.Pods(ns).Get(name)
|
pod, err := client.Pods(ns.Name).Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("Couldn't get %v: %v", name, err))
|
panic(fmt.Sprintf("Couldn't get %v: %v", name, err))
|
||||||
}
|
}
|
||||||
pod.Spec.Containers[0].Image = e2e.GetPauseImageName(client)
|
pod.Spec.Containers[0].Image = e2e.GetPauseImageName(client)
|
||||||
sentTimes <- timePair{time.Now(), name}
|
sentTimes <- timePair{time.Now(), name}
|
||||||
if _, err := client.Pods(ns).Update(pod); err != nil {
|
if _, err := client.Pods(ns.Name).Update(pod); err != nil {
|
||||||
panic(fmt.Sprintf("Couldn't make %v: %v", name, err))
|
panic(fmt.Sprintf("Couldn't make %v: %v", name, err))
|
||||||
}
|
}
|
||||||
}(i)
|
}(i)
|
||||||
@ -777,10 +791,12 @@ func runSelfLinkTestOnNamespace(t *testing.T, c *client.Client, namespace string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSelfLinkOnNamespace(t *testing.T) {
|
func TestSelfLinkOnNamespace(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
runSelfLinkTestOnNamespace(t, c, api.NamespaceDefault)
|
runSelfLinkTestOnNamespace(t, c, api.NamespaceDefault)
|
||||||
|
@ -21,44 +21,33 @@ package integration
|
|||||||
// This file tests use of the configMap API resource.
|
// This file tests use of the configMap API resource.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/testapi"
|
"k8s.io/kubernetes/pkg/api/testapi"
|
||||||
"k8s.io/kubernetes/pkg/client/restclient"
|
"k8s.io/kubernetes/pkg/client/restclient"
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/master"
|
|
||||||
"k8s.io/kubernetes/test/integration/framework"
|
"k8s.io/kubernetes/test/integration/framework"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestConfigMap tests apiserver-side behavior of creation of ConfigMaps and pods that consume them.
|
// TestConfigMap tests apiserver-side behavior of creation of ConfigMaps and pods that consume them.
|
||||||
func TestConfigMap(t *testing.T) {
|
func TestConfigMap(t *testing.T) {
|
||||||
var m *master.Master
|
_, s := framework.RunAMaster(t)
|
||||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
m.Handler.ServeHTTP(w, req)
|
|
||||||
}))
|
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
|
||||||
m, err := master.New(masterConfig)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error in bringing up the master: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
DoTestConfigMap(t, client)
|
ns := framework.CreateTestingNamespace("config-map", s, t)
|
||||||
|
defer framework.DeleteTestingNamespace(ns, s, t)
|
||||||
|
|
||||||
|
DoTestConfigMap(t, client, ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DoTestConfigMap(t *testing.T, client *client.Client) {
|
func DoTestConfigMap(t *testing.T, client *client.Client, ns *api.Namespace) {
|
||||||
ns := "ns"
|
|
||||||
cfg := api.ConfigMap{
|
cfg := api.ConfigMap{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "configmap",
|
Name: "configmap",
|
||||||
Namespace: ns,
|
Namespace: ns.Name,
|
||||||
},
|
},
|
||||||
Data: map[string]string{
|
Data: map[string]string{
|
||||||
"data-1": "value-1",
|
"data-1": "value-1",
|
||||||
@ -74,7 +63,8 @@ func DoTestConfigMap(t *testing.T, client *client.Client) {
|
|||||||
|
|
||||||
pod := &api.Pod{
|
pod := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "XXX",
|
Name: "XXX",
|
||||||
|
Namespace: ns.Name,
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
@ -121,10 +111,10 @@ func DoTestConfigMap(t *testing.T, client *client.Client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pod.ObjectMeta.Name = "uses-configmap"
|
pod.ObjectMeta.Name = "uses-configmap"
|
||||||
if _, err := client.Pods(ns).Create(pod); err != nil {
|
if _, err := client.Pods(ns.Name).Create(pod); err != nil {
|
||||||
t.Errorf("Failed to create pod: %v", err)
|
t.Errorf("Failed to create pod: %v", err)
|
||||||
}
|
}
|
||||||
defer deletePodOrErrorf(t, client, ns, pod.Name)
|
defer deletePodOrErrorf(t, client, ns.Name, pod.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteConfigMapOrErrorf(t *testing.T, c *client.Client, ns, name string) {
|
func deleteConfigMapOrErrorf(t *testing.T, c *client.Client, ns, name string) {
|
||||||
|
@ -34,10 +34,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestDynamicClient(t *testing.T) {
|
func TestDynamicClient(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
gv := testapi.Default.GroupVersion()
|
gv := testapi.Default.GroupVersion()
|
||||||
config := &restclient.Config{
|
config := &restclient.Config{
|
||||||
Host: s.URL,
|
Host: s.URL,
|
||||||
|
@ -36,7 +36,6 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/client/record"
|
"k8s.io/kubernetes/pkg/client/record"
|
||||||
"k8s.io/kubernetes/pkg/client/restclient"
|
"k8s.io/kubernetes/pkg/client/restclient"
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/master"
|
|
||||||
"k8s.io/kubernetes/pkg/util/wait"
|
"k8s.io/kubernetes/pkg/util/wait"
|
||||||
"k8s.io/kubernetes/plugin/pkg/scheduler"
|
"k8s.io/kubernetes/plugin/pkg/scheduler"
|
||||||
_ "k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider"
|
_ "k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider"
|
||||||
@ -186,20 +185,12 @@ func machine_3_Prioritizer(pod *api.Pod, nodes *api.NodeList) (*schedulerapi.Hos
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSchedulerExtender(t *testing.T) {
|
func TestSchedulerExtender(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
var m *master.Master
|
_, s := framework.RunAMaster(t)
|
||||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
m.Handler.ServeHTTP(w, req)
|
|
||||||
}))
|
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
|
||||||
m, err := master.New(masterConfig)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error in bringing up the master: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
restClient := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
restClient := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
extender1 := &Extender{
|
extender1 := &Extender{
|
||||||
|
@ -79,5 +79,4 @@ func DeleteAllEtcdKeys() {
|
|||||||
glog.Fatalf("Unable delete key: %v", err)
|
glog.Fatalf("Unable delete key: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -239,6 +239,22 @@ func (m *MasterComponents) Stop(apiServer, rcManager bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CreateTestingNamespace(baseName string, apiserver *httptest.Server, t *testing.T) *api.Namespace {
|
||||||
|
// TODO: Create a namespace with a given basename.
|
||||||
|
// Currently we neither create the namespace nor delete all its contents at the end.
|
||||||
|
// But as long as tests are not using the same namespaces, this should work fine.
|
||||||
|
return &api.Namespace{
|
||||||
|
ObjectMeta: api.ObjectMeta{
|
||||||
|
// TODO: Once we start creating namespaces, switch to GenerateName.
|
||||||
|
Name: baseName,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteTestingNamespace(ns *api.Namespace, apiserver *httptest.Server, t *testing.T) {
|
||||||
|
// TODO: Remove all resources from a given namespace once we implement CreateTestingNamespace.
|
||||||
|
}
|
||||||
|
|
||||||
// RCFromManifest reads a .json file and returns the rc in it.
|
// RCFromManifest reads a .json file and returns the rc in it.
|
||||||
func RCFromManifest(fileName string) *api.ReplicationController {
|
func RCFromManifest(fileName string) *api.ReplicationController {
|
||||||
data, err := ioutil.ReadFile(fileName)
|
data, err := ioutil.ReadFile(fileName)
|
||||||
|
@ -117,6 +117,9 @@ func newOwnerRC(name string) *v1.ReplicationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setup(t *testing.T) (*garbagecollector.GarbageCollector, clientset.Interface) {
|
func setup(t *testing.T) (*garbagecollector.GarbageCollector, clientset.Interface) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
var m *master.Master
|
var m *master.Master
|
||||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||||
m.Handler.ServeHTTP(w, req)
|
m.Handler.ServeHTTP(w, req)
|
||||||
@ -130,7 +133,6 @@ func setup(t *testing.T) (*garbagecollector.GarbageCollector, clientset.Interfac
|
|||||||
t.Fatalf("Error in bringing up the master: %v", err)
|
t.Fatalf("Error in bringing up the master: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
clientSet, err := clientset.NewForConfig(&restclient.Config{Host: s.URL})
|
clientSet, err := clientset.NewForConfig(&restclient.Config{Host: s.URL})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error in create clientset: %v", err)
|
t.Fatalf("Error in create clientset: %v", err)
|
||||||
|
@ -392,6 +392,9 @@ func countEndpoints(eps *api.Endpoints) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMasterService(t *testing.T) {
|
func TestMasterService(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
m, err := master.New(framework.NewIntegrationTestMasterConfig())
|
m, err := master.New(framework.NewIntegrationTestMasterConfig())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error in bringing up the master: %v", err)
|
t.Fatalf("Error in bringing up the master: %v", err)
|
||||||
@ -401,7 +404,6 @@ func TestMasterService(t *testing.T) {
|
|||||||
}))
|
}))
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
err = wait.Poll(time.Second, time.Minute, func() (bool, error) {
|
err = wait.Poll(time.Second, time.Minute, func() (bool, error) {
|
||||||
|
@ -104,11 +104,13 @@ func testSleep() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPersistentVolumeRecycler(t *testing.T) {
|
func TestPersistentVolumeRecycler(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
glog.V(2).Infof("TestPersistentVolumeRecycler started")
|
glog.V(2).Infof("TestPersistentVolumeRecycler started")
|
||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
testClient, ctrl, watchPV, watchPVC := createClients(t, s)
|
testClient, ctrl, watchPV, watchPVC := createClients(t, s)
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
@ -152,11 +154,13 @@ func TestPersistentVolumeRecycler(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPersistentVolumeDeleter(t *testing.T) {
|
func TestPersistentVolumeDeleter(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
glog.V(2).Infof("TestPersistentVolumeDeleter started")
|
glog.V(2).Infof("TestPersistentVolumeDeleter started")
|
||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
testClient, ctrl, watchPV, watchPVC := createClients(t, s)
|
testClient, ctrl, watchPV, watchPVC := createClients(t, s)
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
@ -202,13 +206,15 @@ func TestPersistentVolumeDeleter(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPersistentVolumeBindRace(t *testing.T) {
|
func TestPersistentVolumeBindRace(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
// Test a race binding many claims to a PV that is pre-bound to a specific
|
// Test a race binding many claims to a PV that is pre-bound to a specific
|
||||||
// PVC. Only this specific PVC should get bound.
|
// PVC. Only this specific PVC should get bound.
|
||||||
glog.V(2).Infof("TestPersistentVolumeBindRace started")
|
glog.V(2).Infof("TestPersistentVolumeBindRace started")
|
||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
testClient, ctrl, watchPV, watchPVC := createClients(t, s)
|
testClient, ctrl, watchPV, watchPVC := createClients(t, s)
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
@ -270,10 +276,12 @@ func TestPersistentVolumeBindRace(t *testing.T) {
|
|||||||
|
|
||||||
// TestPersistentVolumeClaimLabelSelector test binding using label selectors
|
// TestPersistentVolumeClaimLabelSelector test binding using label selectors
|
||||||
func TestPersistentVolumeClaimLabelSelector(t *testing.T) {
|
func TestPersistentVolumeClaimLabelSelector(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
testClient, controller, watchPV, watchPVC := createClients(t, s)
|
testClient, controller, watchPV, watchPVC := createClients(t, s)
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
@ -343,10 +351,12 @@ func TestPersistentVolumeClaimLabelSelector(t *testing.T) {
|
|||||||
// TestPersistentVolumeClaimLabelSelectorMatchExpressions test binding using
|
// TestPersistentVolumeClaimLabelSelectorMatchExpressions test binding using
|
||||||
// MatchExpressions label selectors
|
// MatchExpressions label selectors
|
||||||
func TestPersistentVolumeClaimLabelSelectorMatchExpressions(t *testing.T) {
|
func TestPersistentVolumeClaimLabelSelectorMatchExpressions(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
testClient, controller, watchPV, watchPVC := createClients(t, s)
|
testClient, controller, watchPV, watchPVC := createClients(t, s)
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
@ -435,10 +445,12 @@ func TestPersistentVolumeClaimLabelSelectorMatchExpressions(t *testing.T) {
|
|||||||
// TestPersistentVolumeMultiPVs tests binding of one PVC to 100 PVs with
|
// TestPersistentVolumeMultiPVs tests binding of one PVC to 100 PVs with
|
||||||
// different size.
|
// different size.
|
||||||
func TestPersistentVolumeMultiPVs(t *testing.T) {
|
func TestPersistentVolumeMultiPVs(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
testClient, controller, watchPV, watchPVC := createClients(t, s)
|
testClient, controller, watchPV, watchPVC := createClients(t, s)
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
@ -512,17 +524,17 @@ func TestPersistentVolumeMultiPVs(t *testing.T) {
|
|||||||
|
|
||||||
waitForAnyPersistentVolumePhase(watchPV, api.VolumeReleased)
|
waitForAnyPersistentVolumePhase(watchPV, api.VolumeReleased)
|
||||||
t.Log("volumes released")
|
t.Log("volumes released")
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestPersistentVolumeMultiPVsPVCs tests binding of 100 PVC to 100 PVs.
|
// TestPersistentVolumeMultiPVsPVCs tests binding of 100 PVC to 100 PVs.
|
||||||
// This test is configurable by KUBE_INTEGRATION_PV_* variables.
|
// This test is configurable by KUBE_INTEGRATION_PV_* variables.
|
||||||
func TestPersistentVolumeMultiPVsPVCs(t *testing.T) {
|
func TestPersistentVolumeMultiPVsPVCs(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
testClient, binder, watchPV, watchPVC := createClients(t, s)
|
testClient, binder, watchPV, watchPVC := createClients(t, s)
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
@ -593,16 +605,17 @@ func TestPersistentVolumeMultiPVsPVCs(t *testing.T) {
|
|||||||
glog.V(2).Infof("PVC %q is bound to PV %q", pvc.Name, pvc.Spec.VolumeName)
|
glog.V(2).Infof("PVC %q is bound to PV %q", pvc.Name, pvc.Spec.VolumeName)
|
||||||
}
|
}
|
||||||
testSleep()
|
testSleep()
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestPersistentVolumeProvisionMultiPVCs tests provisioning of many PVCs.
|
// TestPersistentVolumeProvisionMultiPVCs tests provisioning of many PVCs.
|
||||||
// This test is configurable by KUBE_INTEGRATION_PV_* variables.
|
// This test is configurable by KUBE_INTEGRATION_PV_* variables.
|
||||||
func TestPersistentVolumeProvisionMultiPVCs(t *testing.T) {
|
func TestPersistentVolumeProvisionMultiPVCs(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
testClient, binder, watchPV, watchPVC := createClients(t, s)
|
testClient, binder, watchPV, watchPVC := createClients(t, s)
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
@ -671,17 +684,17 @@ func TestPersistentVolumeProvisionMultiPVCs(t *testing.T) {
|
|||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
}
|
}
|
||||||
glog.V(2).Infof("TestPersistentVolumeProvisionMultiPVCs: volumes are deleted")
|
glog.V(2).Infof("TestPersistentVolumeProvisionMultiPVCs: volumes are deleted")
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestPersistentVolumeMultiPVsDiffAccessModes tests binding of one PVC to two
|
// TestPersistentVolumeMultiPVsDiffAccessModes tests binding of one PVC to two
|
||||||
// PVs with different access modes.
|
// PVs with different access modes.
|
||||||
func TestPersistentVolumeMultiPVsDiffAccessModes(t *testing.T) {
|
func TestPersistentVolumeMultiPVsDiffAccessModes(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
_, s := framework.RunAMaster(t)
|
_, s := framework.RunAMaster(t)
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
testClient, controller, watchPV, watchPVC := createClients(t, s)
|
testClient, controller, watchPV, watchPVC := createClients(t, s)
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
@ -746,8 +759,6 @@ func TestPersistentVolumeMultiPVsDiffAccessModes(t *testing.T) {
|
|||||||
|
|
||||||
waitForAnyPersistentVolumePhase(watchPV, api.VolumeReleased)
|
waitForAnyPersistentVolumePhase(watchPV, api.VolumeReleased)
|
||||||
t.Log("volume released")
|
t.Log("volume released")
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitForPersistentVolumePhase(client *clientset.Clientset, pvName string, w watch.Interface, phase api.PersistentVolumePhase) {
|
func waitForPersistentVolumePhase(client *clientset.Clientset, pvName string, w watch.Interface, phase api.PersistentVolumePhase) {
|
||||||
|
@ -20,33 +20,22 @@ package integration
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/testapi"
|
"k8s.io/kubernetes/pkg/api/testapi"
|
||||||
"k8s.io/kubernetes/pkg/client/restclient"
|
"k8s.io/kubernetes/pkg/client/restclient"
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/master"
|
|
||||||
"k8s.io/kubernetes/test/integration/framework"
|
"k8s.io/kubernetes/test/integration/framework"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPodUpdateActiveDeadlineSeconds(t *testing.T) {
|
func TestPodUpdateActiveDeadlineSeconds(t *testing.T) {
|
||||||
var m *master.Master
|
_, s := framework.RunAMaster(t)
|
||||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
m.Handler.ServeHTTP(w, req)
|
|
||||||
}))
|
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
ns := "pod-activedeadline-update"
|
ns := framework.CreateTestingNamespace("pod-activedeadline-update", s, t)
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
defer framework.DeleteTestingNamespace(ns, s, t)
|
||||||
m, err := master.New(masterConfig)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error in bringing up the master: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -140,39 +129,31 @@ func TestPodUpdateActiveDeadlineSeconds(t *testing.T) {
|
|||||||
pod.Spec.ActiveDeadlineSeconds = tc.original
|
pod.Spec.ActiveDeadlineSeconds = tc.original
|
||||||
pod.ObjectMeta.Name = fmt.Sprintf("activedeadlineseconds-test-%v", i)
|
pod.ObjectMeta.Name = fmt.Sprintf("activedeadlineseconds-test-%v", i)
|
||||||
|
|
||||||
if _, err := client.Pods(ns).Create(pod); err != nil {
|
if _, err := client.Pods(ns.Name).Create(pod); err != nil {
|
||||||
t.Errorf("Failed to create pod: %v", err)
|
t.Errorf("Failed to create pod: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.Spec.ActiveDeadlineSeconds = tc.update
|
pod.Spec.ActiveDeadlineSeconds = tc.update
|
||||||
|
|
||||||
_, err := client.Pods(ns).Update(pod)
|
_, err := client.Pods(ns.Name).Update(pod)
|
||||||
if tc.valid && err != nil {
|
if tc.valid && err != nil {
|
||||||
t.Errorf("%v: failed to update pod: %v", tc.name, err)
|
t.Errorf("%v: failed to update pod: %v", tc.name, err)
|
||||||
} else if !tc.valid && err == nil {
|
} else if !tc.valid && err == nil {
|
||||||
t.Errorf("%v: unexpected allowed update to pod", tc.name)
|
t.Errorf("%v: unexpected allowed update to pod", tc.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
deletePodOrErrorf(t, client, ns, pod.Name)
|
deletePodOrErrorf(t, client, ns.Name, pod.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPodReadOnlyFilesystem(t *testing.T) {
|
func TestPodReadOnlyFilesystem(t *testing.T) {
|
||||||
var m *master.Master
|
_, s := framework.RunAMaster(t)
|
||||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
m.Handler.ServeHTTP(w, req)
|
|
||||||
}))
|
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
isReadOnly := true
|
isReadOnly := true
|
||||||
ns := "pod-readonly-root"
|
ns := framework.CreateTestingNamespace("pod-readonly-root", s, t)
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
defer framework.DeleteTestingNamespace(ns, s, t)
|
||||||
m, err := master.New(masterConfig)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error in bringing up the master: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
pod := &api.Pod{
|
pod := &api.Pod{
|
||||||
@ -192,9 +173,9 @@ func TestPodReadOnlyFilesystem(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := client.Pods(ns).Create(pod); err != nil {
|
if _, err := client.Pods(ns.Name).Create(pod); err != nil {
|
||||||
t.Errorf("Failed to create pod: %v", err)
|
t.Errorf("Failed to create pod: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
deletePodOrErrorf(t, client, ns, pod.Name)
|
deletePodOrErrorf(t, client, ns.Name, pod.Name)
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ func init() {
|
|||||||
// quota_test.go:100: Took 4.196205966s to scale up without quota
|
// quota_test.go:100: Took 4.196205966s to scale up without quota
|
||||||
// quota_test.go:115: Took 12.021640372s to scale up with quota
|
// quota_test.go:115: Took 12.021640372s to scale up with quota
|
||||||
func TestQuota(t *testing.T) {
|
func TestQuota(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
initializationCh := make(chan struct{})
|
initializationCh := make(chan struct{})
|
||||||
|
@ -355,6 +355,7 @@ func TestRBAC(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range tests {
|
for i, tc := range tests {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
var m *master.Master
|
var m *master.Master
|
||||||
|
@ -22,8 +22,6 @@ package integration
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -36,7 +34,6 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/client/record"
|
"k8s.io/kubernetes/pkg/client/record"
|
||||||
"k8s.io/kubernetes/pkg/client/restclient"
|
"k8s.io/kubernetes/pkg/client/restclient"
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/master"
|
|
||||||
"k8s.io/kubernetes/pkg/util/wait"
|
"k8s.io/kubernetes/pkg/util/wait"
|
||||||
"k8s.io/kubernetes/plugin/pkg/scheduler"
|
"k8s.io/kubernetes/plugin/pkg/scheduler"
|
||||||
_ "k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider"
|
_ "k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider"
|
||||||
@ -53,20 +50,12 @@ type nodeStateManager struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUnschedulableNodes(t *testing.T) {
|
func TestUnschedulableNodes(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
var m *master.Master
|
_, s := framework.RunAMaster(t)
|
||||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
m.Handler.ServeHTTP(w, req)
|
|
||||||
}))
|
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
|
||||||
m, err := master.New(masterConfig)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error in bringing up the master: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
restClient := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
restClient := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
schedulerConfigFactory := factory.NewConfigFactory(restClient, api.DefaultSchedulerName, api.DefaultHardPodAffinitySymmetricWeight, api.DefaultFailureDomains)
|
schedulerConfigFactory := factory.NewConfigFactory(restClient, api.DefaultSchedulerName, api.DefaultHardPodAffinitySymmetricWeight, api.DefaultFailureDomains)
|
||||||
@ -300,21 +289,14 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMultiScheduler(t *testing.T) {
|
func TestMultiScheduler(t *testing.T) {
|
||||||
|
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
var m *master.Master
|
_, s := framework.RunAMaster(t)
|
||||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
m.Handler.ServeHTTP(w, req)
|
|
||||||
}))
|
|
||||||
// TODO: Uncomment when fix #19254
|
// TODO: Uncomment when fix #19254
|
||||||
|
// This seems to be a different issue - it still doesn't work.
|
||||||
// defer s.Close()
|
// defer s.Close()
|
||||||
|
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
|
||||||
m, err := master.New(masterConfig)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error in bringing up the master: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This integration tests the multi-scheduler feature in the following way:
|
This integration tests the multi-scheduler feature in the following way:
|
||||||
1. create a default scheduler
|
1. create a default scheduler
|
||||||
@ -491,18 +473,9 @@ func createPod(client *client.Client, name string, annotation map[string]string)
|
|||||||
func TestAllocatable(t *testing.T) {
|
func TestAllocatable(t *testing.T) {
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
var m *master.Master
|
_, s := framework.RunAMaster(t)
|
||||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
m.Handler.ServeHTTP(w, req)
|
|
||||||
}))
|
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
|
||||||
m, err := master.New(masterConfig)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error in bringing up the master: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. create and start default-scheduler
|
// 1. create and start default-scheduler
|
||||||
restClient := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
restClient := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
|
|
||||||
|
@ -21,15 +21,12 @@ package integration
|
|||||||
// This file tests use of the secrets API resource.
|
// This file tests use of the secrets API resource.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/testapi"
|
"k8s.io/kubernetes/pkg/api/testapi"
|
||||||
"k8s.io/kubernetes/pkg/client/restclient"
|
"k8s.io/kubernetes/pkg/client/restclient"
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/master"
|
|
||||||
"k8s.io/kubernetes/test/integration/framework"
|
"k8s.io/kubernetes/test/integration/framework"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -41,31 +38,24 @@ func deleteSecretOrErrorf(t *testing.T, c *client.Client, ns, name string) {
|
|||||||
|
|
||||||
// TestSecrets tests apiserver-side behavior of creation of secret objects and their use by pods.
|
// TestSecrets tests apiserver-side behavior of creation of secret objects and their use by pods.
|
||||||
func TestSecrets(t *testing.T) {
|
func TestSecrets(t *testing.T) {
|
||||||
var m *master.Master
|
_, s := framework.RunAMaster(t)
|
||||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
m.Handler.ServeHTTP(w, req)
|
|
||||||
}))
|
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
|
||||||
m, err := master.New(masterConfig)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error in bringing up the master: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
|
||||||
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
|
||||||
DoTestSecrets(t, client)
|
|
||||||
|
ns := framework.CreateTestingNamespace("secret", s, t)
|
||||||
|
defer framework.DeleteTestingNamespace(ns, s, t)
|
||||||
|
|
||||||
|
DoTestSecrets(t, client, ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DoTestSecrets test secrets for one api version.
|
// DoTestSecrets test secrets for one api version.
|
||||||
func DoTestSecrets(t *testing.T, client *client.Client) {
|
func DoTestSecrets(t *testing.T, client *client.Client, ns *api.Namespace) {
|
||||||
// Make a secret object.
|
// Make a secret object.
|
||||||
ns := "ns"
|
|
||||||
s := api.Secret{
|
s := api.Secret{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "secret",
|
Name: "secret",
|
||||||
Namespace: ns,
|
Namespace: ns.Name,
|
||||||
},
|
},
|
||||||
Data: map[string][]byte{
|
Data: map[string][]byte{
|
||||||
"data": []byte("value1\n"),
|
"data": []byte("value1\n"),
|
||||||
@ -80,7 +70,8 @@ func DoTestSecrets(t *testing.T, client *client.Client) {
|
|||||||
// Template for pods that use a secret.
|
// Template for pods that use a secret.
|
||||||
pod := &api.Pod{
|
pod := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "XXX",
|
Name: "XXX",
|
||||||
|
Namespace: ns.Name,
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Volumes: []api.Volume{
|
Volumes: []api.Volume{
|
||||||
@ -111,17 +102,17 @@ func DoTestSecrets(t *testing.T, client *client.Client) {
|
|||||||
|
|
||||||
// Create a pod to consume secret.
|
// Create a pod to consume secret.
|
||||||
pod.ObjectMeta.Name = "uses-secret"
|
pod.ObjectMeta.Name = "uses-secret"
|
||||||
if _, err := client.Pods(ns).Create(pod); err != nil {
|
if _, err := client.Pods(ns.Name).Create(pod); err != nil {
|
||||||
t.Errorf("Failed to create pod: %v", err)
|
t.Errorf("Failed to create pod: %v", err)
|
||||||
}
|
}
|
||||||
defer deletePodOrErrorf(t, client, ns, pod.Name)
|
defer deletePodOrErrorf(t, client, ns.Name, pod.Name)
|
||||||
|
|
||||||
// Create a pod that consumes non-existent secret.
|
// Create a pod that consumes non-existent secret.
|
||||||
pod.ObjectMeta.Name = "uses-non-existent-secret"
|
pod.ObjectMeta.Name = "uses-non-existent-secret"
|
||||||
if _, err := client.Pods(ns).Create(pod); err != nil {
|
if _, err := client.Pods(ns.Name).Create(pod); err != nil {
|
||||||
t.Errorf("Failed to create pod: %v", err)
|
t.Errorf("Failed to create pod: %v", err)
|
||||||
}
|
}
|
||||||
defer deletePodOrErrorf(t, client, ns, pod.Name)
|
defer deletePodOrErrorf(t, client, ns.Name, pod.Name)
|
||||||
// This pod may fail to run, but we don't currently prevent this, and this
|
// This pod may fail to run, but we don't currently prevent this, and this
|
||||||
// test can't check whether the kubelet actually pulls the secret.
|
// test can't check whether the kubelet actually pulls the secret.
|
||||||
|
|
||||||
|
@ -336,7 +336,6 @@ func TestServiceAccountTokenAuthentication(t *testing.T) {
|
|||||||
// startServiceAccountTestServer returns a started server
|
// startServiceAccountTestServer returns a started server
|
||||||
// It is the responsibility of the caller to ensure the returned stopFunc is called
|
// It is the responsibility of the caller to ensure the returned stopFunc is called
|
||||||
func startServiceAccountTestServer(t *testing.T) (*clientset.Clientset, restclient.Config, func()) {
|
func startServiceAccountTestServer(t *testing.T) (*clientset.Clientset, restclient.Config, func()) {
|
||||||
|
|
||||||
framework.DeleteAllEtcdKeys()
|
framework.DeleteAllEtcdKeys()
|
||||||
|
|
||||||
// Listener
|
// Listener
|
||||||
|
Loading…
Reference in New Issue
Block a user