Skip to content

Commit

Permalink
Merge 676f5fb into b338d86
Browse files Browse the repository at this point in the history
  • Loading branch information
mohierf committed Apr 25, 2018
2 parents b338d86 + 676f5fb commit 218a918
Show file tree
Hide file tree
Showing 770 changed files with 63,148 additions and 29,270 deletions.
69 changes: 69 additions & 0 deletions .former_travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
language: python
#dist: trusty
sudo: required
python:
- "2.7"

env:
- TEST_SUITE=unit
# Alignak daemons run tests
- TEST_SUITE=run
- TEST_SUITE=load
- TEST_SUITE=codingstandard
- TEST_SUITE=virtualenv

matrix:
exclude:
- python: "2.6"
env: TEST_SUITE=load
- python: "2.6"
env: TEST_SUITE=codingstandard
- python: "2.6"
env: TEST_SUITE=virtualenv

install:
# Remove python warnings
- unset PYTHONWARNINGS
# command to install dependencies
# some are only used for travis/coveralls so we are installing them here only
- ./test/setup_test.sh

# command to run tests
script:
# so to help eventual debug: know what exact versions are in use can be rather useful.
- pip freeze
# run test suite (wait no more than 30 minutes)
- travis_wait 60 ./.travis/$TEST_SUITE.sh

# specific call to launch coverage data into coveralls.io
after_success:
- echo "Test Success - Branch($TRAVIS_BRANCH) Pull Request($TRAVIS_PULL_REQUEST) Tag($TRAVIS_TAG)"
# Send coverage report only for the Python 2.7 unit tests
- if [[ $TEST_SUITE == 'unit' && $TRAVIS_PYTHON_VERSION == '2.7' ]]; then ./.travis/report_coveralls.sh; fi
- if [[ $TEST_SUITE == 'unit' && $TRAVIS_PYTHON_VERSION == '2.7' ]]; then ./package.sh $TRAVIS_BRANCH $TRAVIS_PYTHON_VERSION; fi

notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/b40202d91150d5c75582
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # default: false

deploy:
- provider: bintray
skip_cleanup: true
file: .bintray.json
user: ddurieux
key:
secure: "yuhgpgyEEvYnY1+a+Y68L7nFFUJYcSAOEo66pYis8ZduHN+1NWbynDdu7I/ndgk66iZOFA2XyVccE9kP0lLpAcQI2h8/nxFnydwzASJTusacgh/CJPrcNCbS+j/y7pWRDKkH9HRy9FWwx0DWm4PYiDe4kPVqsymuHV5eZmFpQfJMsc8e+/mfFJ2d7P0RC2fEEM1fpOhiVmL8WePmxLaNtoPudFeDHNVYd1ebNdDcmpsiLQeG/aRO2/kKGlbTREN+pm83VstwBOiVfiz3I3aj9EUz1XTTQUlVL9nTkNjwcmyF0YI5wR0ef6re0lDKrgISsRN3QP9/YJ0596k1CwRXr08vUKqMw2pZMAzNyJiyGTwus0+NN8zopLEz+ZfmRBViz/Qh8oTvgso9LQPzvy8LDEpfAzS9WHJFvkJm/SlT7VNHfJfh5SLuVWrt532Aqr6dhyuMBisQdwAo2Fo1DLkJDDDRAEiuJbceTZMYoQv29yTj81cVUmdCa67b9BrRbn+c//2xmZXpcbcyoEOjMBvIN1tlyvh7A/CoHflQak16TPfS5YkFDiy/2YTGi2aYlFVkdJwdU77By7IA2cGnupyywfOOxmLl1x/rnKfJ06G2vblBYSkBCiokO2pwArUZW2W5yVY7ycf/fMOiqKDpn2RJYqpeloeDf+c0aZFTmvzY4ug="
on:
branch: develop
- provider: bintray
skip_cleanup: true
file: .bintray.json
user: ddurieux
key:
secure: "yuhgpgyEEvYnY1+a+Y68L7nFFUJYcSAOEo66pYis8ZduHN+1NWbynDdu7I/ndgk66iZOFA2XyVccE9kP0lLpAcQI2h8/nxFnydwzASJTusacgh/CJPrcNCbS+j/y7pWRDKkH9HRy9FWwx0DWm4PYiDe4kPVqsymuHV5eZmFpQfJMsc8e+/mfFJ2d7P0RC2fEEM1fpOhiVmL8WePmxLaNtoPudFeDHNVYd1ebNdDcmpsiLQeG/aRO2/kKGlbTREN+pm83VstwBOiVfiz3I3aj9EUz1XTTQUlVL9nTkNjwcmyF0YI5wR0ef6re0lDKrgISsRN3QP9/YJ0596k1CwRXr08vUKqMw2pZMAzNyJiyGTwus0+NN8zopLEz+ZfmRBViz/Qh8oTvgso9LQPzvy8LDEpfAzS9WHJFvkJm/SlT7VNHfJfh5SLuVWrt532Aqr6dhyuMBisQdwAo2Fo1DLkJDDDRAEiuJbceTZMYoQv29yTj81cVUmdCa67b9BrRbn+c//2xmZXpcbcyoEOjMBvIN1tlyvh7A/CoHflQak16TPfS5YkFDiy/2YTGi2aYlFVkdJwdU77By7IA2cGnupyywfOOxmLl1x/rnKfJ06G2vblBYSkBCiokO2pwArUZW2W5yVY7ycf/fMOiqKDpn2RJYqpeloeDf+c0aZFTmvzY4ug="
on:
tags: true
4 changes: 2 additions & 2 deletions .pylintrc

