mirror of https://github.com/status-im/consul.git
Merge pull request #12467 from hashicorp/dnephin/ci-vault-test-safer
ca: require that tests that use Vault are named correctly
This commit is contained in:
commit
73c91ed80f
|
@ -330,15 +330,15 @@ ifeq ("$(CIRCLECI)","true")
|
||||||
# Run in CI
|
# Run in CI
|
||||||
gotestsum --format=short-verbose --junitfile "$(TEST_RESULTS_DIR)/gotestsum-report.xml" -- -cover -coverprofile=coverage.txt ./agent/connect/ca
|
gotestsum --format=short-verbose --junitfile "$(TEST_RESULTS_DIR)/gotestsum-report.xml" -- -cover -coverprofile=coverage.txt ./agent/connect/ca
|
||||||
# Run leader tests that require Vault
|
# Run leader tests that require Vault
|
||||||
gotestsum --format=short-verbose --junitfile "$(TEST_RESULTS_DIR)/gotestsum-report-leader.xml" -- -cover -coverprofile=coverage-leader.txt -run '.*_Vault_' ./agent/consul
|
gotestsum --format=short-verbose --junitfile "$(TEST_RESULTS_DIR)/gotestsum-report-leader.xml" -- -cover -coverprofile=coverage-leader.txt -run Vault ./agent/consul
|
||||||
# Run agent tests that require Vault
|
# Run agent tests that require Vault
|
||||||
gotestsum --format=short-verbose --junitfile "$(TEST_RESULTS_DIR)/gotestsum-report-agent.xml" -- -cover -coverprofile=coverage-agent.txt -run '.*_Vault_' ./agent
|
gotestsum --format=short-verbose --junitfile "$(TEST_RESULTS_DIR)/gotestsum-report-agent.xml" -- -cover -coverprofile=coverage-agent.txt -run Vault ./agent
|
||||||
else
|
else
|
||||||
# Run locally
|
# Run locally
|
||||||
@echo "Running /agent/connect/ca tests in verbose mode"
|
@echo "Running /agent/connect/ca tests in verbose mode"
|
||||||
@go test -v ./agent/connect/ca
|
@go test -v ./agent/connect/ca
|
||||||
@go test -v ./agent/consul -run '.*_Vault_'
|
@go test -v ./agent/consul -run Vault
|
||||||
@go test -v ./agent -run '.*_Vault_'
|
@go test -v ./agent -run Vault
|
||||||
endif
|
endif
|
||||||
|
|
||||||
proto: $(PROTOGOFILES) $(PROTOGOBINFILES)
|
proto: $(PROTOGOFILES) $(PROTOGOBINFILES)
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/hashicorp/go-hclog"
|
"github.com/hashicorp/go-hclog"
|
||||||
|
@ -86,6 +87,13 @@ func TestConsulProvider(t testing.T, d ConsulProviderStateDelegate) *ConsulProvi
|
||||||
// These tests may be skipped in CI. They are run as part of a separate
|
// These tests may be skipped in CI. They are run as part of a separate
|
||||||
// integration test suite.
|
// integration test suite.
|
||||||
func SkipIfVaultNotPresent(t testing.T) {
|
func SkipIfVaultNotPresent(t testing.T) {
|
||||||
|
// Try to safeguard against tests that will never run in CI.
|
||||||
|
// This substring should match the pattern used by the
|
||||||
|
// test-connect-ca-providers CI job.
|
||||||
|
if !strings.Contains(t.Name(), "Vault") {
|
||||||
|
t.Fatalf("test name must contain Vault, otherwise CI will never run it")
|
||||||
|
}
|
||||||
|
|
||||||
vaultBinaryName := os.Getenv("VAULT_BINARY_NAME")
|
vaultBinaryName := os.Getenv("VAULT_BINARY_NAME")
|
||||||
if vaultBinaryName == "" {
|
if vaultBinaryName == "" {
|
||||||
vaultBinaryName = "vault"
|
vaultBinaryName = "vault"
|
||||||
|
|
|
@ -1490,8 +1490,6 @@ func TestCAManager_Initialize_Vault_BadCAConfigDoesNotPreventLeaderEstablishment
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCAManager_Initialize_BadCAConfigDoesNotPreventLeaderEstablishment(t *testing.T) {
|
func TestCAManager_Initialize_BadCAConfigDoesNotPreventLeaderEstablishment(t *testing.T) {
|
||||||
ca.SkipIfVaultNotPresent(t)
|
|
||||||
|
|
||||||
_, s1 := testServerWithConfig(t, func(c *Config) {
|
_, s1 := testServerWithConfig(t, func(c *Config) {
|
||||||
c.Build = "1.9.1"
|
c.Build = "1.9.1"
|
||||||
c.PrimaryDatacenter = "dc1"
|
c.PrimaryDatacenter = "dc1"
|
||||||
|
|
Loading…
Reference in New Issue