From f0169656ba57dcea47eaed808cfb7758b39a6755 Mon Sep 17 00:00:00 2001 From: Michael Ambrose Date: Wed, 7 Jun 2017 16:07:47 -0400 Subject: [PATCH] Added test to for Cloudwatch EC2 tag selection --- .../cloudwatch/specs/datasource_specs.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts b/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts index afc0f4a5962..28fd524663b 100644 --- a/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts +++ b/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts @@ -318,4 +318,38 @@ describe('CloudWatchDatasource', function() { expect(scenario.request.data.action).to.be('ListMetrics'); }); }); + + describeMetricFindQuery('ec2_instance_attribute(us-east-1, Tags.Name, { "tag:team": [ "sysops" ] })', scenario => { + scenario.setup(() => { + scenario.requestResponse = { + Reservations: [ + { + Instances: [ + { + Tags: [ + { Key: 'InstanceId', Value: 'i-123456' }, + { Key: 'Name', Value: 'Sysops Dev Server' }, + { Key: 'env', Value: 'dev' }, + { Key: 'team', Value: 'sysops' } + ] + }, + { + Tags: [ + { Key: 'InstanceId', Value: 'i-789012' }, + { Key: 'Name', Value: 'Sysops Staging Server' }, + { Key: 'env', Value: 'staging' }, + { Key: 'team', Value: 'sysops' } + ] + } + ] + } + ] + }; + }); + + it('should return the "Name" tag for each instance', function() { + expect(scenario.result[0].text).to.be('Sysops Dev Server'); + expect(scenario.result[1].text).to.be('Sysops Staging Server'); + }); + }); });