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