Exemple #1
0
 def testPartialHDMIStatsFiles(self):
     """Test deserialization when a subset of files are not present."""
     stbservice.HDMI_DISPLAY_DEVICE_STATS_FILES = [
         'testdata/stbservice/hdmi_dispdev_status*.json',
         'testdata/stbservice/nosuchfile*.json'
     ]
     stb = stbservice.STBService()
     self.assertEqual(stb.Components.HDMINumberOfEntries, 1)
     for v in stb.Components.HDMIList.values():
         self.assertEqual(v.ResolutionMode, 'Auto')
         self.assertEqual(v.ResolutionValue, '640x480 @ 51Hz')
         self.assertEqual(v.DisplayDevice.Status, 'Present')
         self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_NegotiationCount4, 3)
         self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_NegotiationCount24,
                          9)
         self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_HDCPAuthFailureCnt,
                          5)
         self.assertEqual(v.DisplayDevice.Name, '')
         self.assertEqual(v.DisplayDevice.EEDID, '')
         self.assertEqual(len(v.DisplayDevice.SupportedResolutions), 0)
         self.assertEqual(v.DisplayDevice.PreferredResolution, '')
         self.assertEqual(v.DisplayDevice.VideoLatency, 0)
         self.assertEqual(v.DisplayDevice.AutoLipSyncSupport, False)
         self.assertEqual(v.DisplayDevice.HDMI3DPresent, False)
         self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_VendorId, '')
         self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_ProductId, 0)
         self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_MfgYear, 1990)
Exemple #2
0
 def testNonexistentHDMIStatsFile(self):
     """Test whether the absence of HDMI stats file is handled gracefully."""
     stbservice.HDMI_STATS_FILE = self.STATS_FILES_NOEXST[0]
     stbservice.HDMI_DISPLAY_DEVICE_STATS_FILES = self.STATS_FILES_NOEXST
     stb = stbservice.STBService()
     self.assertEqual(stb.Components.HDMINumberOfEntries, 1)
     for v in stb.Components.HDMIList.values():
         self.assertEqual(v.ResolutionMode, 'Auto')
         self.assertEqual(v.ResolutionValue, '')
         self.assertEqual(v.DisplayDevice.Status, 'None')
         self.assertEqual(v.DisplayDevice.Name, '')
         self.assertEqual(v.DisplayDevice.EEDID, '')
         self.assertEqual(len(v.DisplayDevice.SupportedResolutions), 0)
         self.assertEqual(v.DisplayDevice.PreferredResolution, '')
         self.assertEqual(v.DisplayDevice.VideoLatency, 0)
         self.assertEqual(v.DisplayDevice.AutoLipSyncSupport, False)
         self.assertEqual(v.DisplayDevice.HDMI3DPresent, False)
         self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_NegotiationCount4, 0)
         self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_NegotiationCount24,
                          0)
         self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_VendorId, '')
         self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_ProductId, 0)
         self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_MfgYear, 1990)
         self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_LastUpdateTimestamp,
                          '0001-01-01T00:00:00Z')
Exemple #3
0
 def testClientGroupsStable(self):
     stbservice.PROCNETIGMP = 'testdata/stbservice/igmp_stable1'
     stbservice.PROCNETIGMP6 = 'testdata/stbservice/igmp6_stable1'
     stb = stbservice.STBService()
     igmp = stb.Components.FrontEndList['1'].IP.IGMP
     self.assertEqual(len(igmp.ClientGroupList), 5)
     # instances are sorted when possible
     self.assertEqual(igmp.ClientGroupList[1].GroupAddress, '224.0.0.1')
     self.assertEqual(igmp.ClientGroupList[2].GroupAddress, '225.0.1.3')
     self.assertEqual(igmp.ClientGroupList[3].GroupAddress, '225.0.1.4')
     self.assertEqual(igmp.ClientGroupList[4].GroupAddress, '225.0.1.5')
     self.assertEqual(igmp.ClientGroupList[5].GroupAddress, '225.0.1.6')
     stbservice.PROCNETIGMP = 'testdata/stbservice/igmp_stable2'
     tr.session.cache.flush()
     self.assertEqual(len(igmp.ClientGroupList), 5)
     # instances retain stable numbering when possible
     self.assertEqual(igmp.ClientGroupList[1].GroupAddress, '224.0.0.1')
     self.assertEqual(igmp.ClientGroupList[2].GroupAddress, '225.0.1.3')
     self.assertEqual(igmp.ClientGroupList[3].GroupAddress, '225.0.1.4')
     self.assertEqual(igmp.ClientGroupList[4].GroupAddress, '225.0.1.7')
     self.assertEqual(igmp.ClientGroupList[5].GroupAddress, '225.0.1.6')
     stbservice.PROCNETIGMP = 'testdata/stbservice/igmp_stable3'
     tr.session.cache.flush()
     self.assertEqual(len(igmp.ClientGroupList), 6)
     # instances retain stable numbering when possible
     self.assertEqual(igmp.ClientGroupList[1].GroupAddress, '224.0.0.1')
     self.assertEqual(igmp.ClientGroupList[2].GroupAddress, '225.0.1.3')
     self.assertEqual(igmp.ClientGroupList[3].GroupAddress, '225.0.1.8')
     self.assertEqual(igmp.ClientGroupList[4].GroupAddress, '225.0.1.7')
     self.assertEqual(igmp.ClientGroupList[5].GroupAddress, '225.0.1.6')
     self.assertEqual(igmp.ClientGroupList[6].GroupAddress, '225.0.1.9')
