Skip to content

Commit

Permalink
Merge pull request #4058 from hashicorp/f-mock-by-default
Browse files Browse the repository at this point in the history
[Post-0.8] test: build with mock_driver by default
  • Loading branch information
schmichael committed Apr 18, 2018
2 parents 9e1145e + 29da24b commit a516dcd
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 33 deletions.
8 changes: 4 additions & 4 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,18 @@ dev: vendorfmt changelogfmt ## Build for the current development platform
@rm -f $(GOPATH)/bin/nomad
@$(MAKE) --no-print-directory \
$(DEV_TARGET) \
GO_TAGS="nomad_test $(NOMAD_UI_TAG)"
GO_TAGS="$(NOMAD_UI_TAG)"
@mkdir -p $(PROJECT_ROOT)/bin
@mkdir -p $(GOPATH)/bin
@cp $(PROJECT_ROOT)/$(DEV_TARGET) $(PROJECT_ROOT)/bin/
@cp $(PROJECT_ROOT)/$(DEV_TARGET) $(GOPATH)/bin

.PHONY: prerelease
prerelease: GO_TAGS=ui
prerelease: GO_TAGS=ui release
prerelease: check generate ember-dist static-assets ## Generate all the static assets for a Nomad release

.PHONY: release
release: GO_TAGS=ui
release: GO_TAGS=ui release
release: clean $(foreach t,$(ALL_TARGETS),pkg/$(t).zip) ## Build all release packages which can be built on this platform.
@echo "==> Results:"
@tree --dirsfirst $(PROJECT_ROOT)/pkg
Expand All @@ -247,7 +247,7 @@ test-nomad: dev ## Run Nomad test suites
go test $(if $(VERBOSE),-v) \
-cover \
-timeout=900s \
-tags="nomad_test $(if $(HAS_LXC),lxc)" ./... $(if $(VERBOSE), >test.log ; echo $$? > exit-code)
-tags="$(if $(HAS_LXC),lxc)" ./... $(if $(VERBOSE), >test.log ; echo $$? > exit-code)
@if [ $(VERBOSE) ] ; then \
bash -C "$(PROJECT_ROOT)/scripts/test_check.sh" ; \
fi
Expand Down
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ install:
- ps: Expand-Archive C:\gopath\bin\vault.zip -DestinationPath C:\gopath\bin
- ps: appveyor DownloadFile "https://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_windows_amd64.zip" -FileName "C:\\gopath\\bin\\consul.zip"
- ps: Expand-Archive C:\gopath\bin\consul.zip -DestinationPath C:\gopath\bin
#- cmd: go install -tags nomad_test
#- cmd: go install
build_script:
#- cmd: go test -tags nomad_test ./...
- cmd: go install -tags nomad_test
#- cmd: go test ./...
- cmd: go install
4 changes: 1 addition & 3 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func TestClient_RPC_Passthrough(t *testing.T) {

func TestClient_Fingerprint(t *testing.T) {
t.Parallel()

c := TestClient(t, nil)
defer c.Shutdown()

Expand All @@ -157,11 +158,8 @@ func TestClient_Fingerprint(t *testing.T) {
}

func TestClient_Fingerprint_Periodic(t *testing.T) {
driver.CheckForMockDriver(t)
t.Parallel()

// these constants are only defined when nomad_test is enabled, so these fail
// our linter without explicit disabling.
c1 := TestClient(t, func(c *config.Config) {
c.Options = map[string]string{
driver.ShutdownPeriodicAfter: "true",
Expand Down
2 changes: 1 addition & 1 deletion client/driver/mock_driver_testing.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build nomad_test
// +build !release

package driver

Expand Down
13 changes: 0 additions & 13 deletions client/driver/testing.go

This file was deleted.

4 changes: 0 additions & 4 deletions client/fingerprint_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import (
"testing"

"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/client/driver"
"github.com/hashicorp/nomad/testutil"
"github.com/stretchr/testify/require"
)

func TestFingerprintManager_Run_MockDriver(t *testing.T) {
driver.CheckForMockDriver(t)
t.Parallel()
require := require.New(t)
testClient := TestClient(t, nil)
Expand Down Expand Up @@ -42,7 +40,6 @@ func TestFingerprintManager_Run_MockDriver(t *testing.T) {

func TestFingerprintManager_Run_ResourcesFingerprint(t *testing.T) {
t.Parallel()
driver.CheckForMockDriver(t)
require := require.New(t)
testClient := TestClient(t, nil)

Expand Down Expand Up @@ -98,7 +95,6 @@ func TestFingerprintManager_Fingerprint_Run(t *testing.T) {
func TestFingerprintManager_Fingerprint_Periodic(t *testing.T) {
t.Parallel()
require := require.New(t)
driver.CheckForMockDriver(t)
testClient := TestClient(t, func(c *config.Config) {
c.Options = map[string]string{
"test.shutdown_periodic_after": "true",
Expand Down
4 changes: 0 additions & 4 deletions command/agent/consul/int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/hashicorp/nomad/client"
"github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/client/driver"
"github.com/hashicorp/nomad/client/vaultclient"
"github.com/hashicorp/nomad/command/agent/consul"
"github.com/hashicorp/nomad/nomad/mock"
Expand All @@ -32,9 +31,6 @@ func testLogger() *log.Logger {
// TestConsul_Integration asserts TaskRunner properly registers and deregisters
// services and checks with Consul using an embedded Consul agent.
func TestConsul_Integration(t *testing.T) {
if _, ok := driver.BuiltinDrivers["mock_driver"]; !ok {
t.Skip(`test requires mock_driver; run with "-tags nomad_test"`)
}
if testing.Short() {
t.Skip("-short set; skipping")
}
Expand Down
2 changes: 1 addition & 1 deletion testutil/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func NewTestServer(t testing.T, cb ServerConfigCallback) *TestServer {
vcmd.Stdout = nil
vcmd.Stderr = nil
if err := vcmd.Run(); err != nil {
t.Skipf("nomad version failed. Did you run your test with -tags nomad_test (%v)", err)
t.Skipf("nomad version failed: %v", err)
}

dataDir, err := ioutil.TempDir("", "nomad")
Expand Down

0 comments on commit a516dcd

Please sign in to comment.