aboutsummaryrefslogtreecommitdiff
path: root/test/testrig
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-09-01 14:15:41 +0100
committerGitHub <noreply@github.com>2022-09-01 14:15:41 +0100
commit51d229b02505df770ed891ec8ab20843bc2b1d1d (patch)
tree24fe6f8ba56b8e59226574f0b2971c24418ba44b /test/testrig
parentad6b902b8462adb568d799c69a74b60d69574d0c (diff)
Configuration tweaks (#2567)
This makes the following changes: * The various `Defaults` functions are now responsible for setting sane defaults if `generate` is specified, rather than hiding them in `generate-config` * Some configuration options have been marked as `omitempty` so that they don't appear in generated configs unnecessarily (monolith-specific vs. polylith-specific options) * A new option `-polylith` has been added to `generate-config` to create a config that makes sense for polylith deployments (i.e. including the internal/external API listeners and per-component database sections) * A new option `-normalise` has been added to `generate-config` to take an existing file and add any missing options and/or defaults
Diffstat (limited to 'test/testrig')
-rw-r--r--test/testrig/base.go25
1 files changed, 20 insertions, 5 deletions
diff --git a/test/testrig/base.go b/test/testrig/base.go
index 33230921..9747ea60 100644
--- a/test/testrig/base.go
+++ b/test/testrig/base.go
@@ -30,12 +30,21 @@ import (
func CreateBaseDendrite(t *testing.T, dbType test.DBType) (*base.BaseDendrite, func()) {
var cfg config.Dendrite
- cfg.Defaults(false)
+ cfg.Defaults(config.DefaultOpts{
+ Generate: false,
+ Monolithic: true,
+ })
cfg.Global.JetStream.InMemory = true
switch dbType {
case test.DBTypePostgres:
- cfg.Global.Defaults(true) // autogen a signing key
- cfg.MediaAPI.Defaults(true) // autogen a media path
+ cfg.Global.Defaults(config.DefaultOpts{ // autogen a signing key
+ Generate: true,
+ Monolithic: true,
+ })
+ cfg.MediaAPI.Defaults(config.DefaultOpts{ // autogen a media path
+ Generate: true,
+ Monolithic: true,
+ })
cfg.Global.ServerName = "test"
// use a distinct prefix else concurrent postgres/sqlite runs will clash since NATS will use
// the file system event with InMemory=true :(
@@ -49,7 +58,10 @@ func CreateBaseDendrite(t *testing.T, dbType test.DBType) (*base.BaseDendrite, f
}
return base.NewBaseDendrite(&cfg, "Test", base.DisableMetrics), close
case test.DBTypeSQLite:
- cfg.Defaults(true) // sets a sqlite db per component
+ cfg.Defaults(config.DefaultOpts{
+ Generate: true,
+ Monolithic: false, // because we need a database per component
+ })
cfg.Global.ServerName = "test"
// use a distinct prefix else concurrent postgres/sqlite runs will clash since NATS will use
// the file system event with InMemory=true :(
@@ -82,7 +94,10 @@ func CreateBaseDendrite(t *testing.T, dbType test.DBType) (*base.BaseDendrite, f
func Base(cfg *config.Dendrite) (*base.BaseDendrite, nats.JetStreamContext, *nats.Conn) {
if cfg == nil {
cfg = &config.Dendrite{}
- cfg.Defaults(true)
+ cfg.Defaults(config.DefaultOpts{
+ Generate: true,
+ Monolithic: true,
+ })
}
cfg.Global.JetStream.InMemory = true
base := base.NewBaseDendrite(cfg, "Tests")