Merge "Initial seed of hacking"
This commit is contained in:
commit
e397e9a519
27
HACKING.rst
Normal file
27
HACKING.rst
Normal file
@ -0,0 +1,27 @@
|
||||
Ceilometer Style Commandments
|
||||
=============================
|
||||
|
||||
- Step 1: Read the OpenStack Style Commandments
|
||||
http://docs.openstack.org/developer/hacking/
|
||||
- Step 2: Read on
|
||||
|
||||
Ceilometer Specific Commandments
|
||||
--------------------------------
|
||||
|
||||
- [C301] LOG.warn() is not allowed. Use LOG.warning()
|
||||
- [C302] Deprecated library function os.popen()
|
||||
|
||||
Creating Unit Tests
|
||||
-------------------
|
||||
For every new feature, unit tests should be created that both test and
|
||||
(implicitly) document the usage of said feature. If submitting a patch for a
|
||||
bug that had no unit test, a new passing unit test should be added. If a
|
||||
submitted bug fix does have a unit test, be sure to add a new one that fails
|
||||
without the patch and passes with the patch.
|
||||
|
||||
All unittest classes must ultimately inherit from testtools.TestCase.
|
||||
|
||||
All setUp and tearDown methods must upcall using the super() method.
|
||||
tearDown methods should be avoided and addCleanup calls should be preferred.
|
||||
Never manually create tempfiles. Always use the tempfile fixtures from
|
||||
the fixture library to ensure that they are cleaned up.
|
@ -34,7 +34,7 @@ from stevedore import extension
|
||||
|
||||
from ceilometer.agent import plugin_base
|
||||
from ceilometer import coordination
|
||||
from ceilometer.i18n import _, _LI, _LE, _LW
|
||||
from ceilometer.i18n import _, _LE, _LI, _LW
|
||||
from ceilometer import keystone_client
|
||||
from ceilometer import messaging
|
||||
from ceilometer import pipeline
|
||||
|
@ -25,8 +25,8 @@ from oslo_utils import netutils
|
||||
from oslo_utils import units
|
||||
|
||||
from ceilometer import dispatcher
|
||||
from ceilometer import messaging
|
||||
from ceilometer.i18n import _, _LE
|
||||
from ceilometer import messaging
|
||||
from ceilometer import utils
|
||||
|
||||
OPTS = [
|
||||
|
@ -19,7 +19,7 @@ import ceilometer
|
||||
from ceilometer.compute import pollsters
|
||||
from ceilometer.compute.pollsters import util
|
||||
from ceilometer.compute.virt import inspector as virt_inspector
|
||||
from ceilometer.i18n import _, _LW, _LE
|
||||
from ceilometer.i18n import _, _LE, _LW
|
||||
from ceilometer import sample
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
0
ceilometer/hacking/__init__.py
Normal file
0
ceilometer/hacking/__init__.py
Normal file
57
ceilometer/hacking/checks.py
Normal file
57
ceilometer/hacking/checks.py
Normal file
@ -0,0 +1,57 @@
|
||||
# Copyright (c) 2016 OpenStack Foundation
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Guidelines for writing new hacking checks
|
||||
|
||||
- Use only for Ceilometer specific tests. OpenStack general tests
|
||||
should be submitted to the common 'hacking' module.
|
||||
- Pick numbers in the range X3xx. Find the current test with
|
||||
the highest allocated number and then pick the next value.
|
||||
- Keep the test method code in the source file ordered based
|
||||
on the C3xx value.
|
||||
- List the new rule in the top level HACKING.rst file
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def no_log_warn(logical_line):
|
||||
"""Disallow 'LOG.warn('
|
||||
|
||||
https://bugs.launchpad.net/tempest/+bug/1508442
|
||||
|
||||
C301
|
||||
"""
|
||||
if logical_line.startswith('LOG.warn('):
|
||||
yield(0, 'C301 Use LOG.warning() rather than LOG.warn()')
|
||||
|
||||
|
||||
def no_os_popen(logical_line):
|
||||
"""Disallow 'os.popen('
|
||||
|
||||
Deprecated library function os.popen() Replace it using subprocess
|
||||
https://bugs.launchpad.net/tempest/+bug/1529836
|
||||
|
||||
C302
|
||||
"""
|
||||
|
||||
if 'os.popen(' in logical_line:
|
||||
yield(0, 'C302 Deprecated library function os.popen(). '
|
||||
'Replace it using subprocess module. ')
|
||||
|
||||
|
||||
def factory(register):
|
||||
register(no_log_warn)
|
||||
register(no_os_popen)
|
@ -24,8 +24,8 @@ from stevedore import extension
|
||||
from ceilometer.agent import plugin_base as base
|
||||
from ceilometer import coordination
|
||||
from ceilometer.event import endpoint as event_endpoint
|
||||
from ceilometer.i18n import _, _LI, _LW
|
||||
from ceilometer import exchange_control
|
||||
from ceilometer.i18n import _, _LI, _LW
|
||||
from ceilometer import messaging
|
||||
from ceilometer import pipeline
|
||||
from ceilometer import service_base
|
||||
|
@ -27,7 +27,7 @@ from oslo_utils import excutils
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from ceilometer.i18n import _, _LI, _LE
|
||||
from ceilometer.i18n import _, _LE, _LI
|
||||
from ceilometer import messaging
|
||||
from ceilometer import publisher
|
||||
from ceilometer.publisher import utils
|
||||
|
@ -11,6 +11,7 @@
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
@ -150,8 +151,10 @@ html_theme_options = {
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
git_cmd = "git log --pretty=format:'%ad, commit %h' --date=local -n1"
|
||||
html_last_updated_fmt = os.popen(git_cmd).read()
|
||||
git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local",
|
||||
"-n1"]
|
||||
html_last_updated_fmt = subprocess.Popen(
|
||||
git_cmd, stdout=subprocess.PIPE).communicate()[0]
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
|
Loading…
Reference in New Issue
Block a user