mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
loader test for custom grains
This commit is contained in:
parent
af6d37caaf
commit
f13e9435b1
@ -765,7 +765,8 @@ class TestDaemon(object):
|
||||
if sync_needed:
|
||||
# Wait for minions to "sync_all"
|
||||
for target in [self.sync_minion_modules,
|
||||
self.sync_minion_states]:
|
||||
self.sync_minion_states,
|
||||
self.sync_minion_grains]:
|
||||
sync_minions = MultiprocessingProcess(
|
||||
target=target,
|
||||
args=(self.minion_targets, self.MINIONS_SYNC_TIMEOUT)
|
||||
@ -1021,6 +1022,9 @@ class TestDaemon(object):
|
||||
salt.utils.appendproctitle('SyncMinionModules')
|
||||
self.sync_minion_modules_('modules', targets, timeout=timeout)
|
||||
|
||||
def sync_minion_grains(self, targets, timeout=None):
|
||||
self.sync_minion_modules_('grains', targets, timeout=timeout)
|
||||
|
||||
|
||||
class AdaptedConfigurationTestCaseMixIn(object):
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
def myfunction():
|
||||
grains = {}
|
||||
grains['a_custom'] = {'k1': 'v1'}
|
||||
return grains
|
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
def myfunction():
|
||||
grains = {}
|
||||
grains['a_custom'] = {'k2': 'v2'}
|
||||
return grains
|
42
tests/integration/loader/ext_grains.py
Normal file
42
tests/integration/loader/ext_grains.py
Normal file
@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
integration.loader.ext_grains
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test Salt's loader regarding external grains
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import Salt Testing libs
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
ensure_in_syspath('../')
|
||||
|
||||
# Import salt libs
|
||||
import integration
|
||||
from salt.config import minion_config
|
||||
|
||||
from salt.loader import grains
|
||||
|
||||
|
||||
class LoaderGrainsTest(integration.ModuleCase):
|
||||
'''
|
||||
Test the loader standard behavior with external grains
|
||||
'''
|
||||
|
||||
def setUp(self):
|
||||
self.opts = minion_config(None)
|
||||
self.opts['disable_modules'] = ['pillar']
|
||||
self.opts['grains'] = grains(self.opts)
|
||||
|
||||
def test_grains_overwrite(self):
|
||||
grains = self.run_function('grains.items')
|
||||
|
||||
# Check that custom grains are overwritten
|
||||
self.assertEqual({'k2': 'v2'}, grains['a_custom'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
run_tests(LoaderGrainsTest)
|
Loading…
Reference in New Issue
Block a user