Exemple #4
0
 def testStallAlarm(self):
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_small%d.json'
     ]
     ioloop = MockIoloop()
     stb = stbservice.STBService(ioloop=ioloop)
     self.assertEqual(stb.ServiceMonitoring.X_CATAWAMPUS_ORG_StallAlarmTime,
                      '0001-01-01T00:00:00Z')
     stb.ServiceMonitoring.X_CATAWAMPUS_ORG_StallAlarmValue = 1
     # small1 is not exceeding the AlarmValue
     self.assertEqual(stb.ServiceMonitoring.X_CATAWAMPUS_ORG_StallAlarmTime,
                      '0001-01-01T00:00:00Z')
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_full%d.json'
     ]
     tr.session.cache.flush()
     self.assertEqual(stb.ServiceMonitoring.X_CATAWAMPUS_ORG_StallAlarmTime,
                      '2013-01-11T10:00:00Z')
     self.assertTrue(ioloop.callback is not None)
     # Alarm should stay asserted even when stalltime drops below threshold.
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_small%d.json'
     ]
     tr.session.cache.flush()
     self.assertEqual(stb.ServiceMonitoring.X_CATAWAMPUS_ORG_StallAlarmTime,
                      '2013-01-11T10:00:00Z')
     # Explicitly clear
     stb.ServiceMonitoring.X_CATAWAMPUS_ORG_StallAlarmTime = 0
     self.assertEqual(stb.ServiceMonitoring.X_CATAWAMPUS_ORG_StallAlarmTime,
                      '0001-01-01T00:00:00Z')
Exemple #5
0
 def testDejitteringStats(self):
     """Test whether Dejittering stats are deserialized."""
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 9)
     ml = stb.ServiceMonitoring.MainStreamList
     self.assertEqual(ml[1].Total.DejitteringStats.EmptyBufferTime, 47)
     self.assertEqual(ml[2].Total.DejitteringStats.EmptyBufferTime, 41)
     self.assertEqual(ml[3].Total.DejitteringStats.EmptyBufferTime, 31)
     self.assertEqual(ml[4].Total.DejitteringStats.EmptyBufferTime, 23)
     self.assertEqual(ml[5].Total.DejitteringStats.EmptyBufferTime, 17)
     self.assertEqual(ml[6].Total.DejitteringStats.EmptyBufferTime, 11)
     self.assertEqual(ml[7].Total.DejitteringStats.EmptyBufferTime, 5)
     self.assertEqual(ml[8].Total.DejitteringStats.EmptyBufferTime, 1)
     self.assertEqual(ml[1].Total.DejitteringStats.Overruns, 8)
     self.assertEqual(ml[2].Total.DejitteringStats.Overruns, 7)
     self.assertEqual(ml[3].Total.DejitteringStats.Overruns, 6)
     self.assertEqual(ml[4].Total.DejitteringStats.Overruns, 5)
     self.assertEqual(ml[5].Total.DejitteringStats.Overruns, 4)
     self.assertEqual(ml[6].Total.DejitteringStats.Overruns, 3)
     self.assertEqual(ml[7].Total.DejitteringStats.Overruns, 2)
     self.assertEqual(ml[8].Total.DejitteringStats.Overruns, 1)
     self.assertEqual(ml[1].Total.DejitteringStats.Underruns, 11)
     self.assertEqual(ml[2].Total.DejitteringStats.Underruns, 12)
     self.assertEqual(ml[3].Total.DejitteringStats.Underruns, 13)
     self.assertEqual(ml[4].Total.DejitteringStats.Underruns, 14)
     self.assertEqual(ml[5].Total.DejitteringStats.Underruns, 15)
     self.assertEqual(ml[6].Total.DejitteringStats.Underruns, 16)
     self.assertEqual(ml[7].Total.DejitteringStats.Underruns, 17)
     self.assertEqual(ml[8].Total.DejitteringStats.Underruns, 18)
