@@ -17,28 +17,172 @@ SPDX-License-Identifier: Apache-2.0
17
17
#include " autoscaling_samples.h"
18
18
19
19
namespace AwsDocTest {
20
+ extern const std::vector<std::string> RESPONSES;
21
+ bool addHttpResponses (MockHTTP &mockHttp);
22
+
23
+ #if 0
24
+ // Only run the un-mocked test in special cases because of its long execution time.
25
+ // NOLINTNEXTLINE (readability-named-parameter)
26
+ TEST_F(AutoScaling_GTests, groups_and_instances_scenario_2L_) {
27
+ AddCommandLineResponses(RESPONSES);
28
+
29
+ bool result = AwsDoc::AutoScaling::groupsAndInstancesScenario(*s_clientConfig);
30
+ ASSERT_TRUE(result);
31
+ }
32
+ #endif
20
33
// NOLINTNEXTLINE (readability-named-parameter)
21
- TEST_F (AutoScaling_GTests, groups_and_instances_scenario_2_
22
- ) {
23
- AddCommandLineResponses ( {
24
- " n" , // "Would you like to use an existing EC2 launch template (y/n)?"
25
- " integration_tests_template" , // "Enter the name for a new EC2 launch template: "
26
- " integration_tests_group" , // "Enter a name for the Amazon EC2 Auto Scaling group: "
27
- " 1" , // "Choose an Availability Zone: "
28
- " y" , // "Do you want to collect metrics about the Amazon EC2 Auto Scaling during this demo (y/n)?"
29
- " " , // "Press enter to continue:"
30
- " " , // "Press enter to continue:"
31
- " 1" , // "Which EC2 instance do you want to stop?"
32
- " " , // "Press enter to continue:"
33
- " 1" , // "Which metric would you like to view? "
34
- " n" , // "Would you like to view another metric (y/n)? "
35
- " " , // "Press enter to continue:"
36
- " y" , // "Delete the EC2 Auto Scaling group 'integration_tests_group' (y/n)?"
37
- " y" // "Delete the EC2 launch template 'integration_tests_template' (y/n)?"
38
- }
39
- );
40
-
41
- bool result = AwsDoc::AutoScaling::groupsAndInstancesScenario (*s_clientConfig);
42
- ASSERT_TRUE (result);
43
- }
34
+ TEST_F (AutoScaling_GTests, groups_and_instances_scenario_3_) {
35
+ AddCommandLineResponses (RESPONSES);
36
+ MockHTTP mockHttp;
37
+ bool result = addHttpResponses (mockHttp);
38
+ ASSERT_TRUE (result) << preconditionError ();
39
+
40
+ result = AwsDoc::AutoScaling::groupsAndInstancesScenario (*s_clientConfig);
41
+ ASSERT_TRUE (result);
42
+ }
43
+
44
+ const std::vector<std::string> RESPONSES = {
45
+ " n" , // "Would you like to use an existing EC2 launch template (y/n)?"
46
+ " integration_tests_template" , // "Enter the name for a new EC2 launch template: "
47
+ " integration_tests_group" , // "Enter a name for the Amazon EC2 Auto Scaling group: "
48
+ " 1" , // "Choose an Availability Zone: "
49
+ " y" , // "Do you want to collect metrics about the Amazon EC2 Auto Scaling during this demo (y/n)?"
50
+ " " , // "Press enter to continue:"
51
+ " " , // "Press enter to continue:"
52
+ " 1" , // "Which EC2 instance do you want to stop?"
53
+ " " , // "Press enter to continue:"
54
+ " 1" , // "Which metric would you like to view? "
55
+ " n" , // "Would you like to view another metric (y/n)? "
56
+ " " , // "Press enter to continue:"
57
+ " y" , // "Delete the EC2 Auto Scaling group 'integration_tests_group' (y/n)?"
58
+ " y" // "Delete the EC2 launch template 'integration_tests_template' (y/n)?"
59
+ };
60
+
61
+ bool addHttpResponses (MockHTTP &mockHttp) {
62
+ if (!mockHttp.addResponseWithBody (
63
+ " mock_input/1-CreateLaunchTemplate.xml" )) {
64
+ return false ;
65
+ }
66
+ if (!mockHttp.addResponseWithBody (
67
+ " mock_input/2-DescribeAvailabilityZones.xml" )) {
68
+ return false ;
69
+ }
70
+ if (!mockHttp.addResponseWithBody (
71
+ " mock_input/3-CreateAutoScalingGroup.xml" )) {
72
+ return false ;
73
+ }
74
+ if (!mockHttp.addResponseWithBody (
75
+ " mock_input/4-DescribeAutoScalingGroups.xml" )) {
76
+ return false ;
77
+ }
78
+ if (!mockHttp.addResponseWithBody (
79
+ " mock_input/5-DescribeAutoScalingGroups.xml" )) {
80
+ return false ;
81
+ }
82
+ if (!mockHttp.addResponseWithBody (
83
+ " mock_input/6-DescribeAutoScalingInstances.xml" )) {
84
+ return false ;
85
+ }
86
+ if (!mockHttp.addResponseWithBody (
87
+ " mock_input/7-DescribeAutoScalingGroups.xml" )) {
88
+ return false ;
89
+ }
90
+ if (!mockHttp.addResponseWithBody (" mock_input/8-EnableMetricsCollection.xml" )) {
91
+ return false ;
92
+ }
93
+ if (!mockHttp.addResponseWithBody (
94
+ " mock_input/9-UpdateAutoScalingGroup.xml" )) {
95
+ return false ;
96
+ }
97
+ if (!mockHttp.addResponseWithBody (
98
+ " mock_input/10-DescribeAutoScalingGroups.xml" )) {
99
+ return false ;
100
+ }
101
+ if (!mockHttp.addResponseWithBody (
102
+ " mock_input/11-SetDesiredCapacity.xml" )) {
103
+ return false ;
104
+ }
105
+ if (!mockHttp.addResponseWithBody (
106
+ " mock_input/12-DescribeAutoScalingGroups.xml" )) {
107
+ return false ;
108
+ }
109
+ if (!mockHttp.addResponseWithBody (
110
+ " mock_input/13-DescribeAutoScalingGroups.xml" )) {
111
+ return false ;
112
+ }
113
+ if (!mockHttp.addResponseWithBody (
114
+ " mock_input/14-DescribeAutoScalingInstances.xml" )) {
115
+ return false ;
116
+ }
117
+ if (!mockHttp.addResponseWithBody (" mock_input/15-DescribeAutoScalingGroups.xml" )) {
118
+ return false ;
119
+ }
120
+ if (!mockHttp.addResponseWithBody (" mock_input/16-TerminateInstanceInAutoScalingGroup.xml" )) {
121
+ return false ;
122
+ }
123
+ if (!mockHttp.addResponseWithBody (" mock_input/17-DescribeAutoScalingGroups.xml" )) {
124
+ return false ;
125
+ }
126
+ if (!mockHttp.addResponseWithBody (
127
+ " mock_input/72-DescribeAutoScalingInstances.xml" )) {
128
+ return false ;
129
+ }
130
+ if (!mockHttp.addResponseWithBody (
131
+ " mock_input/73-DescribeAutoScalingGroups.xml" )) {
132
+ return false ;
133
+ }
134
+ if (!mockHttp.addResponseWithBody (
135
+ " mock_input/74-DescribeScalingActivities.xml" )) {
136
+ return false ;
137
+ }
138
+ if (!mockHttp.addResponseWithBody (" mock_input/75-ListMetrics.xml" )) {
139
+ return false ;
140
+ }
141
+ if (!mockHttp.addResponseWithBody (" mock_input/76-GetMetricStatistics.xml" )) {
142
+ return false ;
143
+ }
144
+ if (!mockHttp.addResponseWithBody (" mock_input/77-DisableMetricsCollection.xml" )) {
145
+ return false ;
146
+ }
147
+ if (!mockHttp.addResponseWithBody (" mock_input/78-UpdateAutoScalingGroup.xml" )) {
148
+ return false ;
149
+ }
150
+ if (!mockHttp.addResponseWithBody (" mock_input/79-DescribeAutoScalingGroups.xml" )) {
151
+ return false ;
152
+ }
153
+ if (!mockHttp.addResponseWithBody (" mock_input/80-TerminateInstanceInAutoScalingGroup.xml" )) {
154
+ return false ;
155
+ }
156
+ if (!mockHttp.addResponseWithBody (
157
+ " mock_input/81-TerminateInstanceInAutoScalingGroup.xml" )) {
158
+ return false ;
159
+ }
160
+ if (!mockHttp.addResponseWithBody (
161
+ " mock_input/82-DescribeAutoScalingGroups.xml" )) {
162
+ return false ;
163
+ }
164
+ if (!mockHttp.addResponseWithBody (
165
+ " mock_input/133-DescribeAutoScalingInstances.xml" )) {
166
+ return false ;
167
+ }
168
+ if (!mockHttp.addResponseWithBody (
169
+ " mock_input/134-DescribeAutoScalingGroups.xml" )) {
170
+ return false ;
171
+ }
172
+ if (!mockHttp.addResponseWithBody (
173
+ " mock_input/135-DescribeAutoScalingGroups.xml" )) {
174
+ return false ;
175
+ }
176
+ if (!mockHttp.addResponseWithBody (
177
+ " mock_input/136-DeleteAutoScalingGroup.xml" )) {
178
+ return false ;
179
+ }
180
+ if (!mockHttp.addResponseWithBody (
181
+ " mock_input/137-DeleteLaunchTemplate.xml" )) {
182
+ return false ;
183
+ }
184
+
185
+ return true ;
186
+ }
187
+
44
188
} // AwsDocTest
0 commit comments