@@ -29,10 +29,10 @@ import (
29
29
dm "github.com/aws/amazon-ecs-agent/agent/engine/daemonmanager"
30
30
"github.com/aws/amazon-ecs-agent/agent/statechange"
31
31
"github.com/aws/amazon-ecs-agent/ecs-agent/eventstream"
32
- "github.com/aws/amazon-ecs-agent/ecs-agent/tcs/model/ecstcs"
33
32
33
+ "github.com/aws/aws-sdk-go-v2/aws"
34
34
ecstypes "github.com/aws/aws-sdk-go-v2/service/ecs/types"
35
- "github.com/aws/aws-sdk-go/aws "
35
+ tcstypes "github.com/aws/aws-sdk-go-v2/service/tcs/types "
36
36
"github.com/docker/docker/api/types"
37
37
dockercontainer "github.com/docker/docker/api/types/container"
38
38
"github.com/docker/docker/api/types/network"
@@ -157,8 +157,8 @@ func validateInstanceMetrics(t *testing.T, engine *DockerStatsEngine, includeSer
157
157
assert .Len (t , taskMetrics , 1 , "incorrect number of tasks" )
158
158
159
159
taskMetric := taskMetrics [0 ]
160
- assert .Equal (t , aws .StringValue (taskMetric .TaskDefinitionFamily ), taskDefinitionFamily , "unexpected task definition family" )
161
- assert .Equal (t , aws .StringValue (taskMetric .TaskDefinitionVersion ), taskDefinitionVersion , "unexpected task definition version" )
160
+ assert .Equal (t , aws .ToString (taskMetric .TaskDefinitionFamily ), taskDefinitionFamily , "unexpected task definition family" )
161
+ assert .Equal (t , aws .ToString (taskMetric .TaskDefinitionVersion ), taskDefinitionVersion , "unexpected task definition version" )
162
162
assert .NoError (t , validateContainerMetrics (taskMetric .ContainerMetrics , 1 ), "validating container metrics failed" )
163
163
if includeServiceConnectStats {
164
164
assert .NoError (t , validateServiceConnectMetrics (taskMetric .ServiceConnectMetricsWrapper , 1 ), "validating service connect metrics failed" )
@@ -172,15 +172,15 @@ func validateInstanceMetricsWithDisabledMetrics(t *testing.T, engine *DockerStat
172
172
assert .Len (t , taskMetrics , 1 , "incorrect number of tasks" )
173
173
174
174
taskMetric := taskMetrics [0 ]
175
- assert .Equal (t , aws .StringValue (taskMetric .TaskDefinitionFamily ), taskDefinitionFamily , "unexpected task definition family" )
176
- assert .Equal (t , aws .StringValue (taskMetric .TaskDefinitionVersion ), taskDefinitionVersion , "unexpected task definition version" )
175
+ assert .Equal (t , aws .ToString (taskMetric .TaskDefinitionFamily ), taskDefinitionFamily , "unexpected task definition family" )
176
+ assert .Equal (t , aws .ToString (taskMetric .TaskDefinitionVersion ), taskDefinitionVersion , "unexpected task definition version" )
177
177
assert .NoError (t , validateContainerMetrics (taskMetric .ContainerMetrics , 0 ), "validating container metrics failed" )
178
178
if includeServiceConnectStats {
179
179
assert .NoError (t , validateServiceConnectMetrics (taskMetric .ServiceConnectMetricsWrapper , 1 ), "validating service connect metrics failed" )
180
180
}
181
181
}
182
182
183
- func validateContainerMetrics (containerMetrics []* ecstcs .ContainerMetric , expected int ) error {
183
+ func validateContainerMetrics (containerMetrics []tcstypes .ContainerMetric , expected int ) error {
184
184
if len (containerMetrics ) != expected {
185
185
return fmt .Errorf ("Mismatch in number of ContainerStatsSet elements. Expected: %d, Got: %d" , expected , len (containerMetrics ))
186
186
}
@@ -204,7 +204,7 @@ func validateContainerMetrics(containerMetrics []*ecstcs.ContainerMetric, expect
204
204
return nil
205
205
}
206
206
207
- func validateServiceConnectMetrics (serviceConnectMetrics []* ecstcs .GeneralMetricsWrapper , expected int ) error {
207
+ func validateServiceConnectMetrics (serviceConnectMetrics []tcstypes .GeneralMetricsWrapper , expected int ) error {
208
208
if len (serviceConnectMetrics ) != expected {
209
209
return fmt .Errorf ("Mismatch in number of serviceConnectMetrics elements. Expected: %d, Got: %d" , expected , len (serviceConnectMetrics ))
210
210
}
@@ -224,12 +224,12 @@ func validateIdleContainerMetrics(t *testing.T, engine *DockerStatsEngine) {
224
224
assert .NoError (t , err , "getting instance metrics failed" )
225
225
assert .NoError (t , validateMetricsMetadata (metadata ), "validating metadata failed" )
226
226
227
- assert .True (t , aws . BoolValue ( metadata .Idle ) , "expected idle metadata to be true" )
228
- assert .True (t , aws . BoolValue ( metadata .Fin ) , "fin not set to true when idle" )
227
+ assert .True (t , metadata .Idle , "expected idle metadata to be true" )
228
+ assert .True (t , metadata .Fin , "fin not set to true when idle" )
229
229
assert .Len (t , taskMetrics , 0 , "expected empty task metrics" )
230
230
}
231
231
232
- func validateMetricsMetadata (metadata * ecstcs .MetricsMetadata ) error {
232
+ func validateMetricsMetadata (metadata * tcstypes .MetricsMetadata ) error {
233
233
if metadata == nil {
234
234
return fmt .Errorf ("Metadata is nil" )
235
235
}
@@ -248,40 +248,40 @@ func validateMetricsMetadata(metadata *ecstcs.MetricsMetadata) error {
248
248
return nil
249
249
}
250
250
251
- func validateHealthMetricsMetadata (metadata * ecstcs .HealthMetadata ) error {
251
+ func validateHealthMetricsMetadata (metadata * tcstypes .HealthMetadata ) error {
252
252
if metadata == nil {
253
253
return fmt .Errorf ("metadata is nil" )
254
254
}
255
255
256
- if aws .StringValue (metadata .Cluster ) != defaultCluster {
256
+ if aws .ToString (metadata .Cluster ) != defaultCluster {
257
257
return fmt .Errorf ("expected cluster in metadata to be: %s, got %s" ,
258
- defaultCluster , aws .StringValue (metadata .Cluster ))
258
+ defaultCluster , aws .ToString (metadata .Cluster ))
259
259
}
260
260
261
- if aws .StringValue (metadata .ContainerInstance ) != defaultContainerInstance {
261
+ if aws .ToString (metadata .ContainerInstance ) != defaultContainerInstance {
262
262
return fmt .Errorf ("expected container instance in metadata to be %s, got %s" ,
263
- defaultContainerInstance , aws .StringValue (metadata .ContainerInstance ))
263
+ defaultContainerInstance , aws .ToString (metadata .ContainerInstance ))
264
264
}
265
- if len (aws .StringValue (metadata .MessageId )) == 0 {
265
+ if len (aws .ToString (metadata .MessageId )) == 0 {
266
266
return fmt .Errorf ("empty MessageId" )
267
267
}
268
268
269
269
return nil
270
270
}
271
271
272
- func validateContainerHealthMetrics (metrics []* ecstcs .ContainerHealth , expected int ) error {
272
+ func validateContainerHealthMetrics (metrics []tcstypes .ContainerHealth , expected int ) error {
273
273
if len (metrics ) != expected {
274
274
return fmt .Errorf ("mismatch in number of ContainerHealth elements. Expected: %d, Got: %d" ,
275
275
expected , len (metrics ))
276
276
}
277
277
for _ , health := range metrics {
278
- if aws .StringValue (health .ContainerName ) == "" {
278
+ if aws .ToString (health .ContainerName ) == "" {
279
279
return fmt .Errorf ("container name is empty" )
280
280
}
281
- if aws . StringValue ( health .HealthStatus ) == "" {
281
+ if health .HealthStatus == "" {
282
282
return fmt .Errorf ("container health status is empty" )
283
283
}
284
- if aws . TimeValue ( health .StatusSince ) .IsZero () {
284
+ if health .StatusSince .IsZero () {
285
285
return fmt .Errorf ("container health status change timestamp is empty" )
286
286
}
287
287
}
@@ -293,9 +293,9 @@ func validateTaskHealthMetrics(t *testing.T, engine *DockerStatsEngine) {
293
293
assert .NoError (t , err , "getting task health metrics failed" )
294
294
require .Len (t , healthMetrics , 1 )
295
295
assert .NoError (t , validateHealthMetricsMetadata (healthMetadata ), "validating health metedata failed" )
296
- assert .Equal (t , aws .StringValue (healthMetrics [0 ].TaskArn ), taskArn , "task arn not expected" )
297
- assert .Equal (t , aws .StringValue (healthMetrics [0 ].TaskDefinitionFamily ), taskDefinitionFamily , "task definition family not expected" )
298
- assert .Equal (t , aws .StringValue (healthMetrics [0 ].TaskDefinitionVersion ), taskDefinitionVersion , "task definition version not expected" )
296
+ assert .Equal (t , aws .ToString (healthMetrics [0 ].TaskArn ), taskArn , "task arn not expected" )
297
+ assert .Equal (t , aws .ToString (healthMetrics [0 ].TaskDefinitionFamily ), taskDefinitionFamily , "task definition family not expected" )
298
+ assert .Equal (t , aws .ToString (healthMetrics [0 ].TaskDefinitionVersion ), taskDefinitionVersion , "task definition version not expected" )
299
299
assert .NoError (t , validateContainerHealthMetrics (healthMetrics [0 ].Containers , 1 ))
300
300
}
301
301
0 commit comments