Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix condition for replication status #8475

Merged
merged 2 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mysql/datadog_checks/mysql/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def _check_replication_status(self, results):
if not slave_io_running and not slave_sql_running:
self.log.debug("Slave_IO_Running and Slave_SQL_Running are not ok")
slave_running_status = AgentCheck.CRITICAL
if not slave_io_running or not slave_sql_running:
elif not slave_io_running or not slave_sql_running:
self.log.debug("Either Slave_IO_Running or Slave_SQL_Running are not ok")
slave_running_status = AgentCheck.WARNING

Expand Down
25 changes: 25 additions & 0 deletions mysql/tests/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,31 @@ def cursor(self):
assert v.build == 'log'


@pytest.mark.unit
@pytest.mark.parametrize(
'slave_io_running, slave_sql_running, check_status',
[
pytest.param({}, {}, MySql.CRITICAL),
pytest.param({'stuff': 'yes'}, {}, MySql.WARNING),
pytest.param({}, {'stuff': 'yes'}, MySql.WARNING),
pytest.param({'stuff': 'yes'}, {'stuff': 'yes'}, MySql.OK),
],
)
def test_replication_check_status(slave_io_running, slave_sql_running, check_status, instance_basic, aggregator):
mysql_check = MySql(common.CHECK_NAME, {}, instances=[instance_basic])
mysql_check.service_check_tags = ['foo:bar']
mocked_results = {
'Slaves_connected': 1,
'Binlog_enabled': True,
'Slave_IO_Running': slave_io_running,
'Slave_SQL_Running': slave_sql_running,
}

mysql_check._check_replication_status(mocked_results)

aggregator.assert_service_check('mysql.replication.slave_running', check_status, tags=['foo:bar'], count=1)


@pytest.mark.integration
@pytest.mark.usefixtures('dd_environment')
def test_version_metadata(instance_basic, datadog_agent, version_metadata):
Expand Down