def test_parse_qos_compatible_expressions(): tests = [([ "Reliability.Reliable 10,", "History.KeepLast: 10", "ResourceLimits 100, -1 100", "PresentationAccessScope.Topic 1 no", "liFespAn seconds=1000;days=12", "deadline seconds=1", "WriterDataLifecycle off" ], [ Policy.Reliability.Reliable(max_blocking_time=10), Policy.History.KeepLast(depth=10), Policy.ResourceLimits(max_samples=100, max_instances=-1, max_samples_per_instance=100), Policy.PresentationAccessScope.Topic(coherent_access=True, ordered_access=False), Policy.Lifespan(lifespan=1037800000000000), Policy.Deadline(deadline=1000000000), Policy.WriterDataLifecycle(autodispose=False) ])] for (input, result) in tests: pubsub, ddsls = run_pubsub_ddsls(["-T", "test", "-q", ' '.join(input)], ["-a"], runtime=2) for policy in result: assert str(policy) in ddsls["stdout"] assert pubsub["status"] == 0
def test_on_requested_deadline_missed(manual_setup, hitpoint): class MyListener(Listener): def on_requested_deadline_missed(self, reader, status): hitpoint.hit(data=timestamp.now()) qos = Qos(Policy.Deadline(duration(seconds=0.2))) datawriter = manual_setup.dw(qos=qos) manual_setup.dr(qos=qos, listener=MyListener()) write_time = timestamp.now() datawriter.write(manual_setup.msg) assert hitpoint.was_hit() assert hitpoint.data - write_time >= duration(seconds=0.2)
import time import random from cyclonedds.core import Qos, Policy from cyclonedds.domain import DomainParticipant from cyclonedds.pub import Publisher, DataWriter from cyclonedds.topic import Topic from cyclonedds.util import duration from vehicles import Vehicle qos = Qos(Policy.Reliability.BestEffort, Policy.Deadline(duration(microseconds=10)), Policy.Durability.Transient, Policy.History.KeepLast(10)) domain_participant = DomainParticipant(0) topic = Topic(domain_participant, 'Vehicle', Vehicle, qos=qos) publisher = Publisher(domain_participant) writer = DataWriter(publisher, topic) cart = Vehicle(name="Dallara IL-15", x=200, y=200) while True: cart.x += random.choice([-1, 0, 1]) cart.y += random.choice([-1, 0, 1]) writer.write(cart) print(">> Wrote vehicle") time.sleep(random.random() * 0.9 + 0.1)
def test_parse_qos(): tests = \ [ ( [ "Reliability.Reliable 10000000", "Durability.TransientLocal", "History.KeepLast 10", "ResourceLimits 100 -1 100", "PresentationAccessScope.Topic True False", "Lifespan 1000000", "Deadline seconds=1", "LatencyBudget 10000000", "Ownership.Exclusive", "OwnershipStrength 20", "Liveliness.ManualByParticipant 100000", "TimeBasedFilter 100000", "Partition Hello, world", "TransportPriority 1", "DestinationOrder.BySourceTimestamp", "WriterDataLifecycle False", "ReaderDataLifecycle 10000000 10000000", "DurabilityService 100000 History.KeepLast 100, 2000, 1000, 1000", "Userdata HiUser", "Groupdata HiGroup", "Topicdata HiTopic" ], Qos( Policy.Reliability.Reliable(max_blocking_time=10000000), Policy.Durability.TransientLocal, Policy.History.KeepLast(depth=10), Policy.ResourceLimits(max_samples=100, max_instances=-1, max_samples_per_instance=100), Policy.PresentationAccessScope.Topic(coherent_access=True, ordered_access=False), Policy.Lifespan(lifespan=1000000), Policy.Deadline(deadline=1000000000), Policy.LatencyBudget(budget=10000000), Policy.Ownership.Exclusive, Policy.OwnershipStrength(strength=20), Policy.Liveliness.ManualByParticipant(lease_duration=100000), Policy.TimeBasedFilter(filter_time=100000), Policy.Partition(partitions=('Hello', 'world')), Policy.TransportPriority(priority=1), Policy.DestinationOrder.BySourceTimestamp, Policy.WriterDataLifecycle(autodispose=False), Policy.ReaderDataLifecycle(autopurge_nowriter_samples_delay=10000000, autopurge_disposed_samples_delay=10000000), Policy.DurabilityService(cleanup_delay=100000, history=Policy.History.KeepLast(depth=100), max_samples=2000, max_instances=1000, max_samples_per_instance=1000), Policy.Userdata(data=b'HiUser'), Policy.Groupdata(data=b'HiGroup'), Policy.Topicdata(data=b'HiTopic'), ) ) ] for (input, result) in tests: pubsub, ddsls = run_pubsub_ddsls(["-T", "test", "-q", ' '.join(input)], ["-a"], runtime=2) for policy in result: assert str(policy) in ddsls["stdout"] assert pubsub["status"] == 0