fleet/server/live_query/mock_live_query.go
Zachary Wasserman 0502412e15 Move live query operations from MySQL to Redis
This change optimizes live queries by pushing the computation of query
targets to the creation time of the query, and efficiently caching the
targets in Redis. This results in a huge performance improvement at both
steady-state, and when running live queries.

- Live queries are stored using a bitfield in Redis, and takes
advantage of bitfield operations to be extremely efficient.

- Only run Redis live query test when REDIS_TEST is set in environment

- Ensure that live queries are only sent to hosts when there is a client
listening for results. Addresses an existing issue in Fleet along with
appropriate cleanup for the refactored live query backend.
2020-07-21 14:05:46 -07:00

33 lines
717 B
Go

package live_query
import (
"github.com/kolide/fleet/server/kolide"
"github.com/stretchr/testify/mock"
)
type MockLiveQuery struct {
mock.Mock
kolide.LiveQueryStore
}
func (m *MockLiveQuery) RunQuery(name, sql string, hostIDs []uint) error {
args := m.Called(name, sql, hostIDs)
return args.Error(0)
}
func (m *MockLiveQuery) StopQuery(name string) error {
args := m.Called(name)
return args.Error(0)
}
func (m *MockLiveQuery) QueriesForHost(hostID uint) (map[string]string, error) {
args := m.Called(hostID)
return args.Get(0).(map[string]string), args.Error(1)
}
func (m *MockLiveQuery) QueryCompletedByHost(name string, hostID uint) error {
args := m.Called(name, hostID)
return args.Error(0)
}