Large diffs are not rendered by default.

128 changes: 110 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,140 @@
language: python
dist: trusty
sudo: required
python:
- "2.6"
- "2.7"

env:
- TEST_SUITE=unit
# Alignak daemons run tests
- TEST_SUITE=run
- TEST_SUITE=load
- TEST_SUITE=unit_tests
- TEST_SUITE=integration
- TEST_SUITE=codingstandard
- TEST_SUITE=virtualenv

matrix:
# fast_finish: true
allow_failures:
- python: "2.6"
exclude:
- python: "2.6"
env: TEST_SUITE=load
env: TEST_SUITE=integration
- python: "2.6"
env: TEST_SUITE=codingstandard
- python: "2.6"
env: TEST_SUITE=virtualenv

#services:
# - mongodb

# command to install dependencies
# some are only used for travis/coveralls so we are installing them here only
install:
# Remove python warnings
- unset PYTHONWARNINGS
# command to install dependencies
# some are only used for travis/coveralls so we are installing them here only
# - sudo apt-get install -y gdb # gdb debugger
- ./test/setup_test.sh
# some are specific for daemons run tests
- ./test_run/setup_test.sh

#before_script:
# - ulimit -c unlimited -S # enable core dumps

# command to run tests
script:
# so to help eventual debug: know what exact versions are in use can be rather useful.
# To help eventual debug, knowing which exact packages are installed can be rather useful ;)
- pip freeze
# run test suite (wait no more than 30 minutes)
- travis_wait 60 ./.travis/$TEST_SUITE.sh

