Skip to content

Commit dbe6fab

Browse files
committed
Add the subcommand "recreate-service"
1 parent c2ec595 commit dbe6fab

File tree

9 files changed

+672
-38
lines changed

9 files changed

+672
-38
lines changed

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,103 @@ make install
5050

5151
## Usage
5252

53+
### recreate-service
54+
55+
```
56+
$ ecsmec recreate-service --help
57+
This command creates a new service from the specified service with overrides,
58+
and after the new service becomes stable, it deletes the old one.
59+
Therefore, as necessary, you have to increase the capacity of the cluster the
60+
service belongs to manually so that it has enough capacity for the new service
61+
to place its tasks.
62+
63+
Usage:
64+
ecsmec recreate-service [flags]
65+
66+
Examples:
67+
You can change the placement strategy of the service "test" in the default cluster
68+
by the following command:
69+
70+
ecsmec recreate-service --service test --overrides '{
71+
"PlacementStrategy": [
72+
{ "Field": "attribute:ecs.availability-zone", "Type": "spread" },
73+
{ "Field": "CPU", "Type": "binpack" }
74+
]
75+
}'
76+
77+
In the same way, you can change the name of the service "test" in the default
78+
cluster like below:
79+
80+
ecsmec recreate-service --service test --overrides '{
81+
"ServiceName": "new-name"
82+
}'
83+
84+
85+
Flags:
86+
--cluster CLUSTER The name of the target CLUSTER (default "default")
87+
-h, --help help for recreate-service
88+
--overrides JSON An JSON to override some fields of the new service (default "{}")
89+
--service SERVICE The name of the target SERVICE (required)
90+
91+
Global Flags:
92+
--profile string An AWS profile name in your credential file
93+
--region string The AWS region
94+
```
95+
96+
The option "overrides" is in the same format as the [CreateService API](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateService.html) parameter, except that the first letter of each field is uppercase.
97+
Although the [UpdateService API](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html) supports updating the task placement strategies and constraints, the feature is still in preview and the command helps you to update the task placement strategies and constraints safely.
98+
99+
This command does the following operations to recreate the specified service:
100+
101+
1. Create a temporal service from the service with overrides
102+
1. Delete the old service
103+
1. Create a new service from the temporal service
104+
1. Delete the temporal service
105+
106+
If the service name is overridden, the operations change as follow:
107+
108+
1. Create a new service from the service with overrides
109+
1. Delete the old service
110+
111+
112+
You need the following permissions to execute the command:
113+
114+
```
115+
{
116+
"Version": "2012-10-17",
117+
"Statement": [
118+
{
119+
"Effect": "Allow",
120+
"Action": [
121+
"ecs:ListTasks"
122+
],
123+
"Resource": "*"
124+
},
125+
{
126+
"Effect": "Allow",
127+
"Action": [
128+
"ecs:DescribeTasks"
129+
],
130+
"Resource": [
131+
"arn:aws:ecs:<region>:<account-id>:task/<cluster>/*"
132+
]
133+
},
134+
{
135+
"Effect": "Allow",
136+
"Action": [
137+
"ecs:CreateService",
138+
"ecs:DeleteService",
139+
"ecs:DescribeServices",
140+
"ecs:UpdateService"
141+
],
142+
"Resource": [
143+
"arn:aws:ecs:<region>:<account-id>:service/<cluster>/*"
144+
]
145+
}
146+
]
147+
}
148+
```
149+
53150
### reduce-cluster-capacity
54151

