2016-06-29 21:52:10 +00:00
|
|
|
// +build integration
|
|
|
|
|
|
|
|
/*
|
|
|
|
Copyright 2016 The Kubernetes Authors All rights reserved.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2017-05-18 16:56:07 +00:00
|
|
|
"github.com/docker/machine/libmachine/state"
|
2016-06-29 21:52:10 +00:00
|
|
|
"k8s.io/minikube/test/integration/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPersistence(t *testing.T) {
|
2019-08-01 23:42:29 +00:00
|
|
|
if isTestNoneDriver(t) {
|
2019-07-30 04:52:05 +00:00
|
|
|
t.Skip("skipping test as none driver does not support persistence")
|
2019-07-26 22:27:05 +00:00
|
|
|
}
|
2019-08-01 19:44:41 +00:00
|
|
|
p := profileName(t)
|
2019-08-01 23:42:29 +00:00
|
|
|
if shouldRunInParallel(t) {
|
2019-08-01 06:05:43 +00:00
|
|
|
t.Parallel()
|
|
|
|
}
|
|
|
|
|
|
|
|
mk := NewMinikubeRunner(t, p, "--wait=false")
|
2019-07-30 05:17:03 +00:00
|
|
|
defer mk.TearDown(t)
|
2019-08-01 06:05:43 +00:00
|
|
|
|
2019-07-31 18:37:35 +00:00
|
|
|
stdout, stderr, err := mk.Start()
|
|
|
|
if err != nil {
|
2019-07-31 19:05:57 +00:00
|
|
|
t.Fatalf("failed to start minikube (for profile %s) failed : %v\nstdout: %s\nstderr: %s", t.Name(), err, stdout, stderr)
|
2019-07-31 18:37:35 +00:00
|
|
|
}
|
2019-07-24 02:05:57 +00:00
|
|
|
kr := util.NewKubectlRunner(t, p)
|
2019-07-27 05:00:57 +00:00
|
|
|
if _, err := kr.RunCommand([]string{"create", "-f", filepath.Join(*testdataDir, "busybox.yaml")}); err != nil {
|
|
|
|
t.Fatalf("creating busybox pod: %s", err)
|
2016-06-29 21:52:10 +00:00
|
|
|
}
|
2019-07-27 05:00:57 +00:00
|
|
|
verifyBusybox := func(t *testing.T) {
|
2019-07-24 19:38:40 +00:00
|
|
|
if err := util.WaitForBusyboxRunning(t, "default", p); err != nil {
|
2018-09-28 23:18:22 +00:00
|
|
|
t.Fatalf("waiting for busybox to be up: %v", err)
|
2016-07-12 17:50:44 +00:00
|
|
|
}
|
2016-07-18 22:35:37 +00:00
|
|
|
|
|
|
|
}
|
2017-08-23 18:33:00 +00:00
|
|
|
// Make sure everything is up before we stop.
|
2019-07-27 05:00:57 +00:00
|
|
|
verifyBusybox(t)
|
2017-08-23 18:33:00 +00:00
|
|
|
|
2019-08-01 07:31:38 +00:00
|
|
|
mk.RunCommand("stop", true)
|
2019-08-01 06:05:43 +00:00
|
|
|
mk.CheckStatus(state.Stopped.String())
|
2016-07-18 22:35:37 +00:00
|
|
|
|
2019-07-31 19:05:57 +00:00
|
|
|
stdout, stderr, err = mk.Start()
|
2019-07-30 00:57:36 +00:00
|
|
|
if err != nil {
|
2019-07-31 19:05:57 +00:00
|
|
|
t.Fatalf("failed to start minikube (for profile %s) failed : %v\nstdout: %s\nstderr: %s", t.Name(), err, stdout, stderr)
|
2019-07-30 00:57:36 +00:00
|
|
|
}
|
2019-07-12 18:50:57 +00:00
|
|
|
mk.CheckStatus(state.Running.String())
|
2016-07-18 22:35:37 +00:00
|
|
|
|
2017-08-23 18:33:00 +00:00
|
|
|
// Make sure the same things come up after we've restarted.
|
2019-07-27 05:00:57 +00:00
|
|
|
verifyBusybox(t)
|
2016-06-29 21:52:10 +00:00
|
|
|
}
|