Skip to content

Commit

Permalink
run v2 in ci instead of v1
Browse files Browse the repository at this point in the history
  • Loading branch information
leon1995 committed Nov 15, 2024
1 parent be635e3 commit 59b530b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pat_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:

- name: Run tests with tls enabled
if: ${{ matrix.tls_enable }}
run: python -m examples.ReferenceTest.run --tls
run: python -m examples.ReferenceTestV2.run --tls
timeout-minutes: 2

- name: Run tests with tls disabled
if: ${{ !matrix.tls_enable }}
run: python -m examples.ReferenceTest.run
run: python -m examples.ReferenceTestV2.run
timeout-minutes: 2
2 changes: 1 addition & 1 deletion examples/ReferenceTestV2/reference_consumer_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def run_ref_test(results_collector: ResultsCollector) -> ResultsCollector: # no
results_collector.log_result(max(durations) <= 15, step, info) # noqa: PLR2004
step = "2b.2"
info = "the Reference Provider grants subscriptions of at most 15 seconds (renew)"
subscription = next(client.subscription_mgr.subscriptions.values())
subscription = list(client.subscription_mgr.subscriptions.values())[0] # noqa: RUF015
granted = subscription.renew(30000)
print(f"renew granted = {granted}")
results_collector.log_result(max(durations) <= 15, step, info) # noqa: PLR2004
Expand Down
7 changes: 5 additions & 2 deletions examples/ReferenceTestV2/reference_provider_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ def provide_realtime_data(sdc_provider: SdcProvider):
waveform_provider.register_waveform_generator(waveform.Handle, wf_generator)


if __name__ == "__main__":
with pathlib.Path(__file__).parent.joinpath("logging_default.json") as f:
def run_provider():

Check failure on line 183 in examples/ReferenceTestV2/reference_provider_v2.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (C901)

examples/ReferenceTestV2/reference_provider_v2.py:183:5: C901 `run_provider` is too complex (48 > 10)

Check failure on line 183 in examples/ReferenceTestV2/reference_provider_v2.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (PLR0912)

examples/ReferenceTestV2/reference_provider_v2.py:183:5: PLR0912 Too many branches (59 > 12)

Check failure on line 183 in examples/ReferenceTestV2/reference_provider_v2.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (PLR0915)

examples/ReferenceTestV2/reference_provider_v2.py:183:5: PLR0915 Too many statements (216 > 50)

Check failure on line 183 in examples/ReferenceTestV2/reference_provider_v2.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (D103)

examples/ReferenceTestV2/reference_provider_v2.py:183:5: D103 Missing docstring in public function
with pathlib.Path(__file__).parent.joinpath("logging_default.json").open() as f:
logging_setup = json.load(f)
logging.config.dictConfig(logging_setup)
xtra_log_config = os.getenv("ref_xtra_log_cnf") # noqa:SIM112
Expand Down Expand Up @@ -471,3 +471,6 @@ def provide_realtime_data(sdc_provider: SdcProvider):
sleep(5)
except KeyboardInterrupt:
print("Exiting...")

if __name__ == "__main__":
run_provider()
47 changes: 47 additions & 0 deletions examples/ReferenceTestV2/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Script that executes the plug-a-thon tests."""

import os
import pathlib
import platform
import sys
import threading
import uuid

from sdc11073 import network

from examples.ReferenceTestV2 import reference_provider_v2, reference_consumer_v2


def setup(tls: bool):

Check failure on line 15 in examples/ReferenceTestV2/run.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

examples/ReferenceTestV2/run.py:3:1: I001 Import block is un-sorted or un-formatted

Check failure on line 15 in examples/ReferenceTestV2/run.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (D103)

examples/ReferenceTestV2/run.py:15:5: D103 Missing docstring in public function
os.environ['ref_search_epr'] = str(uuid.uuid4())

Check failure on line 16 in examples/ReferenceTestV2/run.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (SIM112)

examples/ReferenceTestV2/run.py:16:16: SIM112 Use capitalized environment variable `REF_SEARCH_EPR` instead of `ref_search_epr`
if platform.system() == 'Darwin':
os.environ['ref_ip'] = next(str(adapter.ip) for adapter in network.get_adapters() if not adapter.is_loopback)

Check failure on line 18 in examples/ReferenceTestV2/run.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (SIM112)

examples/ReferenceTestV2/run.py:18:20: SIM112 Use capitalized environment variable `REF_IP` instead of `ref_ip`
else:
os.environ['ref_ip'] = next(str(adapter.ip) for adapter in network.get_adapters() if adapter.is_loopback)
if tls:
certs_path = pathlib.Path(__file__).parent.parent.joinpath('certs')
assert certs_path.exists()
os.environ['ref_ca'] = str(certs_path)
os.environ['ref_ssl_passwd'] = 'dummypass'


def run() -> reference_consumer_v2.ResultsCollector:
threading.Thread(target=reference_provider_v2.run_provider, daemon=True).start()
return reference_consumer_v2.run_ref_test(reference_consumer_v2.ResultsCollector())


def main(tls: bool):
setup(tls)
return run()


if __name__ == '__main__':
import argparse

parser = argparse.ArgumentParser(description='run plug-a-thon tests')
parser.add_argument('--tls', action='store_true', help='Indicates whether tls encryption should be enabled.')

args = parser.parse_args()
run_results = main(tls=args.tls)
run_results.print_summary()
sys.exit(bool(results.failed_count))

0 comments on commit 59b530b

Please sign in to comment.