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