示例#1
0
 def testNoDefaultRuncmdOption(self):
     opts = Options()  # default options object
     opts.cluster = 'cubone'
     opts.quattor_nodes = True
     manager = Manager(opts)
     print "showcommands", manager.nodes.showCommands()
     self.assertFalse(bool(manager.nodes.showCommands()))
示例#2
0
    def testdoitOutput(self):
        """Test the consistency of the output of manager.doit"""
        opts = Options()  # default options object
        opts.cluster = TEST_CLUSTER
        opts.quattor_nodes = True
        opts.ledon = True
        manager = Manager(opts)
        manager.nodes = CompositeNode(timeout=1)
        # create a fake node
        testnode = TestNode('node111', 'localhost', None)
        # overwrite it's testcommand to be sure it times out
        testnode.ledoncommand = Command('sleep 3', timeout=1)
        manager.nodes.add(testnode)

        # make sure this works for multiple nodes
        testnode2 = TestNode('node112', 'localhost', None)
        # overwrite it's testcommand to be sure it times out
        testnode2.ledoncommand = Command('sleep 3', timeout=1)
        manager.nodes.add(testnode2)
        # parse actions again so they get applied on the new node
        manager.parseActions()
        out = manager.doit()
        # make sure this output is of a format we can handle
        errors = []
        for i in out:
            if len(i) > 1 and len(i[1]) > 0:
                for j in i[1]:  # second element is an array of [outputs of commands,errors]
                    self.assertEquals(j[1][0], None)
                    if j[1][1]:
                        self.assertEquals(j[1][1], 'command timed out')
                        errors.append(i[0])

        # actuall node should be in output, not just the name, because this is also used for printstatussee
        self.assertTrue(testnode in errors)
        self.assertTrue(testnode2 in errors)
示例#3
0
 def testManagerCreatorNodesFromChassis(self):
     """
     test the manager constructor with the chassis option
     """
     opts = Options()  # default options object
     opts.cluster = TEST_CLUSTER
     opts.chassis = "61"
     Manager(opts)
示例#4
0
 def testManagerSetOffline(self):
     """
     test the setoffline option parameter
     """
     opts = Options()  # default options object
     opts.cluster = TEST_CLUSTER
     opts.node = TEST_NODE
     opts.setoffline = True
     Manager(opts).doit()
示例#5
0
 def testManagerSetOfflineOption(self):
     """
     test the setoffline option parameter
     """
     opts = Options()  # default options object
     opts.cluster = TEST_CLUSTER
     opts.worker = True
     opts.setoffline = True
     Manager(opts)
示例#6
0
 def testManagerTestrun(self):
     """
     test the setonline option parameter
     """
     opts = Options()  # default options object
     opts.cluster = TEST_CLUSTER
     opts.worker = True
     opts.testrun = True
     Manager(opts).doit()
示例#7
0
 def testAckService(self):
     """
     test the setoffline option parameter
     """
     opts = Options()  # default options object
     opts.cluster = TEST_CLUSTER
     opts.node = 'node2201-node2208'
     opts.ack_service = "Swapping"
     Manager(opts)
示例#8
0
 def testManagerPowercutOptions(self):
     """
     test the powercut option parameter
     """
     opts = Options()  # default options object
     opts.cluster = TEST_CLUSTER
     opts.worker = True
     opts.powercut = True
     Manager(opts)
示例#9
0
 def testAckService(self):
     """
     test the setoffline option parameter
     """
     opts = Options()  # default options object
     opts.cluster = 'cubone'
     opts.node = 'node610-617'
     opts.ack_service = "Swapping"
     Manager(opts)
示例#10
0
 def testManagerSetOffline(self):
     """
     test the setoffline option parameter
     """
     opts = Options()  # default options object
     opts.cluster = 'cubone'
     opts.node = 'node610'
     opts.setoffline = True
     Manager(opts).doit()
示例#11
0
 def testAck(self):
     """
     test the setoffline option parameter
     """
     opts = Options()  # default options object
     opts.cluster = 'cubone'
     opts.node = 'node610-617'
     opts.setoffline = True
     opts.ack = True
     Manager(opts)
