Skip to content

Commit

Permalink
test: fix TestConfigFileDeprecatedOptions
Browse files Browse the repository at this point in the history
Use minimal config struct for YAML marshaling.
Replace custom mapToSortedSlice with standard library functions.
Fix flag verification for deprecated experimental options.

Fixes #19066

Signed-off-by: mansoora <[email protected]>
  • Loading branch information
mansoor17syed committed Jan 10, 2025
1 parent d83f391 commit f8c0bf3
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions server/etcdmain/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ import (
"errors"
"flag"
"fmt"
"maps"
"net/url"
"os"
"reflect"
"slices"
"strings"
"testing"
"time"

"sigs.k8s.io/yaml"

"github.com/stretchr/testify/assert"
"go.etcd.io/etcd/pkg/v3/featuregate"
"go.etcd.io/etcd/pkg/v3/flags"
"go.etcd.io/etcd/server/v3/embed"
Expand Down Expand Up @@ -728,15 +727,12 @@ func TestConfigFileDeprecatedOptions(t *testing.T) {
}

// Compare sets of flags
if !reflect.DeepEqual(foundFlags, tc.expectedFlags) {
t.Errorf("deprecated flags mismatch:\ngot: %v\nwant: %v",
slices.Sorted(maps.Keys(foundFlags)),
slices.Sorted(maps.Keys(tc.expectedFlags)))
}
assert.Equal(t, tc.expectedFlags, foundFlags, "deprecated flags mismatch")

// Special check for experimental-warning-unary-request-duration
// Note: experimental-warning-unary-request-duration deprecation is handled
// through a separate mechanism in embed.Config
if tc.configFileYAML.ExperimentalWarningUnaryRequestDuration != 0 {
t.Log("Note: experimental-warning-unary-request-duration deprecation is handled separately")
// Skip checking this flag as it's handled differently
}
})
}
Expand Down

0 comments on commit f8c0bf3

Please sign in to comment.