コード例 #1
0
 def testInitialFunction2(self):
     """ Test non-transition on online message. """
     rec = MultipathRecognizer(self.PARSER)
     entry = Entry({
        '_COMM' : 'multipathd',
        'MESSAGE' : self.MESSAGE_UP
     })
     rec.consume(entry)
     self.assertEqual(rec.state, RecognizerStates.NO)
     self.assertEqual(rec.info, dict())
コード例 #2
0
    def testIrrelevantProcess(self):
        """ If the process is not multipathd, the message is irrelevant. """
        rec = MultipathRecognizer(self.PARSER)
        entry = Entry({
           '_COMM' : 'multipathr',
           'MESSAGE' : self.MESSAGE_DOWN
        })
        rec.consume(entry)
        self.assertEqual(rec.state, RecognizerStates.NO)
        self.assertEqual(len(rec.evidence), 0)

        rec2 = rec.initializeNew()
        self.assertEqual(rec, rec2)
コード例 #3
0
 def testDifferentOnline(self):
     """ Test online message that does not match offline message. """
     rec = MultipathRecognizer(self.PARSER)
     entry = Entry({
        '_COMM' : 'multipathd',
        'MESSAGE' : self.MESSAGE_DOWN
     })
     rec.consume(entry)
     message = 'WDC_WD10EFRX-68PJCN0_WD-WCC4JLHVDELK: sda - directio checker reports path is up' # pylint: disable=line-too-long
     entry = Entry({
        '_COMM' : 'multipathd',
        'MESSAGE' : message
     })
     rec.consume(entry)
     self.assertEqual(rec.state, RecognizerStates.MAYBE_YES)
コード例 #4
0
 def testTransitionToFalse(self):
     """ Test transition to True and back to false. """
     rec = MultipathRecognizer(self.PARSER)
     entry = Entry({
        '_COMM' : 'multipathd',
        'MESSAGE' : self.MESSAGE_DOWN
     })
     rec.consume(entry)
     entry = Entry({
        '_COMM' : 'multipathd',
        'MESSAGE' : self.MESSAGE_UP
     })
     rec.consume(entry)
     self.assertEqual(rec.state, RecognizerStates.NO)
     self.assertEqual(rec.info, dict())
コード例 #5
0
    def testManyOffline1(self):
        """ Two offline state messages about the same device should yield
            the same as one.
        """
        rec = MultipathRecognizer(self.PARSER)
        entry = Entry({
           '_COMM' : 'multipathd',
           'MESSAGE' : self.MESSAGE_DOWN
        })
        rec.consume(entry)
        rec.consume(entry)
        self.assertEqual(rec.state, RecognizerStates.MAYBE_YES)
        self.assertEqual(len(rec.evidence), 2)

        info = rec.info
        self.assertEqual(info['DEVICE'], 'WDC_WD10EFRX-68PJCN0_WD-WCC4JLHVDELY')
        self.assertEqual(info['PATH'], 'sdk')
コード例 #6
0
    def testInitialFunction(self):
        """ Test initial state to recognized state by match. """
        rec = MultipathRecognizer(self.PARSER)
        entry = Entry({
           '_COMM' : 'multipathd',
           'MESSAGE' : self.MESSAGE_DOWN
        })
        rec.consume(entry)
        self.assertEqual(rec.state, RecognizerStates.MAYBE_YES)
        self.assertEqual(len(rec.evidence), 1)

        info = rec.info
        self.assertEqual(info['DEVICE'], 'WDC_WD10EFRX-68PJCN0_WD-WCC4JLHVDELY')
        self.assertEqual(info['PATH'], 'sdk')

        rec2 = rec.initializeNew()
        self.assertNotEqual(rec, rec2)
コード例 #7
0
    def testMany(self):
        """ An offline state messages followed by an irrelevant message. """
        rec = MultipathRecognizer(self.PARSER)
        entry = Entry({
           '_COMM' : 'multipathd',
           'MESSAGE' : self.MESSAGE_DOWN
        })
        rec.consume(entry)
        entry = Entry({
           '_COMM' : 'multipathr',
           'MESSAGE' : 'WDC_WD10EFRX-68PJCN0_WD-WCC4JLHVDELK: sda - path offline' # pylint: disable=line-too-long
        })
        rec.consume(entry)
        self.assertEqual(rec.state, RecognizerStates.MAYBE_YES)
        self.assertEqual(len(rec.evidence), 1)

        info = rec.info
        self.assertEqual(info['DEVICE'], 'WDC_WD10EFRX-68PJCN0_WD-WCC4JLHVDELY')
        self.assertEqual(info['PATH'], 'sdk')
コード例 #8
0
    def testMany2(self):
        """ An offline state messages followed by an irrelevant message.
            Unlike the other, this originated w/ multipathd.
        """
        rec = MultipathRecognizer(self.PARSER)
        entry = Entry({
           '_COMM' : 'multipathd',
           'MESSAGE' : self.MESSAGE_DOWN
        })
        rec.consume(entry)
        entry = Entry({
           '_COMM' : 'multipathd',
           'MESSAGE' : 'WDC_WD10EFRX-68PJCN0_WD-WCC4JLHVDELK: sda - irrelevant'
        })
        rec.consume(entry)
        self.assertEqual(rec.state, RecognizerStates.MAYBE_YES)
        self.assertEqual(len(rec.evidence), 1)

        info = rec.info
        self.assertEqual(info['DEVICE'], 'WDC_WD10EFRX-68PJCN0_WD-WCC4JLHVDELY')
        self.assertEqual(info['PATH'], 'sdk')
コード例 #9
0
    def testManyOffline2(self):
        """ Two offline state messages about different devices should cause
            second message to be ignored.
        """
        rec = MultipathRecognizer(self.PARSER)
        entry = Entry({
           '_COMM' : 'multipathd',
           'MESSAGE' : self.MESSAGE_DOWN
        })
        rec.consume(entry)
        entry = Entry({
           '_COMM' : 'multipathd',
           'MESSAGE' : 'WDC_WD10EFRX-68PJCN0_WD-WCC4JLHVDELK: sda - path offline' # pylint: disable=line-too-long
        })
        rec.consume(entry)
        self.assertEqual(rec.state, RecognizerStates.MAYBE_YES)
        self.assertEqual(len(rec.evidence), 1)

        info = rec.info
        self.assertEqual(info['DEVICE'], 'WDC_WD10EFRX-68PJCN0_WD-WCC4JLHVDELY')
        self.assertEqual(info['PATH'], 'sdk')