# specific call to launch coverage data into coveralls.io
- |
if [[ $TEST_SUITE == 'virtualenv' ]]; then
# Virtual environment setup tests
./test/test_virtualenv_setup.sh || travis_terminate 1;
fi
- |
if [[ $TEST_SUITE == 'codingstandard' ]]; then
# Static code analysis
# -- pycodestyle (former pep8)
# Exclude the dictconfig.py vendor file
travis_wait 60 pycodestyle --max-line-length=100 --exclude='*.pyc,alignak/misc/dictconfig.py,alignak/misc/carboniface.py' alignak/* || travis_terminate 1;
# -- pylint
unset PYTHONWARNINGS
travis_wait 60 pylint --rcfile=.pylintrc -r no alignak || travis_terminate 1;
export PYTHONWARNINGS=all
# -- pep257
travis_wait 60 pep257 --select=D300 alignak || travis_terminate 1;
fi
- |
if [[ $TEST_SUITE == 'unit_tests' && $TRAVIS_PYTHON_VERSION == '2.7' ]]; then
# Run unit tests and code coverage analysis
cd test
# Run test suite with py.test running its coverage plugin
# Dump the 10 slowest tests
# Do not print log synthesis on test end
echo "Starting tests..."
pytest --verbose --durations=10 --no-print-logs --cov=alignak --cov-report term-missing --cov-config .coveragerc test_*.py || travis_terminate 1;
cd ..
cp test/.coverage .
# codecov
bash <(curl -s https://codecov.io/bash) -e TEST_SUITE
fi
- |
if [[ $TEST_SUITE == 'unit_tests' && $TRAVIS_PYTHON_VERSION == '2.6' ]]; then
# Run unit tests and code coverage analysis
cd test
# Run test suite with py.test running its coverage plugin
# Dump the 10 slowest tests
# Do not print log synthesis on test end
echo "Starting tests..."
pytest --verbose --durations=10 --cov=alignak --cov-report term-missing --cov-config .coveragerc test_*.py || travis_terminate 1;
cd ..
cp test/.coverage .
# codecov
bash <(curl -s https://codecov.io/bash) -e TEST_SUITE
fi
- |
if [[ $TEST_SUITE == 'integration' ]]; then
# Run load tests and code dynamic analysis
cd test_load
# Run test suite with py.test running its coverage plugin
# Dump the 10 slowest tests - do not capture to have some activity in Travis
travis_wait 60 pytest --durations=10 --no-print-logs --capture=no -s --cov=alignak --cov-config .coveragerc test_*.py || travis_terminate 1;
cd ..
cp test_load/.coverage .
# codecov
bash <(curl -s https://codecov.io/bash) -e TEST_SUITE
# Run load tests and code dynamic analysis
cd test_run
# Run test suite with py.test running its coverage plugin
# Dump the 10 slowest tests - do not capture to have some activity in Travis
travis_wait 60 pytest --durations=10 --no-print-logs --capture=no -s --cov=alignak --cov-config .coveragerc test_*.py || travis_terminate 1;
cd ..
cp test_run/.coverage .
# codecov
bash <(curl -s https://codecov.io/bash) -e TEST_SUITE
fi
after_failure:
- COREFILE=$(find . -maxdepth 1 -name "core*" | head -n 1) # find core file
- if [[ -f "$COREFILE" ]]; then gdb -c "$COREFILE" example -ex "thread apply all bt" -ex "set pagination 0" -batch; fi


after_success:
- echo "Test Success - Branch($TRAVIS_BRANCH) Pull Request($TRAVIS_PULL_REQUEST) Tag($TRAVIS_TAG)"
# Send coverage report only for the Python 2.7 unit tests
- if [[ $TEST_SUITE == 'unit' && $TRAVIS_PYTHON_VERSION == '2.7' ]]; then ./.travis/report_coveralls.sh; fi
- |
if [[ $TEST_SUITE == 'unit_tests' && $TRAVIS_PYTHON_VERSION == '2.7' ]]; then
# to get coverage data with relative paths and not absolute we have to
# execute coveralls from the base directory of the project,
# so we need to move the .coverage file here :
# mv test/.coverage ./coverage_unit
# mv test_load/.coverage ./coverage_load
# mv test_run/.coverage ./coverage_run
# Combine the coverage collected data
# coverage combine coverage_unit coverage_load coverage_run
echo "Submitting coverage results to coveralls.io..."
coveralls --rcfile=test/.coveragerc
echo "Submitted"
fi
- if [[ $TEST_SUITE == 'unit' && $TRAVIS_PYTHON_VERSION == '2.7' ]]; then ./package.sh $TRAVIS_BRANCH $TRAVIS_PYTHON_VERSION; fi

notifications:
Expand Down
7 changes: 6 additions & 1 deletion .travis/codingstandard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

set -ev

pycodestyle --max-line-length=100 --exclude='*.pyc' alignak/*
# Static code analysis
# -- pycodestyle (former pep8)
# Exclude the dictconfig.py vendor file
pycodestyle --max-line-length=100 --exclude='*.pyc,alignak/misc/dictconfig.py' alignak/*
# -- pylint
unset PYTHONWARNINGS
pylint --rcfile=.pylintrc -r no alignak
export PYTHONWARNINGS=all
# -- pep257
pep257 --select=D300 alignak
3 changes: 3 additions & 0 deletions .travis/load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ cd test_load
# Delete previously existing coverage results
coverage erase

# Setup test environment
./setup_test.sh

# Run test suite with py.test running its coverage plugin
pytest -v --cov=alignak --cov-config .coveragerc test_*.py

Expand Down
4 changes: 3 additions & 1 deletion .travis/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ set -ev

cd test_run

if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
# Setup test environment
./setup_test.sh

# Run test suite with py.test running its coverage plugin
# Dump the 10 slowest tests
pytest --durations=10 --cov=alignak --cov-report term-missing --cov-config .coveragerc test_*.py
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Please have a look to the `development`_ guidline before sumitting a pull request
Please have a look to the `development`_ guidline before submitting a pull request


.. _development: https://github.com/Alignak-monitoring/alignak/wiki
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ Presentation of the Alignak project
:alt: Development code tests coverage

.. image:: https://readthedocs.org/projects/alignak-doc/badge/?version=latest
:target: http://alignak-doc.readthedocs.org/en/latest/?badge=latest
:target: http://alignak-doc.readthedocs.org/en/latest
:alt: Lastest documentation Status

.. image:: https://readthedocs.org/projects/alignak-doc/badge/?version=develop
:target: http://alignak-doc.readthedocs.org/en/update/?badge=develop
:target: http://alignak-doc.readthedocs.org/en/develop
:alt: Development branch documentation Status

.. image:: https://img.shields.io/badge/IRC-%23alignak-1e72ff.svg?style=flat
Expand Down
2 changes: 1 addition & 1 deletion alignak/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2016: Alignak team, see AUTHORS.txt file for contributors
# Copyright (C) 2015-2018: Alignak team, see AUTHORS.txt file for contributors
#
# This file is part of Alignak.
#
Expand Down
2 changes: 1 addition & 1 deletion alignak/acknowledge.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2016: Alignak team, see AUTHORS.txt file for contributors
# Copyright (C) 2015-2018: Alignak team, see AUTHORS.txt file for contributors
#
# This file is part of Alignak.
#
Expand Down
22 changes: 11 additions & 11 deletions alignak/action.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2016: Alignak team, see AUTHORS.txt file for contributors
# Copyright (C) 2015-2018: Alignak team, see AUTHORS.txt file for contributors
#
# This file is part of Alignak.
#
Expand Down Expand Up @@ -100,7 +100,7 @@ def no_block_read(output):
fcntl.fcntl(o_fd, fcntl.F_SETFL, o_fl | os.O_NONBLOCK)
try:
return output.read()
except Exception: # pylint: disable=W0703
except Exception: # pylint: disable=broad-except
return ''


Expand Down Expand Up @@ -160,7 +160,7 @@ def __init__(self, params=None, parsing=True):
self.creation_time = time.time()
# Set actions log only if not provided
if not params or 'log_actions' not in params:
self.log_actions = 'TEST_LOG_ACTIONS' in os.environ
self.log_actions = 'ALIGNAK_LOG_ACTIONS' in os.environ

# Fill default parameters
self.fill_default()
Expand Down Expand Up @@ -213,7 +213,7 @@ def execute(self):

logger.debug("Launch command: '%s', ref: %s", self.command, self.ref)
if self.log_actions:
if os.environ['TEST_LOG_ACTIONS'] == 'WARNING':
if os.environ['ALIGNAK_LOG_ACTIONS'] == 'WARNING':
logger.warning("Launch command: '%s'", self.command)
else:
logger.info("Launch command: '%s'", self.command)
Expand Down Expand Up @@ -276,7 +276,7 @@ def get_outputs(self, out, max_plugins_output_length):
logger.debug("Command result for '%s': %d, %s",
self.command, self.exit_status, self.output)
if self.log_actions:
if os.environ['TEST_LOG_ACTIONS'] == 'WARNING':
if os.environ['ALIGNAK_LOG_ACTIONS'] == 'WARNING':
logger.warning("Check result for '%s': %d, %s",
self.command, self.exit_status, self.output)
if self.perf_data:
Expand Down Expand Up @@ -330,7 +330,7 @@ def check_finished(self, max_plugins_output_length):
self.u_time = n_child_utime - child_utime
self.s_time = n_child_stime - child_stime
if self.log_actions:
if os.environ['TEST_LOG_ACTIONS'] == 'WARNING':
if os.environ['ALIGNAK_LOG_ACTIONS'] == 'WARNING':
logger.warning("Action '%s' exited on timeout (%d s)",
self.command, self.timeout)
else:
Expand All @@ -353,7 +353,7 @@ def check_finished(self, max_plugins_output_length):

self.exit_status = self.process.returncode
if self.log_actions:
if os.environ['TEST_LOG_ACTIONS'] == 'WARNING':
if os.environ['ALIGNAK_LOG_ACTIONS'] == 'WARNING':
logger.warning("Action '%s' exited with return code %d",
self.command, self.exit_status)
else:
Expand Down Expand Up @@ -478,7 +478,7 @@ def execute__(self, force_shell=sys.version_info < (2, 7)):
else:
try:
cmd = shlex.split(self.command.encode('utf8', 'ignore'))
except Exception as exp: # pylint: disable=W0703
except Exception as exp: # pylint: disable=broad-except
self.output = 'Not a valid shell command: ' + exp.__str__()
self.exit_status = 3
self.status = 'done'
Expand Down Expand Up @@ -518,7 +518,7 @@ def execute__(self, force_shell=sys.version_info < (2, 7)):
if exp.errno == 24 and exp.strerror == 'Too many open files':
return 'toomanyopenfiles'
return 'process_launch_failed'
except Exception as exp: # pylint: disable=W0703
except Exception as exp: # pylint: disable=broad-except
logger.error("Fail launching command: %s, force shell: %s, exception: %s",
self.command, force_shell, exp)
return 'process_launch_failed'
Expand All @@ -540,7 +540,7 @@ def kill__(self):
for file_d in [self.process.stdout, self.process.stderr]:
try:
file_d.close()
except Exception as exp: # pylint: disable=W0703
except Exception as exp: # pylint: disable=broad-except
logger.error("Exception stopping command: %s %s",
self.command, exp)

Expand Down Expand Up @@ -568,7 +568,7 @@ def execute__(self, force_shell=False):
else:
try:
cmd = shlex.split(self.command.encode('utf8', 'ignore'))
except Exception, exp: # pylint: disable=W0703
except Exception as exp: # pylint: disable=broad-except
self.output = 'Not a valid shell command: ' + exp.__str__()
self.exit_status = 3
self.status = 'done'
Expand Down
Loading

0 comments on commit 218a918

Please sign in to comment.