etcd_config_test.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 TestEtcd(t *testing.T) {
  20. e := &Etcd{
  21. Name: "s1",
  22. DataDir: "/tmp/etcd-functionl-1/etcd.data",
  23. WALDir: "/tmp/etcd-functionl-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. Logger: "zap",
  48. LogOutputs: []string{"/tmp/etcd-functional-1/etcd.log"},
  49. LogLevel: "info",
  50. }
  51. exps := []string{
  52. "--name=s1",
  53. "--data-dir=/tmp/etcd-functionl-1/etcd.data",
  54. "--wal-dir=/tmp/etcd-functionl-1/etcd.data/member/wal",
  55. "--heartbeat-interval=100",
  56. "--election-timeout=1000",
  57. "--listen-client-urls=https://127.0.0.1:1379",
  58. "--advertise-client-urls=https://127.0.0.1:13790",
  59. "--auto-tls=true",
  60. "--client-cert-auth=false",
  61. "--listen-peer-urls=https://127.0.0.1:1380",
  62. "--initial-advertise-peer-urls=https://127.0.0.1:13800",
  63. "--peer-auto-tls=true",
  64. "--peer-client-cert-auth=false",
  65. "--initial-cluster=s1=https://127.0.0.1:13800,s2=https://127.0.0.1:23800,s3=https://127.0.0.1:33800",
  66. "--initial-cluster-state=new",
  67. "--initial-cluster-token=tkn",
  68. "--snapshot-count=10000",
  69. "--quota-backend-bytes=10740000000",
  70. "--pre-vote=true",
  71. "--experimental-initial-corrupt-check=true",
  72. "--logger=zap",
  73. "--log-outputs=/tmp/etcd-functional-1/etcd.log",
  74. "--log-level=info",
  75. }
  76. fs := e.Flags()
  77. if !reflect.DeepEqual(exps, fs) {
  78. t.Fatalf("expected %q, got %q", exps, fs)
  79. }
  80. }