Skip to content

Commit

Permalink
Adhere to code style (#3488)
Browse files Browse the repository at this point in the history
* Adhere to code style

* Apply suggestions from code review

Co-Authored-By: ofek <[email protected]>
  • Loading branch information
ofek authored Apr 12, 2019
1 parent f3310c1 commit 53d4be6
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 75 deletions.
5 changes: 1 addition & 4 deletions ceph/datadog_checks/ceph/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from .ceph import Ceph

__all__ = [
'__version__',
'Ceph'
]
__all__ = ['__version__', 'Ceph']
9 changes: 5 additions & 4 deletions ceph/datadog_checks/ceph/ceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from __future__ import division

import os
import re

from datadog_checks.checks import AgentCheck
from datadog_checks.utils.subprocess_output import get_subprocess_output
from datadog_checks.config import _is_affirmative

import simplejson as json
from six import iteritems

from datadog_checks.checks import AgentCheck
from datadog_checks.config import _is_affirmative
from datadog_checks.utils.subprocess_output import get_subprocess_output


class Ceph(AgentCheck):
""" Collect metrics and events from ceph """
Expand Down
13 changes: 3 additions & 10 deletions ceph/setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Always prefer setuptools over distutils
from setuptools import setup
# To use a consistent encoding
from codecs import open
from os import path

# Always prefer setuptools over distutils
from setuptools import setup

HERE = path.abspath(path.dirname(__file__))

# Get version info
Expand Down Expand Up @@ -31,17 +32,13 @@ def get_requirements(fpath):
long_description=long_description,
long_description_content_type='text/markdown',
keywords='datadog agent ceph check',

# The project's main homepage.
url='https://github.com/DataDog/integrations-core',

# Author details
author='Datadog',
author_email='[email protected]',

# License
license='BSD',

# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 5 - Production/Stable',
Expand All @@ -52,14 +49,10 @@ def get_requirements(fpath):
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
],

# The package we're going to ship
packages=['datadog_checks.ceph'],

# Run-time dependencies
install_requires=[CHECKS_BASE_REQ],


# Extra files to ship with the wheel package
include_package_data=True,
)
41 changes: 19 additions & 22 deletions ceph/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
HERE = os.path.abspath(os.path.dirname(__file__))
FIXTURE_DIR = os.path.join(HERE, 'fixtures')

BASIC_CONFIG = {
'ceph_cmd': os.path.join(FIXTURE_DIR, 'ceph_bin.sh'),
'tags': ['optional:tag1'],
}
BASIC_CONFIG = {'ceph_cmd': os.path.join(FIXTURE_DIR, 'ceph_bin.sh'), 'tags': ['optional:tag1']}

