Esempio n. 1
0
func setup(hostIP string) (*Listener, store.Store, *mockInspector) {
	st := inmem.NewInMemStore()
	dc := newMockInspector()
	return NewListener(Config{
		Store:     st,
		HostIP:    hostIP,
		Inspector: dc,
	}), st, dc
}
Esempio n. 2
0
func TestList(t *testing.T) {
	st := inmem.NewInMemStore()
	err := st.AddService("foo", data.Service{})
	require.NoError(t, err)

	opts := &listOpts{}
	bufout, buferr := opts.tapOutput()
	err = runOptsWithStore(opts, st, []string{})
	require.NoError(t, err)
	require.Equal(t, "foo\n", bufout.String())
	require.Equal(t, "", buferr.String())
}
Esempio n. 3
0
func TestListServices(t *testing.T) {
	st := inmem.NewInMemStore()
	st.AddService("svc", testService)
	st.AddInstance("svc", "inst", testInstance)

	resp := doRequest(t, st, "/api/services")
	require.Equal(t, 200, resp.Code)

	var deets []*store.ServiceInfo
	require.Nil(t, json.Unmarshal(resp.Body.Bytes(), &deets))
	services := allServices(t, st)
	require.Equal(t, services, deets)
}
Esempio n. 4
0
func newBalancerAgent(t *testing.T) *BalancerAgent {
	dir, err := ioutil.TempDir("", "balagent_test")
	require.Nil(t, err)

	return &BalancerAgent{
		errorSink: daemon.NewErrorSink(),
		store:     inmem.NewInMemStore(),
		filename:  path.Join(dir, "output"),

		generated:        make(chan struct{}),
		updaterStopped:   make(chan struct{}),
		generatorStopped: make(chan struct{}),
	}
}
Esempio n. 5
0
func runOpts(opts commandOpts, args []string) (store.Store, error) {
	st := inmem.NewInMemStore()
	return st, runOptsWithStore(opts, st, args)
}