Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ONBOARDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ There is no syntactically pleasing way to do this. Create a separate function wh

This is done using standard Go testing mechanisms, use `t.Logf(...)` which will be logged only if the test fails or if `-v` is set. Note that you will not need to log HTTP requests performed using one of the built in deployment clients as they are already wrapped in loggers. For full HTTP logs, use `COMPLEMENT_DEBUG=1`.


### How do I show the server logs even when the tests pass?

Normally, server logs are only printed when one of the tests fail. To override that behavior to always show server logs, you can use `COMPLEMENT_ALWAYS_PRINT_SERVER_LOGS=1`.


### How do I skip a test?

Use one of `t.Skipf(...)` or `t.SkipNow()`.
Expand Down
2 changes: 2 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Complement struct {
BaseImageURI string
BaseImageArgs []string
DebugLoggingEnabled bool
AlwaysPrintServerLogs bool
BestEffort bool
VersionCheckIterations int
KeepBlueprints []string
Expand All @@ -20,6 +21,7 @@ func NewConfigFromEnvVars() *Complement {
cfg.BaseImageURI = os.Getenv("COMPLEMENT_BASE_IMAGE")
cfg.BaseImageArgs = strings.Split(os.Getenv("COMPLEMENT_BASE_IMAGE_ARGS"), " ")
cfg.DebugLoggingEnabled = os.Getenv("COMPLEMENT_DEBUG") == "1"
cfg.AlwaysPrintServerLogs = os.Getenv("COMPLEMENT_ALWAYS_PRINT_SERVER_LOGS") == "1"
cfg.VersionCheckIterations = parseEnvWithDefault("COMPLEMENT_VERSION_CHECK_ITERATIONS", 100)
cfg.KeepBlueprints = strings.Split(os.Getenv("COMPLEMENT_KEEP_BLUEPRINTS"), " ")
if cfg.BaseImageURI == "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/docker/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type HomeserverDeployment struct {
// will print container logs before killing the container.
func (d *Deployment) Destroy(t *testing.T) {
t.Helper()
d.Deployer.Destroy(d, t.Failed())
d.Deployer.Destroy(d, d.Deployer.config.AlwaysPrintServerLogs || t.Failed())
}

// Client returns a CSAPI client targeting the given hsName, using the access token for the given userID.
Expand Down