EXPECTED_METRICS = [
"ceph.commit_latency_ms",
Expand Down Expand Up @@ -43,24 +40,24 @@
EXPECTED_SERVICE_TAGS = ['optional:tag1']

EXPECTED_SERVICE_CHECKS = [
'ceph.osd_down',
'ceph.osd_orphan',
'ceph.osd_full',
'ceph.osd_nearfull',
'ceph.pool_full',
'ceph.pool_near_full',
'ceph.pg_availability',
'ceph.pg_degraded',
'ceph.pg_degraded_full',
'ceph.pg_damaged',
'ceph.pg_not_scrubbed',
'ceph.pg_not_deep_scrubbed',
'ceph.cache_pool_near_full',
'ceph.too_few_pgs',
'ceph.too_many_pgs',
'ceph.object_unfound',
'ceph.request_slow',
'ceph.request_stuck',
'ceph.osd_down',
'ceph.osd_orphan',
'ceph.osd_full',
'ceph.osd_nearfull',
'ceph.pool_full',
'ceph.pool_near_full',
'ceph.pg_availability',
'ceph.pg_degraded',
'ceph.pg_degraded_full',
'ceph.pg_damaged',
'ceph.pg_not_scrubbed',
'ceph.pg_not_deep_scrubbed',
'ceph.cache_pool_near_full',
'ceph.too_few_pgs',
'ceph.too_many_pgs',
'ceph.object_unfound',
'ceph.request_slow',
'ceph.request_stuck',
]


Expand Down
5 changes: 3 additions & 2 deletions ceph/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from datadog_checks.dev import docker_run
from datadog_checks.dev.conditions import CheckDockerLogs

from .common import HERE, BASIC_CONFIG
from .common import BASIC_CONFIG, HERE


@pytest.fixture(scope="session")
Expand All @@ -18,7 +18,8 @@ def dd_environment():
# We need a custom condition to wait a bit longer
condition = CheckDockerLogs(compose_file, "spawning ceph --cluster ceph -w", wait=5)
with docker_run(
compose_file=compose_file, conditions=[condition],
compose_file=compose_file,
conditions=[condition],
sleep=5, # Let's wait just a little bit after ceph got spawned to remove flakyness
):
yield BASIC_CONFIG, "local"
4 changes: 1 addition & 3 deletions ceph/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

from datadog_checks.ceph import Ceph

from .common import (
CHECK_NAME, BASIC_CONFIG, EXPECTED_METRICS, EXPECTED_SERVICE_CHECKS, EXPECTED_SERVICE_TAGS
)
from .common import BASIC_CONFIG, CHECK_NAME, EXPECTED_METRICS, EXPECTED_SERVICE_CHECKS, EXPECTED_SERVICE_TAGS


@pytest.mark.integration
Expand Down
26 changes: 6 additions & 20 deletions ceph/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,11 @@

from datadog_checks.ceph import Ceph

from .common import (
CHECK_NAME, BASIC_CONFIG, EXPECTED_SERVICE_TAGS, mock_data
)

EXPECTED_METRICS = [
'ceph.num_mons',
'ceph.total_objects',
'ceph.pgstate.active_clean'
]

EXPECTED_TAGS = [
'ceph_fsid:e0efcf84-e8ed-4916-8ce1-9c70242d390a',
'ceph_mon_state:peon',
'optional:tag1'
]
from .common import BASIC_CONFIG, CHECK_NAME, EXPECTED_SERVICE_TAGS, mock_data

EXPECTED_METRICS = ['ceph.num_mons', 'ceph.total_objects', 'ceph.pgstate.active_clean']

EXPECTED_TAGS = ['ceph_fsid:e0efcf84-e8ed-4916-8ce1-9c70242d390a', 'ceph_mon_state:peon', 'optional:tag1']

pytestmark = pytest.mark.unit

Expand Down Expand Up @@ -110,11 +100,7 @@ def test_osd_status_metrics(_, aggregator):
ceph_check = Ceph(CHECK_NAME, {}, {})
ceph_check.check(copy.deepcopy(BASIC_CONFIG))

expected_metrics = [
'ceph.read_op_per_sec',
'ceph.write_op_per_sec',
'ceph.op_per_sec'
]
expected_metrics = ['ceph.read_op_per_sec', 'ceph.write_op_per_sec', 'ceph.op_per_sec']

for osd, pct_used in [('osd1', 94), ('osd2', 95)]:
expected_tags = EXPECTED_TAGS + ['ceph_osd:%s' % osd]
Expand Down
11 changes: 1 addition & 10 deletions ceph/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ minversion = 2.0
basepython = py37
envlist =
{py27,py37}-{unit,integration}
flake8

[testenv]
dd_check_style = true
usedevelop = true
platform = linux|darwin|win32
deps =
Expand All @@ -20,12 +20,3 @@ commands =
pip install -r requirements.in
unit: pytest -v -m"unit"
integration: pytest -v -m"integration"

[testenv:flake8]
skip_install = true
deps = flake8
commands = flake8 .

[flake8]
exclude = .eggs,.tox,build
max-line-length = 120

0 comments on commit 53d4be6

Please sign in to comment.