diff --git a/.gitlab/.gitlab-ci.yml b/.gitlab/.gitlab-ci.yml index e1ac9fa06..57ea4d522 100644 --- a/.gitlab/.gitlab-ci.yml +++ b/.gitlab/.gitlab-ci.yml @@ -216,7 +216,7 @@ run go tests race: script: - echo "Running featurebase race tests..." - PKG_LIST=$(go list ./... | grep -Ev 'internal/clustertests|simulacraData|batch|idk|v3/dax/test/dax' | paste -s -d, -) - - RAMDISK=/mnt/ramdisk go test -race -v -timeout=10m ${PKG_LIST//,/ } + - TMPDIR=/mnt/ramdisk go test -race -v -timeout=10m ${PKG_LIST//,/ } tags: - docker @@ -232,7 +232,7 @@ run go tests: script: - echo "Running featurebase unit tests..." - PKG_LIST=$(go list ./... | grep -Ev 'internal/clustertests|simulacraData|batch|idk|v3/dax/test/dax' | paste -s -d, -) - - RAMDISK=/mnt/ramdisk go test -tags=shardwidth22 -timeout=10m -coverprofile=coverage.out -covermode=atomic -coverpkg=${PKG_LIST} ${PKG_LIST//,/ } + - TMPDIR=/mnt/ramdisk go test -tags=shardwidth22 -timeout=10m -coverprofile=coverage.out -covermode=atomic -coverpkg=${PKG_LIST} ${PKG_LIST//,/ } artifacts: paths: - coverage.out diff --git a/Makefile b/Makefile index a3ff35bea..d482b2f4e 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,9 @@ BUILD_TAGS += TEST_TAGS = roaringparanoia TEST_TIMEOUT=10m RACE_TEST_TIMEOUT=10m +# size in GB to use for ramdisk, ?= so you can override it with env +# 4GB is not enough for `make test`, 8GB usually is. +RAMDISK_SIZE ?= 8 export GO111MODULE=on export GOPRIVATE=github.com/molecula @@ -77,13 +80,18 @@ testvsub: echo; echo "999 done testing subpkg $$pkg"; \ done -# make a 2GB RAMDisk. Speed up tests by running them with RAMDISK=/mnt/ramdisk +# make a $(RAMDISK_SIZE)GB RAMDisk. Speed up tests by running +# them with TMPDIR=/mnt/ramdisk. ramdisk-linux: - mount -o size=2G -t tmpfs none /mnt/ramdisk + mount -o size=$(RAMDISK__SIZE)G -t tmpfs none /mnt/ramdisk -# make a 2GB RAMDisk. Speed up tests by running them with RAMDISK=/Volumes/RAMDisk +# make a $(RAMDISK_SIZE)GB RAMDisk. Speed up tests by running +# them with TMPDIR=/Volumes/RAMDisk. This is more important on +# OS X than it is on Linux, because there's performance issues +# with fsync on OS X that can make the SSD slow down to moving-platters +# drive speeds. Oops. ramdisk-osx: - diskutil erasevolume HFS+ 'RAMDisk' `hdiutil attach -nobrowse -nomount ram://4194304` + diskutil erasevolume HFS+ 'RAMDisk' $$(hdiutil attach -nobrowse -nomount ram://$$(expr 2097152 \* $(RAMDISK_SIZE))) detach-ramdisk-osx: hdiutil detach /Volumes/RAMDisk diff --git a/translate.go b/translate.go index 852420abc..2573a14f4 100644 --- a/translate.go +++ b/translate.go @@ -289,7 +289,7 @@ func OpenInMemTranslateStore(rawurl, index, field string, partitionID, partition fname = fname[:10] } - tf, err := os.CreateTemp(os.Getenv("RAMDISK"), fmt.Sprintf("bolt-i%s-f%s-%d-%d-", iname, fname, partitionID, partitionN)) + tf, err := os.CreateTemp("", fmt.Sprintf("bolt-i%s-f%s-%d-%d-", iname, fname, partitionID, partitionN)) if err != nil { return nil, errors.Wrap(err, "making temp file for boltdb key translation") }