Skip to content

Commit

Permalink
zalando-stups#493: Support ClusterName for RedisNode component
Browse files Browse the repository at this point in the history
  • Loading branch information
inikolaev committed Nov 28, 2017
1 parent d35c8e5 commit 1f29b20
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion senza/components/redis_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def component_redis_node(definition, configuration, args, info, force, account_info):
name = configuration["Name"]
name = configuration.get("ClusterName", configuration["Name"])
definition = ensure_keys(definition, "Resources")

definition["Resources"]["RedisCacheCluster"] = {
Expand Down
35 changes: 35 additions & 0 deletions tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,41 @@ def test_component_redis_node(monkeypatch):
assert 'SubnetIds' in result['Resources']['RedisSubnetGroup']['Properties']


def test_component_redis_node_cluster_name(monkeypatch):
mock_string = "foo"
cluster_name = "foo-redis-cluster"

configuration = {
"Name": mock_string,
"SecurityGroups": "",
"ClusterName": cluster_name,
}
info = {'StackName': 'foobar' * 5, 'StackVersion': '0.1'}
definition = {"Resources": {}}

args = MagicMock()
args.region = "foo"

mock_string_result = MagicMock()
mock_string_result.return_value = mock_string
monkeypatch.setattr('senza.components.redis_node.resolve_security_groups', mock_string_result)

result = component_redis_node(definition, configuration, args, info, False, MagicMock())

assert 'RedisCacheCluster' in result['Resources']
assert mock_string == result['Resources']['RedisCacheCluster']['Properties']['VpcSecurityGroupIds']
assert cluster_name == result['Resources']['RedisCacheCluster']['Properties']['ClusterName']
assert 1 == result['Resources']['RedisCacheCluster']['Properties']['NumCacheNodes']
assert 'Engine' in result['Resources']['RedisCacheCluster']['Properties']
assert 'EngineVersion' in result['Resources']['RedisCacheCluster']['Properties']
assert 'CacheNodeType' in result['Resources']['RedisCacheCluster']['Properties']
assert 'CacheSubnetGroupName' in result['Resources']['RedisCacheCluster']['Properties']
assert 'CacheParameterGroupName' in result['Resources']['RedisCacheCluster']['Properties']

assert 'RedisSubnetGroup' in result['Resources']
assert 'SubnetIds' in result['Resources']['RedisSubnetGroup']['Properties']


def test_component_redis_cluster(monkeypatch):
mock_string = "foo"

Expand Down

0 comments on commit 1f29b20

Please sign in to comment.