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