Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Vault
Commits
b42125f3
Unverified
Commit
b42125f3
authored
5 years ago
by
ncabatoff
Committed by
GitHub
5 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Write NewTestCluster logs to files, which get deleted if the test passes (#8911)
parent
ed937c46
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.circleci/config.yml
+17
-1
.circleci/config.yml
.circleci/config/commands/go_test.yml
+4
-0
.circleci/config/commands/go_test.yml
.circleci/config/jobs/test-go-race.yml
+3
-0
.circleci/config/jobs/test-go-race.yml
.circleci/config/jobs/test-go.yml
+4
-1
.circleci/config/jobs/test-go.yml
vault/testing.go
+30
-2
vault/testing.go
with
58 additions
and
4 deletions
+58
-4
.circleci/config.yml
+
17
-
1
View file @
b42125f3
...
...
@@ -225,6 +225,7 @@ jobs:
VAULT_TOKEN= \
VAULT_DEV_ROOT_TOKEN_ID= \
VAULT_ACC= \
VAULT_TEST_LOG_DIR=/tmp/testlogs \
gotestsum --format=short-verbose --junitfile test-results/go-test/results.xml -- \
-tags "${GO_TAGS}" \
-timeout=60m \
...
...
@@ -237,6 +238,8 @@ jobs:
path
:
test-results
-
store_test_results
:
path
:
test-results
-
store_artifacts
:
path
:
/tmp/testlogs
environment
:
-
CIRCLECI_CLI_VERSION
:
0.1.5546
-
GO_TAGS
:
'
'
...
...
@@ -298,6 +301,7 @@ jobs:
VAULT_TOKEN= \
VAULT_DEV_ROOT_TOKEN_ID= \
VAULT_ACC= \
VAULT_TEST_LOG_DIR=/tmp/testlogs \
gotestsum --format=short-verbose --junitfile test-results/go-test/results.xml -- \
-tags "${GO_TAGS}" \
-timeout=60m \
...
...
@@ -310,6 +314,8 @@ jobs:
path
:
test-results
-
store_test_results
:
path
:
test-results
-
store_artifacts
:
path
:
/tmp/testlogs
environment
:
-
CIRCLECI_CLI_VERSION
:
0.1.5546
-
GO_TAGS
:
'
'
...
...
@@ -402,6 +408,9 @@ workflows:
# extra_flags:
# default: \"\"
# type: string
# log_dir:
# default: /tmp/testlogs
# type: string
# steps:
# - run:
# command: |
...
...
@@ -435,6 +444,7 @@ workflows:
# VAULT_TOKEN= \\
# VAULT_DEV_ROOT_TOKEN_ID= \\
# VAULT_ACC= \\
# VAULT_TEST_LOG_DIR=<< parameters.log_dir >> \\
# gotestsum --format=short-verbose --junitfile test-results/go-test/results.xml -- \\
# -tags \"${GO_TAGS}\" \\
# -timeout=60m \\
...
...
@@ -571,11 +581,14 @@ workflows:
# - check-branch-name
# - setup-go
# - checkout
# - go_test
# - go_test:
# log_dir: /tmp/testlogs
# - store_artifacts:
# path: test-results
# - store_test_results:
# path: test-results
# - store_artifacts:
# path: /tmp/testlogs
# test-go-race:
# executor: go-machine
# steps:
...
...
@@ -583,10 +596,13 @@ workflows:
# - checkout
# - go_test:
# extra_flags: -race
# log_dir: /tmp/testlogs
# - store_artifacts:
# path: test-results
# - store_test_results:
# path: test-results
# - store_artifacts:
# path: /tmp/testlogs
# test-ui:
# executor: node
# resource_class: medium+
...
...
This diff is collapsed.
Click to expand it.
.circleci/config/commands/go_test.yml
+
4
-
0
View file @
b42125f3
...
...
@@ -3,6 +3,9 @@ parameters:
extra_flags
:
type
:
string
default
:
"
"
log_dir
:
type
:
string
default
:
"
/tmp/testlogs"
steps
:
-
run
:
name
:
Run Go tests
...
...
@@ -38,6 +41,7 @@ steps:
VAULT_TOKEN= \
VAULT_DEV_ROOT_TOKEN_ID= \
VAULT_ACC= \
VAULT_TEST_LOG_DIR=<< parameters.log_dir >> \
gotestsum --format=short-verbose --junitfile test-results/go-test/results.xml -- \
-tags "${GO_TAGS}" \
-timeout=60m \
...
...
This diff is collapsed.
Click to expand it.
.circleci/config/jobs/test-go-race.yml
+
3
-
0
View file @
b42125f3
...
...
@@ -4,7 +4,10 @@ steps:
-
checkout
-
go_test
:
extra_flags
:
"
-race"
log_dir
:
"
/tmp/testlogs"
-
store_artifacts
:
path
:
test-results
-
store_test_results
:
path
:
test-results
-
store_artifacts
:
path
:
"
/tmp/testlogs"
This diff is collapsed.
Click to expand it.
.circleci/config/jobs/test-go.yml
+
4
-
1
View file @
b42125f3
...
...
@@ -4,8 +4,11 @@ steps:
-
check-branch-name
-
setup-go
-
checkout
-
go_test
-
go_test
:
log_dir
:
"
/tmp/testlogs"
-
store_artifacts
:
path
:
test-results
-
store_test_results
:
path
:
test-results
-
store_artifacts
:
path
:
"
/tmp/testlogs"
This diff is collapsed.
Click to expand it.
vault/testing.go
+
30
-
2
View file @
b42125f3
...
...
@@ -1132,9 +1132,30 @@ func NewTestCluster(t testing.T, base *CoreConfig, opts *TestClusterOptions) *Te
var
testCluster
TestCluster
if
opts
!=
nil
&&
opts
.
Logger
!=
nil
{
var
logDir
=
os
.
Getenv
(
"VAULT_TEST_LOG_DIR"
)
var
logFileName
string
var
logFile
*
os
.
File
switch
{
case
opts
!=
nil
&&
opts
.
Logger
!=
nil
:
testCluster
.
Logger
=
opts
.
Logger
}
else
{
case
logDir
!=
""
:
// This is not ideal because t.Name does not include the package, and
// there's no easy way to get it. However, at present there aren't many
// tests that have the same name, and from what I can see there are no
// duplicates that call NewTestCluster.
logFileName
=
filepath
.
Join
(
logDir
,
t
.
Name
()
+
".log"
)
// t.Name may include slashes.
dir
,
_
:=
filepath
.
Split
(
logFileName
)
if
err
:=
os
.
MkdirAll
(
dir
,
0755
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
logFile
,
err
=
os
.
Create
(
logFileName
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
testCluster
.
Logger
=
logging
.
NewVaultLoggerWithWriter
(
logFile
,
log
.
Trace
)
default
:
testCluster
.
Logger
=
logging
.
NewVaultLogger
(
log
.
Trace
)
.
Named
(
t
.
Name
())
}
...
...
@@ -1789,6 +1810,13 @@ func NewTestCluster(t testing.T, base *CoreConfig, opts *TestClusterOptions) *Te
for
_
,
c
:=
range
cleanupFuncs
{
c
()
}
if
logFile
!=
nil
{
if
t
.
Failed
()
{
logFile
.
Close
()
}
else
{
os
.
Remove
(
logFileName
)
}
}
}
if
opts
!=
nil
{
if
opts
.
SetupFunc
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help