Skip to content

Commit fc96ab2

Browse files
committed
Add to existing integration test
1 parent 5684309 commit fc96ab2

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

packages/go/analysis/agt_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"testing"
2626

2727
"github.com/gofrs/uuid"
28+
"github.com/prometheus/client_golang/prometheus"
29+
"github.com/prometheus/client_golang/prometheus/testutil"
2830
"github.com/specterops/bloodhound/cmd/api/src/database/types/null"
2931
"github.com/specterops/bloodhound/cmd/api/src/model"
3032
"github.com/specterops/bloodhound/cmd/api/src/model/appcfg"
@@ -311,6 +313,8 @@ func TestTagAssetGroupNodesForTag(t *testing.T) {
311313
)
312314

313315
t.Run("removes the tag kind from every previously tagged node when no selector references them", func(t *testing.T) {
316+
pzNodeTagCounterVec.Reset()
317+
314318
tag, err := bhDB.CreateAssetGroupTag(testCtx, model.AssetGroupTagTypeLabel, testActor, "regression label all", "", null.Int32{}, null.Bool{}, null.String{})
315319
require.NoError(t, err)
316320

@@ -353,9 +357,13 @@ func TestTagAssetGroupNodesForTag(t *testing.T) {
353357
_, present := nodesToUpdate[nodeId.Uint64()]
354358
assert.Truef(t, present, "expected node %d to be queued for kind removal", nodeId)
355359
}
360+
361+
assert.Equal(t, 0.0, testutil.ToFloat64(pzNodeTagCounterVec.With(prometheus.Labels{"action": "tag_added", "tag": tag.Name})))
362+
assert.Equal(t, float64(nodeCount), testutil.ToFloat64(pzNodeTagCounterVec.With(prometheus.Labels{"action": "tag_removed", "tag": tag.Name})))
356363
})
357364

358365
t.Run("preserves the tag on selected nodes and removes it from no longer selected nodes", func(t *testing.T) {
366+
pzNodeTagCounterVec.Reset()
359367
tag, err := bhDB.CreateAssetGroupTag(testCtx, model.AssetGroupTagTypeLabel, testActor, "regression label mixed", "", null.Int32{}, null.Bool{}, null.String{})
360368
require.NoError(t, err)
361369

@@ -418,5 +426,8 @@ func TestTagAssetGroupNodesForTag(t *testing.T) {
418426
}
419427
_, selectedEnqueued := nodesToUpdate[selectedNodeId.Uint64()]
420428
assert.Falsef(t, selectedEnqueued, "expected selected node %d to NOT be queued for kind removal", selectedNodeId)
429+
430+
assert.Equal(t, 0.0, testutil.ToFloat64(pzNodeTagCounterVec.With(prometheus.Labels{"action": "tag_added", "tag": tag.Name})))
431+
assert.Equal(t, float64(len(expectedRemovals)), testutil.ToFloat64(pzNodeTagCounterVec.With(prometheus.Labels{"action": "tag_removed", "tag": tag.Name})))
421432
})
422433
}

0 commit comments

Comments
 (0)