Skip to content

Commit fcaff23

Browse files
committed
Python3 version:
- trying to clean some broken tests on Python 3 - pylint - fixes in the downtimes notifications
1 parent 1f21d78 commit fcaff23

File tree

315 files changed

+16292
-1405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

315 files changed

+16292
-1405
lines changed

.former_travis.yml

-69
This file was deleted.

.landscape.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ ignore-paths:
2020
- doc
2121
- etc
2222
- test
23+
- test_load
24+
- test_run
2325
ignore-patterns:
2426
# This file is only defining the imported Alignak version
2527
- alignak/__init__.py
2628
# This file is necessary because imported by daemons but it does not use imported packages...
2729
- alignak/objects/__init__.py
28-
# This file is for setup only and not yet pep8/pylint compliant
29-
- install_hooks.py

.travis.yml

+20-27
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,24 @@ env:
1515
install:
1616
# Remove python warnings
1717
- unset PYTHONWARNINGS
18-
# - sudo apt-get install -y gdb # gdb debugger
1918
- ./test/setup_test.sh
2019

21-
#before_script:
22-
# - ulimit -c unlimited -S # enable core dumps
23-
2420
# command to run tests
2521
script:
2622
# To help eventual debug, knowing which exact packages are installed can be rather useful ;)
2723
- pip freeze
2824

29-
# - |
30-
# if [[ $TEST_SUITE == 'virtualenv' ]]; then
31-
# # Virtual environment setup tests
32-
# ./test/test_virtualenv_setup.sh || travis_terminate 1;
33-
# fi
34-
3525
- |
3626
if [[ $TEST_SUITE == 'codingstandard' ]]; then
3727
# Static code analysis
3828
# -- pycodestyle (former pep8)
39-
# Exclude the dictconfig.py vendor file
40-
travis_wait 60 pycodestyle --max-line-length=100 --exclude='*.pyc,alignak/misc/dictconfig.py,alignak/misc/carboniface.py' alignak/* || travis_terminate 1;
29+
pycodestyle --max-line-length=100 --exclude='*.pyc,alignak/misc/carboniface.py' alignak/*
4130
# -- pylint
4231
unset PYTHONWARNINGS
43-
travis_wait 60 pylint --rcfile=.pylintrc -r no alignak || travis_terminate 1;
32+
pylint --rcfile=.pylintrc -r no alignak
4433
export PYTHONWARNINGS=all
4534
# -- pep257
46-
travis_wait 60 pep257 --select=D300 alignak || travis_terminate 1;
35+
pep257 --select=D300 alignak
4736
fi
4837
4938
- |
@@ -53,6 +42,7 @@ script:
5342
# Run test suite with py.test running its coverage plugin
5443
# Dump the 10 slowest tests
5544
# Do not print log synthesis on test end
45+
# Get coverage on tests run
5646
echo "Starting tests..."
5747
pytest --verbose --durations=10 --no-print-logs --cov=alignak --cov-report term-missing --cov-config .coveragerc test_*.py || travis_terminate 1;
5848
cd ..
@@ -75,14 +65,14 @@ script:
7565
bash <(curl -s https://codecov.io/bash) -e TEST_SUITE
7666
7767
# Run load tests and code dynamic analysis
78-
cd test_run
79-
# Run test suite with py.test running its coverage plugin
80-
# Dump the 10 slowest tests - do not capture to have some activity in Travis
81-
travis_wait 60 pytest --durations=10 --no-print-logs --capture=no -s --cov=alignak --cov-config .coveragerc test_*.py || travis_terminate 1;
82-
cd ..
83-
cp test_run/.coverage .
84-
# codecov
85-
bash <(curl -s https://codecov.io/bash) -e TEST_SUITE
68+
# cd test_run
69+
# # Run test suite with py.test running its coverage plugin
70+
# # Dump the 10 slowest tests - do not capture to have some activity in Travis
71+
# travis_wait 60 pytest --durations=10 --no-print-logs --capture=no -s --cov=alignak --cov-config .coveragerc test_*.py || travis_terminate 1;
72+
# cd ..
73+
# cp test_run/.coverage .
74+
# # codecov
75+
# bash <(curl -s https://codecov.io/bash) -e TEST_SUITE
8676
fi
8777
8878
after_success:
@@ -91,18 +81,21 @@ after_success:
9181
# to get coverage data with relative paths and not absolute we have to
9282
# execute coveralls from the base directory of the project,
9383
# so we need to move the .coverage file here :
94-
# mv test/.coverage ./coverage_unit
95-
# mv test_load/.coverage ./coverage_load
96-
# mv test_run/.coverage ./coverage_run
84+
mv test/.coverage ./coverage_unit
85+
mv test_load/.coverage ./coverage_load
86+
mv test_run/.coverage ./coverage_run
9787
# Combine the coverage collected data
98-
# coverage combine coverage_unit coverage_load coverage_run
88+
coverage combine coverage_unit coverage_load coverage_run
9989
10090
echo "Submitting coverage results to coveralls.io..."
10191
coveralls --rcfile=test/.coveragerc
10292
echo "Submitted"
10393
fi
10494
105-
- if [[ $TEST_SUITE == 'unit' && $TRAVIS_PYTHON_VERSION == '2.7' ]]; then ./package.sh $TRAVIS_BRANCH $TRAVIS_PYTHON_VERSION; fi
95+
- |
96+
if [[ $TEST_SUITE == 'unit_tests' ]]; then
97+
./package.sh $TRAVIS_BRANCH $TRAVIS_PYTHON_VERSION;
98+
fi
10699
107100
notifications:
108101
webhooks:

.travis/codingstandard.sh

-14
This file was deleted.

.travis/load.sh

-17
This file was deleted.

.travis/report_coveralls.sh

-13
This file was deleted.

.travis/run.sh

-19
This file was deleted.

.travis/unit.sh

-18
This file was deleted.

.travis/virtualenv.sh

-5
This file was deleted.

alignak/brok.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"""
5151
import time
5252
from datetime import datetime
53-
import uuid
5453

5554
from alignak.alignakobject import get_a_new_object_id
5655
from alignak.misc.serialization import serialize, unserialize, AlignakClassLookupException
@@ -87,6 +86,7 @@ class Brok(object):
8786
my_type = 'brok'
8887

8988
def __init__(self, params, parsing=True):
89+
# pylint: disable=unused-argument
9090
"""
9191
:param params: initialization parameters
9292
:type params: dict

alignak/daemons/schedulerdaemon.py

+8
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ def get_daemon_stats(self, details=False):
507507
res.update({'name': self.name, 'type': self.type, 'monitored_objects': {}})
508508

509509
counters = res['counters']
510+
511+
# Satellites counters
510512
counters['brokers'] = len(self.brokers)
511513
counters['pollers'] = len(self.pollers)
512514
counters['reactionners'] = len(self.reactionners)
@@ -515,6 +517,12 @@ def get_daemon_stats(self, details=False):
515517
if not self.sched:
516518
return res
517519

520+
# Hosts/services problems counters
521+
counters['hosts_problems'] = m_solver._get_total_host_problems()
522+
counters['hosts_unhandled_problems'] = m_solver._get_total_host_problems_unhandled()
523+
counters['services_problems'] = m_solver._get_total_service_problems()
524+
counters['services_unhandled_problems'] = m_solver._get_total_service_problems_unhandled()
525+
518526
# Get statistics from the scheduler
519527
scheduler_stats = self.sched.get_scheduler_stats(details=details)
520528
res['counters'].update(scheduler_stats['counters'])

alignak/downtime.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -231,35 +231,37 @@ def exit(self, timeperiods, hosts, services):
231231
item = hosts[self.ref]
232232
else:
233233
item = services[self.ref]
234+
234235
broks = []
236+
# If not is_in_effect means that ot was probably a flexible downtime which was
237+
# not triggered. In this case, nothing special to do...
235238
if self.is_in_effect is True:
236239
# This was a fixed or a flexible+triggered downtime
237240
self.is_in_effect = False
238241
item.scheduled_downtime_depth -= 1
239242
if item.scheduled_downtime_depth == 0:
240243
item.raise_exit_downtime_log_entry()
241-
notif_period = timeperiods[item.notification_period]
244+
notification_period = timeperiods[item.notification_period]
242245
# Notification author data
243246
# todo: note that alias and name are not implemented yet
244247
author_data = {
245-
'author': self.author, u'author_name': 'Not available',
248+
'author': self.author, 'author_name': u'Not available',
246249
'author_alias': u'Not available', 'author_comment': self.comment
247250
}
248-
item.create_notifications('DOWNTIMEEND', notif_period, hosts, services,
251+
item.create_notifications(u'DOWNTIMEEND', notification_period, hosts, services,
249252
author_data=author_data)
250253
item.in_scheduled_downtime = False
251254
if self.ref in hosts:
252255
broks.append(self.get_expire_brok(item.get_name()))
253256
else:
254257
broks.append(self.get_expire_brok(item.host_name, item.get_name()))
255-
else:
256-
# This was probably a flexible downtime which was not triggered
257-
# In this case it silently disappears
258-
pass
258+
259259
item.del_comment(self.comment_id)
260260
self.can_be_deleted = True
261-
# when a downtime ends and the service was critical
262-
# a notification is sent with the next critical check
261+
262+
# when a downtime ends and the concerned item was a problem
263+
# a notification should be sent with the next critical check
264+
263265
# So we should set a flag here which informs the consume_result function
264266
# to send a notification
265267
item.in_scheduled_downtime_during_last_check = True

alignak/http/arbiter_interface.py

+23
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,29 @@ def wait_new_conf(self):
244244
logger.warning("My master Arbiter wants me to wait for a new configuration.")
245245
self.app.cur_conf = {}
246246

247+
@cherrypy.expose
248+
@cherrypy.tools.json_out()
249+
def get_alignak_status(self, details=False):
250+
"""Get the overall alignak status
251+
252+
Returns a list of the satellites as in:
253+
{
254+
'scheduler': ['Scheduler1']
255+
'poller': ['Poller1', 'Poller2']
256+
...
257+
}
258+
259+
:param details: Details are required (different from 0)
260+
:type details str
261+
262+
:return: dict with key *daemon_type* and value list of daemon name
263+
:rtype: dict
264+
"""
265+
if details is not False:
266+
details = bool(details)
267+
268+
return self.app.push_passive_check(details=details)
269+
247270
@cherrypy.expose
248271
@cherrypy.tools.json_out()
249272
def get_satellites_list(self, daemon_type=''):

alignak/http/daemon.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def __init__(self, host, port, http_interface, use_ssl, ca_cert,
101101
# - socket_queue_size
102102
cherrypy.config.update({'engine.autoreload.on': False,
103103
'server.thread_pool': thread_pool_size,
104-
'server.socket_host': self.host.encode('utf-8'),
104+
# 'server.socket_host': self.host.encode('utf-8'),
105+
'server.socket_host': self.host,
105106
'server.socket_port': self.port})
106107

107108
# Default is to disable CherryPy logging

0 commit comments

Comments
 (0)