Enable diagnostics via build constraint to prevent from running in tests

This commit is contained in:
Cody Soyland 2018-02-02 17:32:14 -06:00
parent 0dee49279c
commit 6756d97089
7 changed files with 23 additions and 9 deletions

View file

@ -6,7 +6,7 @@ COPY . /go/src/github.com/pilosa/pilosa
RUN cd /go/src/github.com/pilosa/pilosa \
&& make vendor \
&& CGO_ENABLED=0 go install -a -ldflags "$ldflags" github.com/pilosa/pilosa/cmd/pilosa
&& CGO_ENABLED=0 go install -tags release -a -ldflags "$ldflags" github.com/pilosa/pilosa/cmd/pilosa
FROM scratch

View file

@ -53,7 +53,7 @@ cover-viz: cover
go tool cover -html=build/coverage/all.out
pilosa: vendor
go build -ldflags $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa
go build -tags release -ldflags $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa
release-build: vendor
ifdef DOCKER_BUILD
@ -114,7 +114,7 @@ docker:
@echo "Created image: pilosa:$(VERSION)"
docker-build:
docker run --rm -v $(PWD):/go/src/$(CLONE_URL) -w /go/src/$(CLONE_URL) -e GOOS=$(GOOS) -e GOARCH=$(GOARCH) $(DOCKER_GOLANG_IMAGE) go build -ldflags $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa
docker run --rm -v $(PWD):/go/src/$(CLONE_URL) -w /go/src/$(CLONE_URL) -e GOOS=$(GOOS) -e GOARCH=$(GOARCH) $(DOCKER_GOLANG_IMAGE) go build -tags release -ldflags $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa
docker-test:
docker run --rm -v $(PWD):/go/src/$(CLONE_URL) -w /go/src/$(CLONE_URL) $(DOCKER_GOLANG_IMAGE) go test $(TESTFLAGS) $(PKGS)

10
server/default.go Normal file
View file

@ -0,0 +1,10 @@
// +build !release
//
// This file sets defaults to be overridden by release.go
package server
import "time"
// DefaultDiagnosticsInterval is the default sync frequency diagnostic metrics. A value of 0 disables diagnostics.
const DefaultDiagnosticsInterval = time.Duration(0)

10
server/release.go Normal file
View file

@ -0,0 +1,10 @@
// +build release
//
// This file sets release-specific variables.
package server
import "time"
// DefaultDiagnosticsInterval is the default sync frequency diagnostic metrics.
const DefaultDiagnosticsInterval = 1 * time.Hour

View file

@ -45,9 +45,6 @@ func init() {
const (
// DefaultDataDir is the default data directory.
DefaultDataDir = "~/.pilosa"
// DefaultDiagnosticsInterval is the default sync frequency diagnostic metrics.
DefaultDiagnosticsInterval = 1 * time.Hour
)
// Command represents the state of the pilosa server command.

View file

@ -539,7 +539,6 @@ func NewMainArrayWithCluster(size int) []*Main {
// MustRunMain returns a new, running Main. Panic on error.
func MustRunMain() *Main {
m := NewMain()
m.Config.Metric.Diagnostics = false // Disable diagnostics.
if err := m.Run(); err != nil {
panic(err)
}

View file

@ -41,7 +41,6 @@ func newServer() (*server.Command, error) {
s.Config.GossipSeed = "localhost:" + s.Config.GossipPort
s.Config.Cluster.Type = "gossip"
s.Config.Metric.Diagnostics = false
td, err := ioutil.TempDir("", "")
if err != nil {
return nil, errors.Wrap(err, "temp dir")
@ -101,7 +100,6 @@ func NewServerCluster(size int) (cluster *Cluster, err error) {
cluster.Servers[i] = s
hosts[i] = s.Config.Bind
s.Config.GossipSeed = cluster.Servers[0].Config.GossipSeed
s.Config.Metric.Diagnostics = false // Disable diagnostics.
}