(t *testing.T)
| 201 | } |
| 202 | |
| 203 | func TestRun_ConfigFileWithTokensProvided(t *testing.T) { |
| 204 | ctx, cancel := context.WithCancel(context.Background()) |
| 205 | |
| 206 | proxy1Addr, proxy2Addr := testAddr, generateTestAddr(testAddr, 1) |
| 207 | clusterPort, clusterAddr, proxy1BindAddr, httpBindAddr := generateTestAddrs(testAddr) |
| 208 | |
| 209 | cluster := proxycore.NewMockCluster(net.ParseIP(testStartAddr), clusterPort) |
| 210 | defer cluster.Shutdown() |
| 211 | |
| 212 | err := cluster.Add(ctx, 1) |
| 213 | require.NoError(t, err) |
| 214 | |
| 215 | configFileName, err := writeTempYaml(struct { |
| 216 | Bind string |
| 217 | Port int |
| 218 | RPCAddr string `yaml:"rpc-address"` |
| 219 | DataCenter string `yaml:"data-center"` |
| 220 | Tokens []string |
| 221 | ContactPoints []string `yaml:"contact-points"` |
| 222 | HealthCheck bool `yaml:"health-check"` |
| 223 | HttpBind string `yaml:"http-bind"` |
| 224 | Peers []PeerConfig |
| 225 | }{ |
| 226 | Bind: proxy1BindAddr, |
| 227 | RPCAddr: proxy1Addr, |
| 228 | DataCenter: "dc-1", |
| 229 | Tokens: []string{"0", "1"}, // Provide custom tokens |
| 230 | Port: clusterPort, |
| 231 | ContactPoints: []string{clusterAddr}, |
| 232 | HealthCheck: true, |
| 233 | HttpBind: httpBindAddr, |
| 234 | Peers: []PeerConfig{{ |
| 235 | RPCAddr: proxy2Addr, |
| 236 | Tokens: []string{"42", "613"}, // Same here |
| 237 | }}, |
| 238 | }) |
| 239 | |
| 240 | var wg sync.WaitGroup |
| 241 | wg.Add(1) |
| 242 | |
| 243 | go func() { |
| 244 | rc := Run(ctx, []string{ |
| 245 | "--config", configFileName, |
| 246 | }) |
| 247 | assert.Equal(t, 0, rc) |
| 248 | wg.Done() |
| 249 | }() |
| 250 | |
| 251 | defer func() { |
| 252 | cancel() |
| 253 | wg.Wait() |
| 254 | }() |
| 255 | |
| 256 | require.True(t, waitUntil(10*time.Second, func() bool { |
| 257 | return checkLiveness(httpBindAddr) |
| 258 | })) |
| 259 | |
| 260 | cl := connectTestClient(t, ctx, proxy1BindAddr) |
nothing calls this directly
no test coverage detected