Exemple #6
0
 def testTCPStatsMultiple(self):
     """Test whether TCP stats are deserialized."""
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 9)
     ml = stb.ServiceMonitoring.MainStreamList
     self.assertEqual(ml[1].Total.TCPStats.PacketsReceived, 8000)
     self.assertEqual(ml[1].Total.TCPStats.BytesReceived, 2048000)
     self.assertEqual(ml[1].Total.TCPStats.PacketsRetransmitted, 9)
     self.assertEqual(ml[2].Total.TCPStats.PacketsReceived, 7000)
     self.assertEqual(ml[2].Total.TCPStats.BytesReceived, 1792000)
     self.assertEqual(ml[2].Total.TCPStats.PacketsRetransmitted, 6)
     self.assertEqual(ml[3].Total.TCPStats.PacketsReceived, 6000)
     self.assertEqual(ml[3].Total.TCPStats.BytesReceived, 1536000)
     self.assertEqual(ml[3].Total.TCPStats.PacketsRetransmitted, 7)
     self.assertEqual(ml[4].Total.TCPStats.PacketsReceived, 5000)
     self.assertEqual(ml[4].Total.TCPStats.BytesReceived, 1280000)
     self.assertEqual(ml[4].Total.TCPStats.PacketsRetransmitted, 4)
     self.assertEqual(ml[5].Total.TCPStats.PacketsReceived, 4000)
     self.assertEqual(ml[5].Total.TCPStats.BytesReceived, 1024000)
     self.assertEqual(ml[5].Total.TCPStats.PacketsRetransmitted, 5)
     self.assertEqual(ml[6].Total.TCPStats.PacketsReceived, 3000)
     self.assertEqual(ml[6].Total.TCPStats.BytesReceived, 768000)
     self.assertEqual(ml[6].Total.TCPStats.PacketsRetransmitted, 2)
     self.assertEqual(ml[7].Total.TCPStats.PacketsReceived, 2000)
     self.assertEqual(ml[7].Total.TCPStats.BytesReceived, 512000)
     self.assertEqual(ml[7].Total.TCPStats.PacketsRetransmitted, 3)
     self.assertEqual(ml[8].Total.TCPStats.PacketsReceived, 1000)
     self.assertEqual(ml[8].Total.TCPStats.BytesReceived, 256000)
     self.assertEqual(ml[8].Total.TCPStats.PacketsRetransmitted, 1)
Exemple #7
0
 def testDynamicUpdate(self):
     """Test whether the object stays consistent when the file is updated."""
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_small%d.json'
     ]
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 9)
     ml = stb.ServiceMonitoring.MainStreamList
     self.assertEqual(ml[1].Total.MPEG2TSStats.TSPacketsReceived, 400)
     self.assertEqual(ml[2].Total.MPEG2TSStats.TSPacketsReceived, 350)
     self.assertEqual(ml[3].Total.MPEG2TSStats.TSPacketsReceived, 300)
     self.assertEqual(ml[4].Total.MPEG2TSStats.TSPacketsReceived, 0)
     self.assertEqual(ml[5].Total.MPEG2TSStats.TSPacketsReceived, 0)
     self.assertEqual(ml[6].Total.MPEG2TSStats.TSPacketsReceived, 0)
     self.assertEqual(ml[7].Total.MPEG2TSStats.TSPacketsReceived, 0)
     self.assertEqual(ml[8].Total.MPEG2TSStats.TSPacketsReceived, 50)
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_full%d.json'
     ]
     tr.session.cache.flush()
     self.assertEqual(ml[1].Total.MPEG2TSStats.TSPacketsReceived, 800)
     self.assertEqual(ml[2].Total.MPEG2TSStats.TSPacketsReceived, 700)
     self.assertEqual(ml[3].Total.MPEG2TSStats.TSPacketsReceived, 600)
     self.assertEqual(ml[4].Total.MPEG2TSStats.TSPacketsReceived, 500)
     self.assertEqual(ml[5].Total.MPEG2TSStats.TSPacketsReceived, 400)
     self.assertEqual(ml[6].Total.MPEG2TSStats.TSPacketsReceived, 300)
     self.assertEqual(ml[7].Total.MPEG2TSStats.TSPacketsReceived, 200)
     self.assertEqual(ml[8].Total.MPEG2TSStats.TSPacketsReceived, 100)
