mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add testrunner boilerplate code to run tests
This commit is contained in:
parent
df219b715b
commit
cb5e3ea089
17 changed files with 219 additions and 7 deletions
|
@ -1,7 +1,11 @@
|
|||
# Import python libs
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class StdTest(integration.ModuleCase):
|
||||
'''
|
||||
|
@ -83,3 +87,11 @@ class StdTest(integration.ModuleCase):
|
|||
self.assertEqual(data['foo'], 'bar')
|
||||
self.assertEqual(data['baz'], 'quo')
|
||||
self.assertEqual(data['qux'], 'quux')
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(StdTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
# Import python libs
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class StdTest(integration.ModuleCase):
|
||||
'''
|
||||
Test standard client calls
|
||||
'''
|
||||
|
||||
def test_cli(self):
|
||||
'''
|
||||
Test cli function
|
||||
|
@ -49,3 +56,11 @@ class StdTest(integration.ModuleCase):
|
|||
'test.ping',
|
||||
)
|
||||
self.assertTrue(ret['minion'])
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(StdTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
# Import python libs
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
class TestSyndicTest(integration.SyndicCase):
|
||||
|
||||
class TestSyndic(integration.SyndicCase):
|
||||
'''
|
||||
Validate the syndic interface by testing the test module
|
||||
'''
|
||||
|
@ -26,3 +29,10 @@ class TestSyndicTest(integration.SyndicCase):
|
|||
34
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(TestSyndic)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
# Import python libs
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class CMDModuleTest(integration.ModuleCase):
|
||||
'''
|
||||
|
@ -89,3 +93,11 @@ sys.stdout.write('cheese')
|
|||
self.run_function('cmd.exec_code', ['python', code]),
|
||||
'cheese'
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(CMDModuleTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
# Import python libs
|
||||
import os
|
||||
import sys
|
||||
import hashlib
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class CPModuleTest(integration.ModuleCase):
|
||||
'''
|
||||
|
@ -194,3 +198,11 @@ class CPModuleTest(integration.ModuleCase):
|
|||
md5_hash['hsum'],
|
||||
hashlib.md5(fn_.read()).hexdigest()
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(CPModuleTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
# Import python libs
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class DataModuleTest(integration.ModuleCase):
|
||||
'''
|
||||
|
@ -56,3 +62,10 @@ class DataModuleTest(integration.ModuleCase):
|
|||
)
|
||||
self._clear_db()
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(DataModuleTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
# Import python libs
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class DiskModuleTest(integration.ModuleCase):
|
||||
'''
|
||||
|
@ -38,3 +41,10 @@ class DiskModuleTest(integration.ModuleCase):
|
|||
self.assertTrue('use' in val)
|
||||
self.assertTrue('filesystem' in val)
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(DiskModuleTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
'''
|
||||
Test the grains module
|
||||
'''
|
||||
# Import python libs
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class TestModulesGrains(integration.ModuleCase):
|
||||
'''
|
||||
|
@ -46,3 +52,11 @@ class TestModulesGrains(integration.ModuleCase):
|
|||
self.assertTrue('saltpath' in lsgrains)
|
||||
self.assertTrue('saltversion' in lsgrains)
|
||||
self.assertTrue('virtual' in lsgrains)
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(TestModulesGrains)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -3,13 +3,17 @@ Test the hosts module
|
|||
'''
|
||||
# Import python libs
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
# Import Salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
HFN = os.path.join(integration.TMP, 'hosts')
|
||||
|
||||
|
||||
class HostsModuleTest(integration.ModuleCase):
|
||||
'''
|
||||
Test the hosts module
|
||||
|
@ -138,3 +142,11 @@ class HostsModuleTest(integration.ModuleCase):
|
|||
"192.168.1.2\t\thost2.fqdn.com\thost2\toldhost2\thost2-reorder\n",
|
||||
"192.168.1.1\t\thost1.fqdn.com\thost1\thost1-reorder\n",
|
||||
])
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(HostsModuleTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
# Import python libs
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class PillarModuleTest(integration.ModuleCase):
|
||||
'''
|
||||
|
@ -25,3 +31,11 @@ class PillarModuleTest(integration.ModuleCase):
|
|||
self.assertEqual(
|
||||
self.run_function('pillar.data')['ext_spam'], 'eggs'
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(PillarModuleTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
# Import python libs
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class PipModuleTest(integration.ModuleCase):
|
||||
'''
|
||||
|
@ -16,3 +19,10 @@ class PipModuleTest(integration.ModuleCase):
|
|||
self.assertIsInstance(ret, list)
|
||||
self.assertGreater(len(ret), 1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(PipModuleTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
# Import python libs
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class PublishModuleTest(integration.ModuleCase):
|
||||
'''
|
||||
|
@ -25,7 +31,7 @@ class PublishModuleTest(integration.ModuleCase):
|
|||
]
|
||||
)
|
||||
self.assertEqual(ret['minion']['ret'][0][-1], 34)
|
||||
|
||||
|
||||
def test_kwarg(self):
|
||||
'''
|
||||
Verify that the pub data is making it to the minion functions
|
||||
|
@ -64,3 +70,11 @@ class PublishModuleTest(integration.ModuleCase):
|
|||
]
|
||||
)
|
||||
self.assertEqual(ret, {})
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(PublishModuleTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
# Import python libs
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class StateModuleTest(integration.ModuleCase):
|
||||
'''
|
||||
|
@ -22,3 +28,10 @@ class StateModuleTest(integration.ModuleCase):
|
|||
self.assertTrue(isinstance(low, list))
|
||||
self.assertTrue(isinstance(low[0], dict))
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(StateModuleTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
# Import python libs
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class SysModuleTest(integration.ModuleCase):
|
||||
'''
|
||||
|
@ -23,3 +26,11 @@ class SysModuleTest(integration.ModuleCase):
|
|||
mods = self.run_function('sys.list_modules')
|
||||
self.assertTrue('hosts' in mods)
|
||||
self.assertTrue('pkg' in mods)
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(SysModuleTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
# Import python libs
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class TestModuleTest(integration.ModuleCase):
|
||||
'''
|
||||
|
@ -89,3 +93,11 @@ class TestModuleTest(integration.ModuleCase):
|
|||
test.outputter
|
||||
'''
|
||||
self.assertEqual(self.run_function('test.outputter', ['text']), 'text')
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(TestModuleTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
# Import python libs
|
||||
import sys
|
||||
|
||||
# Import salt libs
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class KeyTest(integration.ShellCase):
|
||||
'''
|
||||
|
@ -36,3 +42,11 @@ class KeyTest(integration.ShellCase):
|
|||
data,
|
||||
['']
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(KeyTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
'''
|
||||
Tests for the salt-run command
|
||||
'''
|
||||
# Import python libs
|
||||
import sys
|
||||
|
||||
# Import Salt Modules
|
||||
from saltunittest import TestLoader, TextTestRunner
|
||||
import integration
|
||||
from integration import TestDaemon
|
||||
|
||||
|
||||
class RunTest(integration.ShellCase):
|
||||
'''
|
||||
|
@ -29,3 +35,11 @@ class RunTest(integration.ShellCase):
|
|||
data = self.run_run('-d')
|
||||
data = '\n'.join(data)
|
||||
self.assertNotIn('jobs.SaltException:', data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(RunTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
with TestDaemon():
|
||||
runner = TextTestRunner(verbosity=1).run(tests)
|
||||
sys.exit(runner.wasSuccessful())
|
||||
|
|
Loading…
Add table
Reference in a new issue