Fix issues running libnetwork tests.
libnetwork does different stuff depending on if you are running the tests in a container or not... without telling it we are in a container a bunch of the tests actually fail. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
4da0dc974c
commit
72c4a7b496
|
@ -190,7 +190,7 @@ pipeline {
|
||||||
-e VALIDATE_REPO=${GIT_URL} \
|
-e VALIDATE_REPO=${GIT_URL} \
|
||||||
-e VALIDATE_BRANCH=${CHANGE_TARGET} \
|
-e VALIDATE_BRANCH=${CHANGE_TARGET} \
|
||||||
docker:${GIT_COMMIT} \
|
docker:${GIT_COMMIT} \
|
||||||
hack/test/unit"
|
hack/test/unit
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
|
@ -587,7 +587,7 @@ pipeline {
|
||||||
-e VALIDATE_REPO=${GIT_URL} \
|
-e VALIDATE_REPO=${GIT_URL} \
|
||||||
-e VALIDATE_BRANCH=${CHANGE_TARGET} \
|
-e VALIDATE_BRANCH=${CHANGE_TARGET} \
|
||||||
docker:${GIT_COMMIT} \
|
docker:${GIT_COMMIT} \
|
||||||
hack/test/unit"
|
hack/test/unit
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
|
@ -786,7 +786,7 @@ pipeline {
|
||||||
-e VALIDATE_REPO=${GIT_URL} \
|
-e VALIDATE_REPO=${GIT_URL} \
|
||||||
-e VALIDATE_BRANCH=${CHANGE_TARGET} \
|
-e VALIDATE_BRANCH=${CHANGE_TARGET} \
|
||||||
docker:${GIT_COMMIT} \
|
docker:${GIT_COMMIT} \
|
||||||
hack/test/unit"
|
hack/test/unit
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
|
@ -982,7 +982,7 @@ pipeline {
|
||||||
-e VALIDATE_REPO=${GIT_URL} \
|
-e VALIDATE_REPO=${GIT_URL} \
|
||||||
-e VALIDATE_BRANCH=${CHANGE_TARGET} \
|
-e VALIDATE_BRANCH=${CHANGE_TARGET} \
|
||||||
docker:${GIT_COMMIT} \
|
docker:${GIT_COMMIT} \
|
||||||
hack/test/unit"
|
hack/test/unit
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
|
|
|
@ -30,7 +30,7 @@ for platform in ${DOCKER_CROSSPLATFORMS}; do
|
||||||
echo "Cross building: ${DEST}"
|
echo "Cross building: ${DEST}"
|
||||||
mkdir -p "${DEST}"
|
mkdir -p "${DEST}"
|
||||||
ABS_DEST="$(cd "${DEST}" && pwd -P)"
|
ABS_DEST="$(cd "${DEST}" && pwd -P)"
|
||||||
source "${MAKEDIR}/binary-daemon"
|
source "${MAKEDIR}/binary"
|
||||||
|
|
||||||
source "${MAKEDIR}/cross-platform-dependent"
|
source "${MAKEDIR}/cross-platform-dependent"
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# TESTDIRS='./pkg/term' hack/test/unit
|
# TESTDIRS='./pkg/term' hack/test/unit
|
||||||
#
|
#
|
||||||
set -eu -o pipefail
|
set -eux -o pipefail
|
||||||
|
|
||||||
BUILDFLAGS=(-tags 'netgo seccomp libdm_no_deferred_remove')
|
BUILDFLAGS=(-tags 'netgo seccomp libdm_no_deferred_remove')
|
||||||
TESTFLAGS+=" -test.timeout=${TIMEOUT:-5m}"
|
TESTFLAGS+=" -test.timeout=${TIMEOUT:-5m}"
|
||||||
|
@ -30,4 +30,4 @@ gotestsum --format=standard-quiet --jsonfile=bundles/go-test-report.json --junit
|
||||||
-coverprofile=bundles/profile.out \
|
-coverprofile=bundles/profile.out \
|
||||||
-covermode=atomic \
|
-covermode=atomic \
|
||||||
${TESTFLAGS} \
|
${TESTFLAGS} \
|
||||||
${pkg_list}
|
${pkg_list}
|
|
@ -4,17 +4,19 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/libkv/store"
|
|
||||||
"github.com/docker/libkv/store/boltdb"
|
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
_ "github.com/docker/docker/libnetwork/testutils"
|
_ "github.com/docker/docker/libnetwork/testutils"
|
||||||
|
"github.com/docker/libkv/store"
|
||||||
|
"github.com/docker/libkv/store/boltdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
var (
|
||||||
defaultPrefix = "/tmp/libnetwork/test/bitseq"
|
defaultPrefix = filepath.Join(os.TempDir(), "libnetwork", "test", "bitseq")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -32,7 +34,7 @@ func randomLocalStore() (datastore.DataStore, error) {
|
||||||
return datastore.NewDataStore(datastore.LocalScope, &datastore.ScopeCfg{
|
return datastore.NewDataStore(datastore.LocalScope, &datastore.ScopeCfg{
|
||||||
Client: datastore.ScopeClientCfg{
|
Client: datastore.ScopeClientCfg{
|
||||||
Provider: "boltdb",
|
Provider: "boltdb",
|
||||||
Address: defaultPrefix + tmp.Name(),
|
Address: filepath.Join(defaultPrefix, filepath.Base(tmp.Name())),
|
||||||
Config: &store.Config{
|
Config: &store.Config{
|
||||||
Bucket: "libnetwork",
|
Bucket: "libnetwork",
|
||||||
ConnectionTimeout: 3 * time.Second,
|
ConnectionTimeout: 3 * time.Second,
|
||||||
|
@ -937,7 +939,7 @@ func TestAllocateRandomDeallocate(t *testing.T) {
|
||||||
|
|
||||||
numBlocks := uint32(8)
|
numBlocks := uint32(8)
|
||||||
numBits := int(numBlocks * blockLen)
|
numBits := int(numBlocks * blockLen)
|
||||||
hnd, err := NewHandle("bitseq-test/data/", ds, "test1", uint64(numBits))
|
hnd, err := NewHandle(filepath.Join("bitseq", "test", "data"), ds, "test1", uint64(numBits))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,14 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ishidawataru/sctp"
|
"github.com/ishidawataru/sctp"
|
||||||
|
"gotest.tools/v3/skip"
|
||||||
|
|
||||||
// this takes care of the incontainer flag
|
// this takes care of the incontainer flag
|
||||||
_ "github.com/docker/docker/libnetwork/testutils"
|
_ "github.com/docker/docker/libnetwork/testutils"
|
||||||
)
|
)
|
||||||
|
@ -282,6 +285,8 @@ func TestUDPWriteError(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSCTP4Proxy(t *testing.T) {
|
func TestSCTP4Proxy(t *testing.T) {
|
||||||
|
skip.If(t, runtime.GOOS == "windows", "sctp is not supported on windows")
|
||||||
|
|
||||||
backend := NewEchoServer(t, "sctp", "127.0.0.1:0", EchoServerOptions{})
|
backend := NewEchoServer(t, "sctp", "127.0.0.1:0", EchoServerOptions{})
|
||||||
defer backend.Close()
|
defer backend.Close()
|
||||||
backend.Run()
|
backend.Run()
|
||||||
|
@ -295,6 +300,8 @@ func TestSCTP4Proxy(t *testing.T) {
|
||||||
|
|
||||||
func TestSCTP6Proxy(t *testing.T) {
|
func TestSCTP6Proxy(t *testing.T) {
|
||||||
t.Skip("Need to start CI docker with --ipv6")
|
t.Skip("Need to start CI docker with --ipv6")
|
||||||
|
skip.If(t, runtime.GOOS == "windows", "sctp is not supported on windows")
|
||||||
|
|
||||||
backend := NewEchoServer(t, "sctp", "[::1]:0", EchoServerOptions{})
|
backend := NewEchoServer(t, "sctp", "[::1]:0", EchoServerOptions{})
|
||||||
defer backend.Close()
|
defer backend.Close()
|
||||||
backend.Run()
|
backend.Run()
|
||||||
|
|
|
@ -11,14 +11,16 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/plugins"
|
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/docker/libnetwork/discoverapi"
|
"github.com/docker/docker/libnetwork/discoverapi"
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
_ "github.com/docker/docker/libnetwork/testutils"
|
_ "github.com/docker/docker/libnetwork/testutils"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
func decodeToMap(r *http.Request) (res map[string]interface{}, err error) {
|
func decodeToMap(r *http.Request) (res map[string]interface{}, err error) {
|
||||||
|
@ -41,16 +43,27 @@ func handle(t *testing.T, mux *http.ServeMux, method string, h func(map[string]i
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
|
func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
|
||||||
if err := os.MkdirAll("/etc/docker/plugins", 0755); err != nil {
|
specPath := "/etc/docker/plugins"
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
specPath = filepath.Join(os.Getenv("programdata"), "docker", "plugins")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.MkdirAll(specPath, 0755); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if t.Failed() {
|
||||||
|
os.RemoveAll(specPath)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
server := httptest.NewServer(mux)
|
server := httptest.NewServer(mux)
|
||||||
if server == nil {
|
if server == nil {
|
||||||
t.Fatal("Failed to start an HTTP Server")
|
t.Fatal("Failed to start an HTTP Server")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ioutil.WriteFile(fmt.Sprintf("/etc/docker/plugins/%s.spec", name), []byte(server.URL), 0644); err != nil {
|
if err := ioutil.WriteFile(filepath.Join(specPath, name+".spec"), []byte(server.URL), 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +73,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
return func() {
|
return func() {
|
||||||
if err := os.RemoveAll("/etc/docker/plugins"); err != nil {
|
if err := os.RemoveAll(specPath); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
server.Close()
|
server.Close()
|
||||||
|
|
|
@ -7,24 +7,26 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/libkv/store"
|
|
||||||
"github.com/docker/libkv/store/boltdb"
|
|
||||||
"github.com/docker/docker/libnetwork/bitseq"
|
"github.com/docker/docker/libnetwork/bitseq"
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/docker/libnetwork/ipamapi"
|
"github.com/docker/docker/libnetwork/ipamapi"
|
||||||
_ "github.com/docker/docker/libnetwork/testutils"
|
_ "github.com/docker/docker/libnetwork/testutils"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/libkv/store"
|
||||||
|
"github.com/docker/libkv/store/boltdb"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
var (
|
||||||
defaultPrefix = "/tmp/libnetwork/test/ipam"
|
defaultPrefix = filepath.Join(os.TempDir(), "libnetwork", "test", "ipam")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -46,7 +48,7 @@ func randomLocalStore(needStore bool) (datastore.DataStore, error) {
|
||||||
return datastore.NewDataStore(datastore.LocalScope, &datastore.ScopeCfg{
|
return datastore.NewDataStore(datastore.LocalScope, &datastore.ScopeCfg{
|
||||||
Client: datastore.ScopeClientCfg{
|
Client: datastore.ScopeClientCfg{
|
||||||
Provider: "boltdb",
|
Provider: "boltdb",
|
||||||
Address: defaultPrefix + tmp.Name(),
|
Address: filepath.Join(defaultPrefix, filepath.Base(tmp.Name())),
|
||||||
Config: &store.Config{
|
Config: &store.Config{
|
||||||
Bucket: "libnetwork",
|
Bucket: "libnetwork",
|
||||||
ConnectionTimeout: 3 * time.Second,
|
ConnectionTimeout: 3 * time.Second,
|
||||||
|
|
|
@ -9,11 +9,13 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/plugins"
|
|
||||||
"github.com/docker/docker/libnetwork/ipamapi"
|
"github.com/docker/docker/libnetwork/ipamapi"
|
||||||
_ "github.com/docker/docker/libnetwork/testutils"
|
_ "github.com/docker/docker/libnetwork/testutils"
|
||||||
|
"github.com/docker/docker/pkg/plugins"
|
||||||
)
|
)
|
||||||
|
|
||||||
func decodeToMap(r *http.Request) (res map[string]interface{}, err error) {
|
func decodeToMap(r *http.Request) (res map[string]interface{}, err error) {
|
||||||
|
@ -36,16 +38,27 @@ func handle(t *testing.T, mux *http.ServeMux, method string, h func(map[string]i
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
|
func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
|
||||||
if err := os.MkdirAll("/etc/docker/plugins", 0755); err != nil {
|
specPath := "/etc/docker/plugins"
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
specPath = filepath.Join(os.Getenv("programdata"), "docker", "plugins")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.MkdirAll(specPath, 0755); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if t.Failed() {
|
||||||
|
os.RemoveAll(specPath)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
server := httptest.NewServer(mux)
|
server := httptest.NewServer(mux)
|
||||||
if server == nil {
|
if server == nil {
|
||||||
t.Fatal("Failed to start an HTTP Server")
|
t.Fatal("Failed to start an HTTP Server")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ioutil.WriteFile(fmt.Sprintf("/etc/docker/plugins/%s.spec", name), []byte(server.URL), 0644); err != nil {
|
if err := ioutil.WriteFile(filepath.Join(specPath, name+".spec"), []byte(server.URL), 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +68,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
return func() {
|
return func() {
|
||||||
if err := os.RemoveAll("/etc/docker/plugins"); err != nil {
|
if err := os.RemoveAll(specPath); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
server.Close()
|
server.Close()
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -1314,10 +1315,6 @@ func TestEndpointUpdateParent(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInvalidRemoteDriver(t *testing.T) {
|
func TestInvalidRemoteDriver(t *testing.T) {
|
||||||
if !testutils.IsRunningInContainer() {
|
|
||||||
t.Skip("Skipping test when not running inside a Container")
|
|
||||||
}
|
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
server := httptest.NewServer(mux)
|
server := httptest.NewServer(mux)
|
||||||
if server == nil {
|
if server == nil {
|
||||||
|
@ -1334,16 +1331,16 @@ func TestInvalidRemoteDriver(t *testing.T) {
|
||||||
fmt.Fprintln(w, `{"Implements": ["InvalidDriver"]}`)
|
fmt.Fprintln(w, `{"Implements": ["InvalidDriver"]}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
if err := os.MkdirAll("/etc/docker/plugins", 0755); err != nil {
|
if err := os.MkdirAll(specPath, 0755); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := os.RemoveAll("/etc/docker/plugins"); err != nil {
|
if err := os.RemoveAll(specPath); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err := ioutil.WriteFile("/etc/docker/plugins/invalid-network-driver.spec", []byte(server.URL), 0644); err != nil {
|
if err := ioutil.WriteFile(filepath.Join(specPath, "invalid-network-driver.spec"), []byte(server.URL), 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1365,10 +1362,6 @@ func TestInvalidRemoteDriver(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidRemoteDriver(t *testing.T) {
|
func TestValidRemoteDriver(t *testing.T) {
|
||||||
if !testutils.IsRunningInContainer() {
|
|
||||||
t.Skip("Skipping test when not running inside a Container")
|
|
||||||
}
|
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
server := httptest.NewServer(mux)
|
server := httptest.NewServer(mux)
|
||||||
if server == nil {
|
if server == nil {
|
||||||
|
@ -1397,16 +1390,16 @@ func TestValidRemoteDriver(t *testing.T) {
|
||||||
fmt.Fprintf(w, "null")
|
fmt.Fprintf(w, "null")
|
||||||
})
|
})
|
||||||
|
|
||||||
if err := os.MkdirAll("/etc/docker/plugins", 0755); err != nil {
|
if err := os.MkdirAll(specPath, 0755); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := os.RemoveAll("/etc/docker/plugins"); err != nil {
|
if err := os.RemoveAll(specPath); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err := ioutil.WriteFile("/etc/docker/plugins/valid-network-driver.spec", []byte(server.URL), 0644); err != nil {
|
if err := ioutil.WriteFile(filepath.Join(specPath, "valid-network-driver.spec"), []byte(server.URL), 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package libnetwork_test
|
||||||
|
|
||||||
|
var specPath = "/etc/docker/plugins"
|
|
@ -0,0 +1,3 @@
|
||||||
|
package libnetwork_test
|
||||||
|
|
||||||
|
var specPath = filepath.Join(os.Getenv("programdata"), "docker", "plugins")
|
|
@ -1,10 +1,11 @@
|
||||||
package testutils
|
package testutils
|
||||||
|
|
||||||
import "flag"
|
import (
|
||||||
|
"os"
|
||||||
var runningInContainer = flag.Bool("incontainer", false, "Indicates if the test is running in a container")
|
)
|
||||||
|
|
||||||
// IsRunningInContainer returns whether the test is running inside a container.
|
// IsRunningInContainer returns whether the test is running inside a container.
|
||||||
func IsRunningInContainer() bool {
|
func IsRunningInContainer() bool {
|
||||||
return (*runningInContainer)
|
_, err := os.Stat("/.dockerenv")
|
||||||
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue