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
5 changes: 5 additions & 0 deletions services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ 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(
"DEPRECATED - The usage of the flag --captive-core-use-db has been deprecated. This in-memory " +
aditya1702 marked this conversation as resolved.
Show resolved Hide resolved
"functionality will soon be removed in the future. We recommend keeping the default value of True, " +
"to use the external DB rather than in-memory mode. ",
)
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), "DEPRECATED - The usage of the flag --captive-core-use-db has been deprecated. This in-memory "+
"functionality will soon be removed in the future. We recommend keeping the default value of True, "+
"to use the external DB rather than in-memory mode. ")
})
}

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