1
0
mirror of https://github.com/rancher/os.git synced 2025-06-30 08:41:48 +00:00

Merge pull request #1341 from joshwget/always-test-runqemu

Always assert RunQemu is successful
This commit is contained in:
Sven Dowideit 2016-10-26 11:35:21 -04:00 committed by GitHub
commit bbf822e430
28 changed files with 36 additions and 72 deletions

View File

@ -3,13 +3,11 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestBadState(c *C) {
err := s.RunQemu("--no-format", "--append", "rancher.state.dev=LABEL=BAD_STATE")
c.Assert(err, IsNil)
s.RunQemu(c, "--no-format", "--append", "rancher.state.dev=LABEL=BAD_STATE")
s.CheckCall(c, "mount | grep /var/lib/docker | grep rootfs")
}
func (s *QemuSuite) TestBadStateWithWait(c *C) {
err := s.RunQemu("--no-format", "--append", "rancher.state.dev=LABEL=BAD_STATE", "--append", "rancher.state.wait")
c.Assert(err, IsNil)
s.RunQemu(c, "--no-format", "--append", "rancher.state.dev=LABEL=BAD_STATE", "--append", "rancher.state.wait")
s.CheckCall(c, "mount | grep /var/lib/docker | grep rootfs")
}

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestCloudConfigHostname(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_13/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_13/cloud-config.yml")
s.CheckCall(c, "hostname | grep rancher-test")
s.CheckCall(c, "cat /etc/hosts | grep rancher-test")

View File

@ -31,9 +31,8 @@ var (
"arm": "armhfbuild/nginx",
"arm64": "armhfbuild/nginx",
}[runtime.GOARCH]
DockerUrl = "https://experimental.docker.com/builds/Linux/x86_64/docker-1.10.0-dev"
Version = os.Getenv("VERSION")
Suffix = os.Getenv("SUFFIX")
Version = os.Getenv("VERSION")
Suffix = os.Getenv("SUFFIX")
)
type QemuSuite struct {
@ -47,7 +46,7 @@ func (s *QemuSuite) TearDownTest(c *C) {
time.Sleep(time.Millisecond * 1000)
}
func (s *QemuSuite) RunQemu(additionalArgs ...string) error {
func (s *QemuSuite) RunQemu(c *C, additionalArgs ...string) {
runArgs := []string{
"--qemu",
"--no-rebuild",
@ -56,10 +55,10 @@ func (s *QemuSuite) RunQemu(additionalArgs ...string) error {
}
runArgs = append(runArgs, additionalArgs...)
return s.runQemu(runArgs...)
c.Assert(s.runQemu(runArgs...), IsNil)
}
func (s *QemuSuite) RunQemuInstalled(additionalArgs ...string) error {
func (s *QemuSuite) RunQemuInstalled(c *C, additionalArgs ...string) {
runArgs := []string{
"--qemu",
"--no-rebuild",
@ -68,7 +67,7 @@ func (s *QemuSuite) RunQemuInstalled(additionalArgs ...string) error {
}
runArgs = append(runArgs, additionalArgs...)
return s.runQemu(runArgs...)
c.Assert(s.runQemu(runArgs...), IsNil)
}
func (s *QemuSuite) runQemu(args ...string) error {

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestCloudConfigConsole(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_03/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_03/cloud-config.yml")
s.CheckCall(c, "apt-get --version")
s.CheckCall(c, `
@ -13,8 +12,7 @@ sudo ros console list | grep debian | grep current`)
}
func (s *QemuSuite) TestConsoleCommand(c *C) {
err := s.RunQemu()
c.Assert(err, IsNil)
s.RunQemu(c)
s.CheckCall(c, `
sudo ros console list | grep default | grep current

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestCustomDocker(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_05/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_05/cloud-config.yml")
s.CheckCall(c, `
set -ex
@ -35,8 +34,7 @@ docker ps | grep nginx`)
}
func (s *QemuSuite) TestCustomDockerInPersistentConsole(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_25/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_25/cloud-config.yml")
s.CheckCall(c, `
set -ex

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestDhcpHostname(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_12/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_12/cloud-config.yml")
s.CheckCall(c, "hostname | grep rancher-dev")
s.CheckCall(c, "cat /etc/hosts | grep rancher-dev")

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestEnvironment(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_11/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_11/cloud-config.yml")
s.CheckCall(c, "sudo system-docker inspect env | grep A=A")
s.CheckCall(c, "sudo system-docker inspect env | grep BB=BB")

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestHttpProxy(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_17/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_17/cloud-config.yml")
s.CheckCall(c, `
set -x -e

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestKernelHeaders(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_22/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_22/cloud-config.yml")
s.CheckCall(c, `
sleep 15

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestLenientServiceParsing(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_19/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_19/cloud-config.yml")
s.CheckCall(c, `
sleep 5

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestMisc(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_01/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_01/cloud-config.yml")
s.CheckCall(c, "sudo ros env printenv FLANNEL_NETWORK | grep '10.244.0.0/16'")

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestMounts(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_23/cloud-config.yml", "--second-drive")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_23/cloud-config.yml", "--second-drive")
s.CheckCall(c, "cat /home/rancher/test | grep test")

View File

@ -8,8 +8,7 @@ func (s *QemuSuite) TestNetworkFromUrl(c *C) {
for i := 0; i < 7; i++ {
args = append(args, netArgs...)
}
err := s.RunQemu(args...)
c.Assert(err, IsNil)
s.RunQemu(c, args...)
s.CheckCall(c, `
cat > test-merge << "SCRIPT"

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestNetworkOnBoot(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_18/cloud-config.yml", "-net", "nic,vlan=1,model=virtio")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_18/cloud-config.yml", "-net", "nic,vlan=1,model=virtio")
s.CheckCall(c, "apt-get --version")
s.CheckCall(c, "sudo system-docker images | grep tianon/true")

View File

@ -8,8 +8,7 @@ func (s *QemuSuite) TestNetwork(c *C) {
for i := 0; i < 7; i++ {
args = append(args, netArgs...)
}
err := s.RunQemu(args...)
c.Assert(err, IsNil)
s.RunQemu(c, args...)
s.CheckCall(c, `
cat > test-merge << "SCRIPT"

View File

@ -3,8 +3,6 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestNonexistentState(c *C) {
err := s.RunQemu("--no-format", "--append", "rancher.state.dev=LABEL=NONEXISTENT")
c.Assert(err, IsNil)
s.RunQemu(c, "--no-format", "--append", "rancher.state.dev=LABEL=NONEXISTENT")
s.CheckCall(c, "sudo ros config get rancher.state.dev | grep LABEL=NONEXISTENT")
}

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestOem(c *C) {
err := s.RunQemu("--second-drive")
c.Assert(err, IsNil)
s.RunQemu(c, "--second-drive")
s.CheckCall(c, `
set -x

View File

@ -5,8 +5,7 @@ import (
)
func (s *QemuSuite) TestPreload(c *C) {
err := s.RunQemu()
c.Assert(err, IsNil)
s.RunQemu(c)
s.CheckCall(c, `
docker pull busybox

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestRosConfig(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_14/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_14/cloud-config.yml")
s.CheckCall(c, `
set -x -e

View File

@ -7,9 +7,7 @@ import (
)
func (s *QemuSuite) TestSharedMount(c *C) {
err := s.RunQemu()
c.Assert(err, IsNil)
s.RunQemu(c)
s.CheckCall(c, fmt.Sprintf(`
set -x -e

View File

@ -3,9 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestSshKeyMerge(c *C) {
err := s.RunQemu()
c.Assert(err, IsNil)
s.RunQemu(c)
s.CheckCall(c, `
cat > test-merge << "SCRIPT"
set -x -e

View File

@ -7,8 +7,7 @@ import (
)
func (s *QemuSuite) TestStartCommands(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_26/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_26/cloud-config.yml")
for i := 1; i < 5; i++ {
s.CheckCall(c, fmt.Sprintf("ls /home/rancher | grep test%d", i))

View File

@ -3,9 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestSubdir(c *C) {
err := s.RunQemu("--append", "rancher.state.directory=ros_subdir")
c.Assert(err, IsNil)
s.RunQemu(c, "--append", "rancher.state.directory=ros_subdir")
s.CheckCall(c, `
set -x -e
mkdir x

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestSwap(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_21/cloud-config.yml", "--second-drive")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_21/cloud-config.yml", "--second-drive")
s.CheckCall(c, "sudo mkswap /dev/vdb")
s.CheckCall(c, "sudo cloud-init-execute")

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestSysctl(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_20/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_20/cloud-config.yml")
s.CheckCall(c, "sudo cat /proc/sys/kernel/domainname | grep test")
s.CheckCall(c, "sudo cat /proc/sys/dev/cdrom/debug | grep 1")

View File

@ -3,9 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestTls(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_02/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_02/cloud-config.yml")
s.CheckCall(c, `
set -e -x
sudo ros tls gen

View File

@ -7,8 +7,7 @@ import (
)
func (s *QemuSuite) TestUpgrade(c *C) {
err := s.RunQemuInstalled()
c.Assert(err, IsNil)
s.RunQemuInstalled(c)
s.CheckCall(c, `
set -ex

View File

@ -3,8 +3,7 @@ package integration
import . "gopkg.in/check.v1"
func (s *QemuSuite) TestWriteFiles(c *C) {
err := s.RunQemu("--cloud-config", "./tests/assets/test_24/cloud-config.yml")
c.Assert(err, IsNil)
s.RunQemu(c, "--cloud-config", "./tests/assets/test_24/cloud-config.yml")
s.CheckCall(c, "sudo cat /test | grep 'console content'")
s.CheckCall(c, "sudo cat /test2 | grep 'console content'")