-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[src] Add field strategy to group roll request
- Loading branch information
Showing
6 changed files
with
142 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,7 @@ venv*/ | |
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
Pipfile* | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
PyYaml | ||
requests | ||
pydoc-markdown | ||
pydoc-markdown==2.1.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
import unittest | ||
|
||
from spotinst_sdk import SpotinstClient | ||
from spotinst_sdk.aws_elastigroup import * | ||
|
||
|
||
class AwsElastigroupRollTestCase(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.client = SpotinstClient( | ||
auth_token='dummy-token', | ||
account_id='dummy-account') | ||
self.mock_group_roll_json = self.load_group_roll_json() | ||
|
||
def create_formatted_group_roll_request(self, group_roll): | ||
group_roll_request = ElastigroupRollRequest(group_roll=group_roll) | ||
excluded_group_roll_dict = self.client.exclude_missing( | ||
json.loads(group_roll_request.toJSON())) | ||
formatted_group_roll_dict = self.client.convert_json( | ||
excluded_group_roll_dict, self.client.underscore_to_camel) | ||
return formatted_group_roll_dict | ||
|
||
@staticmethod | ||
def load_group_roll_json(): | ||
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_lib/input/group_roll.json')) as group_roll_json: | ||
return json.load(group_roll_json) | ||
|
||
|
||
# region Roll | ||
class AwsElastigroupRoleTest(AwsElastigroupRollTestCase): | ||
def runTest(self): | ||
on_failure = OnFailure(action_type="DETACH_OLD", should_handle_all_batches=True, batch_num=2, draining_timeout=300, should_decrement_target_capacity=False) | ||
strategy = RollStrategy(action="REPLACE_SERVER", should_drain_instances=True, batch_min_healthy_percentage=100, on_failure=on_failure) | ||
roll = Roll(batch_size_percentage="20", grace_period=500, health_check_type="NONE", strategy=strategy) | ||
|
||
formatted_group_roll_dict = self.create_formatted_group_roll_request(roll) | ||
|
||
self.assertDictEqual(formatted_group_roll_dict, self.mock_group_roll_json) | ||
# endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"batchSizePercentage":"20", | ||
"gracePeriod": 500, | ||
"healthCheckType": "NONE", | ||
"strategy": { | ||
"action": "REPLACE_SERVER", | ||
"shouldDrainInstances": true, | ||
"batchMinHealthyPercentage": 100, | ||
"onFailure": { | ||
"actionType": "DETACH_OLD", | ||
"shouldHandleAllBatches": true, | ||
"batchNum": 2, | ||
"drainingTimeout": 300, | ||
"shouldDecrementTargetCapacity": false | ||
} | ||
} | ||
} |