Exemple #8
0
 def testInstancePersistance(self):
     """Test whether MainStream instance numbers are persistent."""
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_strm1.json'
     ]
     stb = stbservice.STBService()
     m = stb.ServiceMonitoring
     self.assertEqual(m.MainStreamNumberOfEntries, 1)
     self.assertEqual(m.MainStreamList[1].X_GOOGLE_COM_StreamID, 1)
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_strm12.json'
     ]
     self.assertEqual(m.MainStreamNumberOfEntries, 2)
     self.assertEqual(m.MainStreamList[1].X_GOOGLE_COM_StreamID, 1)
     self.assertEqual(m.MainStreamList[2].X_GOOGLE_COM_StreamID, 2)
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_strm123.json'
     ]
     self.assertEqual(m.MainStreamNumberOfEntries, 3)
     self.assertEqual(m.MainStreamList[1].X_GOOGLE_COM_StreamID, 1)
     self.assertEqual(m.MainStreamList[2].X_GOOGLE_COM_StreamID, 2)
     self.assertEqual(m.MainStreamList[3].X_GOOGLE_COM_StreamID, 3)
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_strm2.json'
     ]
     self.assertEqual(m.MainStreamNumberOfEntries, 1)
     self.assertEqual(m.MainStreamList[2].X_GOOGLE_COM_StreamID, 2)
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_strm23.json'
     ]
     self.assertEqual(m.MainStreamNumberOfEntries, 2)
     self.assertEqual(m.MainStreamList[1].X_GOOGLE_COM_StreamID, 3)
     self.assertEqual(m.MainStreamList[2].X_GOOGLE_COM_StreamID, 2)
     stb.ValidateExports()
Exemple #9
0
 def __init__(self):
     tr181.Device_v2_2.Device.Services.__init__(self)
     self.Export(objects=['StorageServices'])
     self.StorageServices = dm.storage.StorageServiceLinux26()
     self._AddStorageDevices()
     self.Export(lists=['STBService'])
     self.Export(['STBServiceNumberOfEntries'])
     self.STBServiceList = {'1': stbservice.STBService()}
Exemple #10
0
    def testDecoderStats(self):
        """Test whether Decoder stats are deserialized."""
        stb = stbservice.STBService()
        self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 9)
        ml = stb.ServiceMonitoring.MainStreamList
        for i in range(1, 7):
            stats = ml[i].Total.X_CATAWAMPUS_ORG_DecoderStats
            self.assertEqual(stats.VideoBytesDecoded, 13)
            self.assertEqual(stats.DecodeDrops, 7)
            self.assertEqual(stats.VideoDecodeErrors, 5)
            self.assertEqual(stats.DecodeOverflows, 6)
            self.assertEqual(stats.DecodedPictures, 4)
            self.assertEqual(stats.DisplayErrors, 9)
            self.assertEqual(stats.DisplayDrops, 10)
            self.assertEqual(stats.DisplayUnderflows, 11)
            self.assertEqual(stats.DisplayedPictures, 8)
            self.assertEqual(stats.ReceivedPictures, 3)
            self.assertEqual(stats.VideoWatchdogs, 12)
            self.assertEqual(stats.VideoPtsStcDifference, 14)
            self.assertEqual(stats.AudioDecodedFrames, 15)
            self.assertEqual(stats.AudioDecodeErrors, 16)
            self.assertEqual(stats.AudioDummyFrames, 17)
            self.assertEqual(stats.AudioFifoOverflows, 18)
            self.assertEqual(stats.AudioFifoUnderflows, 19)
            self.assertEqual(stats.AudioWatchdogs, 20)
            self.assertEqual(stats.AudioBytesDecoded, 21)
            self.assertEqual(stats.AudioPtsStcDifference, 22)
            self.assertEqual(stats.VideoFifoDepth, 30)
            self.assertEqual(stats.VideoDisplayQueueDepth, 31)
            self.assertEqual(stats.VideoCabacQueueDepth, 32)
            self.assertEqual(stats.VideoEnhancementFifoDepth, 33)
            self.assertEqual(stats.VideoPts, 34)
            self.assertEqual(stats.AudioFifoDepth, 35)
            self.assertEqual(stats.AudioQueuedFrames, 36)
            self.assertEqual(stats.AudioPts, 37)

        for i in range(7, 9):
            stats = ml[i].Total.X_CATAWAMPUS_ORG_DecoderStats
            self.assertEqual(stats.VideoBytesDecoded, 0)
            self.assertEqual(stats.DecodeDrops, 0)
            self.assertEqual(stats.VideoDecodeErrors, 0)
            self.assertEqual(stats.DecodeOverflows, 0)
            self.assertEqual(stats.DecodedPictures, 0)
            self.assertEqual(stats.DisplayErrors, 0)
            self.assertEqual(stats.DisplayDrops, 0)
            self.assertEqual(stats.DisplayUnderflows, 0)
            self.assertEqual(stats.DisplayedPictures, 0)
            self.assertEqual(stats.ReceivedPictures, 0)
            self.assertEqual(stats.VideoWatchdogs, 0)
            self.assertEqual(stats.VideoPtsStcDifference, 0)
            self.assertEqual(stats.AudioDecodedFrames, 0)
            self.assertEqual(stats.AudioDecodeErrors, 0)
            self.assertEqual(stats.AudioDummyFrames, 0)
            self.assertEqual(stats.AudioFifoOverflows, 0)
            self.assertEqual(stats.AudioFifoUnderflows, 0)
            self.assertEqual(stats.AudioWatchdogs, 0)
            self.assertEqual(stats.AudioBytesDecoded, 0)
            self.assertEqual(stats.AudioPtsStcDifference, 0)
