def _print_sids(self):
     print ""
     print "*" * 60
     for s in SUBSCRIPTION_MANAGER.diag_get_sids():
         print s
     print "*" * 60
     return
 def test_timeout(self):
     sids = []
     for i in range(2):
         if not i:
             timeout = 1.0
         else:
             timeout = None
         # ID3 is /services/time/UTC/milliseconds which should
         # change "really fast."
         sid = SUBSCRIPTION_MANAGER.create_polled({self.ID3: self.ID3},
                                                  timeout)
         # Make sure it comes up.
         t1 = time.time()
         self.__values_changing(sid)
         sids.append(sid)
     # Double check the values are changing and that the subscriptions
     # stay valid while we poll for values.
     t1 = time.time()
     while (time.time() - t1) < 2.0:
         for sid in sids:
             self.__values_changing(sid)
         time.sleep(0.1)
     # Now ensure that sid[0] times out...
     sid = sids.pop(0)
     t1 = time.time()
     while sid in SUBSCRIPTION_MANAGER.diag_get_sids():
         if (time.time() - t1) > 2.0:
             raise "%r did not timeout." % sid
         time.sleep(0.1)
     # Finally, make sure that the other subscription is valid.
     sid = sids.pop(0)
     self.__values_changing(sid)
     return
 def _print_sids(self):
     print ""
     print "*"*60
     for s in SUBSCRIPTION_MANAGER.diag_get_sids():
         print s
     print "*"*60
     return
 def test_timeout(self):
     sids = []
     for i in range(2):
         if not i:
             timeout = 1.0
         else:
             timeout = None
         # ID3 is /services/time/UTC/milliseconds which should
         # change "really fast."
         sid = SUBSCRIPTION_MANAGER.create_polled({self.ID3:self.ID3},
                                                  timeout)
         # Make sure it comes up.
         t1 = time.time()
         self.__values_changing(sid)
         sids.append(sid)
     # Double check the values are changing and that the subscriptions
     # stay valid while we poll for values.
     t1 = time.time()
     while (time.time() - t1) < 2.0:
         for sid in sids:
             self.__values_changing(sid)
         time.sleep(0.1)
     # Now ensure that sid[0] times out...
     sid = sids.pop(0)
     t1 = time.time()
     while sid in SUBSCRIPTION_MANAGER.diag_get_sids():
         if (time.time()-t1) > 2.0:
             raise "%r did not timeout." % sid
         time.sleep(0.1)
     # Finally, make sure that the other subscription is valid.
     sid = sids.pop(0)
     self.__values_changing(sid)
     return
示例#5
0
 def test_timeout_batch(self):
     # nrtB10 changes "really fast."
     sid = SUBSCRIPTION_MANAGER.create_polled(self.nrtB10, 1.0)
     # Make sure it comes up.
     t1 = time.time()
     self.__values_changing(sid)
     # Double check the values are changing and that the subscriptions
     # stay valid while we poll for values.
     t1 = time.time()
     while (time.time() - t1) < 2.0:
         self.__values_changing(sid)
         time.sleep(0.1)
     if len(SUBSCRIPTION_MANAGER.diag_get_mnrs()) != 10:
         raise ("Bogus test, there should be 10 mnr at this point, not %r."
                % len(SUBSCRIPTION_MANAGER.diag_get_mnrs()))
     if len(SUBSCRIPTION_MANAGER.diag_get_mnbs()) != 1:
         raise ("Bogus test, there should be 1 mnb at this point, not %r." %
                len(SUBSCRIPTION_MANAGER.diag_get_mnbs()))
     t1 = time.time()
     while sid in SUBSCRIPTION_MANAGER.diag_get_sids():
         if (time.time() - t1) > 2.0:
             raise "%r did not timeout." % sid
         time.sleep(0.1)
     # Make sure that the mnr is removed when the last snr is deleted.
     if len(SUBSCRIPTION_MANAGER.diag_get_mnrs()) != 0:
         raise ("There should not be any mnrs at this point,"
                " but there are %r." % len(
                    SUBSCRIPTION_MANAGER.diag_get_mnrs()))
     # Finally, make sure that the mnb is removed when the last mnr is
     # deleted.
     if len(SUBSCRIPTION_MANAGER.diag_get_mnbs()) != 0:
         raise ("There should not be any mnbs at this point,"
                " but there are %r." % len(
                    SUBSCRIPTION_MANAGER.diag_get_mnbs()))
     return
 def test_timeout_batch(self):
     # nrtB10 changes "really fast."
     sid = SUBSCRIPTION_MANAGER.create_polled(self.nrtB10, 1.0)
     # Make sure it comes up.
     t1 = time.time()
     self.__values_changing(sid)
     # Double check the values are changing and that the subscriptions
     # stay valid while we poll for values.
     t1 = time.time()
     while (time.time() - t1) < 2.0:
         self.__values_changing(sid)
         time.sleep(0.1)
     if len(SUBSCRIPTION_MANAGER.diag_get_mnrs()) != 10:
         raise (
             "Bogus test, there should be 10 mnr at this point, not %r." %
             len(SUBSCRIPTION_MANAGER.diag_get_mnrs()))
     if len(SUBSCRIPTION_MANAGER.diag_get_mnbs()) != 1:
         raise ("Bogus test, there should be 1 mnb at this point, not %r." %
                len(SUBSCRIPTION_MANAGER.diag_get_mnbs()))
     t1 = time.time()
     while sid in SUBSCRIPTION_MANAGER.diag_get_sids():
         if (time.time() - t1) > 2.0:
             raise "%r did not timeout." % sid
         time.sleep(0.1)
     # Make sure that the mnr is removed when the last snr is deleted.
     if len(SUBSCRIPTION_MANAGER.diag_get_mnrs()) != 0:
         raise ("There should not be any mnrs at this point,"
                " but there are %r." %
                len(SUBSCRIPTION_MANAGER.diag_get_mnrs()))
     # Finally, make sure that the mnb is removed when the last mnr is
     # deleted.
     if len(SUBSCRIPTION_MANAGER.diag_get_mnbs()) != 0:
         raise ("There should not be any mnbs at this point,"
                " but there are %r." %
                len(SUBSCRIPTION_MANAGER.diag_get_mnbs()))
     return