2017-03-09 19:28:13 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
2018-05-28 21:13:12 +00:00
|
|
|
:codeauthor: Pedro Algarvio (pedro@algarvio.me)
|
2017-06-05 23:07:58 +00:00
|
|
|
:copyright: Copyright 2017 by the SaltStack Team, see AUTHORS for more details.
|
2017-03-09 19:28:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
tests.unit.beacons.test_status
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Status beacon test cases
|
|
|
|
'''
|
|
|
|
|
|
|
|
# Python libs
|
|
|
|
from __future__ import absolute_import
|
2017-09-25 21:06:44 +00:00
|
|
|
import sys
|
2017-03-09 19:28:13 +00:00
|
|
|
|
|
|
|
# Salt libs
|
|
|
|
import salt.config
|
|
|
|
import salt.loader
|
|
|
|
from salt.beacons import status
|
2017-03-21 17:15:36 +00:00
|
|
|
import salt.modules.status as status_module
|
2017-03-09 19:28:13 +00:00
|
|
|
|
|
|
|
# Salt testing libs
|
|
|
|
from tests.support.unit import TestCase
|
|
|
|
from tests.support.mixins import LoaderModuleMockMixin
|
|
|
|
|
|
|
|
|
|
|
|
class StatusBeaconTestCase(TestCase, LoaderModuleMockMixin):
|
|
|
|
'''
|
|
|
|
Test case for salt.beacons.status
|
|
|
|
'''
|
|
|
|
|
2017-03-22 12:12:36 +00:00
|
|
|
def setup_loader_modules(self):
|
2017-03-09 19:28:13 +00:00
|
|
|
opts = salt.config.DEFAULT_MINION_OPTS
|
2017-03-22 12:12:36 +00:00
|
|
|
module_globals = {
|
2017-03-09 19:28:13 +00:00
|
|
|
'__opts__': opts,
|
|
|
|
'__salt__': 'autoload',
|
|
|
|
'__context__': {},
|
|
|
|
'__grains__': {'kernel': 'Linux'}
|
|
|
|
}
|
2017-03-22 12:12:36 +00:00
|
|
|
return {
|
|
|
|
status: module_globals,
|
|
|
|
status_module: module_globals
|
|
|
|
}
|
2017-03-09 19:28:13 +00:00
|
|
|
|
|
|
|
def test_empty_config(self, *args, **kwargs):
|
|
|
|
config = {}
|
|
|
|
ret = status.beacon(config)
|
2017-09-25 21:06:44 +00:00
|
|
|
|
|
|
|
if sys.platform.startswith('win'):
|
|
|
|
expected = []
|
|
|
|
else:
|
|
|
|
expected = sorted(['loadavg', 'meminfo', 'cpustats', 'vmstats', 'time'])
|
|
|
|
|
|
|
|
self.assertEqual(sorted(list(ret[0]['data'])), expected)
|
2017-03-09 19:28:13 +00:00
|
|
|
|
|
|
|
def test_deprecated_dict_config(self):
|
|
|
|
config = {'time': ['all']}
|
|
|
|
ret = status.beacon(config)
|
2017-09-25 21:06:44 +00:00
|
|
|
|
|
|
|
if sys.platform.startswith('win'):
|
|
|
|
expected = []
|
|
|
|
else:
|
|
|
|
expected = ['time']
|
|
|
|
|
|
|
|
self.assertEqual(list(ret[0]['data']), expected)
|
2017-03-09 19:28:13 +00:00
|
|
|
|
|
|
|
def test_list_config(self):
|
|
|
|
config = [{'time': ['all']}]
|
|
|
|
ret = status.beacon(config)
|
2017-09-25 21:06:44 +00:00
|
|
|
|
|
|
|
if sys.platform.startswith('win'):
|
|
|
|
expected = []
|
|
|
|
else:
|
|
|
|
expected = ['time']
|
|
|
|
|
|
|
|
self.assertEqual(list(ret[0]['data']), expected)
|