Module: check_mk
Branch: master
Commit: a154fc8e9b397bcca4573b2eb641b974869789ca
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a154fc8e9b397b…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Apr 26 15:54:05 2019 +0200
Cleaned up AWS tests
Change-Id: I7d259c23a2530eac2099566c7bb519105200f345
---
.../agent_aws/agent_aws_fake_clients.py | 17 +++++
.../agent_aws/test_agent_aws_costs_and_usage.py | 1 -
.../special_agents/agent_aws/test_agent_aws_elb.py | 18 +----
.../special_agents/agent_aws/test_agent_aws_rds.py | 87 +---------------------
4 files changed, 24 insertions(+), 99 deletions(-)
diff --git a/tests/unit/cmk/special_agents/agent_aws/agent_aws_fake_clients.py
b/tests/unit/cmk/special_agents/agent_aws/agent_aws_fake_clients.py
index 681aa45..830f31f 100644
--- a/tests/unit/cmk/special_agents/agent_aws/agent_aws_fake_clients.py
+++ b/tests/unit/cmk/special_agents/agent_aws/agent_aws_fake_clients.py
@@ -566,6 +566,23 @@ class ELBDescribeInstanceHealthIB(InstanceBuilder):
]
+class ELBDescribeAccountLimitsIB(InstanceBuilder):
+ def _fill_instance(self):
+ return [
+ List(
+ 'Limits',
+ [
+ Int('Max'),
+ ],
+ from_choice=Choice('Name', [
+ "classic-load-balancers",
+ "classic-listeners",
+ "classic-registered-instances",
+ ]),
+ ),
+ ]
+
+
#.
# .--ELBv2----------------------------------------------------------------
diff --git a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_costs_and_usage.py
b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_costs_and_usage.py
index 7c4f7c0..0b614e0 100644
--- a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_costs_and_usage.py
+++ b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_costs_and_usage.py
@@ -28,7 +28,6 @@ def test_agent_aws_costs_and_usage():
ce = CostsAndUsage(FakeCEClient(), region, config)
ce_results = ce.run().results
- #--CE-------------------------------------------------------------------
assert ce.cache_interval == 86400
assert ce.name == "costs_and_usage"
assert len(ce_results) == 1
diff --git a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_elb.py
b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_elb.py
index 2cbe3c2..1208f9f 100644
--- a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_elb.py
+++ b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_elb.py
@@ -6,6 +6,7 @@ from agent_aws_fake_clients import (
ELBDescribeLoadBalancersIB,
ELBDescribeTagsIB,
ELBDescribeInstanceHealthIB,
+ ELBDescribeAccountLimitsIB,
)
from cmk.special_agents.agent_aws import (
@@ -28,21 +29,8 @@ class FakeELBClient(object):
def describe_account_limits(self):
return {
- 'Limits': [
- {
- 'Name': 'classic-load-balancers',
- 'Max': 10,
- },
- {
- 'Name': 'classic-listeners',
- 'Max': 10,
- },
- {
- 'Name': 'classic-registered-instances',
- 'Max': 10,
- },
- ],
- 'NextMarker': 'string'
+ 'Limits':
ELBDescribeAccountLimitsIB.create_instances(amount=1)[0]['Limits'],
+ 'NextMarker': 'string',
}
def describe_tags(self, LoadBalancerNames=None):
diff --git a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_rds.py
b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_rds.py
index a6cb1be..721dc3d 100644
--- a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_rds.py
+++ b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_rds.py
@@ -2,8 +2,9 @@
import pytest
from agent_aws_fake_clients import (
- RDSDescribeDBInstancesIB,
FakeCloudwatchClient,
+ RDSDescribeDBInstancesIB,
+ RDSDescribeAccountAttributesIB,
)
from cmk.special_agents.agent_aws import (
@@ -18,88 +19,8 @@ from cmk.special_agents.agent_aws import (
class FakeRDSClient(object):
def describe_account_attributes(self):
return {
- 'AccountQuotas': [
- {
- 'AccountQuotaName': 'unused',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'DBClusters',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'DBClusterParameterGroups',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'DBInstances',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'EventSubscriptions',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'ManualSnapshots',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'OptionGroups',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'DBParameterGroups',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'ReadReplicasPerMaster',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'ReservedDBInstances',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'DBSecurityGroups',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'DBSubnetGroups',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'SubnetsPerDBSubnetGroup',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'AllocatedStorage',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName':
'AuthorizationsPerDBSecurityGroup',
- 'Used': 1,
- 'Max': 2,
- },
- {
- 'AccountQuotaName': 'DBClusterRoles',
- 'Used': 1,
- 'Max': 2,
- },
- ]
+ 'AccountQuotas':
RDSDescribeAccountAttributesIB.create_instances(amount=1)[0]
+ ['AccountQuotas'],
}
def describe_db_instances(self, DBInstanceIdentifier=None, Filters=None):