docker_test_vars.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "os/exec"
  6. )
  7. var (
  8. // the docker binary to use
  9. dockerBinary = "docker"
  10. // the private registry image to use for tests involving the registry
  11. registryImageName = "registry"
  12. // the private registry to use for tests
  13. privateRegistryURL = "127.0.0.1:5000"
  14. dockerBasePath = "/var/lib/docker"
  15. volumesConfigPath = dockerBasePath + "/volumes"
  16. containerStoragePath = dockerBasePath + "/containers"
  17. runtimePath = "/var/run/docker"
  18. execDriverPath = runtimePath + "/execdriver/native"
  19. workingDirectory string
  20. // isLocalDaemon is true if the daemon under test is on the same
  21. // host as the CLI.
  22. isLocalDaemon bool
  23. // daemonPlatform is held globally so that tests can make intelligent
  24. // decisions on how to configure themselves according to the platform
  25. // of the daemon. This is initialised in docker_utils by sending
  26. // a version call to the daemon and examining the response header.
  27. daemonPlatform string
  28. // daemonDefaultImage is the name of the default image to use when running
  29. // tests. This is platform dependent.
  30. daemonDefaultImage string
  31. )
  32. const (
  33. // WindowsBaseImage is the name of the base image for Windows testing
  34. WindowsBaseImage = "windowsservercore"
  35. // DefaultImage is the name of the base image for the majority of tests that
  36. // are run across suites
  37. DefaultImage = "busybox"
  38. )
  39. func init() {
  40. if dockerBin := os.Getenv("DOCKER_BINARY"); dockerBin != "" {
  41. dockerBinary = dockerBin
  42. }
  43. var err error
  44. dockerBinary, err = exec.LookPath(dockerBinary)
  45. if err != nil {
  46. fmt.Printf("ERROR: couldn't resolve full path to the Docker binary (%v)", err)
  47. os.Exit(1)
  48. }
  49. if registryImage := os.Getenv("REGISTRY_IMAGE"); registryImage != "" {
  50. registryImageName = registryImage
  51. }
  52. if registry := os.Getenv("REGISTRY_URL"); registry != "" {
  53. privateRegistryURL = registry
  54. }
  55. workingDirectory, _ = os.Getwd()
  56. // Deterministically working out the environment in which CI is running
  57. // to evaluate whether the daemon is local or remote is not possible through
  58. // a build tag.
  59. //
  60. // For example Windows CI under Jenkins test the 64-bit
  61. // Windows binary build with the daemon build tag, but calls a remote
  62. // Linux daemon.
  63. //
  64. // We can't just say if Windows then assume the daemon is local as at
  65. // some point, we will be testing the Windows CLI against a Windows daemon.
  66. //
  67. // Similarly, it will be perfectly valid to also run CLI tests from
  68. // a Linux CLI (built with the daemon tag) against a Windows daemon.
  69. if len(os.Getenv("DOCKER_REMOTE_DAEMON")) > 0 {
  70. fmt.Println("INFO: Testing against a remote daemon")
  71. isLocalDaemon = false
  72. } else {
  73. fmt.Println("INFO: Testing against a local daemon")
  74. isLocalDaemon = true
  75. }
  76. }