1- /*************************************************************************
2- * Copyright 2009-2016 Eucalyptus Systems, Inc.
3- *
4- * This program is free software: you can redistribute it and/or modify
5- * it under the terms of the GNU General Public License as published by
6- * the Free Software Foundation; version 3 of the License.
7- *
8- * This program is distributed in the hope that it will be useful,
9- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11- * GNU General Public License for more details.
12- *
13- * You should have received a copy of the GNU General Public License
14- * along with this program. If not, see http://www.gnu.org/licenses/.
15- *
16- * Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta
17- * CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need
18- * additional information or have any questions.
19- ************************************************************************/
201package com .eucalyptus .tests .awssdk ;
212
223import com .amazonaws .AmazonServiceException ;
3314/**
3415 * This application tests parameter validation for auto scaling.
3516 * <p/>
36- * This is verification for the story :
17+ * This is verification for:
3718 * <p/>
3819 * https://eucalyptus.atlassian.net/browse/EUCA-5016
20+ * https://eucalyptus.atlassian.net/browse/EUCA-13035
3921 */
4022public class TestAutoScalingValidation {
4123
@@ -66,6 +48,8 @@ public void run() {
6648 assertThat (false , "Expected error when creating launch configuration with invalid name" );
6749 } catch (AmazonServiceException e ) {
6850 print ("Got expected exception: " + e );
51+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
52+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
6953 }
7054
7155 // Create launch configuration with missing required parameter
@@ -77,6 +61,8 @@ public void run() {
7761 assertThat (false , "Expected error when creating launch configuration with missing parameter" );
7862 } catch (AmazonServiceException e ) {
7963 print ("Got expected exception: " + e );
64+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
65+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
8066 }
8167
8268 // Create launch configuration
@@ -106,9 +92,11 @@ public void run() {
10692 .withMaxSize (1 )
10793 .withAvailabilityZones (AVAILABILITY_ZONE )
10894 );
109- assertThat (false , "Expected error when creating launch group with invalid size" );
95+ assertThat (false , "Expected error when creating scaling group with invalid size" );
11096 } catch (AmazonServiceException e ) {
11197 print ("Got expected exception: " + e );
98+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
99+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
112100 }
113101
114102 // Create scaling group with invalid capacity
@@ -122,9 +110,11 @@ public void run() {
122110 .withDesiredCapacity (2 )
123111 .withAvailabilityZones (AVAILABILITY_ZONE )
124112 );
125- assertThat (false , "Expected error when creating launch group with invalid capacity" );
113+ assertThat (false , "Expected error when creating scaling group with invalid capacity" );
126114 } catch (AmazonServiceException e ) {
127115 print ("Got expected exception: " + e );
116+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
117+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
128118 }
129119
130120 // Create scaling group with invalid tag
@@ -143,9 +133,23 @@ public void run() {
143133 new Tag ().withKey ("tag1" + nameSuffix ).withValue ("propagate" ).withPropagateAtLaunch (Boolean .TRUE )
144134 )
145135 );
146- assertThat (false , "Expected error when creating launch group with invalid tag" );
136+ assertThat (false , "Expected error when creating scaling group with invalid tag" );
147137 } catch (AmazonServiceException e ) {
148138 print ("Got expected exception: " + e );
139+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
140+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
141+ }
142+
143+ // Create scaling group with missing required parameter
144+ print ("Creating auto scaling group with missing required parameters" );
145+ try {
146+ as .createAutoScalingGroup ( new CreateAutoScalingGroupRequest ( )
147+ .withAvailabilityZones ( AVAILABILITY_ZONE ) );
148+ assertThat (false , "Expected error when creating scaling group with missing required parameters" );
149+ } catch (AmazonServiceException e ) {
150+ print ("Got expected exception: " + e );
151+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
152+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
149153 }
150154
151155 // Create scaling group
@@ -166,6 +170,8 @@ public void run() {
166170 assertThat (false , "Expected error when creating tag on invalid group" );
167171 } catch (AmazonServiceException e ) {
168172 print ("Got expected exception: " + e );
173+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
174+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
169175 }
170176
171177 // Register cleanup for launch configs
@@ -190,6 +196,8 @@ public void run() {
190196 assertThat (false , "Expected error when creating invalid scaling policy" );
191197 } catch (AmazonServiceException e ) {
192198 print ("Got expected exception: " + e );
199+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
200+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
193201 }
194202
195203 // Create invalid scaling policy
@@ -203,6 +211,102 @@ public void run() {
203211 assertThat (false , "Expected error when creating invalid scaling policy" );
204212 } catch (AmazonServiceException e ) {
205213 print ("Got expected exception: " + e );
214+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
215+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
216+ }
217+
218+ // Update group / set desired capacity with missing parameters
219+ try {
220+ as .updateAutoScalingGroup ( new UpdateAutoScalingGroupRequest ( ) );
221+ assertThat (false , "Expected error when updating scaling group without required parameters" );
222+ } catch (AmazonServiceException e ) {
223+ print ("Got expected exception: " + e );
224+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
225+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
226+ }
227+ try {
228+ as .setDesiredCapacity ( new SetDesiredCapacityRequest ( ) );
229+ assertThat (false , "Expected error when setting desired capacity for scaling group without required parameters" );
230+ } catch (AmazonServiceException e ) {
231+ print ("Got expected exception: " + e );
232+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
233+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
234+ }
235+
236+ // Enable/disable metrics collection with missing parameters
237+ try {
238+ as .enableMetricsCollection ( new EnableMetricsCollectionRequest ( )
239+ .withMetrics ( "GroupMinSize" )
240+ .withGranularity ( "1Minute" )
241+ );
242+ assertThat (false , "Expected error when enabling metrics collection without required parameters" );
243+ } catch (AmazonServiceException e ) {
244+ print ("Got expected exception: " + e );
245+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
246+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
247+ }
248+ try {
249+ as .disableMetricsCollection ( new DisableMetricsCollectionRequest ( )
250+ .withMetrics ( "GroupMinSize" ) );
251+ assertThat (false , "Expected error when disabling metrics collection without required parameters" );
252+ } catch (AmazonServiceException e ) {
253+ print ("Got expected exception: " + e );
254+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
255+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
256+ }
257+
258+ // Suspend/resume scaling processes with missing parameters
259+ try {
260+ as .suspendProcesses ( new SuspendProcessesRequest ( ) );
261+ assertThat (false , "Expected error when suspending processes without required parameters" );
262+ } catch (AmazonServiceException e ) {
263+ print ("Got expected exception: " + e );
264+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
265+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
266+ }
267+ try {
268+ as .resumeProcesses ( new ResumeProcessesRequest ( ) );
269+ assertThat (false , "Expected error when resuming processes without required parameters" );
270+ } catch (AmazonServiceException e ) {
271+ print ("Got expected exception: " + e );
272+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
273+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
274+ }
275+
276+ // Put / execute scaling policies with missing parameters
277+ try {
278+ as .putScalingPolicy ( new PutScalingPolicyRequest ( ) );
279+ assertThat (false , "Expected error when putting scaling policy without required parameters" );
280+ } catch (AmazonServiceException e ) {
281+ print ("Got expected exception: " + e );
282+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
283+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
284+ }
285+ try {
286+ as .executePolicy ( new ExecutePolicyRequest ( ) );
287+ assertThat (false , "Expected error when executing scaling policy without required parameters" );
288+ } catch (AmazonServiceException e ) {
289+ print ("Got expected exception: " + e );
290+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
291+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
292+ }
293+
294+ // Set instance health/terminate instance with missing parameters
295+ try {
296+ as .setInstanceHealth ( new SetInstanceHealthRequest ( ) );
297+ assertThat (false , "Expected error when setting instance health without required parameters" );
298+ } catch (AmazonServiceException e ) {
299+ print ("Got expected exception: " + e );
300+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
301+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
302+ }
303+ try {
304+ as .terminateInstanceInAutoScalingGroup ( new TerminateInstanceInAutoScalingGroupRequest ( ) );
305+ assertThat (false , "Expected error when terminating scaling instance without required parameters" );
306+ } catch (AmazonServiceException e ) {
307+ print ("Got expected exception: " + e );
308+ assertThat ( e .getErrorCode ( ) != null , "Expected error code" );
309+ assertThat ( e .getErrorMessage ( ) != null , "Expected error message" );
206310 }
207311
208312 print ("Test complete" );
0 commit comments