1
0
mirror of https://github.com/golang/go synced 2024-11-19 02:04:42 -07:00
go/src/run.bash
Brad Fitzpatrick 6b1ac8290f cmd/dist: allow builders to control granularity of test/ directory sharding
Even with 10 shards on builders, it still takes about ~2.5 minutes per
shard (and getting slower all the time as the test/ directory grows).
I'm currently experimenting with massively sharding out testing on
Cloud Run (each dist test & normal TestFoo func all running in
parallel), and in such a setup, 2.5 minutes is an eternity. I'd like
to increase that dist test's sharding from 10 to more like 1,000.

Updates golang/go#31834

Change-Id: I8b02989727793b5b5b2013d67e1eb01ef4786e28
Reviewed-on: https://go-review.googlesource.com/c/go/+/175297
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-06 23:02:29 +00:00

60 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# Environment variables that control run.bash:
#
# GO_TEST_SHARDS: number of "dist test" test shards that the
# $GOROOT/test directory will be sliced up into for parallel
# execution. Defaults to 1, unless GO_BUILDER_NAME is also specified,
# in which case it defaults to 10.
#
# GO_BUILDER_NAME: the name of the Go builder that's running the tests.
# Some tests are conditionally enabled or disabled based on the builder
# name or the builder name being non-empty.
set -e
eval $(go env)
export GOROOT # the api test requires GOROOT to be set.
# We disallow local import for non-local packages, if $GOROOT happens
# to be under $GOPATH, then some tests below will fail. $GOPATH needs
# to be set to a non-empty string, else Go will set a default value
# that may also conflict with $GOROOT. The $GOPATH value doesn't need
# to point to an actual directory, it just needs to pass the semantic
# checks performed by Go. Use $GOROOT to define $GOPATH so that we
# don't blunder into a user-defined symbolic link.
export GOPATH=/dev/null
unset CDPATH # in case user has it set
export GOBIN=$GOROOT/bin # Issue 14340
unset GOFLAGS
unset GO111MODULE
export GOHOSTOS
export CC
# no core files, please
ulimit -c 0
# Raise soft limits to hard limits for NetBSD/OpenBSD.
# We need at least 256 files and ~300 MB of bss.
# On OS X ulimit -S -n rejects 'unlimited'.
#
# Note that ulimit -S -n may fail if ulimit -H -n is set higher than a
# non-root process is allowed to set the high limit.
# This is a system misconfiguration and should be fixed on the
# broken system, not "fixed" by ignoring the failure here.
# See longer discussion on golang.org/issue/7381.
[ "$(ulimit -H -n)" = "unlimited" ] || ulimit -S -n $(ulimit -H -n)
[ "$(ulimit -H -d)" = "unlimited" ] || ulimit -S -d $(ulimit -H -d)
# Thread count limit on NetBSD 7.
if ulimit -T &> /dev/null; then
[ "$(ulimit -H -T)" = "unlimited" ] || ulimit -S -T $(ulimit -H -T)
fi
exec go tool dist test -rebuild "$@"