Exemple #11
0
 def testIncorrectHDMIStatsFile(self):
     """Test deserialization when a subset of stats files are invalid."""
     stbservice.HDMI_STATS_FILE = stbservice.PROCNETIGMP
     stb = stbservice.STBService()
     self.assertEqual(stb.Components.HDMINumberOfEntries, 1)
     for v in stb.Components.HDMIList.values():
         self.assertEqual(v.ResolutionMode, 'Auto')
         self.assertEqual(v.ResolutionValue, '')
         self.assertEqual(v.DisplayDevice.Name, 'X213W')
Exemple #12
0
 def testEPGStatsAll(self):
     """Test whether EPG stats are deserialized properly."""
     stb = stbservice.STBService()
     stb.X_CATAWAMPUS_ORG_ProgramMetadata.ValidateExports()
     epgStats = stb.X_CATAWAMPUS_ORG_ProgramMetadata.EPG
     self.assertEqual(epgStats.MulticastPackets, 1002)
     self.assertEqual(epgStats.EPGErrors, 2)
     self.assertEqual(epgStats.LastReceivedTime, '2012-07-25T01:50:37Z')
     self.assertEqual(epgStats.EPGExpireTime, '2012-07-30T01:50:37Z')
Exemple #13
0
 def testEPGStatsNoFile(self):
     """Test whether EPG stats are deserialized properly when not file backed."""
     stbservice.EPG_STATS_FILES = self.STATS_FILES_NOEXST
     stb = stbservice.STBService()
     stb.X_CATAWAMPUS_ORG_ProgramMetadata.ValidateExports()
     epgStats = stb.X_CATAWAMPUS_ORG_ProgramMetadata.EPG
     self.assertEqual(epgStats.MulticastPackets, 0)
     self.assertEqual(epgStats.EPGErrors, 0)
     self.assertEqual(epgStats.LastReceivedTime, '0001-01-01T00:00:00Z')
     self.assertEqual(epgStats.EPGExpireTime, '0001-01-01T00:00:00Z')
Exemple #14
0
 def testEPGStatsIncorrectFileFormat(self):
     """Test whether EPG stats are handled properly for a bad file."""
     stbservice.EPG_STATS_FILES = [stbservice.PROCNETIGMP]
     stb = stbservice.STBService()
     stb.X_CATAWAMPUS_ORG_ProgramMetadata.ValidateExports()
     epgStats = stb.X_CATAWAMPUS_ORG_ProgramMetadata.EPG
     self.assertEqual(epgStats.MulticastPackets, 0)
     self.assertEqual(epgStats.EPGErrors, 0)
     self.assertEqual(epgStats.LastReceivedTime, '0001-01-01T00:00:00Z')
     self.assertEqual(epgStats.EPGExpireTime, '0001-01-01T00:00:00Z')
