go.etcd.io/etcd@v3.3.27+incompatible/functional/rpcpb/etcd_config_test.go (about) 1 // Copyright 2018 The etcd Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package rpcpb 16 17 import ( 18 "reflect" 19 "testing" 20 ) 21 22 func TestEtcdFlags(t *testing.T) { 23 cfg := &Etcd{ 24 Name: "s1", 25 DataDir: "/tmp/etcd-agent-data-1/etcd.data", 26 WALDir: "/tmp/etcd-agent-data-1/etcd.data/member/wal", 27 28 HeartbeatIntervalMs: 100, 29 ElectionTimeoutMs: 1000, 30 31 ListenClientURLs: []string{"https://127.0.0.1:1379"}, 32 AdvertiseClientURLs: []string{"https://127.0.0.1:13790"}, 33 ClientAutoTLS: true, 34 ClientCertAuth: false, 35 ClientCertFile: "", 36 ClientKeyFile: "", 37 ClientTrustedCAFile: "", 38 39 ListenPeerURLs: []string{"https://127.0.0.1:1380"}, 40 AdvertisePeerURLs: []string{"https://127.0.0.1:13800"}, 41 PeerAutoTLS: true, 42 PeerClientCertAuth: false, 43 PeerCertFile: "", 44 PeerKeyFile: "", 45 PeerTrustedCAFile: "", 46 47 InitialCluster: "s1=https://127.0.0.1:13800,s2=https://127.0.0.1:23800,s3=https://127.0.0.1:33800", 48 InitialClusterState: "new", 49 InitialClusterToken: "tkn", 50 51 SnapshotCount: 10000, 52 QuotaBackendBytes: 10740000000, 53 54 PreVote: true, 55 InitialCorruptCheck: true, 56 } 57 58 exp := []string{ 59 "--name=s1", 60 "--data-dir=/tmp/etcd-agent-data-1/etcd.data", 61 "--wal-dir=/tmp/etcd-agent-data-1/etcd.data/member/wal", 62 "--heartbeat-interval=100", 63 "--election-timeout=1000", 64 "--listen-client-urls=https://127.0.0.1:1379", 65 "--advertise-client-urls=https://127.0.0.1:13790", 66 "--auto-tls=true", 67 "--client-cert-auth=false", 68 "--listen-peer-urls=https://127.0.0.1:1380", 69 "--initial-advertise-peer-urls=https://127.0.0.1:13800", 70 "--peer-auto-tls=true", 71 "--peer-client-cert-auth=false", 72 "--initial-cluster=s1=https://127.0.0.1:13800,s2=https://127.0.0.1:23800,s3=https://127.0.0.1:33800", 73 "--initial-cluster-state=new", 74 "--initial-cluster-token=tkn", 75 "--snapshot-count=10000", 76 "--quota-backend-bytes=10740000000", 77 "--pre-vote=true", 78 "--experimental-initial-corrupt-check=true", 79 } 80 fs := cfg.Flags() 81 if !reflect.DeepEqual(exp, fs) { 82 t.Fatalf("expected %q, got %q", exp, fs) 83 } 84 }