Unify DeleteAllEtcdKeys in integration tests.

pull/6/head
Wojciech Tyczynski 2016-06-23 13:43:07 +02:00
parent 37edcc8242
commit 08f17fef27
15 changed files with 89 additions and 35 deletions

View File

@ -412,6 +412,7 @@ func getTestRequests() []struct {
//
// TODO(etune): write a fuzz test of the REST API.
func TestAuthModeAlwaysAllow(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
// Set up a master
@ -517,6 +518,7 @@ func getPreviousResourceVersionKey(url, id string) string {
}
func TestAuthModeAlwaysDeny(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
// Set up a master
@ -571,7 +573,7 @@ func (allowAliceAuthorizer) Authorize(a authorizer.Attributes) error {
// TestAliceNotForbiddenOrUnauthorized tests a user who is known to
// the authentication system and authorized to do any actions.
func TestAliceNotForbiddenOrUnauthorized(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
// 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
// should receive "Forbidden".
func TestBobIsForbidden(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
// 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
// test purposes, but requests aren't expected to reach it.
func TestUnknownUserIsUnauthorized(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
// This file has alice and bob in it.
@ -772,6 +776,7 @@ func (impersonateAuthorizer) Authorize(a authorizer.Attributes) error {
}
func TestImpersonateIsForbidden(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
var m *master.Master
@ -923,6 +928,7 @@ func (a *trackingAuthorizer) Authorize(attributes authorizer.Attributes) error {
// TestAuthorizationAttributeDetermination tests that authorization attributes are built correctly
func TestAuthorizationAttributeDetermination(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
trackingAuthorizer := &trackingAuthorizer{}
@ -993,6 +999,7 @@ func TestAuthorizationAttributeDetermination(t *testing.T) {
// TestNamespaceAuthorization tests that authorization can be controlled
// by namespace.
func TestNamespaceAuthorization(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
// This file has alice and bob in it.
@ -1096,6 +1103,7 @@ func TestNamespaceAuthorization(t *testing.T) {
// TestKindAuthorization tests that authorization can be controlled
// by namespace.
func TestKindAuthorization(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
// This file has alice and bob in it.
@ -1189,6 +1197,7 @@ func TestKindAuthorization(t *testing.T) {
// TestReadOnlyAuthorization tests that authorization can be controlled
// by namespace.
func TestReadOnlyAuthorization(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
// 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
// decisions.
func TestWebhookTokenAuthenticator(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
var m *master.Master

View File

@ -44,11 +44,13 @@ import (
)
func TestClient(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)
defer s.Close()
ns := api.NamespaceDefault
framework.DeleteAllEtcdKeys()
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
info, err := client.Discovery().ServerVersion()
@ -114,10 +116,12 @@ func TestClient(t *testing.T) {
}
func TestAtomicPut(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)
defer s.Close()
framework.DeleteAllEtcdKeys()
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
rcBody := api.ReplicationController{
@ -203,10 +207,12 @@ func TestAtomicPut(t *testing.T) {
}
func TestPatch(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)
defer s.Close()
framework.DeleteAllEtcdKeys()
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
name := "patchpod"
@ -309,10 +315,12 @@ func TestPatch(t *testing.T) {
}
func TestPatchWithCreateOnUpdate(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)
defer s.Close()
framework.DeleteAllEtcdKeys()
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
endpointTemplate := &api.Endpoints{
@ -415,10 +423,12 @@ func TestPatchWithCreateOnUpdate(t *testing.T) {
}
func TestAPIVersions(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)
defer s.Close()
framework.DeleteAllEtcdKeys()
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
clientVersion := c.APIVersion().String()
@ -438,11 +448,13 @@ func TestAPIVersions(t *testing.T) {
}
func TestSingleWatch(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)
defer s.Close()
ns := "blargh"
framework.DeleteAllEtcdKeys()
client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
mkEvent := func(i int) *api.Event {
@ -518,11 +530,13 @@ func TestMultiWatch(t *testing.T) {
// Disable this test as long as it demonstrates a problem.
// TODO: Reenable this test when we get #6059 resolved.
return
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
const watcherCount = 50
rt.GOMAXPROCS(watcherCount)
framework.DeleteAllEtcdKeys()
defer framework.DeleteAllEtcdKeys()
_, s := framework.RunAMaster(t)
defer s.Close()
@ -777,10 +791,12 @@ func runSelfLinkTestOnNamespace(t *testing.T, c *client.Client, namespace string
}
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)
defer s.Close()
framework.DeleteAllEtcdKeys()
c := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
runSelfLinkTestOnNamespace(t, c, api.NamespaceDefault)

View File

@ -35,6 +35,9 @@ import (
// TestConfigMap tests apiserver-side behavior of creation of ConfigMaps and pods that consume them.
func TestConfigMap(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
var m *master.Master
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
m.Handler.ServeHTTP(w, req)
@ -47,7 +50,6 @@ func TestConfigMap(t *testing.T) {
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()}})
DoTestConfigMap(t, client)

View File

@ -34,10 +34,12 @@ import (
)
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)
defer s.Close()
framework.DeleteAllEtcdKeys()
gv := testapi.Default.GroupVersion()
config := &restclient.Config{
Host: s.URL,

View File

@ -186,6 +186,7 @@ func machine_3_Prioritizer(pod *api.Pod, nodes *api.NodeList) (*schedulerapi.Hos
}
func TestSchedulerExtender(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
var m *master.Master

View File

@ -79,5 +79,4 @@ func DeleteAllEtcdKeys() {
glog.Fatalf("Unable delete key: %v", err)
}
}
}

View File

@ -117,6 +117,9 @@ func newOwnerRC(name string) *v1.ReplicationController {
}
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
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
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)
}
framework.DeleteAllEtcdKeys()
clientSet, err := clientset.NewForConfig(&restclient.Config{Host: s.URL})
if err != nil {
t.Fatalf("Error in create clientset: %v", err)

View File

@ -392,6 +392,9 @@ func countEndpoints(eps *api.Endpoints) int {
}
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())
if err != nil {
t.Fatalf("Error in bringing up the master: %v", err)
@ -401,7 +404,6 @@ func TestMasterService(t *testing.T) {
}))
defer s.Close()
framework.DeleteAllEtcdKeys()
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) {

View File

@ -104,11 +104,13 @@ func testSleep() {
}
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")
_, s := framework.RunAMaster(t)
defer s.Close()
framework.DeleteAllEtcdKeys()
testClient, ctrl, watchPV, watchPVC := createClients(t, s)
defer watchPV.Stop()
defer watchPVC.Stop()
@ -152,11 +154,13 @@ func TestPersistentVolumeRecycler(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")
_, s := framework.RunAMaster(t)
defer s.Close()
framework.DeleteAllEtcdKeys()
testClient, ctrl, watchPV, watchPVC := createClients(t, s)
defer watchPV.Stop()
defer watchPVC.Stop()
@ -202,13 +206,15 @@ func TestPersistentVolumeDeleter(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
// PVC. Only this specific PVC should get bound.
glog.V(2).Infof("TestPersistentVolumeBindRace started")
_, s := framework.RunAMaster(t)
defer s.Close()
framework.DeleteAllEtcdKeys()
testClient, ctrl, watchPV, watchPVC := createClients(t, s)
defer watchPV.Stop()
defer watchPVC.Stop()
@ -270,10 +276,12 @@ func TestPersistentVolumeBindRace(t *testing.T) {
// TestPersistentVolumeClaimLabelSelector test binding using label selectors
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)
defer s.Close()
framework.DeleteAllEtcdKeys()
testClient, controller, watchPV, watchPVC := createClients(t, s)
defer watchPV.Stop()
defer watchPVC.Stop()
@ -343,10 +351,12 @@ func TestPersistentVolumeClaimLabelSelector(t *testing.T) {
// TestPersistentVolumeClaimLabelSelectorMatchExpressions test binding using
// MatchExpressions label selectors
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)
defer s.Close()
framework.DeleteAllEtcdKeys()
testClient, controller, watchPV, watchPVC := createClients(t, s)
defer watchPV.Stop()
defer watchPVC.Stop()
@ -435,10 +445,12 @@ func TestPersistentVolumeClaimLabelSelectorMatchExpressions(t *testing.T) {
// TestPersistentVolumeMultiPVs tests binding of one PVC to 100 PVs with
// different size.
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)
defer s.Close()
framework.DeleteAllEtcdKeys()
testClient, controller, watchPV, watchPVC := createClients(t, s)
defer watchPV.Stop()
defer watchPVC.Stop()
@ -512,17 +524,17 @@ func TestPersistentVolumeMultiPVs(t *testing.T) {
waitForAnyPersistentVolumePhase(watchPV, api.VolumeReleased)
t.Log("volumes released")
framework.DeleteAllEtcdKeys()
}
// TestPersistentVolumeMultiPVsPVCs tests binding of 100 PVC to 100 PVs.
// This test is configurable by KUBE_INTEGRATION_PV_* variables.
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)
defer s.Close()
framework.DeleteAllEtcdKeys()
testClient, binder, watchPV, watchPVC := createClients(t, s)
defer watchPV.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)
}
testSleep()
framework.DeleteAllEtcdKeys()
}
// TestPersistentVolumeProvisionMultiPVCs tests provisioning of many PVCs.
// This test is configurable by KUBE_INTEGRATION_PV_* variables.
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)
defer s.Close()
framework.DeleteAllEtcdKeys()
testClient, binder, watchPV, watchPVC := createClients(t, s)
defer watchPV.Stop()
defer watchPVC.Stop()
@ -671,17 +684,17 @@ func TestPersistentVolumeProvisionMultiPVCs(t *testing.T) {
time.Sleep(time.Second)
}
glog.V(2).Infof("TestPersistentVolumeProvisionMultiPVCs: volumes are deleted")
framework.DeleteAllEtcdKeys()
}
// TestPersistentVolumeMultiPVsDiffAccessModes tests binding of one PVC to two
// PVs with different access modes.
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)
defer s.Close()
framework.DeleteAllEtcdKeys()
testClient, controller, watchPV, watchPVC := createClients(t, s)
defer watchPV.Stop()
defer watchPVC.Stop()
@ -746,8 +759,6 @@ func TestPersistentVolumeMultiPVsDiffAccessModes(t *testing.T) {
waitForAnyPersistentVolumePhase(watchPV, api.VolumeReleased)
t.Log("volume released")
framework.DeleteAllEtcdKeys()
}
func waitForPersistentVolumePhase(client *clientset.Clientset, pvName string, w watch.Interface, phase api.PersistentVolumePhase) {

View File

@ -33,6 +33,9 @@ import (
)
func TestPodUpdateActiveDeadlineSeconds(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
var m *master.Master
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
m.Handler.ServeHTTP(w, req)
@ -46,7 +49,6 @@ func TestPodUpdateActiveDeadlineSeconds(t *testing.T) {
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()}})
var (
@ -158,6 +160,9 @@ func TestPodUpdateActiveDeadlineSeconds(t *testing.T) {
}
func TestPodReadOnlyFilesystem(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
var m *master.Master
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
m.Handler.ServeHTTP(w, req)
@ -172,7 +177,6 @@ func TestPodReadOnlyFilesystem(t *testing.T) {
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()}})
pod := &api.Pod{

View File

@ -54,6 +54,7 @@ func init() {
// quota_test.go:100: Took 4.196205966s to scale up without quota
// quota_test.go:115: Took 12.021640372s to scale up with quota
func TestQuota(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
initializationCh := make(chan struct{})

View File

@ -355,6 +355,7 @@ func TestRBAC(t *testing.T) {
}
for i, tc := range tests {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
var m *master.Master

View File

@ -53,6 +53,7 @@ type nodeStateManager struct {
}
func TestUnschedulableNodes(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
var m *master.Master
@ -300,6 +301,7 @@ func DoTestUnschedulableNodes(t *testing.T, restClient *client.Client, nodeStore
}
func TestMultiScheduler(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
var m *master.Master

View File

@ -41,6 +41,9 @@ 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.
func TestSecrets(t *testing.T) {
// TODO: Limit the test to a single non-default namespace and clean this up at the end.
framework.DeleteAllEtcdKeys()
var m *master.Master
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
m.Handler.ServeHTTP(w, req)
@ -53,7 +56,6 @@ func TestSecrets(t *testing.T) {
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()}})
DoTestSecrets(t, client)
}

View File

@ -336,7 +336,6 @@ func TestServiceAccountTokenAuthentication(t *testing.T) {
// startServiceAccountTestServer returns a started server
// It is the responsibility of the caller to ensure the returned stopFunc is called
func startServiceAccountTestServer(t *testing.T) (*clientset.Clientset, restclient.Config, func()) {
framework.DeleteAllEtcdKeys()
// Listener