mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Terminate master and minion processes after tests are finished.
This commit is contained in:
parent
8a2138ff40
commit
099470ab37
2 changed files with 18 additions and 11 deletions
|
@ -10,10 +10,10 @@ import saltunittest
|
|||
TEST_DIR = os.path.dirname(os.path.normpath(os.path.abspath(__file__)))
|
||||
|
||||
def main():
|
||||
saltunittest.TestDaemon()
|
||||
loader = saltunittest.TestLoader()
|
||||
tests = loader.discover(os.path.join(TEST_DIR, 'modules'), '*.py')
|
||||
saltunittest.TextTestRunner(verbosity=1).run(tests)
|
||||
with saltunittest.TestDaemon():
|
||||
loader = saltunittest.TestLoader()
|
||||
tests = loader.discover(os.path.join(TEST_DIR, 'modules'), '*.py')
|
||||
saltunittest.TextTestRunner(verbosity=1).run(tests)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -45,7 +45,8 @@ class TestDaemon(object):
|
|||
'''
|
||||
Set up the master and minion daemons, and run related cases
|
||||
'''
|
||||
def __init__(self):
|
||||
|
||||
def __enter__(self):
|
||||
'''
|
||||
Start a master and minion
|
||||
'''
|
||||
|
@ -59,18 +60,24 @@ class TestDaemon(object):
|
|||
minion_opts['extension_modules'],
|
||||
master_opts['sock_dir'],
|
||||
])
|
||||
# Start the master
|
||||
|
||||
master = salt.master.Master(master_opts)
|
||||
multiprocessing.Process(target=master.start).start()
|
||||
# Start the minion
|
||||
self.master_process = multiprocessing.Process(target=master.start)
|
||||
self.master_process.start()
|
||||
|
||||
minion = salt.minion.Minion(minion_opts)
|
||||
multiprocessing.Process(target=minion.tune_in).start()
|
||||
self.minion_process = multiprocessing.Process(target=minion.tune_in)
|
||||
self.minion_process.start()
|
||||
|
||||
return self
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
def __exit__(self, type, value, traceback):
|
||||
'''
|
||||
Kill the minion and master processes
|
||||
'''
|
||||
pass
|
||||
self.minion_process.terminate()
|
||||
self.master_process.terminate()
|
||||
|
||||
|
||||
class ModuleCase(TestCase):
|
||||
|
|
Loading…
Add table
Reference in a new issue