Exemple #15
0
 def testClientGroups(self):
     stb = stbservice.STBService()
     igmp = stb.Components.FrontEndList['1'].IP.IGMP
     self.assertEqual(len(igmp.ClientGroupList), 12)
     expected = set([
         '224.0.0.1', '225.0.1.3', '225.0.1.6', '225.0.1.10', '225.0.1.13',
         '225.0.1.18', '225.0.1.20', '225.0.1.153', '225.0.1.158',
         'ff02::1', 'ff02::1:ff30:66af', 'ff02::1:ff30:64af'
     ])
     actual = set()
     for i in range(1, 13):
         actual.add(igmp.ClientGroupList[i].GroupAddress)
     self.assertEqual(expected, actual)
Exemple #16
0
 def testNonexistentStatsFile(self):
     """Test whether the absence of stats file is handled gracefully."""
     stbservice.CONT_MONITOR_FILES = self.STATS_FILES_NOEXST
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 9)
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[1])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[2])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[3])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[4])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[5])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[6])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[7])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[8])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[256])
Exemple #17
0
 def testTSStats(self):
     """Test whether transport stream stats are deserialized."""
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 8)
     expected_discont = set([10, 20, 30, 40, 50, 60, 70, 80])
     expected_pkts = set([100, 200, 300, 400, 500, 600, 700, 800])
     actual_discont = set()
     actual_pkts = set()
     #using iterators to read the stream data. This should reduce the file reads.
     for v in stb.ServiceMonitoring.MainStreamList.values():
         tsstats = v.Total.MPEG2TSStats
         actual_discont.add(tsstats.PacketDiscontinuityCounter)
         actual_pkts.add(tsstats.TSPacketsReceived)
     self.assertEqual(expected_discont, actual_discont)
     self.assertEqual(expected_pkts, actual_pkts)
Exemple #18
0
 def testPartialUpdate(self):
     """Test whether a stats file with a subset of objects are deserialized."""
     stbservice.CONT_MONITOR_FILES = self.CONT_MONITOR_FILES_P1
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 8)
     # Dejittering stats not present in file. Check whether the object is init'ed
     expected_emptybuftime = set([0, 0, 0, 0, 0, 0, 0, 0])
     expected_discont = set([10, 20, 30, 40, 50, 60, 70, 80])
     actual_emptybuftime = set()
     actual_discont = set()
     for v in stb.ServiceMonitoring.MainStreamList.values():
         actual_emptybuftime.add(v.Total.DejitteringStats.EmptyBufferTime)
         actual_discont.add(v.Total.MPEG2TSStats.PacketDiscontinuityCounter)
     self.assertEqual(expected_emptybuftime, actual_emptybuftime)
     self.assertEqual(expected_discont, actual_discont)
Exemple #19
0
 def testPartialUpdate(self):
     """Test whether a stats file with a subset of objects is deserialized."""
     stbservice.CONT_MONITOR_FILES = ['testdata/stbservice/stats_p%d.json']
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 9)
     ml = stb.ServiceMonitoring.MainStreamList
     self.assertEqual(ml[1].Total.MPEG2TSStats.TSPacketsReceived, 1)
     self.assertEqual(ml[1].Total.MPEG2TSStats.PacketDiscontinuityCounter,
                      2)
     self.assertEqual(ml[1].Total.TCPStats.PacketsReceived, 3)
     self.assertEqual(ml[1].Total.TCPStats.BytesReceived, 4)
     self.assertEqual(ml[1].Total.TCPStats.PacketsRetransmitted, 5)
     # Dejittering stats not present in file. Check whether the object is init'ed
     self.assertEqual(ml[1].Total.DejitteringStats.EmptyBufferTime, 0)
     self.assertEqual(ml[1].Total.DejitteringStats.Overruns, 0)
     self.assertEqual(ml[1].Total.DejitteringStats.Underruns, 0)
Exemple #20
0
 def testIncorrectStatsFileFormat(self):
     """Test whether a malformed stats file is handled gracefully."""
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_notjson%d.json'
     ]
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 9)
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[1])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[2])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[3])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[4])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[5])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[6])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[7])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[8])
     self.checkMPEG2Zero(stb.ServiceMonitoring.MainStreamList[256])
