github.com/akerouanton/docker@v1.11.0-rc3/integration-cli/docker_test_vars.go (about) 1 package main 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "os" 7 "os/exec" 8 9 "github.com/docker/docker/pkg/reexec" 10 ) 11 12 var ( 13 // the docker binary to use 14 dockerBinary = "docker" 15 16 // path to containerd's ctr binary 17 ctrBinary = "docker-containerd-ctr" 18 19 // the private registry image to use for tests involving the registry 20 registryImageName = "registry" 21 22 // the private registry to use for tests 23 privateRegistryURL = "127.0.0.1:5000" 24 25 // TODO Windows CI. These are incorrect and need fixing into 26 // platform specific pieces. 27 runtimePath = "/var/run/docker" 28 29 workingDirectory string 30 31 // isLocalDaemon is true if the daemon under test is on the same 32 // host as the CLI. 33 isLocalDaemon bool 34 35 // daemonPlatform is held globally so that tests can make intelligent 36 // decisions on how to configure themselves according to the platform 37 // of the daemon. This is initialized in docker_utils by sending 38 // a version call to the daemon and examining the response header. 39 daemonPlatform string 40 41 // windowsDaemonKV is used on Windows to distinguish between different 42 // versions. This is necessary to enable certain tests based on whether 43 // the platform supports it. For example, Windows Server 2016 TP3 does 44 // not support volumes, but TP4 does. 45 windowsDaemonKV int 46 47 // daemonDefaultImage is the name of the default image to use when running 48 // tests. This is platform dependent. 49 daemonDefaultImage string 50 51 // For a local daemon on Linux, these values will be used for testing 52 // user namespace support as the standard graph path(s) will be 53 // appended with the root remapped uid.gid prefix 54 dockerBasePath string 55 volumesConfigPath string 56 containerStoragePath string 57 ) 58 59 const ( 60 // WindowsBaseImage is the name of the base image for Windows testing 61 WindowsBaseImage = "windowsservercore" 62 63 // DefaultImage is the name of the base image for the majority of tests that 64 // are run across suites 65 DefaultImage = "busybox" 66 ) 67 68 func init() { 69 reexec.Init() 70 if dockerBin := os.Getenv("DOCKER_BINARY"); dockerBin != "" { 71 dockerBinary = dockerBin 72 } 73 var err error 74 dockerBinary, err = exec.LookPath(dockerBinary) 75 if err != nil { 76 fmt.Printf("ERROR: couldn't resolve full path to the Docker binary (%v)", err) 77 os.Exit(1) 78 } 79 if registryImage := os.Getenv("REGISTRY_IMAGE"); registryImage != "" { 80 registryImageName = registryImage 81 } 82 if registry := os.Getenv("REGISTRY_URL"); registry != "" { 83 privateRegistryURL = registry 84 } 85 workingDirectory, _ = os.Getwd() 86 87 // Deterministically working out the environment in which CI is running 88 // to evaluate whether the daemon is local or remote is not possible through 89 // a build tag. 90 // 91 // For example Windows to Linux CI under Jenkins tests the 64-bit 92 // Windows binary build with the daemon build tag, but calls a remote 93 // Linux daemon. 94 // 95 // We can't just say if Windows then assume the daemon is local as at 96 // some point, we will be testing the Windows CLI against a Windows daemon. 97 // 98 // Similarly, it will be perfectly valid to also run CLI tests from 99 // a Linux CLI (built with the daemon tag) against a Windows daemon. 100 if len(os.Getenv("DOCKER_REMOTE_DAEMON")) > 0 { 101 isLocalDaemon = false 102 } else { 103 isLocalDaemon = true 104 } 105 106 // TODO Windows CI. This are incorrect and need fixing into 107 // platform specific pieces. 108 // This is only used for a tests with local daemon true (Linux-only today) 109 // default is "/var/lib/docker", but we'll try and ask the 110 // /info endpoint for the specific root dir 111 dockerBasePath = "/var/lib/docker" 112 type Info struct { 113 DockerRootDir string 114 } 115 var i Info 116 status, b, err := sockRequest("GET", "/info", nil) 117 if err == nil && status == 200 { 118 if err = json.Unmarshal(b, &i); err == nil { 119 dockerBasePath = i.DockerRootDir 120 } 121 } 122 volumesConfigPath = dockerBasePath + "/volumes" 123 containerStoragePath = dockerBasePath + "/containers" 124 }