Skip to content

Commit

Permalink
Add time to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tcalmant committed Aug 23, 2024
1 parent 440019c commit 1a3c39b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions tests/rsa/test_etcd3_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import json
import time
import unittest
from typing import Any, TypeVar

Expand Down Expand Up @@ -62,7 +63,7 @@
# ------------------------------------------------------------------------------


def start_framework_for_advertise(state_queue: Queue, debug_queue: Queue):
def start_framework_for_advertise(state_queue: Queue, debug_queue: Queue, start:float):
"""
Starts a Pelix framework to advertise (via etcd) a helloimpl_xmlrpc
remote service instance. The tests can/will then discover this
Expand All @@ -71,7 +72,7 @@ def start_framework_for_advertise(state_queue: Queue, debug_queue: Queue):
:param state_queue: Queue to communicate status and terminate
"""
try:
debug_queue.put_nowait("create")
debug_queue.put_nowait(f"{time.time() - start} :: create")
# Start the framework
framework = create_framework(
[
Expand All @@ -91,12 +92,12 @@ def start_framework_for_advertise(state_queue: Queue, debug_queue: Queue):
"etcd.toppath": TEST_ETCD_TOPPATH,
},
)
debug_queue.put_nowait("start")
debug_queue.put_nowait(f"{time.time() - start} :: start")
framework.start()

context = framework.get_bundle_context()
# Start an HTTP server, required by XML-RPC
debug_queue.put_nowait("instantiate")
debug_queue.put_nowait(f"{time.time() - start} :: instantiate")
with use_ipopo(context) as ipopo:
ipopo.instantiate(
"pelix.http.service.basic.factory",
Expand All @@ -105,26 +106,26 @@ def start_framework_for_advertise(state_queue: Queue, debug_queue: Queue):
)

bc = framework.get_bundle_context()
debug_queue.put_nowait("get rsa")
debug_queue.put_nowait(f"{time.time() - start} :: get rsa")
svc_ref = bc.get_service_reference(RemoteServiceAdmin, None)
assert svc_ref is not None
rsa = bc.get_service(svc_ref)
debug_queue.put_nowait(f"get rsa => {svc_ref} - {rsa}")
# export the hello remote service via rsa
# with the BasicTopologyManager, this will result
# in publish via etcd
debug_queue.put_nowait("get hello ref")
debug_queue.put_nowait(f"{time.time() - start} :: get hello ref")
hello_ref = bc.get_service_reference("org.eclipse.ecf.examples.hello.IHello")
assert hello_ref is not None
debug_queue.put_nowait("export")
debug_queue.put_nowait(f"{time.time() - start} :: export")
rsa.export_service(
hello_ref,
{
"service.exported.interfaces": "*",
"service.exported.configs": "ecf.xmlrpc.server",
},
)
debug_queue.put_nowait("send ready")
debug_queue.put_nowait(f"{time.time() - start} :: send ready")
try:
# Send that we are now ready
state_queue.put("ready")
Expand Down Expand Up @@ -187,7 +188,7 @@ def prepareFrameworkProcess(self):
"""
# start external framework that publishes remote service
self.publisher_process = WrappedProcess(
target=start_framework_for_advertise, args=[self.status_queue, self.debug_queue]
target=start_framework_for_advertise, args=[self.status_queue, self.debug_queue, time.time()]
)
self.publisher_process.start()
state = self.status_queue.get(timeout=20)
Expand Down

0 comments on commit 1a3c39b

Please sign in to comment.