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