Пример #1
0
def get_fb303_counter(switch_thrift: FbossAgentClient, counter: str):
    """
    @param switch_thrift: FbossAgentClient object that is part of test topology
    @param counter: a string that identifies fb303 counter

    getCounter will raise an exception on failure. For now we only retry on the
    list of known exceptions above. If any other exception happens, we die
    """
    return switch_thrift.getCounter(counter)
Пример #2
0
class PortStatusTest(unittest.TestCase):

    def setUp(self):
        self.client = FbossAgentClient(host=args['host'], port=args['port'])

    def test_port_status_matchfb303(self):
        """ Verify that for each port, it's internal status (down, up)
        matches what we're reporting to fb303.  See t14145409
        """
        for _pnum, pstate in self.client.getAllPortInfo().items():
            self.assertEqual(pstate.operState,
                             self.client.getCounter("%s.up" % pstate.name))

    def tearDown(self):
        # TODO(rsher) figure out better cleanup
        self.client.__exit__(None, None, None)
Пример #3
0
def get_fb303_counter(switch_thrift: FbossAgentClient,
                      counter: str,
                      log: Logger,
                      try_number: int):
    """
    @param switch_thrift: FbossAgentClient object that is part of test topology
    @param counter: a string that identifies fb303 counter
    @param logger: Logger object
    @param try_number: int passed in by retryable to identified current try

    getCounter will raise an exception on failure. For now we only retry on the
    list of known exceptions above. If any other exception happens, we die
    """
    log.info(
        f"Trying to get counter {counter}, try #{try_number}"
    )
    return switch_thrift.getCounter(counter)