def test_301_busnode_find_helpers(self):
        with mock.patch('sys.argv', [self.prog, 'start', '--conf_file=tests/data/test_bus.conf']):
            options = vars(jnt_parse_args())
            options = JNTOptions(options)
        bus = FakeBus(options=options)
        section = 'fake'
        thread_uuid = options.get_option(section, 'uuid')
        if thread_uuid == None:
            thread_uuid = muuid.uuid1()
            options.set_option(section, 'uuid', "%s"%thread_uuid)
        node_state = JNTBusNodeMan(options, bus, section, thread_uuid)
        print node_state.state
        hadds = { 0 : HADD%(self.add_ctrl,0),
                     }
        node_state.start()
        i = 0
        while node_state.state != 'ONLINE' and i<120:
            i += 1
            print node_state.state
            time.sleep(1)
        self.assertEqual(node_state.state, 'ONLINE')
        try:

            node = node_state.find_node('component1')
            self.assertTrue('rrd1' in node.name)
            node = node_state.find_node('componentbad')
            self.assertEqual(node, None)
            value = node_state.find_value('component1', 'heartbeat')
            self.assertTrue('component1' in value.node_uuid)
            self.assertEqual('heartbeat',value.uuid)
            value = node_state.find_value('componentbad', 'heartbeat')
            self.assertEqual(value, None)
            value = node_state.find_value('component1', 'badbeat')
            self.assertEqual(value, None)

        finally:
            node_state.stop()
            i = 0
            while node_state.state != 'OFFLINE' and i<120:
                i += 1
                print node_state.state
                time.sleep(1)
            self.assertEqual(node_state.state, 'OFFLINE')
Exemple #2
0
    def test_301_busnode_find_helpers(self):
        with mock.patch("sys.argv", [self.prog, "start", "--conf_file=tests/data/test_bus.conf"]):
            options = vars(jnt_parse_args())
            options = JNTOptions(options)
        bus = FakeBus(options=options)
        section = "fake"
        thread_uuid = options.get_option(section, "uuid")
        if thread_uuid == None:
            thread_uuid = muuid.uuid1()
            options.set_option(section, "uuid", "%s" % thread_uuid)
        node_state = JNTBusNodeMan(options, bus, section, thread_uuid)
        print node_state.state
        hadds = {0: HADD % (self.add_ctrl, 0)}
        node_state.start()
        i = 0
        while node_state.state != "ONLINE" and i < 120:
            i += 1
            print node_state.state
            time.sleep(1)
        self.assertEqual(node_state.state, "ONLINE")
        try:

            node = node_state.find_node("component1")
            self.assertTrue("rrd1" in node.name)
            node = node_state.find_node("componentbad")
            self.assertEqual(node, None)
            value = node_state.find_value("component1", "heartbeat")
            self.assertTrue("component1" in value.node_uuid)
            self.assertEqual("heartbeat", value.uuid)
            value = node_state.find_value("componentbad", "heartbeat")
            self.assertEqual(value, None)
            value = node_state.find_value("component1", "badbeat")
            self.assertEqual(value, None)

        finally:
            node_state.stop()
            i = 0
            while node_state.state != "OFFLINE" and i < 120:
                i += 1
                print node_state.state
                time.sleep(1)
            self.assertEqual(node_state.state, "OFFLINE")