Skip to content

Commit

Permalink
Add a unit tests and missing flags in etcd help.
Browse files Browse the repository at this point in the history
Signed-off-by: ishan16696 <ishan.tyagi@sap.com>
  • Loading branch information
ishan16696 committed Jan 5, 2024
1 parent af1fb6f commit 0ac8e50
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
17 changes: 17 additions & 0 deletions server/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 @@ -23,6 +24,7 @@ import (
"strings"
"testing"

"go.etcd.io/etcd/pkg/v3/flags"
"go.etcd.io/etcd/server/v3/embed"
"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
21 changes: 20 additions & 1 deletion server/etcdmain/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

cconfig "go.etcd.io/etcd/server/v3/config"
"go.etcd.io/etcd/server/v3/embed"
"go.etcd.io/etcd/server/v3/etcdserver/api/rafthttp"
"golang.org/x/crypto/bcrypt"
)

Expand Down Expand Up @@ -84,6 +85,8 @@ Member:
Maximum client request size in bytes the server will accept.
--max-concurrent-streams 'math.MaxUint32'
Maximum concurrent streams that each client can open at a time.
--enable-grpc-gateway
Enable GRPC gateway.
--grpc-keepalive-min-time '5s'
Minimum duration interval that a client should wait before pinging server.
--grpc-keepalive-interval '2h'
Expand All @@ -93,7 +96,11 @@ Member:
--socket-reuse-port 'false'
Enable to set socket option SO_REUSEPORT on listeners allowing rebinding of a port already in use.
--socket-reuse-address 'false'
Enable to set socket option SO_REUSEADDR on listeners allowing binding to an address in TIME_WAIT state.
Enable to set socket option SO_REUSEADDR on listeners allowing binding to an address in TIME_WAIT state.
--raft-read-timeout '` + rafthttp.DefaultConnReadTimeout.String() + `'
Read timeout set on each rafthttp connection
--raft-write-timeout '` + rafthttp.DefaultConnWriteTimeout.String() + `'
Write timeout set on each rafthttp connection
Clustering:
--initial-advertise-peer-urls 'http://localhost:2380'
Expand Down Expand Up @@ -145,6 +152,10 @@ Security:
Path to the client server TLS key file.
--client-cert-auth 'false'
Enable client cert authentication.
--client-cert-file ''
Path to an explicit peer client TLS cert file otherwise cert file will be used when client auth is required.
--client-key-file ''
Path to an explicit peer client TLS key file otherwise key file will be used when client auth is required.
--client-crl-file ''
Path to the client certificate revocation list file.
--client-cert-allowed-hostname ''
Expand All @@ -167,6 +178,10 @@ Security:
Allowed TLS hostname for inter peer authentication.
--peer-auto-tls 'false'
Peer TLS using self-generated certificates if --peer-key-file and --peer-cert-file are not provided.
--peer-client-cert-file ''
Path to an explicit peer client TLS cert file otherwise peer cert file will be used when client auth is required.
--peer-client-key-file ''
Path to an explicit peer client TLS key file otherwise peer key file will be used when client auth is required.
--self-signed-cert-validity '1'
The validity period of the client and peer certificates that are automatically generated by etcd when you specify ClientAutoTLS and PeerAutoTLS, the unit is year, and the default is 1.
--peer-crl-file ''
Expand Down Expand Up @@ -257,6 +272,10 @@ Experimental feature:
Skip verification of SAN field in client certificate for peer connections.
--experimental-watch-progress-notify-interval '10m'
Duration of periodical watch progress notification.
--experimental-downgrade-check-time
Duration of time between two downgrade status checks.
--experimental-memory-mlock
Enable to enforce etcd pages (in particular bbolt) to stay in RAM.
--experimental-warning-apply-duration '100ms'
Warning is generated if requests take more than this duration.
--experimental-txn-mode-write-with-shared-buffer 'true'
Expand Down

0 comments on commit 0ac8e50

Please sign in to comment.