@@ -54,84 +54,96 @@ func TestCmd(t *testing.T) {
5454 }()
5555
5656 for _ , test := range []struct {
57- args []string
58- expectedConf coordinator.Config
59- isErr bool
57+ args []string
58+ expectedConf coordinator.Config
59+ expectedClusterConf model.ClusterConfig
60+ isErr bool
6061 }{
6162 {[]string {}, coordinator.Config {
62- InternalServiceAddr : "localhost:6649" ,
63- MetricsServiceAddr : "localhost:8080" ,
64- MetadataProviderImpl : coordinator .File ,
65- ClusterConfig : model.ClusterConfig {
66- Namespaces : []model.NamespaceConfig {{
67- Name : common .DefaultNamespace ,
68- ReplicationFactor : 1 ,
69- InitialShardCount : 2 ,
70- }},
71- Servers : []model.ServerAddress {{
72- Public : "public:1234" ,
73- Internal : "internal:5678" ,
74- }}}}, false },
63+ InternalServiceAddr : "localhost:6649" ,
64+ MetricsServiceAddr : "localhost:8080" ,
65+ MetadataProviderImpl : coordinator .File ,
66+ ClusterConfigRefreshTime : 0 ,
67+ }, model.ClusterConfig {
68+ Namespaces : []model.NamespaceConfig {{
69+ Name : common .DefaultNamespace ,
70+ ReplicationFactor : 1 ,
71+ InitialShardCount : 2 ,
72+ }},
73+ Servers : []model.ServerAddress {{
74+ Public : "public:1234" ,
75+ Internal : "internal:5678" ,
76+ },
77+ },
78+ }, false },
7579 {[]string {"-i=localhost:1234" }, coordinator.Config {
7680 InternalServiceAddr : "localhost:1234" ,
7781 MetricsServiceAddr : "localhost:8080" ,
7882 MetadataProviderImpl : coordinator .File ,
79- ClusterConfig : model.ClusterConfig {
80- Namespaces : []model.NamespaceConfig {{
81- Name : common .DefaultNamespace ,
82- ReplicationFactor : 1 ,
83- InitialShardCount : 2 ,
84- }},
85- Servers : []model.ServerAddress {{
86- Public : "public:1234" ,
87- Internal : "internal:5678" ,
88- }}}}, false },
83+ }, model.ClusterConfig {
84+ Namespaces : []model.NamespaceConfig {{
85+ Name : common .DefaultNamespace ,
86+ ReplicationFactor : 1 ,
87+ InitialShardCount : 2 ,
88+ }},
89+ Servers : []model.ServerAddress {{
90+ Public : "public:1234" ,
91+ Internal : "internal:5678" ,
92+ },
93+ },
94+ }, false },
8995 {[]string {"-i=0.0.0.0:1234" }, coordinator.Config {
9096 InternalServiceAddr : "0.0.0.0:1234" ,
9197 MetricsServiceAddr : "localhost:8080" ,
9298 MetadataProviderImpl : coordinator .File ,
93- ClusterConfig : model.ClusterConfig {
94- Namespaces : []model.NamespaceConfig {{
95- Name : common .DefaultNamespace ,
96- ReplicationFactor : 1 ,
97- InitialShardCount : 2 ,
98- }},
99- Servers : []model.ServerAddress {{
100- Public : "public:1234" ,
101- Internal : "internal:5678" ,
102- }}}}, false },
99+ }, model.ClusterConfig {
100+ Namespaces : []model.NamespaceConfig {{
101+ Name : common .DefaultNamespace ,
102+ ReplicationFactor : 1 ,
103+ InitialShardCount : 2 ,
104+ }},
105+ Servers : []model.ServerAddress {{
106+ Public : "public:1234" ,
107+ Internal : "internal:5678" ,
108+ },
109+ },
110+ }, false },
103111 {[]string {"-m=localhost:1234" }, coordinator.Config {
104112 InternalServiceAddr : "localhost:6649" ,
105113 MetricsServiceAddr : "localhost:1234" ,
106114 MetadataProviderImpl : coordinator .File ,
107- ClusterConfig : model.ClusterConfig {
108- Namespaces : []model.NamespaceConfig {{
109- Name : common .DefaultNamespace ,
110- ReplicationFactor : 1 ,
111- InitialShardCount : 2 ,
112- }},
113- Servers : []model.ServerAddress {{
114- Public : "public:1234" ,
115- Internal : "internal:5678" ,
116- }}}}, false },
115+ }, model.ClusterConfig {
116+ Namespaces : []model.NamespaceConfig {{
117+ Name : common .DefaultNamespace ,
118+ ReplicationFactor : 1 ,
119+ InitialShardCount : 2 ,
120+ }},
121+ Servers : []model.ServerAddress {{
122+ Public : "public:1234" ,
123+ Internal : "internal:5678" ,
124+ },
125+ },
126+ }, false },
117127 {[]string {"-f=" + name }, coordinator.Config {
118128 InternalServiceAddr : "localhost:6649" ,
119129 MetricsServiceAddr : "localhost:8080" ,
120130 MetadataProviderImpl : coordinator .File ,
121- ClusterConfig : model.ClusterConfig {
122- Namespaces : []model.NamespaceConfig {{
123- Name : common .DefaultNamespace ,
124- ReplicationFactor : 1 ,
125- InitialShardCount : 2 ,
126- }},
127- Servers : []model.ServerAddress {{
128- Public : "public:1234" ,
129- Internal : "internal:5678" ,
130- }}}}, false },
131+ }, model.ClusterConfig {
132+ Namespaces : []model.NamespaceConfig {{
133+ Name : common .DefaultNamespace ,
134+ ReplicationFactor : 1 ,
135+ InitialShardCount : 2 ,
136+ }},
137+ Servers : []model.ServerAddress {{
138+ Public : "public:1234" ,
139+ Internal : "internal:5678" ,
140+ },
141+ },
142+ }, false },
131143 {[]string {"-f=invalid.yaml" }, coordinator.Config {
132144 InternalServiceAddr : "localhost:6649" ,
133145 MetricsServiceAddr : "localhost:8080" ,
134- ClusterConfig : model.ClusterConfig {} }, true },
146+ }, model.ClusterConfig {}, true },
135147 } {
136148 t .Run (strings .Join (test .args , "_" ), func (t * testing.T ) {
137149 conf = coordinator .NewConfig ()
@@ -140,6 +152,11 @@ func TestCmd(t *testing.T) {
140152 Cmd .SetArgs (test .args )
141153 Cmd .Run = func (cmd * cobra.Command , args []string ) {
142154 assert .Equal (t , test .expectedConf , conf )
155+
156+ conf .ClusterConfigProvider = loadClusterConfig
157+ clusterConf , err := conf .ClusterConfigProvider ()
158+ assert .NoError (t , err )
159+ assert .Equal (t , test .expectedClusterConf , clusterConf )
143160 }
144161 err = Cmd .Execute ()
145162 assert .Equal (t , test .isErr , err != nil )
0 commit comments