From 40e80e1e75f1f7084f22dba423caf765b53eacd7 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Tue, 18 Aug 2015 17:43:13 -0400 Subject: [PATCH] Soak tests should wait until namespaces are dead before exiting --- test/soak/cauldron/cauldron.go | 24 +++++++++++++++----- test/soak/serve_hostnames/serve_hostnames.go | 24 +++++++++++++++----- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/test/soak/cauldron/cauldron.go b/test/soak/cauldron/cauldron.go index ceb7f39ea52..cf68b21f8c0 100644 --- a/test/soak/cauldron/cauldron.go +++ b/test/soak/cauldron/cauldron.go @@ -31,6 +31,7 @@ import ( "github.com/golang/glog" "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/errors" client "k8s.io/kubernetes/pkg/client/unversioned" "k8s.io/kubernetes/pkg/fields" "k8s.io/kubernetes/pkg/labels" @@ -45,12 +46,13 @@ var ( ) const ( - deleteTimeout = 2 * time.Minute - endpointTimeout = 5 * time.Minute - nodeListTimeout = 2 * time.Minute - podCreateTimeout = 2 * time.Minute - podStartTimeout = 30 * time.Minute - serviceCreateTimeout = 2 * time.Minute + deleteTimeout = 2 * time.Minute + endpointTimeout = 5 * time.Minute + nodeListTimeout = 2 * time.Minute + podCreateTimeout = 2 * time.Minute + podStartTimeout = 30 * time.Minute + serviceCreateTimeout = 2 * time.Minute + namespaceDeleteTimeout = 5 * time.Minute ) func main() { @@ -96,6 +98,16 @@ func main() { defer func(ns string) { if err := c.Namespaces().Delete(ns); err != nil { glog.Warningf("Failed to delete namespace ns: %e", ns, err) + } else { + // wait until the namespace disappears + for i := 0; i < int(namespaceDeleteTimeout/time.Second); i++ { + if _, err := c.Namespaces().Get(ns); err != nil { + if errors.IsNotFound(err) { + return + } + } + time.Sleep(time.Second) + } } }(ns) glog.Infof("Created namespace %s", ns) diff --git a/test/soak/serve_hostnames/serve_hostnames.go b/test/soak/serve_hostnames/serve_hostnames.go index 4d4c985d613..177a46d3e75 100644 --- a/test/soak/serve_hostnames/serve_hostnames.go +++ b/test/soak/serve_hostnames/serve_hostnames.go @@ -31,6 +31,7 @@ import ( "github.com/golang/glog" "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/errors" client "k8s.io/kubernetes/pkg/client/unversioned" "k8s.io/kubernetes/pkg/client/unversioned/clientcmd" "k8s.io/kubernetes/pkg/fields" @@ -47,12 +48,13 @@ var ( ) const ( - deleteTimeout = 2 * time.Minute - endpointTimeout = 5 * time.Minute - nodeListTimeout = 2 * time.Minute - podCreateTimeout = 2 * time.Minute - podStartTimeout = 30 * time.Minute - serviceCreateTimeout = 2 * time.Minute + deleteTimeout = 2 * time.Minute + endpointTimeout = 5 * time.Minute + nodeListTimeout = 2 * time.Minute + podCreateTimeout = 2 * time.Minute + podStartTimeout = 30 * time.Minute + serviceCreateTimeout = 2 * time.Minute + namespaceDeleteTimeout = 5 * time.Minute ) func main() { @@ -116,6 +118,16 @@ func main() { defer func(ns string) { if err := c.Namespaces().Delete(ns); err != nil { glog.Warningf("Failed to delete namespace ns: %e", ns, err) + } else { + // wait until the namespace disappears + for i := 0; i < int(namespaceDeleteTimeout/time.Second); i++ { + if _, err := c.Namespaces().Get(ns); err != nil { + if errors.IsNotFound(err) { + return + } + } + time.Sleep(time.Second) + } } }(ns) glog.Infof("Created namespace %s", ns)