mirror of https://github.com/status-im/consul.git
build: make tests independent of build tags
When the metadata server is scanning the agents for potential servers it is parsing the version number which the agent provided when it joined. This version number has to conform to a certain format, i.e. 'n.n.n'. Without this version number properly set some tests fail with error messages that disguise the root cause. The default version number is currently set to 'unknown' in version/version.go which does not parse and triggers the tests to fail. The work around is to use a build tag 'consul' which will use the version number set in version_base.go instead which has the correct format and is set to the current release version. In addition, some parts of the code also require the version number to be of a certain value. Setting it to '0.0.0' for example makes some tests pass and others fail since they don't pass the semantic check. When using go build/install/test one has to remember to use '-tags consul' or tests will fail with non-obvious error messages. Using build tags makes the build process more complex and error prone since it prevents the use of the plain go toolchain and - at least in its current form - introduces subtle build and test issues. We should try to eliminate build tags for anything else but platform specific code. This patch removes all references to specific version numbers in the code and tests and sets the default version to '9.9.9' which is syntactically correct and passes the semantic check. This solves the issue of running go build/install/test without tags for the OSS build.
This commit is contained in:
parent
58b79d43b7
commit
831d84c940
|
@ -34,7 +34,6 @@ func makeTestACL(t *testing.T, srv *HTTPServer) string {
|
|||
func TestACL_Bootstrap(t *testing.T) {
|
||||
t.Parallel()
|
||||
cfg := TestACLConfig()
|
||||
cfg.Version = "0.9.1"
|
||||
cfg.ACLMasterToken = ""
|
||||
a := NewTestAgent(t.Name(), cfg)
|
||||
defer a.Shutdown()
|
||||
|
|
|
@ -19,16 +19,11 @@ import (
|
|||
"github.com/hashicorp/consul/api"
|
||||
"github.com/hashicorp/consul/testutil"
|
||||
"github.com/hashicorp/consul/types"
|
||||
"github.com/hashicorp/consul/version"
|
||||
"github.com/hashicorp/go-uuid"
|
||||
"github.com/hashicorp/raft"
|
||||
"github.com/pascaldekloe/goe/verify"
|
||||
)
|
||||
|
||||
func init() {
|
||||
version.Version = "0.8.0"
|
||||
}
|
||||
|
||||
func externalIP() (string, error) {
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/hashicorp/consul/agent/structs"
|
||||
"github.com/hashicorp/consul/tlsutil"
|
||||
"github.com/hashicorp/consul/types"
|
||||
"github.com/hashicorp/consul/version"
|
||||
"github.com/hashicorp/memberlist"
|
||||
"github.com/hashicorp/raft"
|
||||
"github.com/hashicorp/serf/serf"
|
||||
|
@ -344,7 +345,7 @@ func DefaultConfig() *Config {
|
|||
}
|
||||
|
||||
conf := &Config{
|
||||
Build: "0.8.0",
|
||||
Build: version.Version,
|
||||
Datacenter: DefaultDC,
|
||||
NodeName: hostname,
|
||||
RPCAddr: DefaultRPCAddr,
|
||||
|
|
|
@ -4,14 +4,9 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/consul/version"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func init() {
|
||||
version.Version = "0.8.0"
|
||||
}
|
||||
|
||||
func assertNoTabs(t *testing.T, c cli.Command) {
|
||||
if strings.ContainsRune(c.Help(), '\t') {
|
||||
t.Errorf("%#v help output contains tabs", c)
|
||||
|
|
|
@ -13,7 +13,12 @@ var (
|
|||
|
||||
// Release versions of the build. These will be filled in by one of the
|
||||
// build tag-specific files.
|
||||
Version = "unknown"
|
||||
//
|
||||
// Version must conform to the format expected by github.com/hashicorp/go-version
|
||||
// for tests to work. Otherwise, the metadata server will not be able to detect
|
||||
// the agent to be a server. The value must be >= '0.8.0' for autopilot to work.
|
||||
// todo(fs): This still feels like a hack but at least the magic values are gone.
|
||||
Version = "9.9.9"
|
||||
VersionPrerelease = "unknown"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue