Skip to content

Commit

Permalink
Merge pull request #836 from Alignak-monitoring/more-run-tests
Browse files Browse the repository at this point in the history
Add more tests for daemons run
  • Loading branch information
ddurieux authored Jun 24, 2017
2 parents 024fa08 + d36884d commit 38b183e
Show file tree
Hide file tree
Showing 146 changed files with 5,612 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ install:
# command to install dependencies
# some are only used for travis/coveralls so we are installing them here only
- ./test/setup_test.sh
# some are specific for daemons run tests
- ./test_run/setup_test.sh

# command to run tests
script:
Expand Down
12 changes: 9 additions & 3 deletions alignak/basemodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ def start(self, http_daemon=None): # pylint: disable=W0613

if not self.is_external:
return
self.stop_process()

if self.process:
self.stop_process()
logger.info("Starting external process for module %s...", self.alias)
proc = Process(target=self.start_module, args=())

Expand Down Expand Up @@ -336,16 +338,20 @@ def manage_brok(self, brok):

def manage_signal(self, sig, frame): # pylint: disable=W0613
"""Generic function to handle signals
Set interrupted attribute to True and return
Only called when the module process received SIGINT or SIGKILL.
Set interrupted attribute to True, self.process to None and returns
:param sig: signal sent
:type sig:
:param frame: frame before catching signal
:type frame:
:return: None
"""
logger.info("process %d received a signal: %s", os.getpid(), str(sig))
logger.info("Process for module %s received a signal: %s", self.alias, str(sig))
self.interrupted = True
self.process = None

def set_signal_handler(self, sigs=None):
"""Set the signal handler function (manage_signal)
Expand Down
2 changes: 0 additions & 2 deletions test/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ pep8
pep257
# Tests time freeze
freezegun
# Alignak modules and checks packs installer
#alignak_setup
# Alignak example module (develop branch)
-e git+git://github.com/Alignak-monitoring/alignak-module-example.git@develop#egg=alignak-module-example
ordereddict==1.1
Expand Down
12 changes: 10 additions & 2 deletions test/test_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,24 @@ def test_realms_with_sub(self):
"""
self.print_header()
self.setup_with_file('cfg/cfg_dispatcher_realm_with_sub.cfg')
# Got 3 realms
assert 3 == len(self.arbiter.dispatcher.realms)
for realm in self.arbiter.dispatcher.realms:
assert 1 == len(realm.confs)
for cfg in realm.confs.values():
assert cfg.is_assigned
# 3 schedulers
assert 3 == len(self.arbiter.dispatcher.schedulers)
assert 10 == len(self.arbiter.dispatcher.satellites), \
self.arbiter.dispatcher.satellites
for satellite in self.arbiter.dispatcher.satellites:
print("Satellite: %s" % (satellite))
# 2 reactionners
# 3 pollers
# 3 receivers
# 2 brokers
assert 10 == len(self.arbiter.dispatcher.satellites), self.arbiter.dispatcher.satellites

for satellite in self.arbiter.dispatcher.satellites:
print("Satellite: %s, schedulers: %s" % (satellite, satellite.cfg['schedulers']))
if satellite.get_name() in ['poller-master', 'reactionner-master', 'broker-master']:
assert {} != satellite.cfg['schedulers'], satellite.get_name()
assert 2 == len(satellite.cfg['schedulers']), \
Expand Down
271 changes: 271 additions & 0 deletions test_run/cfg/run_daemons_backend/alignak.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
# --------------------------------------------------------------------
# Alignak main configuration file
# --------------------------------------------------------------------
# This file is the main file that will be loaded by Alignak on boot.
# It is the entry point for the framework configuration.
# --------------------------------------------------------------------
# Please see the official project documentation for documentation about
# the configuration:
# http://alignak-doc.readthedocs.io/en/latest/04_configuration/index.html
# --------------------------------------------------------------------

# -------------------------------------------------------------------------
# Monitored objects configuration part
# -------------------------------------------------------------------------
# Configuration files with common objects like commands, timeperiods,
# or templates that are used by the host/service/contacts
; When loading data only from the alignak backend, comment this
; block because data do not need to be read from files
cfg_dir=arbiter/objects/realms
cfg_dir=arbiter/objects/commands
cfg_dir=arbiter/objects/timeperiods
cfg_dir=arbiter/objects/escalations
cfg_dir=arbiter/objects/dependencies

# Templates and packs for hosts, services and contacts
; When loading data only from the alignak backend, comment this
; block because data do not need to be read from files
cfg_dir=arbiter/templates
cfg_dir=arbiter/packs

# Notification ways
; When loading data only from the alignak backend, comment this
; block because data do not need to be read from files
cfg_dir=arbiter/objects/notificationways

# Groups
; When loading data only from the alignak backend, comment this
; block because data do not need to be read from files
cfg_dir=arbiter/objects/servicegroups
cfg_dir=arbiter/objects/hostgroups
cfg_dir=arbiter/objects/contactgroups

# Real hosts, services and contacts
; When loading data only from the alignak backend, comment this
; block because data do not need to be read from files
cfg_dir=arbiter/objects/hosts
cfg_dir=arbiter/objects/services
cfg_dir=arbiter/objects/contacts

# Alignak daemons and modules are loaded
cfg_dir=arbiter/daemons
cfg_dir=arbiter/modules

# You will find global MACROS into the files in those directories
cfg_dir=arbiter/resource.d
cfg_dir=arbiter/packs/resource.d

# -------------------------------------------------------------------------
# Alignak framework configuration part
# -------------------------------------------------------------------------

# Alignak instance name
# This information is useful to get/store alignak global configuration in the Alignak backend
# If you share the same backend between several Alignak instances, each instance must have its own
# name. The default is to use the arbiter name as Alignak instance name. Else, you can can define
# your own Alignak instance name in this property
# alignak_name=my_alignak

# Notifications configuration
# ---
# Notifications are enabled/disabled
# enable_notifications=1

# After a timeout, launched plugins are killed
#notification_timeout=30


# Retention configuration
# ---
# Number of minutes between 2 retention save, default is 60 minutes
#retention_update_interval=60

# Checks configuration
# ---
# Active host/service checks are enabled/disabled
#execute_host_checks=1
#execute_service_checks=1

# Passive host/service checks are enabled/disabled
#accept_passive_host_checks=1
#accept_passive_service_checks=1

# As default, passive host checks are HARD states
#passive_host_checks_are_soft=0


# Interval length and re-scheduling configuration
# Do not change those values unless you are reaaly sure to master what you are doing ...
#interval_length=60
#auto_reschedule_checks=1
auto_rescheduling_interval=1
auto_rescheduling_window=180


# Number of interval to spread the first checks for hosts and services
# Default is 30
#max_service_check_spread=30
max_service_check_spread=5
# Default is 30
#max_host_check_spread=30
max_host_check_spread=5


# Max plugin output for the plugins launched by the pollers, in bytes
#max_plugins_output_length=8192
max_plugins_output_length=65536


# After a timeout, launched plugins are killed
# and the host state is set to a default value (2 for DOWN)
# and the service state is set to a default value (2 for CRITICAL)
#host_check_timeout=30
#service_check_timeout=60
#timeout_exit_status=2


# Freshness check
# Default is enabled for hosts and services
#check_host_freshness=1
#check_service_freshness=1
# Default is 60 for hosts and services
#host_freshness_check_interval=60
#service_freshness_check_interval=60
# Extra time for freshness check ...
#additional_freshness_latency=15


# Flapping detection configuration
# ---
# Default is enabled
#enable_flap_detection=1

# Flapping threshold for hosts and services
#low_service_flap_threshold=20
#high_service_flap_threshold=30
#low_host_flap_threshold=20
#high_host_flap_threshold=30

# flap_history is the lengh of history states we keep to look for flapping.
# 20 by default, can be useful to increase it. Each flap_history increases cost:
# flap_history cost = 4Bytes * flap_history * (nb hosts + nb services)
# Example: 4 * 20 * (1000+10000) ~ 900Ko for a quite big conf. So, go for it!
#flap_history=20


# Performance data configuration
# ---
# Performance data management is enabled/disabled
#process_performance_data=1


# Event handlers configuration
# ---
# Event handlers are enabled/disabled
#enable_event_handlers=1

# By default don't launch even handlers during downtime. Put 0 to
# get back the default nagios behavior
no_event_handlers_during_downtimes=1

# Global host/service event handlers
#global_host_event_handler=
#global_service_event_handler=

# After a timeout, launched plugins are killed
#event_handler_timeout=30


# External commands configuration
# ---
# External commands are enabled/disabled
# check_external_commands=1

# By default don't launch even handlers during downtime. Put 0 to
# get back the default nagios behavior
no_event_handlers_during_downtimes=1


# Impacts configuration
# ---
# Enable or not the state change on impact detection (like a host going unreachable
# if a parent is DOWN for example). It's for services and hosts.
# Note: defaults to 0 for Nagios old behavior compatibility
#enable_problem_impacts_states_change=0
enable_problem_impacts_states_change=1


# if 1, disable all notice and warning messages at
# configuration checking when arbiter checks the configuration.
# Default is to log the notices and warnings
#disable_old_nagios_parameters_whining=0
disable_old_nagios_parameters_whining=1


# Environment macros configuration
# ---
# Disabling environment macros is good for performance. If you really need it, enable it.
#enable_environment_macros=1
enable_environment_macros=0


# Monitoring log configuration
# ---
# Note that alerts and downtimes are always logged
# ---
# Notifications
# log_notifications=1

# Services retries
# log_service_retries=1

# Hosts retries
# log_host_retries=1

# Event handlers
# log_event_handlers=1

# Flappings
# log_flappings=1

# Snapshots
# log_snapshots=1

# External commands
# log_external_commands=1

# Active checks
# log_active_checks=0

# Passive checks
# log_passive_checks=0

# Initial states
# log_initial_states=1


# [Optional], a pack distribution file is a local file near the arbiter
# that will keep host pack id association, and so push same host on the same
# scheduler if possible between restarts.
pack_distribution_file=/usr/local/var/lib/alignak/pack_distribution.dat


# If you need to set a specific timezone to your deamons, uncomment it
#use_timezone=Europe/Paris


# Export all alignak inner performances into a statsd server.
# By default at localhost:8125 (UDP) with the alignak prefix
# Default is not enabled
#statsd_host=localhost
#statsd_port=8125
#statsd_prefix=alignak
#statsd_enabled=0


# --------------------------------------------------------------------
## Arbiter daemon part, similar to daemon ini file
# --------------------------------------------------------------------
#
# Those parameters are defined in the arbiterd.ini file
#
Loading

0 comments on commit 38b183e

Please sign in to comment.