Debian Codegraph @

tests/TaskDistantPdshTest.py

raw symbols SCIP
1 """
2 Unit test for ClusterShell Task with all engines (pdsh distant worker)
3 """
4
5 import sys
6 import unittest
7
8 from ClusterShell.Defaults import DEFAULTS
9 from ClusterShell.Engine.Select import EngineSelect
10 from ClusterShell.Engine.Poll import EnginePoll
11 from ClusterShell.Engine.EPoll import EngineEPoll
12 from ClusterShell.Task import *
13
14 from .TaskDistantPdshMixin import TaskDistantPdshMixin
15 from .TLib import which
16
17 ENGINE_SELECT_ID = EngineSelect.identifier
18 ENGINE_POLL_ID = EnginePoll.identifier
19 ENGINE_EPOLL_ID = EngineEPoll.identifier
20
21 @unittest.skipIf(which('pdsh') is None, "pdsh is not installed")
22 class TaskDistantPdshEngineSelectTest(TaskDistantPdshMixin, unittest.TestCase):
23
24 def setUp(self):
25 task_terminate()
26 self.engine_id_save = DEFAULTS.engine
27 DEFAULTS.engine = ENGINE_SELECT_ID
28 # select should be supported anywhere...
29 self.assertEqual(task_self().info('engine'), ENGINE_SELECT_ID)
30 TaskDistantPdshMixin.setUp(self)
31
32 def tearDown(self):
33 DEFAULTS.engine = self.engine_id_save
34 task_terminate()
35
36 @unittest.skipIf(which('pdsh') is None, "pdsh is not installed")
37 class TaskDistantPdshEnginePollTest(TaskDistantPdshMixin, unittest.TestCase):
38
39 def setUp(self):
40 task_terminate()
41 self.engine_id_save = DEFAULTS.engine
42 DEFAULTS.engine = ENGINE_POLL_ID
43 if task_self().info('engine') != ENGINE_POLL_ID:
44 self.skipTest("engine %s not supported on this host" % ENGINE_POLL_ID)
45 TaskDistantPdshMixin.setUp(self)
46
47 def tearDown(self):
48 DEFAULTS.engine = self.engine_id_save
49 task_terminate()
50
51 # select.epoll is only available with Python 2.6 (if condition to be
52 # removed once we only support Py2.6+)
53 if sys.version_info >= (2, 6, 0):
54
55 @unittest.skipIf(which('pdsh') is None, "pdsh is not installed")
56 class TaskDistantPdshEngineEPollTest(TaskDistantPdshMixin, unittest.TestCase):
57
58 def setUp(self):
59 task_terminate()
60 self.engine_id_save = DEFAULTS.engine
61 DEFAULTS.engine = ENGINE_EPOLL_ID
62 if task_self().info('engine') != ENGINE_EPOLL_ID:
63 self.skipTest("engine %s not supported on this host" % ENGINE_EPOLL_ID)
64 TaskDistantPdshMixin.setUp(self)
65
66 def tearDown(self):
67 DEFAULTS.engine = self.engine_id_save
68 task_terminate()