Merge pull request #4058 from hashicorp/f-mock-by-default

[Post-0.8] test: build with mock_driver by default
This commit is contained in:
Michael Schurter 2018-04-18 15:57:00 -07:00 committed by GitHub
commit fdbcbd4e5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 33 deletions

View File

@ -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
@ -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

View File

@ -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

View File

@ -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()
@ -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",

View File

@ -1,4 +1,4 @@
// +build nomad_test
// +build !release
package driver

View File

@ -1,13 +0,0 @@
package driver
import (
"testing"
)
// CheckForMockDriver is a test helper that ensures the mock driver is enabled.
// If not, it skips the current test.
func CheckForMockDriver(t *testing.T) {
if _, ok := BuiltinDrivers["mock_driver"]; !ok {
t.Skip(`test requires mock_driver; run with "-tags nomad_test"`)
}
}

View File

@ -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)
@ -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)
@ -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",

View File

@ -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"
@ -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")
}

View File

@ -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")