Exemple #21
0
 def testDejitteringStats(self):
     """Test whether Dejittering stats are deserialized."""
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 8)
     expected_emptybuftime = set([1, 5, 11, 17, 23, 31, 41, 47])
     expected_overruns = set([1, 2, 3, 4, 5, 6, 7, 8])
     expected_underruns = set([18, 17, 16, 15, 14, 13, 12, 11])
     actual_emptybuftime = set()
     actual_underruns = set()
     actual_overruns = set()
     for v in stb.ServiceMonitoring.MainStreamList.values():
         djstats = v.Total.DejitteringStats
         actual_emptybuftime.add(djstats.EmptyBufferTime)
         actual_overruns.add(djstats.Overruns)
         actual_underruns.add(djstats.Underruns)
     self.assertEqual(expected_emptybuftime, actual_emptybuftime)
     self.assertEqual(expected_underruns, actual_underruns)
     self.assertEqual(expected_overruns, actual_overruns)
Exemple #22
0
 def testStallAlarmReset(self):
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_full%d.json'
     ]
     ioloop = MockIoloop()
     stb = stbservice.STBService(ioloop=ioloop)
     stb.ServiceMonitoring.X_CATAWAMPUS_ORG_StallAlarmValue = 1
     self.assertEqual(stb.ServiceMonitoring.X_CATAWAMPUS_ORG_StallAlarmTime,
                      '2013-01-11T10:00:00Z')
     self.assertTrue(ioloop.callback is not None)
     # Stalltime drops back below threshold
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_small%d.json'
     ]
     tr.session.cache.flush()
     # Simulate timeout callback
     ioloop.callback()
     self.assertEqual(stb.ServiceMonitoring.X_CATAWAMPUS_ORG_StallAlarmTime,
                      '0001-01-01T00:00:00Z')
Exemple #23
0
    def testHDMIStatsAll(self):
        """Test deserialization of all HDMI stats parameters."""
        stb = stbservice.STBService()
        self.assertEqual(stb.Components.HDMINumberOfEntries, 1)
        for v in stb.Components.HDMIList.values():
            self.assertEqual(v.ResolutionMode, 'Auto')
            self.assertEqual(v.ResolutionValue, '640x480 @ 51Hz')
            self.assertEqual(v.DisplayDevice.Status, 'Present')
            self.assertEqual(v.DisplayDevice.Name, 'X213W')
            self.assertEqual(v.DisplayDevice.EEDID,
                             ('00ffffffffffff000472330088b4808'
                              '008120103802f1e78eade95a3544c99'
                              '260f5054bfef90a940714f814001019'
                              '500950f9040010121399030621a2740'
                              '68b03600da2811000019000000fd003'
                              '84d1f5411000a202020202020000000'
                              'ff004c43473043303233343031300a0'
                              '00000fc0058323133570a2020202020'
                              '202000d9'))
            self.assertEqual(v.DisplayDevice.SupportedResolutions,
                             ('640x480 @ 51Hz, '
                              '640x480 @ 52Hz, '
                              '640x480 @ 55Hz'))
            self.assertEqual(v.DisplayDevice.PreferredResolution,
                             '640x480 @ 51Hz')
            self.assertEqual(v.DisplayDevice.VideoLatency, 0)
            self.assertEqual(v.DisplayDevice.AutoLipSyncSupport, False)
            self.assertEqual(v.DisplayDevice.HDMI3DPresent, False)

            self.assertEqual(
                v.DisplayDevice.X_GOOGLE_COM_EDIDExtensions,
                v.DisplayDevice.EEDID + ', ' + v.DisplayDevice.EEDID)

            self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_NegotiationCount4, 3)
            self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_NegotiationCount24,
                             9)
            self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_HDCPAuthFailureCnt,
                             5)
            self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_VendorId, 'ACR')
            self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_ProductId, 51)
            self.assertEqual(v.DisplayDevice.X_GOOGLE_COM_MfgYear, 2008)
Exemple #24
0
 def testTCPStats(self):
     """Test whether TCP stats are deserialized."""
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 8)
     expected_pktsrcvd = set(
         [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000])
     expected_bytesrcvd = set([
         256000, 512000, 768000, 1024000, 1280000, 1536000, 1792000, 2048000
     ])
     expected_pktsretran = set([1, 3, 2, 5, 4, 7, 6, 9])
     actual_pktsrcvd = set()
     actual_bytesrcvd = set()
     actual_pktsretran = set()
     for v in stb.ServiceMonitoring.MainStreamList.values():
         tcpstats = v.Total.TCPStats
         actual_pktsrcvd.add(tcpstats.PacketsReceived)
         actual_bytesrcvd.add(tcpstats.BytesReceived)
         actual_pktsretran.add(tcpstats.PacketsRetransmitted)
     self.assertEqual(expected_pktsrcvd, actual_pktsrcvd)
     self.assertEqual(expected_bytesrcvd, actual_bytesrcvd)
     self.assertEqual(expected_pktsretran, actual_pktsretran)
