2017-03-30 15:31:28 +00:00
|
|
|
package datastore
|
|
|
|
|
|
|
|
import (
|
2017-04-18 17:39:50 +00:00
|
|
|
"strconv"
|
2017-03-30 15:31:28 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/WatchBeam/clock"
|
2021-06-26 04:46:51 +00:00
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/ptr"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/test"
|
2017-03-30 15:31:28 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
func testCountHostsInTargets(t *testing.T, ds fleet.Datastore) {
|
2017-03-30 15:31:28 +00:00
|
|
|
if ds.Name() == "inmem" {
|
|
|
|
t.Skip("inmem is being deprecated, test skipped")
|
|
|
|
}
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
user := &fleet.User{GlobalRole: ptr.String(fleet.RoleAdmin)}
|
|
|
|
filter := fleet.TeamFilter{User: user}
|
2021-05-25 04:34:08 +00:00
|
|
|
|
2017-03-30 15:31:28 +00:00
|
|
|
mockClock := clock.NewMockClock()
|
|
|
|
|
2017-04-18 17:39:50 +00:00
|
|
|
hostCount := 0
|
2021-06-06 22:07:29 +00:00
|
|
|
initHost := func(seenTime time.Time, distributedInterval uint, configTLSRefresh uint, teamID *uint) *fleet.Host {
|
2017-04-18 17:39:50 +00:00
|
|
|
hostCount += 1
|
2021-06-06 22:07:29 +00:00
|
|
|
h, err := ds.NewHost(&fleet.Host{
|
2017-04-18 17:39:50 +00:00
|
|
|
OsqueryHostID: strconv.Itoa(hostCount),
|
2021-06-24 00:32:19 +00:00
|
|
|
DetailUpdatedAt: mockClock.Now(),
|
|
|
|
LabelUpdatedAt: mockClock.Now(),
|
2017-04-18 17:39:50 +00:00
|
|
|
SeenTime: mockClock.Now(),
|
|
|
|
NodeKey: strconv.Itoa(hostCount),
|
|
|
|
DistributedInterval: distributedInterval,
|
|
|
|
ConfigTLSRefresh: configTLSRefresh,
|
2021-05-27 20:18:00 +00:00
|
|
|
TeamID: teamID,
|
2017-04-18 17:39:50 +00:00
|
|
|
})
|
|
|
|
require.Nil(t, err)
|
|
|
|
require.Nil(t, ds.MarkHostSeen(h, seenTime))
|
|
|
|
return h
|
|
|
|
}
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
team1, err := ds.NewTeam(&fleet.Team{Name: "team1"})
|
2021-05-27 20:18:00 +00:00
|
|
|
require.NoError(t, err)
|
2021-06-06 22:07:29 +00:00
|
|
|
team2, err := ds.NewTeam(&fleet.Team{Name: "team2"})
|
2021-05-27 20:18:00 +00:00
|
|
|
require.NoError(t, err)
|
2021-06-06 22:07:29 +00:00
|
|
|
team3, err := ds.NewTeam(&fleet.Team{Name: "team3"})
|
2021-05-27 20:18:00 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
h1 := initHost(mockClock.Now().Add(-1*time.Second), 10, 60, &team1.ID)
|
|
|
|
h2 := initHost(mockClock.Now().Add(-1*time.Hour), 30, 7200, &team2.ID)
|
|
|
|
h3 := initHost(mockClock.Now().Add(-5*time.Second), 20, 20, &team2.ID)
|
|
|
|
h4 := initHost(mockClock.Now().Add(-47*time.Second), 10, 10, &team2.ID)
|
|
|
|
h5 := initHost(mockClock.Now(), 5, 5, nil)
|
2017-03-30 15:31:28 +00:00
|
|
|
const thirtyDaysAndAMinuteAgo = -1 * (30*24*60 + 1)
|
2021-05-27 20:18:00 +00:00
|
|
|
h6 := initHost(mockClock.Now().Add(thirtyDaysAndAMinuteAgo*time.Minute), 3600, 3600, nil)
|
2017-03-30 15:31:28 +00:00
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
l1 := fleet.LabelSpec{
|
2018-01-10 19:38:20 +00:00
|
|
|
ID: 1,
|
2017-03-30 15:31:28 +00:00
|
|
|
Name: "label foo",
|
|
|
|
Query: "query foo",
|
2018-01-10 19:38:20 +00:00
|
|
|
}
|
2021-06-06 22:07:29 +00:00
|
|
|
l2 := fleet.LabelSpec{
|
2018-01-10 19:38:20 +00:00
|
|
|
ID: 2,
|
2017-03-30 15:31:28 +00:00
|
|
|
Name: "label bar",
|
2018-01-10 19:38:20 +00:00
|
|
|
Query: "query bar",
|
|
|
|
}
|
2021-06-06 22:07:29 +00:00
|
|
|
require.NoError(t, ds.ApplyLabelSpecs([]*fleet.LabelSpec{&l1, &l2}))
|
2017-03-30 15:31:28 +00:00
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
for _, h := range []*fleet.Host{h1, h2, h3, h6} {
|
2017-03-30 15:31:28 +00:00
|
|
|
err = ds.RecordLabelQueryExecutions(h, map[uint]bool{l1.ID: true}, mockClock.Now())
|
|
|
|
assert.Nil(t, err)
|
|
|
|
}
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
for _, h := range []*fleet.Host{h3, h4, h5} {
|
2017-03-30 15:31:28 +00:00
|
|
|
err = ds.RecordLabelQueryExecutions(h, map[uint]bool{l2.ID: true}, mockClock.Now())
|
|
|
|
assert.Nil(t, err)
|
|
|
|
}
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics, err := ds.CountHostsInTargets(filter, fleet.HostTargets{LabelIDs: []uint{l1.ID, l2.ID}}, mockClock.Now())
|
2021-05-27 20:18:00 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, uint(6), metrics.TotalHosts)
|
|
|
|
assert.Equal(t, uint(2), metrics.OfflineHosts)
|
|
|
|
assert.Equal(t, uint(3), metrics.OnlineHosts)
|
|
|
|
assert.Equal(t, uint(1), metrics.MissingInActionHosts)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics, err = ds.CountHostsInTargets(filter, fleet.HostTargets{HostIDs: []uint{h1.ID, h2.ID}, LabelIDs: []uint{l1.ID, l2.ID}}, mockClock.Now())
|
2017-03-30 15:31:28 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, uint(6), metrics.TotalHosts)
|
2017-04-18 17:39:50 +00:00
|
|
|
assert.Equal(t, uint(2), metrics.OfflineHosts)
|
|
|
|
assert.Equal(t, uint(3), metrics.OnlineHosts)
|
2017-03-30 15:31:28 +00:00
|
|
|
assert.Equal(t, uint(1), metrics.MissingInActionHosts)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics, err = ds.CountHostsInTargets(filter, fleet.HostTargets{HostIDs: []uint{h1.ID, h2.ID}, LabelIDs: []uint{l1.ID, l2.ID}, TeamIDs: []uint{team1.ID, team2.ID}}, mockClock.Now())
|
2017-03-30 15:31:28 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, uint(6), metrics.TotalHosts)
|
2017-04-18 17:39:50 +00:00
|
|
|
assert.Equal(t, uint(2), metrics.OfflineHosts)
|
|
|
|
assert.Equal(t, uint(3), metrics.OnlineHosts)
|
2017-03-30 15:31:28 +00:00
|
|
|
assert.Equal(t, uint(1), metrics.MissingInActionHosts)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics, err = ds.CountHostsInTargets(filter, fleet.HostTargets{HostIDs: []uint{h1.ID, h2.ID}}, mockClock.Now())
|
2017-03-30 15:31:28 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, uint(2), metrics.TotalHosts)
|
|
|
|
assert.Equal(t, uint(1), metrics.OnlineHosts)
|
|
|
|
assert.Equal(t, uint(1), metrics.OfflineHosts)
|
|
|
|
assert.Equal(t, uint(0), metrics.MissingInActionHosts)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics, err = ds.CountHostsInTargets(filter, fleet.HostTargets{HostIDs: []uint{h1.ID, h2.ID}, TeamIDs: []uint{team2.ID}}, mockClock.Now())
|
2021-05-27 20:18:00 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, uint(4), metrics.TotalHosts)
|
|
|
|
assert.Equal(t, uint(2), metrics.OnlineHosts)
|
|
|
|
assert.Equal(t, uint(2), metrics.OfflineHosts)
|
|
|
|
assert.Equal(t, uint(0), metrics.MissingInActionHosts)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics, err = ds.CountHostsInTargets(filter, fleet.HostTargets{HostIDs: []uint{h1.ID}, LabelIDs: []uint{l2.ID}}, mockClock.Now())
|
2017-03-30 15:31:28 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, uint(4), metrics.TotalHosts)
|
2017-04-18 17:39:50 +00:00
|
|
|
assert.Equal(t, uint(3), metrics.OnlineHosts)
|
|
|
|
assert.Equal(t, uint(1), metrics.OfflineHosts)
|
|
|
|
assert.Equal(t, uint(0), metrics.MissingInActionHosts)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics, err = ds.CountHostsInTargets(filter, fleet.HostTargets{}, mockClock.Now())
|
2017-04-18 17:39:50 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, uint(0), metrics.TotalHosts)
|
|
|
|
assert.Equal(t, uint(0), metrics.OnlineHosts)
|
2017-03-30 15:31:28 +00:00
|
|
|
assert.Equal(t, uint(0), metrics.OfflineHosts)
|
|
|
|
assert.Equal(t, uint(0), metrics.MissingInActionHosts)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics, err = ds.CountHostsInTargets(filter, fleet.HostTargets{HostIDs: []uint{}, LabelIDs: []uint{}, TeamIDs: []uint{}}, mockClock.Now())
|
2017-03-30 15:31:28 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, uint(0), metrics.TotalHosts)
|
|
|
|
assert.Equal(t, uint(0), metrics.OnlineHosts)
|
|
|
|
assert.Equal(t, uint(0), metrics.OfflineHosts)
|
|
|
|
assert.Equal(t, uint(0), metrics.MissingInActionHosts)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics, err = ds.CountHostsInTargets(filter, fleet.HostTargets{TeamIDs: []uint{team1.ID, team3.ID}}, mockClock.Now())
|
2021-05-27 20:18:00 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, uint(1), metrics.TotalHosts)
|
|
|
|
assert.Equal(t, uint(1), metrics.OnlineHosts)
|
|
|
|
assert.Equal(t, uint(0), metrics.OfflineHosts)
|
|
|
|
assert.Equal(t, uint(0), metrics.MissingInActionHosts)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics, err = ds.CountHostsInTargets(filter, fleet.HostTargets{TeamIDs: []uint{team2.ID}}, mockClock.Now())
|
2021-05-27 20:18:00 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, uint(3), metrics.TotalHosts)
|
|
|
|
assert.Equal(t, uint(1), metrics.OnlineHosts)
|
|
|
|
assert.Equal(t, uint(2), metrics.OfflineHosts)
|
|
|
|
assert.Equal(t, uint(0), metrics.MissingInActionHosts)
|
|
|
|
|
2017-03-30 15:31:28 +00:00
|
|
|
// Advance clock so all hosts are offline
|
2017-04-18 17:39:50 +00:00
|
|
|
mockClock.AddTime(2 * time.Minute)
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics, err = ds.CountHostsInTargets(filter, fleet.HostTargets{LabelIDs: []uint{l1.ID, l2.ID}}, mockClock.Now())
|
2017-03-30 15:31:28 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, uint(6), metrics.TotalHosts)
|
|
|
|
assert.Equal(t, uint(0), metrics.OnlineHosts)
|
|
|
|
assert.Equal(t, uint(5), metrics.OfflineHosts)
|
|
|
|
assert.Equal(t, uint(1), metrics.MissingInActionHosts)
|
|
|
|
|
|
|
|
}
|
2017-04-18 17:39:50 +00:00
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
func testHostStatus(t *testing.T, ds fleet.Datastore) {
|
2020-04-07 01:10:20 +00:00
|
|
|
test.AddAllHostsLabel(t, ds)
|
|
|
|
|
2017-04-18 17:39:50 +00:00
|
|
|
if ds.Name() == "inmem" {
|
|
|
|
t.Skip("inmem is being deprecated, test skipped")
|
|
|
|
}
|
|
|
|
|
|
|
|
mockClock := clock.NewMockClock()
|
|
|
|
|
2021-05-31 16:02:05 +00:00
|
|
|
h, err := ds.EnrollHost("1", "key1", nil, 0)
|
2017-04-18 17:39:50 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
user := &fleet.User{GlobalRole: ptr.String(fleet.RoleAdmin)}
|
|
|
|
filter := fleet.TeamFilter{User: user}
|
2021-05-25 04:34:08 +00:00
|
|
|
|
2017-04-18 17:39:50 +00:00
|
|
|
// Make host no longer appear new
|
|
|
|
mockClock.AddTime(36 * time.Hour)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
expectOnline := fleet.TargetMetrics{TotalHosts: 1, OnlineHosts: 1}
|
|
|
|
expectOffline := fleet.TargetMetrics{TotalHosts: 1, OfflineHosts: 1}
|
|
|
|
expectMIA := fleet.TargetMetrics{TotalHosts: 1, MissingInActionHosts: 1}
|
2017-04-18 17:39:50 +00:00
|
|
|
|
|
|
|
var testCases = []struct {
|
|
|
|
seenTime time.Time
|
|
|
|
distributedInterval uint
|
|
|
|
configTLSRefresh uint
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics fleet.TargetMetrics
|
2017-04-18 17:39:50 +00:00
|
|
|
}{
|
|
|
|
{mockClock.Now().Add(-30 * time.Second), 10, 3600, expectOnline},
|
|
|
|
{mockClock.Now().Add(-45 * time.Second), 10, 3600, expectOffline},
|
|
|
|
{mockClock.Now().Add(-30 * time.Second), 3600, 10, expectOnline},
|
|
|
|
{mockClock.Now().Add(-45 * time.Second), 3600, 10, expectOffline},
|
|
|
|
|
|
|
|
{mockClock.Now().Add(-70 * time.Second), 60, 60, expectOnline},
|
|
|
|
{mockClock.Now().Add(-91 * time.Second), 60, 60, expectOffline},
|
|
|
|
|
|
|
|
{mockClock.Now().Add(-1 * time.Second), 10, 10, expectOnline},
|
|
|
|
{mockClock.Now().Add(-1 * time.Minute), 10, 10, expectOffline},
|
|
|
|
{mockClock.Now().Add(-31 * 24 * time.Hour), 10, 10, expectMIA},
|
|
|
|
|
|
|
|
// Ensure behavior is reasonable if we don't have the values
|
|
|
|
{mockClock.Now().Add(-1 * time.Second), 0, 0, expectOnline},
|
|
|
|
{mockClock.Now().Add(-1 * time.Minute), 0, 0, expectOffline},
|
|
|
|
{mockClock.Now().Add(-31 * 24 * time.Hour), 0, 0, expectMIA},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tt := range testCases {
|
|
|
|
t.Run("", func(t *testing.T) {
|
|
|
|
// Save interval values
|
|
|
|
h.DistributedInterval = tt.distributedInterval
|
|
|
|
h.ConfigTLSRefresh = tt.configTLSRefresh
|
|
|
|
require.Nil(t, ds.SaveHost(h))
|
|
|
|
|
|
|
|
// Mark seen
|
|
|
|
require.Nil(t, ds.MarkHostSeen(h, tt.seenTime))
|
|
|
|
|
|
|
|
// Verify status
|
2021-06-06 22:07:29 +00:00
|
|
|
metrics, err := ds.CountHostsInTargets(filter, fleet.HostTargets{HostIDs: []uint{h.ID}}, mockClock.Now())
|
2017-04-18 17:39:50 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, tt.metrics, metrics)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-03-23 01:33:04 +00:00
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
func testHostIDsInTargets(t *testing.T, ds fleet.Datastore) {
|
2020-03-23 01:33:04 +00:00
|
|
|
if ds.Name() == "inmem" {
|
|
|
|
t.Skip("inmem is being deprecated, test skipped")
|
|
|
|
}
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
user := &fleet.User{GlobalRole: ptr.String(fleet.RoleAdmin)}
|
|
|
|
filter := fleet.TeamFilter{User: user}
|
2021-05-25 04:34:08 +00:00
|
|
|
|
2020-03-23 01:33:04 +00:00
|
|
|
hostCount := 0
|
2021-06-06 22:07:29 +00:00
|
|
|
initHost := func() *fleet.Host {
|
2020-03-23 01:33:04 +00:00
|
|
|
hostCount += 1
|
2021-06-06 22:07:29 +00:00
|
|
|
h, err := ds.NewHost(&fleet.Host{
|
2021-06-24 00:32:19 +00:00
|
|
|
OsqueryHostID: strconv.Itoa(hostCount),
|
|
|
|
NodeKey: strconv.Itoa(hostCount),
|
|
|
|
DetailUpdatedAt: time.Now(),
|
|
|
|
LabelUpdatedAt: time.Now(),
|
|
|
|
SeenTime: time.Now(),
|
2020-03-23 01:33:04 +00:00
|
|
|
})
|
|
|
|
require.Nil(t, err)
|
|
|
|
return h
|
|
|
|
}
|
|
|
|
|
|
|
|
h1 := initHost()
|
|
|
|
h2 := initHost()
|
|
|
|
h3 := initHost()
|
|
|
|
h4 := initHost()
|
|
|
|
h5 := initHost()
|
|
|
|
h6 := initHost()
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
l1 := fleet.LabelSpec{
|
2020-03-23 01:33:04 +00:00
|
|
|
ID: 1,
|
|
|
|
Name: "label foo",
|
|
|
|
Query: "query foo",
|
|
|
|
}
|
2021-06-06 22:07:29 +00:00
|
|
|
l2 := fleet.LabelSpec{
|
2020-03-23 01:33:04 +00:00
|
|
|
ID: 2,
|
|
|
|
Name: "label bar",
|
|
|
|
Query: "query bar",
|
|
|
|
}
|
2021-06-06 22:07:29 +00:00
|
|
|
err := ds.ApplyLabelSpecs([]*fleet.LabelSpec{&l1, &l2})
|
2020-03-23 01:33:04 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
for _, h := range []*fleet.Host{h1, h2, h3, h6} {
|
2020-03-23 01:33:04 +00:00
|
|
|
err = ds.RecordLabelQueryExecutions(h, map[uint]bool{l1.ID: true}, time.Now())
|
|
|
|
assert.Nil(t, err)
|
|
|
|
}
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
for _, h := range []*fleet.Host{h3, h4, h5} {
|
2020-03-23 01:33:04 +00:00
|
|
|
err = ds.RecordLabelQueryExecutions(h, map[uint]bool{l2.ID: true}, time.Now())
|
|
|
|
assert.Nil(t, err)
|
|
|
|
}
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
ids, err := ds.HostIDsInTargets(filter, fleet.HostTargets{LabelIDs: []uint{l1.ID, l2.ID}})
|
2020-03-23 01:33:04 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, []uint{1, 2, 3, 4, 5, 6}, ids)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
ids, err = ds.HostIDsInTargets(filter, fleet.HostTargets{HostIDs: []uint{h1.ID}})
|
2020-03-23 01:33:04 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, []uint{1}, ids)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
ids, err = ds.HostIDsInTargets(filter, fleet.HostTargets{HostIDs: []uint{h1.ID}, LabelIDs: []uint{l1.ID}})
|
2020-03-23 01:33:04 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, []uint{1, 2, 3, 6}, ids)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
ids, err = ds.HostIDsInTargets(filter, fleet.HostTargets{HostIDs: []uint{4}, LabelIDs: []uint{l1.ID}})
|
2020-03-23 01:33:04 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, []uint{1, 2, 3, 4, 6}, ids)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
ids, err = ds.HostIDsInTargets(filter, fleet.HostTargets{HostIDs: []uint{4}, LabelIDs: []uint{l2.ID}})
|
2020-03-23 01:33:04 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, []uint{3, 4, 5}, ids)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
ids, err = ds.HostIDsInTargets(filter, fleet.HostTargets{HostIDs: []uint{}, LabelIDs: []uint{l2.ID}})
|
2020-03-23 01:33:04 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, []uint{3, 4, 5}, ids)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
ids, err = ds.HostIDsInTargets(filter, fleet.HostTargets{HostIDs: []uint{1, 6}, LabelIDs: []uint{l2.ID}})
|
2020-03-23 01:33:04 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, []uint{1, 3, 4, 5, 6}, ids)
|
|
|
|
}
|