Skip to content

Commit

Permalink
Run push av server in the background
Browse files Browse the repository at this point in the history
  • Loading branch information
fmonniot committed Oct 22, 2024
1 parent 905edc7 commit 1695ca6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/python_testing/TC_PAVS_1_0.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import push_av_server

from multiprocessing import Process
import chip.clusters as Clusters
from chip.clusters import ClusterObjects as ClusterObjects
from matter_testing_support import (ClusterAttributeChangeAccumulator, MatterBaseTest, TestStep, default_matter_test_main,
Expand All @@ -14,6 +15,18 @@ class TC_PAVS_1_0(MatterBaseTest):
for a better integration. It is not designed to be merged nor does it actually run.
"""

def setup_class(self):
super().setup_class()

self.proc = Process(target=push_av_server.run,
args=("127.0.0.1", 1234, None, "localhost"),
daemon=True)
self.proc.start()

def teardown_class(self):
super().teardown_class()
self.proc.terminate()

def steps_TC_PAVS_1_0(self):
return [TestStep(1, "Commissioning, already done", is_commissioning=True),
TestStep(2, "Install CA onto the device"),
Expand Down
12 changes: 6 additions & 6 deletions src/tools/push_av_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,6 @@ def gen_keypair(self, dns: str, override=False) -> tuple[Path, Path, bool]:

@app.get("/", response_class=HTMLResponse)
def root():
# TODO Include the UI here

with open("index.html", "r") as f:
return f.read()

Expand Down Expand Up @@ -474,8 +472,8 @@ def ffprobe_check(file_path: str, stream_id: int):

@app.get("/certs", status_code=200)
def list_certs():
server = [f.name for f in pathlib.Path(wd.path("server")).iterdir()]
device = [f.name for f in pathlib.Path(wd.path("device")).iterdir()]
server = [f.name for f in pathlib.Path(wd.path("certs", "server")).iterdir()]
device = [f.name for f in pathlib.Path(wd.path("certs", "device")).iterdir()]

return {"server": server, "device": device}

Expand All @@ -502,8 +500,10 @@ def sign_client_certificate(

def run(host: Optional[str], port: Optional[int], working_directory: Optional[str], dns: Optional[str]):
global wd, device_hierarchy
# For the Test Harness implementation, will need to find a way to return a reference
# to the server running in the background. This function currently doesn't return.
"""Run the reference server. This function will not return.
In the context where a background server is required, the multiprocessing.Process object
can be used.
"""
with WorkingDirectory(working_directory) as directory:

# Sharing state with the various endpoints
Expand Down

0 comments on commit 1695ca6

Please sign in to comment.