@@ -1234,36 +1234,32 @@ func TestSupervisorAgentDescriptionConfigApplies(t *testing.T) {
12341234 t .Fatal ("Failed to get agent description after 5 seconds" )
12351235 }
12361236
1237- expectedDescription := & protobufs.AgentDescription {
1238- IdentifyingAttributes : []* protobufs.KeyValue {
1239- stringKeyValue ("client.id" , "my-client-id" ),
1240- stringKeyValue ("service.name" , command ),
1241- stringKeyValue ("service.version" , version ),
1242- stringKeyValue ("service.instance.id" , uuid .UUID (ad .InstanceUid ).String ()),
1243- },
1244- NonIdentifyingAttributes : []* protobufs.KeyValue {
1245- stringKeyValue ("env" , "prod" ),
1246- stringKeyValue ("host.arch" , runtime .GOARCH ),
1247- stringKeyValue ("host.name" , host ),
1248- stringKeyValue ("os.type" , runtime .GOOS ),
1249- },
1237+ expectedIdentifyingAttributes := map [string ]string {
1238+ "client.id" : "my-client-id" ,
1239+ "service.instance.id" : uuid .UUID (ad .InstanceUid ).String (),
1240+ "service.name" : command ,
1241+ "service.version" : version ,
12501242 }
1251-
1252- require .Subset (t , ad .AgentDescription .IdentifyingAttributes , expectedDescription .IdentifyingAttributes )
1253- require .Subset (t , ad .AgentDescription .NonIdentifyingAttributes , expectedDescription .NonIdentifyingAttributes )
1243+ expectedNonIdentifyingAttributes := map [string ]string {
1244+ "env" : "prod" ,
1245+ "host.arch" : runtime .GOARCH ,
1246+ "host.name" : host ,
1247+ "os.type" : runtime .GOOS ,
1248+ }
1249+ actualIdentifyingAttributes := keyValuesToStringMap (ad .AgentDescription .IdentifyingAttributes )
1250+ require .Subset (t , actualIdentifyingAttributes , expectedIdentifyingAttributes )
1251+ actualNonIdentifyingAttributes := keyValuesToStringMap (ad .AgentDescription .NonIdentifyingAttributes )
1252+ require .Subset (t , actualNonIdentifyingAttributes , expectedNonIdentifyingAttributes )
12541253
12551254 time .Sleep (250 * time .Millisecond )
12561255}
12571256
1258- func stringKeyValue (key , val string ) * protobufs.KeyValue {
1259- return & protobufs.KeyValue {
1260- Key : key ,
1261- Value : & protobufs.AnyValue {
1262- Value : & protobufs.AnyValue_StringValue {
1263- StringValue : val ,
1264- },
1265- },
1257+ func keyValuesToStringMap (kvs []* protobufs.KeyValue ) map [string ]string {
1258+ out := make (map [string ]string , len (kvs ))
1259+ for _ , kv := range kvs {
1260+ out [kv .Key ] = kv .Value .GetStringValue ()
12661261 }
1262+ return out
12671263}
12681264
12691265// Creates a Collector config that reads and writes logs to files and provides
0 commit comments