github.com/brahmaroutu/docker@v1.2.1-0.20160809185609-eb28dde01f16/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 // WindowsBaseImage is the name of the base image for Windows testing 66 // Environment variable WINDOWS_BASE_IMAGE can override this 67 WindowsBaseImage = "windowsservercore" 68 ) 69 70 const ( 71 // DefaultImage is the name of the base image for the majority of tests that 72 // are run across suites 73 DefaultImage = "busybox" 74 ) 75 76 func init() { 77 reexec.Init() 78 if dockerBin := os.Getenv("DOCKER_BINARY"); dockerBin != "" { 79 dockerBinary = dockerBin 80 } 81 var err error 82 dockerBinary, err = exec.LookPath(dockerBinary) 83 if err != nil { 84 fmt.Printf("ERROR: couldn't resolve full path to the Docker binary (%v)", err) 85 os.Exit(1) 86 } 87 if registryImage := os.Getenv("REGISTRY_IMAGE"); registryImage != "" { 88 registryImageName = registryImage 89 } 90 if registry := os.Getenv("REGISTRY_URL"); registry != "" { 91 privateRegistryURL = registry 92 } 93 workingDirectory, _ = os.Getwd() 94 95 // Deterministically working out the environment in which CI is running 96 // to evaluate whether the daemon is local or remote is not possible through 97 // a build tag. 98 // 99 // For example Windows to Linux CI under Jenkins tests the 64-bit 100 // Windows binary build with the daemon build tag, but calls a remote 101 // Linux daemon. 102 // 103 // We can't just say if Windows then assume the daemon is local as at 104 // some point, we will be testing the Windows CLI against a Windows daemon. 105 // 106 // Similarly, it will be perfectly valid to also run CLI tests from 107 // a Linux CLI (built with the daemon tag) against a Windows daemon. 108 if len(os.Getenv("DOCKER_REMOTE_DAEMON")) > 0 { 109 isLocalDaemon = false 110 } else { 111 isLocalDaemon = true 112 } 113 114 // TODO Windows CI. This are incorrect and need fixing into 115 // platform specific pieces. 116 // This is only used for a tests with local daemon true (Linux-only today) 117 // default is "/var/lib/docker", but we'll try and ask the 118 // /info endpoint for the specific root dir 119 dockerBasePath = "/var/lib/docker" 120 type Info struct { 121 DockerRootDir string 122 } 123 var i Info 124 status, b, err := sockRequest("GET", "/info", nil) 125 if err == nil && status == 200 { 126 if err = json.Unmarshal(b, &i); err == nil { 127 dockerBasePath = i.DockerRootDir 128 } 129 } 130 volumesConfigPath = dockerBasePath + "/volumes" 131 containerStoragePath = dockerBasePath + "/containers" 132 133 if len(os.Getenv("WINDOWS_BASE_IMAGE")) > 0 { 134 WindowsBaseImage = os.Getenv("WINDOWS_BASE_IMAGE") 135 fmt.Println("INFO: Windows Base image is ", WindowsBaseImage) 136 } 137 }