Skip to content

Commit

Permalink
Merge pull request #17202 from ishan16696/Backport-PR16465-3.4
Browse files Browse the repository at this point in the history
[3.4]Add a unit tests and missing flags in etcd help.
  • Loading branch information
ahrtr committed Jan 5, 2024
2 parents 2664430 + 06d7312 commit c7eab9d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions etcdmain/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package etcdmain

import (
"flag"
"fmt"
"io/ioutil"
"net/url"
Expand All @@ -24,6 +25,7 @@ import (
"testing"

"go.etcd.io/etcd/embed"
"go.etcd.io/etcd/pkg/flags"
"sigs.k8s.io/yaml"
)

Expand Down Expand Up @@ -496,6 +498,21 @@ func TestConfigFileElectionTimeout(t *testing.T) {
}
}

func TestFlagsPresentInHelp(t *testing.T) {
cfg := newConfig()
cfg.cf.flagSet.VisitAll(func(f *flag.Flag) {
if _, ok := f.Value.(*flags.IgnoredFlag); ok {
// Ignored flags do not need to be in the help
return
}

flagText := fmt.Sprintf("--%s", f.Name)
if !strings.Contains(flagsline, flagText) && !strings.Contains(usageline, flagText) {
t.Errorf("Neither flagsline nor usageline in help.go contains flag named %s", flagText)
}
})
}

func mustCreateCfgFile(t *testing.T, b []byte) *os.File {
tmpfile, err := ioutil.TempFile("", "servercfg")
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions etcdmain/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ Member:
Minimum duration interval that a client should wait before pinging server.
--grpc-keepalive-interval '2h'
Frequency duration of server-to-client ping to check if a connection is alive (0 to disable).
--enable-grpc-gateway
Enable GRPC gateway.
--grpc-keepalive-timeout '20s'
Additional duration of wait before closing a non-responsive connection (0 to disable).
Expand Down Expand Up @@ -229,6 +231,8 @@ Experimental feature:
Unsafe feature:
--force-new-cluster 'false'
Force to create a new one-member cluster.
--unsafe-no-fsync 'false'
Disables fsync, unsafe, will cause data loss.
CAUTIOUS with unsafe flag! It may break the guarantees given by the consensus protocol!
Expand Down

0 comments on commit c7eab9d

Please sign in to comment.