示例#12
0
 def testAck(self):
     """
     test the setoffline option parameter
     """
     opts = Options()  # default options object
     opts.cluster = TEST_CLUSTER
     opts.node = 'node2201-node2208'
     opts.setoffline = True
     opts.ack = True
     Manager(opts)
示例#13
0
 def testManagerSetOnline(self):
     """
     test the setonline option parameter
     """
     opts = Options()  # default options object
     opts.cluster = 'cubone'
     opts.node = 'node610'
     opts.setonline = True
     #TODO: fails, since no worker nodes can be found
     Manager(opts).doit()
示例#14
0
    def testManagerCreatorNodesFromID(self):
        """
        test the manager constructor with a nodename option
        """
        opts = Options()
        opts.cluster = 'cubone'
        opts.node = 'nosuchnodeid3234#%'
        opts.setonline = True

        try:
            Manager(opts)
            self.fail("manager didn't fail with unknown node selected")
        except NodeException:
            pass
        else:
            self.fail("manager didn't fail with a NodeException when an unknown node was selected")
        opts.node = '32x,node120'
        try:
            Manager(opts)
            self.fail("manager didn't fail with unknown node selected")
        except NodeException:
            pass
        else:
            self.fail("manager didn't fail with a NodeException when an unknown node was selected")

        opts.node = 'node323,node120Xde#'
        try:
            Manager(opts)
            self.fail("manager didn't fail with unknown node selected")
        except NodeException:
            pass
        else:
            self.fail("manager didn't fail with a NodeException when an unknown node was selected")
        opts.node = 'node323,node120'
        try:
            Manager(opts)
            self.fail("manager didn't fail with unknown node selected")
        except NodeException:
            pass
        else:
            self.fail("manager didn't fail with a NodeException when an unknown node was selected")
        opts.node = 'node613,610,magikarp'
        Manager(opts)
        opts.node = 'node613-node615'
        Manager(opts)
        opts.node = 'node610,node613-node615,magikarp'
        Manager(opts)
示例#15
0
 def testDowntime(self):
     """
     test the setoffline option parameter
     """
     opts = Options()  # default options object
     opts.cluster = TEST_CLUSTER
     opts.node = 'node2201-node2208'
     opts.setoffline = True
     opts.downtime = "2 m"
     Manager(opts)  # should fail
     opts.downtime = "2h"
     Manager(opts)
示例#16
0
 def testDowntime(self):
     """
     test the setoffline option parameter
     """
     opts = Options()  # default options object
     opts.cluster = 'cubone'
     opts.node = 'node610-617'
     opts.setoffline = True
     opts.downtime = "2 m"
     Manager(opts)  # should fail
     opts.downtime = "2h"
     Manager(opts)
示例#17
0
 def testManagerLEDs(self):
     """
     test the Ledon, ledoff and ledstatus option parameter
     """
     opts = Options()  # default options object
     opts.cluster = TEST_CLUSTER
     opts.node = TEST_NODE
     opts.ledon = True
     Manager(opts).doit()
     # TODO: get led status and test if it's on
     opts.ledon = False
     opts.ledoff = True
     Manager(opts).doit()
示例#18
0
    def testManagerhasSpecials(self):
        """
        test on inclusion of special nodes
        """
        opts = Options()
        opts.cluster = TEST_CLUSTER

        manager = Manager(opts)
        self.assertFalse(manager.hasSpecials())
        opts.worker = True
        manager = Manager(opts)
        self.assertFalse(manager.hasSpecials())
        opts.all_nodes = True
        manager = Manager(opts)
        self.assertTrue(manager.hasSpecials())  # should have special nodes with force (the master)

        opts = Options()
        opts.cluster = TEST_CLUSTER
        opts.master = "master1"
        self.assertTrue(Manager(opts).hasSpecials())  # should create a manager
