Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services/horizon: Add deprecation warning for --captive-core-use-db #5231

Merged
merged 10 commits into from
Mar 25, 2024
3 changes: 3 additions & 0 deletions services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ func Flags() (*Config, support.ConfigOptions) {
Usage: `when enabled, Horizon ingestion will instruct the captive core invocation to use an external db url for ledger states rather than in memory(RAM). Will result in several GB of space shifting out of RAM and to the external db persistence. The external db url is determined by the presence of DATABASE parameter in the captive-core-config-path or if absent, the db will default to sqlite and the db file will be stored at location derived from captive-core-storage-path parameter.`,
CustomSetValue: func(opt *support.ConfigOption) error {
if val := viper.GetBool(opt.Name); val {
stdLog.Printf("The usage of the flag --captive-core-use-db has been deprecated. " +
"Setting it to false to achieve in-memory functionality on captive core will be removed in " +
"future releases. We recommend removing usage of this flag now in preparation.")
config.CaptiveCoreConfigUseDB = val
config.CaptiveCoreTomlParams.UseDB = val
}
Expand Down
33 changes: 33 additions & 0 deletions services/horizon/internal/integration/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,39 @@ func TestDeprecatedOutputs(t *testing.T) {
"Configuring section in the developer documentation on how to use them - "+
"https://developers.stellar.org/docs/run-api-server/configuring")
})
t.Run("deprecated output for --captive-core-use-db", func(t *testing.T) {
originalStderr := os.Stderr
r, w, _ := os.Pipe()
os.Stderr = w
stdLog.SetOutput(os.Stderr)

testConfig := integration.GetTestConfig()
testConfig.HorizonIngestParameters = map[string]string{"captive-core-use-db": "false"}
test := integration.NewTest(t, *testConfig)
err := test.StartHorizon()
assert.NoError(t, err)
test.WaitForHorizon()

// Use a wait group to wait for the goroutine to finish before proceeding
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
if err := w.Close(); err != nil {
t.Errorf("Failed to close Stdout")
return
}
}()

outputBytes, _ := io.ReadAll(r)
wg.Wait() // Wait for the goroutine to finish before proceeding
_ = r.Close()
os.Stderr = originalStderr

assert.Contains(t, string(outputBytes), "The usage of the flag --captive-core-use-db has been deprecated. "+
"Setting it to false to achieve in-memory functionality on captive core will be removed in "+
"future releases. We recommend removing usage of this flag now in preparation.")
})
}

func TestGlobalFlagsOutput(t *testing.T) {
Expand Down
Loading