Fix zombie defuncts by not waiting for tear down

pull/4946/head
Medya Gh 2019-07-29 22:17:03 -07:00
parent 4728165354
commit e94da73884
9 changed files with 19 additions and 12 deletions

View File

@ -16,9 +16,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// a_download_only_test.go filename starts with a, for the purpose that it runs before all parallel tests and downloads the images and caches them.
package integration
// this file name has to start with a so it be run before all other tests
import (
"testing"
"time"
@ -34,7 +35,7 @@ func TestDownloadOnly(t *testing.T) {
}
mk := NewMinikubeRunner(t, p)
if !isTestNoneDriver() { // none driver doesnt need to be deleted
defer mk.Delete()
defer mk.TearDown(t)
}
stdout, stderr, err := mk.StartWithStds(15*time.Minute, "--download-only")

View File

@ -37,7 +37,7 @@ func TestContainerd(t *testing.T) {
mk := NewMinikubeRunner(t, p)
if !isTestNoneDriver() { // none driver doesnt need to be deleted
defer mk.Delete()
defer mk.TearDown(t)
}
if isTestNoneDriver() {

View File

@ -34,7 +34,7 @@ func TestDocker(t *testing.T) {
p := profile(t)
t.Parallel()
mk := NewMinikubeRunner(t, p, "--wait=false")
defer mk.Delete()
defer mk.TearDown(t)
// Start a timer for all remaining commands, to display failure output before a panic.
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Minute)

View File

@ -31,7 +31,7 @@ func TestFunctional(t *testing.T) {
t.Fatalf("%s minikube start failed : %v\nstdout: %s\nstderr: %s", t.Name(), err, stdout, stderr)
}
if !isTestNoneDriver() { // none driver doesn't need to be deleted
defer mk.Delete()
defer mk.TearDown(t)
}
// group is needed to make sure tear down runs after parallel runs

View File

@ -40,7 +40,7 @@ func TestISO(t *testing.T) {
t.Fatalf("%s minikube start failed : %v\nstdout: %s\nstderr: %s", t.Name(), err, stdout, stderr)
}
if !isTestNoneDriver() { // none driver doesn't need to be deleted
defer mk.Delete()
defer mk.TearDown(t)
}
t.Run("permissions", testMountPermissions)

View File

@ -34,7 +34,7 @@ func TestPersistence(t *testing.T) {
t.Parallel()
p := profile(t) // profile name
mk := NewMinikubeRunner(t, p)
defer mk.Delete()
defer mk.TearDown(t)
mk.EnsureRunning()
kr := util.NewKubectlRunner(t, p)

View File

@ -74,7 +74,7 @@ func TestProxy(t *testing.T) {
// making sure there is no running minikube to avoid https://github.com/kubernetes/minikube/issues/4132
p := profile(t)
mk := NewMinikubeRunner(t, p)
defer mk.Delete()
defer mk.TearDown(t)
// Clean up after setting up proxy
defer func(t *testing.T) {

View File

@ -39,7 +39,7 @@ func TestStartStop(t *testing.T) {
}
mk := NewMinikubeRunner(t, p)
if !isTestNoneDriver() { // none driver doesn't need to be deleted
defer mk.Delete()
defer mk.TearDown(t)
}
tests := []struct {

View File

@ -219,9 +219,15 @@ func (m *MinikubeRunner) StartWithStds(timeout time.Duration, opts ...string) (s
return m.RunWithContext(ctx, cmd)
}
// Delete deletes the minikube profile to be used to clean up after a test
func (m *MinikubeRunner) Delete(wait ...bool) string {
return m.RunCommand("delete", true, wait...)
// TearDown deletes minikube without waiting for it. used to free up ram/cpu after each test
func (m *MinikubeRunner) TearDown(t *testing.T) {
profileArg := fmt.Sprintf("-p=%s", m.Profile)
path, _ := filepath.Abs(m.BinaryPath)
cmd := exec.Command(path, profileArg, "delete")
err := cmd.Start()
if err != nil {
t.Errorf("error tearing down minikube %s : %v", profileArg, err)
}
}
// EnsureRunning makes sure the container runtime is running