8799: shutdown_eligible() returns "node is draining" when in drain state. Add commen...
[arvados.git] / services / nodemanager / tests / test_config.py
index 3aa95410c439daa16b70b795781a058776db9dcc..e5669286543991efc99e2549051a1fb5720d7f39 100644 (file)
@@ -6,6 +6,8 @@ import io
 import logging
 import unittest
 
+import arvnodeman.computenode.dispatch as dispatch
+import arvnodeman.computenode.dispatch.slurm as slurm_dispatch
 import arvnodeman.config as nmconfig
 
 class NodeManagerConfigTestCase(unittest.TestCase):
@@ -22,6 +24,7 @@ creds = dummy_creds
 
 [Size 1]
 cores = 1
+price = 0.8
 
 [Logging]
 file = /dev/null
@@ -53,6 +56,7 @@ testlogger = INFO
         size, kwargs = sizes[0]
         self.assertEqual('Small', size.name)
         self.assertEqual(1, kwargs['cores'])
+        self.assertEqual(0.8, kwargs['price'])
 
     def test_shutdown_windows(self):
         config = self.load_config()
@@ -63,3 +67,19 @@ testlogger = INFO
         self.assertEqual({'level': logging.DEBUG,
                           'testlogger': logging.INFO},
                          config.log_levels())
+
+    def check_dispatch_classes(self, config, module):
+        setup, shutdown, update, monitor = config.dispatch_classes()
+        self.assertIs(setup, module.ComputeNodeSetupActor)
+        self.assertIs(shutdown, module.ComputeNodeShutdownActor)
+        self.assertIs(update, module.ComputeNodeUpdateActor)
+        self.assertIs(monitor, module.ComputeNodeMonitorActor)
+
+    def test_default_dispatch(self):
+        config = self.load_config()
+        self.check_dispatch_classes(config, dispatch)
+
+    def test_custom_dispatch(self):
+        config = self.load_config(
+            config_str=self.TEST_CONFIG + "[Daemon]\ndispatcher=slurm\n")
+        self.check_dispatch_classes(config, slurm_dispatch)