示例#19
0
 def testSchedulerOptions(self):
     """
     test the cheduler options
     """
     opts = Options()  # default options object
     opts.cluster = TEST_CLUSTER
     opts.pause = True
     Manager(opts)
     opts.resume = True
     Manager(opts)
     opts.pause = False
     opts.resume = True
     Manager(opts)
     Manager(opts).doit()
     opts.restart = True
     try:
         if Manager(opts).doit():
             self.fail("Scheduler restart ran without the --force option")
     except Exception, ex:
         self.fail("Scheduler restart failed with ex %s" % ex)
         print traceback.format_exc()
示例#20
0
    def testManagerhasSpecials(self):
        """
        test on inclusion of special nodes
        """
        opts = Options()
        opts.cluster = 'cubone'

        manager = Manager(opts)
        self.assertFalse(manager.hasSpecials())
        opts.worker = True
        #self.assertRaises(Exception, Manager, opts)
        manager = Manager(opts)
        self.assertFalse(manager.hasSpecials())
        opts.all_nodes = True
        manager = Manager(opts)
        self.assertTrue(manager.hasSpecials())  # should have special nodes with force (the master)

        opts = Options()
        opts.cluster = 'cubone'
        opts.master = "master7"
        self.assertTrue(Manager(opts).hasSpecials())  # should create a manager
示例#21
0
    def testManagerCreatorNodesFromID(self):
        """
        test the manager constructor with a nodename option
        """
        opts = Options()
        opts.cluster = TEST_CLUSTER
        opts.node = 'nosuchnodeid3234#%'
        opts.setonline = True

        try:
            Manager(opts)
            self.fail("manager didn't fail with unknown node selected")
        except NodeException:
            pass
        else:
            self.fail("manager didn't fail with a NodeException when an unknown node was selected")
        opts.node = 'node2201,201,magikarp'
        Manager(opts)
        opts.node = 'node2201-node2205'
        Manager(opts)
        opts.node = 'node2208,node2203-node2205,magikarp'
        Manager(opts)
示例#22
0
    def testManagerCreatorNodeOptions(self):
        """
        test the manager constructor
        """
#        debug = True cluster = None chassis = None down = False all = False
#        idle = False offline = False node = ""
        opts = Options()  # default options object
        opts.cluster = TEST_CLUSTER
        Manager(opts)  # should create a manager

        opts.down = True
        Manager(opts)  # should create a manager

        opts.idle = True
        Manager(opts)  # should create a manager

        opts.offline = True
        Manager(opts)  # should create a manager

        opts.master = "master7"
        Manager(opts)  # should create a manager
示例#23
0
    def testManagerCreatorActionOptions(self):
        """
        test the manager constructor
        """
#        debug = True cluster = None chassis = None down = False all = False
#        idle = False offline = False node = ""
        opts = Options()  # default options object
        opts.cluster = TEST_CLUSTER
        opts.quattor = True
        opts.all = True
        opts.forced = True
        opts.state = True
        manager = Manager(opts)
        manager.doit()
        opts.non_threaded = True
        manager = Manager(opts)
        opts.non_threaded = False
        manager = Manager(opts)
        manager.doit()

        opts.non_threaded = False
        opts.poweron = True
        Manager(opts).doit()

        opts.postpoweron = True
        Manager(opts)  # should create a manager

        opts.postpoweron = False
        opts.hardreboot = True
        Manager(opts)

        opts.hardreboot = False
        opts.softreboot = True
        Manager(opts)

        opts.all = False
        opts.worker = True
        opts.forced = False

        opts.pbsmomstatus = True
        Manager(opts).doit()

        opts.pbsmomrestart = True
        Manager(opts)  # should create a manager

        opts.pbsmomstop = True
        Manager(opts)  # should create a manager

        opts.pbsmomcleanup = True
        Manager(opts)  # should create a manager

        opts.runcmd = "echo hello"
        Manager(opts).doit()  # should create a manager
示例#24
0
 def testNoDefaultRuncmdOption(self):
     opts = Options()  # default options object
     opts.cluster = TEST_CLUSTER
     opts.quattor_nodes = True
     manager = Manager(opts)
     self.assertFalse(bool(manager.nodes.showCommands()))
示例#25
0
 def testManagerQuattorOption(self):
     opts = Options()  # default options object
     opts.cluster = TEST_CLUSTER
     opts.quattor_nodes = True
     opts.runcmd = "echo hello"