@@ -41,6 +41,7 @@ import (
41
41
v3matcherpb "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3"
42
42
"google.golang.org/protobuf/types/known/anypb"
43
43
"google.golang.org/protobuf/types/known/durationpb"
44
+ "google.golang.org/protobuf/types/known/structpb"
44
45
"google.golang.org/protobuf/types/known/wrapperspb"
45
46
)
46
47
@@ -1216,6 +1217,71 @@ func (s) TestUnmarshalCluster(t *testing.T) {
1216
1217
},
1217
1218
},
1218
1219
})
1220
+
1221
+ v3ClusterAnyWithTelemetryLabels = testutils .MarshalAny (t , & v3clusterpb.Cluster {
1222
+ Name : v3ClusterName ,
1223
+ ClusterDiscoveryType : & v3clusterpb.Cluster_Type {Type : v3clusterpb .Cluster_EDS },
1224
+ EdsClusterConfig : & v3clusterpb.Cluster_EdsClusterConfig {
1225
+ EdsConfig : & v3corepb.ConfigSource {
1226
+ ConfigSourceSpecifier : & v3corepb.ConfigSource_Ads {
1227
+ Ads : & v3corepb.AggregatedConfigSource {},
1228
+ },
1229
+ },
1230
+ ServiceName : v3Service ,
1231
+ },
1232
+ LbPolicy : v3clusterpb .Cluster_ROUND_ROBIN ,
1233
+ LrsServer : & v3corepb.ConfigSource {
1234
+ ConfigSourceSpecifier : & v3corepb.ConfigSource_Self {
1235
+ Self : & v3corepb.SelfConfigSource {},
1236
+ },
1237
+ },
1238
+ Metadata : & v3corepb.Metadata {
1239
+ FilterMetadata : map [string ]* structpb.Struct {
1240
+ "com.google.csm.telemetry_labels" : {
1241
+ Fields : map [string ]* structpb.Value {
1242
+ "service_name" : structpb .NewStringValue ("grpc-service" ),
1243
+ "service_namespace" : structpb .NewStringValue ("grpc-service-namespace" ),
1244
+ },
1245
+ },
1246
+ },
1247
+ },
1248
+ })
1249
+ v3ClusterAnyWithTelemetryLabelsIgnoreSome = testutils .MarshalAny (t , & v3clusterpb.Cluster {
1250
+ Name : v3ClusterName ,
1251
+ ClusterDiscoveryType : & v3clusterpb.Cluster_Type {Type : v3clusterpb .Cluster_EDS },
1252
+ EdsClusterConfig : & v3clusterpb.Cluster_EdsClusterConfig {
1253
+ EdsConfig : & v3corepb.ConfigSource {
1254
+ ConfigSourceSpecifier : & v3corepb.ConfigSource_Ads {
1255
+ Ads : & v3corepb.AggregatedConfigSource {},
1256
+ },
1257
+ },
1258
+ ServiceName : v3Service ,
1259
+ },
1260
+ LbPolicy : v3clusterpb .Cluster_ROUND_ROBIN ,
1261
+ LrsServer : & v3corepb.ConfigSource {
1262
+ ConfigSourceSpecifier : & v3corepb.ConfigSource_Self {
1263
+ Self : & v3corepb.SelfConfigSource {},
1264
+ },
1265
+ },
1266
+ Metadata : & v3corepb.Metadata {
1267
+ FilterMetadata : map [string ]* structpb.Struct {
1268
+ "com.google.csm.telemetry_labels" : {
1269
+ Fields : map [string ]* structpb.Value {
1270
+ "string-value-should-ignore" : structpb .NewStringValue ("string-val" ),
1271
+ "float-value-ignore" : structpb .NewNumberValue (3 ),
1272
+ "bool-value-ignore" : structpb .NewBoolValue (false ),
1273
+ "service_name" : structpb .NewStringValue ("grpc-service" ), // shouldn't ignore
1274
+ "service_namespace" : structpb .NewNullValue (), // should ignore - wrong type
1275
+ },
1276
+ },
1277
+ "ignore-this-metadata" : { // should ignore this filter_metadata
1278
+ Fields : map [string ]* structpb.Value {
1279
+ "service_namespace" : structpb .NewStringValue ("string-val-should-ignore" ),
1280
+ },
1281
+ },
1282
+ },
1283
+ },
1284
+ })
1219
1285
)
1220
1286
1221
1287
tests := []struct {
@@ -1300,6 +1366,35 @@ func (s) TestUnmarshalCluster(t *testing.T) {
1300
1366
Raw : v3ClusterAnyWithEDSConfigSourceSelf ,
1301
1367
},
1302
1368
},
1369
+ {
1370
+ name : "v3 cluster with telemetry case" ,
1371
+ resource : v3ClusterAnyWithTelemetryLabels ,
1372
+ wantName : v3ClusterName ,
1373
+ wantUpdate : ClusterUpdate {
1374
+ ClusterName : v3ClusterName ,
1375
+ EDSServiceName : v3Service ,
1376
+ LRSServerConfig : ClusterLRSServerSelf ,
1377
+ Raw : v3ClusterAnyWithTelemetryLabels ,
1378
+ TelemetryLabels : map [string ]string {
1379
+ "service_name" : "grpc-service" ,
1380
+ "service_namespace" : "grpc-service-namespace" ,
1381
+ },
1382
+ },
1383
+ },
1384
+ {
1385
+ name : "v3 metadata ignore other types not string and not com.google.csm.telemetry_labels" ,
1386
+ resource : v3ClusterAnyWithTelemetryLabelsIgnoreSome ,
1387
+ wantName : v3ClusterName ,
1388
+ wantUpdate : ClusterUpdate {
1389
+ ClusterName : v3ClusterName ,
1390
+ EDSServiceName : v3Service ,
1391
+ LRSServerConfig : ClusterLRSServerSelf ,
1392
+ Raw : v3ClusterAnyWithTelemetryLabelsIgnoreSome ,
1393
+ TelemetryLabels : map [string ]string {
1394
+ "service_name" : "grpc-service" ,
1395
+ },
1396
+ },
1397
+ },
1303
1398
{
1304
1399
name : "xdstp cluster resource with unset EDS service name" ,
1305
1400
resource : testutils .MarshalAny (t , & v3clusterpb.Cluster {
0 commit comments