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 _print_mnbs(self): print "" print "*" * 60 for s in SUBSCRIPTION_MANAGER.diag_get_mnbs(): print s print "*" * 60 return
def _print_mnbs(self): print "" print "*"*60 for s in SUBSCRIPTION_MANAGER.diag_get_mnbs(): print s print "*"*60 return
def test_destroy_batch(self): sids = [] for i in range(2): # BatchNodes change "really fast." sid = SUBSCRIPTION_MANAGER.create_polled(self.nrtB10) # Make sure it comes up. t1 = time.time() self.__values_changing(sid) sids.append(sid) # Double check the values are changing. for sid in sids: self.__values_changing(sid) # Now nuke one of the suscriptions and see that the other stays valid. sid = sids.pop(0) SUBSCRIPTION_MANAGER.destroy(sid) try: SUBSCRIPTION_MANAGER.destroy(sid) except ENoSuchSubscription: pass else: raise "No such subscription not detected." # Make sure that the other subscription is valid. sid = sids.pop(0) self.__values_changing(sid) 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())) SUBSCRIPTION_MANAGER.destroy(sid) # 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_destroy_batch(self): sids = [] for i in range(2): # BatchNodes change "really fast." sid = SUBSCRIPTION_MANAGER.create_polled(self.nrtB10) # Make sure it comes up. t1 = time.time() self.__values_changing(sid) sids.append(sid) # Double check the values are changing. for sid in sids: self.__values_changing(sid) # Now nuke one of the suscriptions and see that the other stays valid. sid = sids.pop(0) SUBSCRIPTION_MANAGER.destroy(sid) try: SUBSCRIPTION_MANAGER.destroy(sid) except ENoSuchSubscription: pass else: raise "No such subscription not detected." # Make sure that the other subscription is valid. sid = sids.pop(0) self.__values_changing(sid) 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())) SUBSCRIPTION_MANAGER.destroy(sid) # 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