Exemple #25
0
 def testTCPStatsAll(self):
     """Test whether all TCP stats are deserialized."""
     stbservice.CONT_MONITOR_FILES = [
         'testdata/stbservice/stats_tcp%d.json'
     ]
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 9)
     tcp = stb.ServiceMonitoring.MainStreamList[1].Total.TCPStats
     self.assertEqual(tcp.BytesReceived, 1)
     self.assertEqual(tcp.X_CATAWAMPUS_ORG_BytesSent, 2)
     self.assertEqual(tcp.PacketsReceived, 3)
     self.assertEqual(tcp.X_CATAWAMPUS_ORG_Cwnd, 5)
     self.assertEqual(tcp.X_CATAWAMPUS_ORG_SlowStartThreshold, 6)
     self.assertEqual(tcp.X_CATAWAMPUS_ORG_Unacked, 7)
     self.assertEqual(tcp.X_CATAWAMPUS_ORG_Sacked, 8)
     self.assertEqual(tcp.X_CATAWAMPUS_ORG_Lost, 9)
     self.assertEqual(tcp.X_CATAWAMPUS_ORG_Rtt, 10)
     self.assertEqual(tcp.X_CATAWAMPUS_ORG_RttVariance, 11)
     self.assertEqual(tcp.X_CATAWAMPUS_ORG_ReceiveRTT, 12)
     self.assertEqual(tcp.X_CATAWAMPUS_ORG_ReceiveSpace, 13)
     self.assertEqual(tcp.X_CATAWAMPUS_ORG_RetransmitTimeout, 14)
     self.assertEqual(tcp.PacketsRetransmitted, 15)
Exemple #26
0
 def testDynamicUpdate(self):
     """Test whether the object stays consistent when the file is updated."""
     savedfnames = stbservice.CONT_MONITOR_FILES
     stbservice.CONT_MONITOR_FILES = self.CONT_MONITOR_FILES_ALT
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 4)
     for stream in stb.ServiceMonitoring.MainStreamList.values():
         if stream.X_GOOGLE_COM_StreamID == 3:
             self.assertEqual(stream.Total.MPEG2TSStats.TSPacketsReceived,
                              600)
     self.assertRaises(KeyError,
                       lambda: stb.ServiceMonitoring.MainStreamList[6])
     # Change the underlying json file; The new one has more entries
     stbservice.CONT_MONITOR_FILES = savedfnames
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 8)
     self.assertEqual(stream.Total.MPEG2TSStats.TSPacketsReceived, 600)
     for stream in stb.ServiceMonitoring.MainStreamList.values():
         if stream.X_GOOGLE_COM_StreamID == 3:
             self.assertEqual(stream.Total.MPEG2TSStats.TSPacketsReceived,
                              600)
         if stream.X_GOOGLE_COM_StreamID == 6:
             self.assertEqual(stream.Total.MPEG2TSStats.TSPacketsReceived,
                              300)
Exemple #27
0
 def testIncorrectObjectListIndex(self):
     """Test whether incorrect indexing of the stream object is handled."""
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 8)
     self.assertRaises(KeyError,
                       lambda: stb.ServiceMonitoring.MainStreamList[9])
Exemple #28
0
 def testIncorrectStatsFileFormat(self):
     """Test whether a malformed stats file is handled gracefully."""
     # stbservice.PROCNETIGMP is not a JSON file.
     stbservice.CONT_MONITOR_FILES = [stbservice.PROCNETIGMP]
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 0)
Exemple #29
0
 def testNonexistentStatsFile(self):
     """Test whether the absence of stats file is handled gracefully."""
     stbservice.CONT_MONITOR_FILES = self.STATS_FILES_NOEXST
     stb = stbservice.STBService()
     self.assertEqual(stb.ServiceMonitoring.MainStreamNumberOfEntries, 0)
Exemple #30
0
 def testValidateExports(self):
     stb = stbservice.STBService()
     stb.ValidateExports()