Example #1
0
func TestLBUtilsNoSuchBackend(t *testing.T) {
	kvs := config.BuildKVStoreTestConfig(t)
	assert.NotNil(t, kvs)
	sc, err := config.ReadServiceConfig("listener", kvs)
	assert.Nil(t, err)
	assert.NotNil(t, sc)

	config.RecordActiveConfig(sc)

	lb, err := NewBackendLoadBalancer("no-such-backed")
	assert.Nil(t, lb)
	assert.NotNil(t, err)
	assert.Equal(t, ErrBackendNotFound, err)
}
Example #2
0
func TestLBUtilsBuildFromConfig(t *testing.T) {
	kvs := config.BuildKVStoreTestConfig(t)
	assert.NotNil(t, kvs)
	sc, err := config.ReadServiceConfig("listener", kvs)
	assert.Nil(t, err)
	assert.NotNil(t, sc)

	config.RecordActiveConfig(sc)

	lb, err := NewBackendLoadBalancer("hello-backend")
	assert.Nil(t, err)
	assert.NotNil(t, lb)

	assert.Equal(t, "hello-backend", lb.BackendConfig.Name)
	assert.Equal(t, "", lb.BackendConfig.CACertPath)
	assert.Equal(t, 2, len(lb.BackendConfig.ServerNames))

	h, _ := lb.LoadBalancer.GetEndpoints()
	if assert.True(t, len(h) == 2) {
		assert.Equal(t, "localhost:3000", h[0])
		assert.Equal(t, "localhost:3100", h[1])
	}
}
Example #3
0
func initKVStore(t *testing.T) kvstore.KVStore {
	return config.BuildKVStoreTestConfig(t)
}