@@ -23,6 +23,7 @@ import (
23
23
"github.com/grafana/grafana/pkg/setting"
24
24
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/mocks"
25
25
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models"
26
+ "github.com/grafana/grafana/pkg/tsdb/cloudwatch/models/resources"
26
27
"github.com/stretchr/testify/assert"
27
28
"github.com/stretchr/testify/require"
28
29
)
@@ -52,7 +53,7 @@ func TestNewInstanceSettings(t *testing.T) {
52
53
},
53
54
},
54
55
expectedDS : DataSource {
55
- Settings : & models.CloudWatchSettings {
56
+ Settings : models.CloudWatchSettings {
56
57
AWSDatasourceSettings : awsds.AWSDatasourceSettings {
57
58
Profile : "foo" ,
58
59
Region : "us-east2" ,
@@ -112,7 +113,7 @@ func Test_CheckHealth(t *testing.T) {
112
113
t .Run ("successfully query metrics and logs" , func (t * testing.T ) {
113
114
client = fakeCheckHealthClient {}
114
115
im := datasource .NewInstanceManager (func (s backend.DataSourceInstanceSettings ) (instancemgmt.Instance , error ) {
115
- return DataSource {Settings : & models.CloudWatchSettings {}}, nil
116
+ return DataSource {Settings : models.CloudWatchSettings {}}, nil
116
117
})
117
118
executor := newExecutor (im , newTestConfig (), & fakeSessionCache {}, featuremgmt .WithFeatures ())
118
119
@@ -133,7 +134,7 @@ func Test_CheckHealth(t *testing.T) {
133
134
return nil , fmt .Errorf ("some logs query error" )
134
135
}}
135
136
im := datasource .NewInstanceManager (func (s backend.DataSourceInstanceSettings ) (instancemgmt.Instance , error ) {
136
- return DataSource {Settings : & models.CloudWatchSettings {}}, nil
137
+ return DataSource {Settings : models.CloudWatchSettings {}}, nil
137
138
})
138
139
executor := newExecutor (im , newTestConfig (), & fakeSessionCache {}, featuremgmt .WithFeatures ())
139
140
@@ -154,7 +155,7 @@ func Test_CheckHealth(t *testing.T) {
154
155
return fmt .Errorf ("some list metrics error" )
155
156
}}
156
157
im := datasource .NewInstanceManager (func (s backend.DataSourceInstanceSettings ) (instancemgmt.Instance , error ) {
157
- return DataSource {Settings : & models.CloudWatchSettings {}}, nil
158
+ return DataSource {Settings : models.CloudWatchSettings {}}, nil
158
159
})
159
160
executor := newExecutor (im , newTestConfig (), & fakeSessionCache {}, featuremgmt .WithFeatures ())
160
161
@@ -172,7 +173,7 @@ func Test_CheckHealth(t *testing.T) {
172
173
t .Run ("fail to get clients" , func (t * testing.T ) {
173
174
client = fakeCheckHealthClient {}
174
175
im := datasource .NewInstanceManager (func (s backend.DataSourceInstanceSettings ) (instancemgmt.Instance , error ) {
175
- return DataSource {Settings : & models.CloudWatchSettings {}}, nil
176
+ return DataSource {Settings : models.CloudWatchSettings {}}, nil
176
177
})
177
178
executor := newExecutor (im , newTestConfig (), & fakeSessionCache {getSession : func (c awsds.SessionConfig ) (* session.Session , error ) {
178
179
return nil , fmt .Errorf ("some sessions error" )
@@ -203,7 +204,7 @@ func Test_executeLogAlertQuery(t *testing.T) {
203
204
t .Run ("getCWLogsClient is called with region from input JSON" , func (t * testing.T ) {
204
205
cli = fakeCWLogsClient {queryResults : cloudwatchlogs.GetQueryResultsOutput {Status : aws .String ("Complete" )}}
205
206
im := datasource .NewInstanceManager (func (s backend.DataSourceInstanceSettings ) (instancemgmt.Instance , error ) {
206
- return DataSource {Settings : & models.CloudWatchSettings {}}, nil
207
+ return DataSource {Settings : models.CloudWatchSettings {}}, nil
207
208
})
208
209
sess := fakeSessionCache {}
209
210
executor := newExecutor (im , newTestConfig (), & sess , featuremgmt .WithFeatures ())
@@ -229,7 +230,7 @@ func Test_executeLogAlertQuery(t *testing.T) {
229
230
t .Run ("getCWLogsClient is called with region from instance manager when region is default" , func (t * testing.T ) {
230
231
cli = fakeCWLogsClient {queryResults : cloudwatchlogs.GetQueryResultsOutput {Status : aws .String ("Complete" )}}
231
232
im := datasource .NewInstanceManager (func (s backend.DataSourceInstanceSettings ) (instancemgmt.Instance , error ) {
232
- return DataSource {Settings : & models.CloudWatchSettings {AWSDatasourceSettings : awsds.AWSDatasourceSettings {Region : "instance manager's region" }}}, nil
233
+ return DataSource {Settings : models.CloudWatchSettings {AWSDatasourceSettings : awsds.AWSDatasourceSettings {Region : "instance manager's region" }}}, nil
233
234
})
234
235
sess := fakeSessionCache {}
235
236
@@ -266,7 +267,7 @@ func TestQuery_ResourceRequest_DescribeAllLogGroups(t *testing.T) {
266
267
}
267
268
268
269
im := datasource .NewInstanceManager (func (s backend.DataSourceInstanceSettings ) (instancemgmt.Instance , error ) {
269
- return DataSource {Settings : & models.CloudWatchSettings {}}, nil
270
+ return DataSource {Settings : models.CloudWatchSettings {}}, nil
270
271
})
271
272
272
273
executor := newExecutor (im , newTestConfig (), & fakeSessionCache {}, featuremgmt .WithFeatures ())
@@ -412,7 +413,7 @@ func TestQuery_ResourceRequest_DescribeLogGroups(t *testing.T) {
412
413
}
413
414
414
415
im := datasource .NewInstanceManager (func (s backend.DataSourceInstanceSettings ) (instancemgmt.Instance , error ) {
415
- return DataSource {Settings : & models.CloudWatchSettings {}}, nil
416
+ return DataSource {Settings : models.CloudWatchSettings {}}, nil
416
417
})
417
418
418
419
executor := newExecutor (im , newTestConfig (), & fakeSessionCache {}, featuremgmt .WithFeatures ())
@@ -467,7 +468,7 @@ func TestQuery_ResourceRequest_DescribeLogGroups(t *testing.T) {
467
468
}
468
469
469
470
im := datasource .NewInstanceManager (func (s backend.DataSourceInstanceSettings ) (instancemgmt.Instance , error ) {
470
- return DataSource {Settings : & models.CloudWatchSettings {}}, nil
471
+ return DataSource {Settings : models.CloudWatchSettings {}}, nil
471
472
})
472
473
473
474
executor := newExecutor (im , newTestConfig (), & fakeSessionCache {}, featuremgmt .WithFeatures ())
@@ -505,7 +506,7 @@ func TestQuery_ResourceRequest_DescribeLogGroups(t *testing.T) {
505
506
}
506
507
507
508
im := datasource .NewInstanceManager (func (s backend.DataSourceInstanceSettings ) (instancemgmt.Instance , error ) {
508
- return DataSource {Settings : & models.CloudWatchSettings {}}, nil
509
+ return DataSource {Settings : models.CloudWatchSettings {}}, nil
509
510
})
510
511
511
512
executor := newExecutor (im , newTestConfig (), & fakeSessionCache {}, featuremgmt .WithFeatures ())
@@ -546,7 +547,7 @@ func Test_CloudWatch_CallResource_Integration_Test(t *testing.T) {
546
547
return & api
547
548
}
548
549
im := datasource .NewInstanceManager (func (s backend.DataSourceInstanceSettings ) (instancemgmt.Instance , error ) {
549
- return DataSource {Settings : & models.CloudWatchSettings {}}, nil
550
+ return DataSource {Settings : models.CloudWatchSettings {}}, nil
550
551
})
551
552
552
553
t .Run ("Should handle dimension value request and return values from the api" , func (t * testing.T ) {
@@ -699,10 +700,10 @@ func Test_CloudWatch_CallResource_Integration_Test(t *testing.T) {
699
700
sent := sender .Response
700
701
require .NotNil (t , sent )
701
702
require .Equal (t , http .StatusOK , sent .Status )
702
- res := []models .Metric {}
703
+ res := []resources .Metric {}
703
704
err = json .Unmarshal (sent .Body , & res )
704
705
require .Nil (t , err )
705
- assert .Equal (t , []models .Metric {{Name : "Test_MetricName1" , Namespace : "AWS/EC2" }, {Name : "Test_MetricName2" , Namespace : "AWS/EC2" }, {Name : "Test_MetricName3" , Namespace : "AWS/ECS" }, {Name : "Test_MetricName10" , Namespace : "AWS/ECS" }, {Name : "Test_MetricName4" , Namespace : "AWS/ECS" }, {Name : "Test_MetricName5" , Namespace : "AWS/Redshift" }}, res )
706
+ assert .Equal (t , []resources .Metric {{Name : "Test_MetricName1" , Namespace : "AWS/EC2" }, {Name : "Test_MetricName2" , Namespace : "AWS/EC2" }, {Name : "Test_MetricName3" , Namespace : "AWS/ECS" }, {Name : "Test_MetricName10" , Namespace : "AWS/ECS" }, {Name : "Test_MetricName4" , Namespace : "AWS/ECS" }, {Name : "Test_MetricName5" , Namespace : "AWS/Redshift" }}, res )
706
707
})
707
708
}
708
709
0 commit comments