etcd_config_test.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. package rpcpb
  15. import (
  16. "reflect"
  17. "testing"
  18. )
  19. func TestEtcdFlags(t *testing.T) {
  20. cfg := &Etcd{
  21. Name: "s1",
  22. DataDir: "/tmp/etcd-agent-data-1/etcd.data",
  23. WALDir: "/tmp/etcd-agent-data-1/etcd.data/member/wal",
  24. HeartbeatIntervalMs: 100,
  25. ElectionTimeoutMs: 1000,
  26. ListenClientURLs: []string{"https://127.0.0.1:1379"},
  27. AdvertiseClientURLs: []string{"https://127.0.0.1:13790"},
  28. ClientAutoTLS: true,
  29. ClientCertAuth: false,
  30. ClientCertFile: "",
  31. ClientKeyFile: "",
  32. ClientTrustedCAFile: "",
  33. ListenPeerURLs: []string{"https://127.0.0.1:1380"},
  34. AdvertisePeerURLs: []string{"https://127.0.0.1:13800"},
  35. PeerAutoTLS: true,
  36. PeerClientCertAuth: false,
  37. PeerCertFile: "",
  38. PeerKeyFile: "",
  39. PeerTrustedCAFile: "",
  40. InitialCluster: "s1=https://127.0.0.1:13800,s2=https://127.0.0.1:23800,s3=https://127.0.0.1:33800",
  41. InitialClusterState: "new",
  42. InitialClusterToken: "tkn",
  43. SnapshotCount: 10000,
  44. QuotaBackendBytes: 10740000000,
  45. PreVote: true,
  46. InitialCorruptCheck: true,
  47. }
  48. exp := []string{
  49. "--name=s1",
  50. "--data-dir=/tmp/etcd-agent-data-1/etcd.data",
  51. "--wal-dir=/tmp/etcd-agent-data-1/etcd.data/member/wal",
  52. "--heartbeat-interval=100",
  53. "--election-timeout=1000",
  54. "--listen-client-urls=https://127.0.0.1:1379",
  55. "--advertise-client-urls=https://127.0.0.1:13790",
  56. "--auto-tls=true",
  57. "--client-cert-auth=false",
  58. "--listen-peer-urls=https://127.0.0.1:1380",
  59. "--initial-advertise-peer-urls=https://127.0.0.1:13800",
  60. "--peer-auto-tls=true",
  61. "--peer-client-cert-auth=false",
  62. "--initial-cluster=s1=https://127.0.0.1:13800,s2=https://127.0.0.1:23800,s3=https://127.0.0.1:33800",
  63. "--initial-cluster-state=new",
  64. "--initial-cluster-token=tkn",
  65. "--snapshot-count=10000",
  66. "--quota-backend-bytes=10740000000",
  67. "--pre-vote=true",
  68. "--experimental-initial-corrupt-check=true",
  69. }
  70. fs := cfg.Flags()
  71. if !reflect.DeepEqual(exp, fs) {
  72. t.Fatalf("expected %q, got %q", exp, fs)
  73. }
  74. }