Skip to content

Commit

Permalink
fix for #19066 Print warnings when deprecated options are configured …
Browse files Browse the repository at this point in the history
…in config file
  • Loading branch information
mansoor17syed committed Jan 10, 2025
1 parent 247ab42 commit 2fca19d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions server/etcdmain/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,32 +657,40 @@ func validateClusteringFlags(t *testing.T, cfg *config) {
}

func TestConfigFileDeprecatedOptions(t *testing.T) {
// Define a minimal config struct with only the fields we need
type configFileYAML struct {
SnapshotCount uint64 `json:"snapshot-count,omitempty"`
MaxSnapFiles uint `json:"max-snapshots,omitempty"`
ExperimentalCompactHashCheckEnabled bool `json:"experimental-compact-hash-check-enabled,omitempty"`
ExperimentalCompactHashCheckTime time.Duration `json:"experimental-compact-hash-check-time,omitempty"`
ExperimentalWarningUnaryRequestDuration time.Duration `json:"experimental-warning-unary-request-duration,omitempty"`
}

testCases := []struct {
name string
configFileYAML embed.Config
configFileYAML configFileYAML
expectedFlags map[string]struct{}
}{
{
name: "no deprecated options",
configFileYAML: embed.Config{},
configFileYAML: configFileYAML{},
expectedFlags: map[string]struct{}{},
},
{
name: "deprecated experimental options",
configFileYAML: embed.Config{
configFileYAML: configFileYAML{
ExperimentalCompactHashCheckEnabled: true,
ExperimentalCompactHashCheckTime: 2 * time.Minute,
ExperimentalWarningUnaryRequestDuration: time.Second,
},
expectedFlags: map[string]struct{}{
"experimental-compact-hash-check-enabled": {},
"experimental-compact-hash-check-time": {},
// experimental-warning-unary-request-duration is handled differently
},
},
{
name: "deprecated snapshot options",
configFileYAML: embed.Config{
configFileYAML: configFileYAML{
SnapshotCount: 10000,
MaxSnapFiles: 5,
},
Expand Down Expand Up @@ -728,8 +736,6 @@ func TestConfigFileDeprecatedOptions(t *testing.T) {

// Special check for experimental-warning-unary-request-duration
if tc.configFileYAML.ExperimentalWarningUnaryRequestDuration != 0 {
// Verify that the warning was logged, but don't require it to be in FlagsExplicitlySet
// The warning is handled in a different way in the code
t.Log("Note: experimental-warning-unary-request-duration deprecation is handled separately")
}
})
Expand Down

0 comments on commit 2fca19d

Please sign in to comment.