@@ -10,6 +10,7 @@ import (
1010
1111 "github.com/newrelic/infra-integrations-sdk/data/attribute"
1212 "github.com/newrelic/infra-integrations-sdk/data/event"
13+ "github.com/newrelic/infra-integrations-sdk/data/metric"
1314 "github.com/newrelic/infra-integrations-sdk/persist"
1415 "github.com/stretchr/testify/assert"
1516 "github.com/stretchr/testify/require"
@@ -248,3 +249,29 @@ func TestEntity_SameAs(t *testing.T) {
248249 assert .True (t , e1 .SameAs (e2 ))
249250 assert .False (t , e1 .SameAs (e3 ))
250251}
252+
253+ func TestEntity_NewMetricSet (t * testing.T ) {
254+ i , err := New (integrationName , integrationVersion )
255+
256+ entity , err := i .Entity ("a-name" , "a-type" )
257+ assert .NoError (t , err )
258+
259+ metricSetChan := make (chan * metric.Set )
260+ go func (e * Entity ) {
261+ metricSetChan <- e .NewMetricSet ("F5BigIpPoolMemberSample" ,
262+ attribute.Attribute {Key : "displayName" , Value : "entityName" },
263+ attribute.Attribute {Key : "entityName" , Value : "entityName" },
264+ attribute.Attribute {Key : "poolName" , Value : "description" },
265+ attribute.Attribute {Key : "url" , Value : "url" },
266+ )
267+ }(entity )
268+
269+ // We retrieve the entity at the same time to check for race conditions
270+ go func (i * Integration ) {
271+ _ , err := i .Entity ("a-name" , "a-type" )
272+ assert .NoError (t , err )
273+ }(i )
274+
275+ metricSet := <- metricSetChan
276+ assert .NotEmpty (t , metricSet )
277+ }
0 commit comments