Module: check_mk
Branch: master
Commit: 978a90d1a2fe38b283602695df9994dcaa199436
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=978a90d1a2fe38…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Apr 24 12:48:50 2019 +0200
Cleaned up AWS cloudwatch fake clients
Change-Id: I6b96284789c70117df28ad1d448e75c6dbc24c1e
---
.../agent_aws/agent_aws_fake_clients.py | 6 +++++
.../agent_aws/test_agent_aws_cloudwatch.py | 10 +-------
.../agent_aws/test_agent_aws_costs_and_usage.py | 1 +
.../special_agents/agent_aws/test_agent_aws_ec2.py | 27 ++--------------------
.../special_agents/agent_aws/test_agent_aws_elb.py | 27 ++--------------------
.../special_agents/agent_aws/test_agent_aws_s3.py | 27 ++--------------------
6 files changed, 14 insertions(+), 84 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 02d5e23..29674be 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
@@ -498,6 +498,12 @@ class RDSDescribeDBInstancesInstanceCreator(InstanceCreator):
class FakeCloudwatchClient(object):
+ def describe_alarms(self, AlarmNames=None):
+ alarms = CloudwatchDescribeAlarmsInstanceCreator.create_instances(amount=2)
+ if AlarmNames:
+ alarms = [alarm for alarm in alarms if alarm['AlarmName'] in
AlarmNames]
+ return {'MetricAlarms': alarms, 'NextToken': 'string'}
+
def get_metric_data(self, MetricDataQueries, StartTime='START',
EndTime='END'):
results = []
for query in MetricDataQueries:
diff --git a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_cloudwatch.py
b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_cloudwatch.py
index 035f37f..8a30643 100644
--- a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_cloudwatch.py
+++ b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_cloudwatch.py
@@ -2,7 +2,7 @@
import pytest
from agent_aws_fake_clients import (
- CloudwatchDescribeAlarmsInstanceCreator,)
+ FakeCloudwatchClient,)
from cmk.special_agents.agent_aws import (
AWSConfig,
@@ -12,14 +12,6 @@ from cmk.special_agents.agent_aws import (
)
-class FakeCloudwatchClient(object):
- def describe_alarms(self, AlarmNames=None):
- alarms = CloudwatchDescribeAlarmsInstanceCreator.create_instances(amount=2)
- if AlarmNames:
- alarms = [alarm for alarm in alarms if alarm['AlarmName'] in
AlarmNames]
- return {'MetricAlarms': alarms, 'NextToken': 'string'}
-
-
@pytest.fixture()
def get_cloudwatch_alarms_sections():
def _create_cloudwatch_alarms_sections(alarm_names):
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 7b1e487..e85a6d2 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
@@ -2,6 +2,7 @@
from agent_aws_fake_clients import (
CEGetCostsAndUsageInstanceCreator,)
+
from cmk.special_agents.agent_aws import (
AWSConfig,
CostsAndUsage,
diff --git a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_ec2.py
b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_ec2.py
index 79fd1d1..5c5f3c0 100644
--- a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_ec2.py
+++ b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_ec2.py
@@ -1,6 +1,8 @@
# encoding: utf-8
import pytest
+from agent_aws_fake_clients import (
+ FakeCloudwatchClient,)
from cmk.special_agents.agent_aws import (
_get_ec2_piggyback_hostname,
@@ -332,31 +334,6 @@ inst2 = {
# '----------------------------------------------------------------------'
-class FakeCloudwatchClient(object):
- def get_metric_data(self, MetricDataQueries, StartTime='START',
EndTime='END'):
- results = []
- for query in MetricDataQueries:
- results.append({
- 'Id': query['Id'],
- 'Label': query['Label'],
- 'Timestamps': ["1970-01-01",],
- 'Values': [123.0,],
- 'StatusCode': "'Complete' | 'InternalError'
| 'PartialData'",
- 'Messages': [{
- 'Code': 'string1',
- 'Value': 'string1'
- },]
- })
- return {
- 'MetricDataResults': results,
- 'NextToken': 'string',
- 'Messages': [{
- 'Code': 'string',
- 'Value': 'string'
- },]
- }
-
-
class FakeEC2Client(object):
def describe_instances(self, InstanceIds=None, Filters=None):
return {
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 f30faa2..89490dd 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
@@ -1,6 +1,8 @@
# encoding: utf-8
import pytest
+from agent_aws_fake_clients import (
+ FakeCloudwatchClient,)
from cmk.special_agents.agent_aws import (
AWSConfig,
@@ -288,31 +290,6 @@ elbv2_lb3 = {
# '----------------------------------------------------------------------'
-class FakeCloudwatchClient(object):
- def get_metric_data(self, MetricDataQueries, StartTime='START',
EndTime='END'):
- results = []
- for query in MetricDataQueries:
- results.append({
- 'Id': query['Id'],
- 'Label': query['Label'],
- 'Timestamps': ["1970-01-01",],
- 'Values': [123.0,],
- 'StatusCode': "'Complete' | 'InternalError'
| 'PartialData'",
- 'Messages': [{
- 'Code': 'string1',
- 'Value': 'string1'
- },]
- })
- return {
- 'MetricDataResults': results,
- 'NextToken': 'string',
- 'Messages': [{
- 'Code': 'string',
- 'Value': 'string'
- },]
- }
-
-
class FakeELBClient(object):
def describe_load_balancers(self, LoadBalancerNames=None):
return {'LoadBalancerDescriptions': [elb_lb1, elb_lb2, elb_lb3],
'NextMarker': 'string'}
diff --git a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_s3.py
b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_s3.py
index 7fd3660..eb217be 100644
--- a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_s3.py
+++ b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_s3.py
@@ -2,9 +2,11 @@
import pytest
from agent_aws_fake_clients import (
+ FakeCloudwatchClient,
S3ListBucketsInstanceCreator,
S3BucketTaggingInstanceCreator,
)
+
from cmk.special_agents.agent_aws import (
AWSConfig,
ResultDistributor,
@@ -15,31 +17,6 @@ from cmk.special_agents.agent_aws import (
)
-class FakeCloudwatchClient(object):
- def get_metric_data(self, MetricDataQueries, StartTime='START',
EndTime='END'):
- results = []
- for query in MetricDataQueries:
- results.append({
- 'Id': query['Id'],
- 'Label': query['Label'],
- 'Timestamps': ["1970-01-01",],
- 'Values': [123.0,],
- 'StatusCode': "'Complete' | 'InternalError'
| 'PartialData'",
- 'Messages': [{
- 'Code': 'string1',
- 'Value': 'string1'
- },]
- })
- return {
- 'MetricDataResults': results,
- 'NextToken': 'string',
- 'Messages': [{
- 'Code': 'string',
- 'Value': 'string'
- },]
- }
-
-
class FakeS3Client(object):
def list_buckets(self):
return {