55152
```

cmd/recreateservice.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package cmd
2+
3+
import (
4+
"encoding/json"
5+
"strings"
6+
7+
"github.com/aws/aws-sdk-go/service/ecs"
8+
"github.com/spf13/cobra"
9+
10+
"github.com/abicky/ecsmec/internal/service"
11+
)
12+
13+
var recreateServiceCmd *cobra.Command
14+
15+
func init() {
16+
cmd := &cobra.Command{
17+
Use: "recreate-service",
18+
Short: "Recreate a service with overrides",
19+
Long: `This command creates a new service from the specified service with overrides,
20+
and after the new service becomes stable, it deletes the old one.
21+
Therefore, as necessary, you have to increase the capacity of the cluster the
22+
service belongs to manually so that it has enough capacity for the new service
23+
to place its tasks.`,
24+
Example: ` You can change the placement strategy of the service "test" in the default cluster
25+
by the following command:
26+
27+
ecsmec recreate-service --service test --overrides '{
28+
"PlacementStrategy": [
29+
{ "Field": "attribute:ecs.availability-zone", "Type": "spread" },
30+
{ "Field": "CPU", "Type": "binpack" }
31+
]
32+
}'
33+
34+
In the same way, you can change the name of the service "test" in the default
35+
cluster like below:
36+
37+
ecsmec recreate-service --service test --overrides '{
38+
"ServiceName": "new-name"
39+
}'
40+
`,
41+
RunE: recreateService,
42+
}
43+
rootCmd.AddCommand(cmd)
44+
45+
cmd.Flags().String("cluster", "default", "The name of the target `CLUSTER`")
46+
47+
cmd.Flags().String("service", "", "The name of the target `SERVICE` (required)")
48+
cmd.MarkFlagRequired("service")
49+
50+
cmd.Flags().String("overrides", "{}", "An `JSON` to override some fields of the new service")
51+
52+
recreateServiceCmd = cmd
53+
}
54+
55+
func recreateService(cmd *cobra.Command, args []string) error {
56+
cluster, _ := recreateServiceCmd.Flags().GetString("cluster")
57+
serviceName, _ := recreateServiceCmd.Flags().GetString("service")
58+
overrides, _ := recreateServiceCmd.Flags().GetString("overrides")
59+
60+
var overrideDef service.Definition
61+
decoder := json.NewDecoder(strings.NewReader(overrides))
62+
decoder.DisallowUnknownFields()
63+
if err := decoder.Decode(&overrideDef); err != nil {
64+
return newRuntimeError("failed to parse \"overrides\": %w", err)
65+
}
66+
67+
sess, err := newSession()
68+
if err != nil {
69+
return newRuntimeError("failed to initialize a session: %w", err)
70+
}
71+
72+
if err := service.NewService(ecs.New(sess)).Recreate(cluster, serviceName, overrideDef); err != nil {
73+
return newRuntimeError("failed to recreate the service: %w", err)
74+
}
75+
return nil
76+
}

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ go 1.15
55
require (
66
github.com/aws/aws-sdk-go v1.36.28
77
github.com/golang/mock v1.4.4
8+
github.com/imdario/mergo v0.0.0-00010101000000-000000000000
89
github.com/spf13/cobra v1.1.1
910
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
1011
)
12+
13+
replace github.com/imdario/mergo => github.com/abicky/mergo v0.3.12-0.20210127171018-7c7592023899

go.sum

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
1414
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
1515
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
1616
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
17+
github.com/abicky/mergo v0.3.12-0.20210127171018-7c7592023899 h1:NwO67PPpUhZTbVkREk0epqzM/11n+vuBAw4JbrYMNCQ=
18+
github.com/abicky/mergo v0.3.12-0.20210127171018-7c7592023899/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
1719
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
1820
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
1921
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
@@ -34,6 +36,7 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7
3436
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
3537
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
3638
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
39+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
3740
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3841
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
3942
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
@@ -92,9 +95,11 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO
9295
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
9396
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
9497
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
98+
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
9599
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
96100
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
97101
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
102+
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
98103
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
99104
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
100105
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
@@ -105,8 +110,10 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
105110
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
106111
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
107112
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
113+
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
108114
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
109115
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
116+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
110117
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
111118
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
112119
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
@@ -130,6 +137,7 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9
130137
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
131138
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
132139
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
140+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
133141
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
134142
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
135143
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
@@ -212,6 +220,7 @@ golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn
212220
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
213221
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
214222
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
223+
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
215224
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
216225
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
217226
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -238,6 +247,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
238247
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
239248
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
240249
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
250+
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
241251
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
242252
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
243253
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -284,14 +294,18 @@ google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiq
284294
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
285295
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
286296
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
297+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
287298
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
288299
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
289300
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
290301
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
291302
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
292303
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
293304
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
305+
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
294306
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
307+
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
308+
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
295309
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
296310
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
297311
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

internal/capacity/autoscalinggroup_test.go

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,9 @@ import (
1414
"github.com/abicky/ecsmec/internal/const/autoscalingconst"
1515
"github.com/abicky/ecsmec/internal/sliceutil"
1616
"github.com/abicky/ecsmec/internal/testing/mocks"
17+
"github.com/abicky/ecsmec/internal/testing/testutil"
1718
)
1819

19-
func inOrder(calls ...*gomock.Call) *gomock.Call {
20-
gomock.InOrder(calls...)
21-
return calls[len(calls)-1]
22-
}
23-
24-
func matchSlice(a, b []string) bool {
25-
if len(a) != len(b) {
26-
return false
27-
}
28-
29-
aMap := make(map[string]int, len(a))
30-
for _, s := range a {
31-
aMap[s]++
32-
}
33-
for _, s := range b {
34-
if _, ok := aMap[s]; !ok {
35-
return false
36-
}
37-
aMap[s]--
38-
if aMap[s] == 0 {
39-
delete(aMap, s)
40-
}
41-
}
42-
43-
if len(aMap) > 0 {
44-
return false
45-
}
46-
47-
return true
48-
}
49-
5020
func createReservation(instance *autoscaling.Instance, launchTime time.Time) *ec2.Reservation {
5121
return createReservations([]*autoscaling.Instance{instance}, launchTime)[0]
5222
}
@@ -92,7 +62,7 @@ func expectLaunchNewInstances(
9262
}
9363
}
9464

95-
return inOrder(
65+
return testutil.InOrder(
9666
asMock.EXPECT().DescribeAutoScalingGroups(gomock.Any()).Return(&autoscaling.DescribeAutoScalingGroupsOutput{
9767
AutoScalingGroups: []*autoscaling.Group{
9868
{
@@ -182,7 +152,7 @@ func expectTerminateInstances(
182152
) *gomock.Call {
183153
t.Helper()
184154

185-
return inOrder(
155+
return testutil.InOrder(
186156
ec2Mock.EXPECT().DescribeInstances(gomock.Any()).Return(&ec2.DescribeInstancesOutput{
187157
Reservations: append(reservationsToTerminate, reservationsToKeep...),
188158
}, nil),
@@ -195,7 +165,7 @@ func expectTerminateInstances(
195165
want[i] = *instance.InstanceId
196166
}
197167
got := aws.StringValueSlice(input.InstanceIds)
198-
if !matchSlice(want, got) {
168+
if !testutil.MatchSlice(want, got) {
199169
t.Errorf("input.InstanceIds = %v; want %v", got, want)
200170
}
201171
}),
@@ -206,7 +176,7 @@ func expectTerminateInstances(
206176
want[i] = *instance.InstanceId
207177
}
208178
got := aws.StringValueSlice(input.InstanceIds)
209-
if !matchSlice(want, got) {
179+
if !testutil.MatchSlice(want, got) {
210180
t.Errorf("input.InstanceIds = %v; want %v", got, want)
211181
}
212182
}),
@@ -235,7 +205,7 @@ func expectRestoreState(
235205
) *gomock.Call {
236206
t.Helper()
237207

238-
return inOrder(
208+
return testutil.InOrder(
239209
asMock.EXPECT().UpdateAutoScalingGroup(gomock.Any()).Do(func(input *autoscaling.UpdateAutoScalingGroupInput) {
240210
if input.DesiredCapacity != nil {
241211
t.Errorf("DesiredCapacity = %d; want nil", *input.DesiredCapacity)
@@ -759,10 +729,10 @@ func TestAutoScalingGroup_ReduceCapacity(t *testing.T) {
759729
for i, instance := range instancesToTerminate {
760730
instanceIdsToTerminate[i] = *instance.InstanceId
761731
}
762-
if !matchSlice(detachedInstanceIds, instanceIdsToTerminate) {
732+
if !testutil.MatchSlice(detachedInstanceIds, instanceIdsToTerminate) {
763733
t.Errorf("detachedInstanceIds = %v; want %v", detachedInstanceIds, instanceIdsToTerminate)
764734
}
765-
if !matchSlice(terminatedInstanceIds, instanceIdsToTerminate) {
735+
if !testutil.MatchSlice(terminatedInstanceIds, instanceIdsToTerminate) {
766736
t.Errorf("terminatedInstanceIds = %v; want %v", terminatedInstanceIds, instanceIdsToTerminate)
767737
}
768738

0 commit comments

Comments
 (0)