consoles_test.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package integration
  2. import . "gopkg.in/check.v1"
  3. func (s *QemuSuite) TestCloudConfigConsole(c *C) {
  4. s.RunQemu(c, "--cloud-config", "./tests/assets/test_03/cloud-config.yml")
  5. s.CheckCall(c, "apt-get --version")
  6. s.CheckCall(c, `
  7. sudo ros console list | grep default | grep disabled
  8. sudo ros console list | grep debian | grep current`)
  9. }
  10. func (s *QemuSuite) TestConsoleCommand(c *C) {
  11. s.RunQemu(c)
  12. s.CheckCall(c, `
  13. sudo ros console list | grep default | grep current
  14. sudo ros console list | grep debian | grep disabled
  15. (sudo ros console switch invalid 2>&1 || true) | grep "invalid is not a valid console"
  16. (sudo ros console enable invalid 2>&1 || true) | grep "invalid is not a valid console"`)
  17. s.MakeCall("sudo ros console switch -f debian")
  18. c.Assert(s.WaitForSSH(), IsNil)
  19. s.CheckCall(c, "apt-get --version")
  20. s.CheckCall(c, `
  21. sudo ros console list | grep default | grep disabled
  22. sudo ros console list | grep debian | grep current`)
  23. s.Reboot(c)
  24. s.CheckCall(c, "apt-get --version")
  25. s.CheckCall(c, `
  26. sudo ros console list | grep default | grep disabled
  27. sudo ros console list | grep debian | grep current`)
  28. s.MakeCall("sudo ros console switch -f default")
  29. c.Assert(s.WaitForSSH(), IsNil)
  30. s.CheckCall(c, `
  31. sudo ros console list | grep default | grep current
  32. sudo ros console list | grep debian | grep disabled`)
  33. s.CheckCall(c, "sudo ros console enable debian")
  34. s.CheckCall(c, "sudo ros console list | grep default | grep current")
  35. s.CheckCall(c, "sudo ros console list | grep debian | grep enabled")
  36. s.Reboot(c)
  37. s.CheckCall(c, `
  38. sudo ros console list | grep default | grep disabled
  39. sudo ros console list | grep debian | grep current`)
  40. }
  41. func (s *QemuSuite) TestContainersRestartAfterConsoleSwitch(c *C) {
  42. s.RunQemu(c)
  43. s.CheckCall(c, `
  44. docker run -d --restart=always nginx
  45. docker ps | grep nginx`)
  46. s.MakeCall("sudo ros console switch -f debian")
  47. c.Assert(s.WaitForSSH(), IsNil)
  48. s.CheckCall(c, "docker ps | grep nginx")
  49. s.CheckCall(c, "sudo ros console enable default")
  50. s.Reboot(c)
  51. s.CheckCall(c, "docker ps | grep nginx")
  52. }