Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

384421113: Add starting status #1032

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions framework/python/src/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ async def start_testrun(self, request: Request, response: Response):
TestrunStatus.IN_PROGRESS,
TestrunStatus.WAITING_FOR_DEVICE,
TestrunStatus.MONITORING,
TestrunStatus.VALIDATING
TestrunStatus.VALIDATING,
TestrunStatus.STARTING

]:
LOGGER.debug("Testrun is already running. Cannot start another instance")
Expand Down Expand Up @@ -341,7 +342,8 @@ async def stop_testrun(self, response: Response):
not in [TestrunStatus.IN_PROGRESS,
TestrunStatus.WAITING_FOR_DEVICE,
TestrunStatus.MONITORING,
TestrunStatus.VALIDATING]):
TestrunStatus.VALIDATING,
TestrunStatus.STARTING]):
response.status_code = 404
return self._generate_msg(False, "Testrun is not currently running")

Expand Down
3 changes: 3 additions & 0 deletions framework/python/src/common/statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@


class TestrunStatus:
"""Enum for all possible Testrun statuses"""
IDLE = "Idle"
STARTING = "Starting"
WAITING_FOR_DEVICE = "Waiting for Device"
MONITORING = "Monitoring"
IN_PROGRESS = "In Progress"
Expand All @@ -27,6 +29,7 @@ class TestrunStatus:


class TestResult:
"""Enum for all possible test results"""
IN_PROGRESS = "In Progress"
COMPLIANT = "Compliant"
NON_COMPLIANT = "Non-Compliant"
Expand Down
2 changes: 1 addition & 1 deletion framework/python/src/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def __init__(self, root_dir):

def start(self):
self.reset()
self._status = TestrunStatus.WAITING_FOR_DEVICE
self._status = TestrunStatus.STARTING
self._started = datetime.datetime.now()

def get_started(self):
Expand Down
1 change: 1 addition & 0 deletions framework/python/src/core/testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ def start(self):
self._device_stable, [NetworkEvent.DEVICE_STABLE])

self.get_net_orc().start_listener()
self.get_session().set_status(TestrunStatus.WAITING_FOR_DEVICE)
LOGGER.info('Waiting for devices on the network...')

# Keep application running until stopped
Expand Down
3 changes: 2 additions & 1 deletion framework/python/src/net_orc/network_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@ def internet_conn_checker(self, mqtt_client: mqtt.MQTT, topic: str):
if self.get_session().get_status() not in [
TestrunStatus.WAITING_FOR_DEVICE,
TestrunStatus.MONITORING,
TestrunStatus.IN_PROGRESS
TestrunStatus.IN_PROGRESS,
TestrunStatus.STARTING
]:
message['connection'] = None

Expand Down
27 changes: 24 additions & 3 deletions testing/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,9 @@ def test_sys_status_cancelled(empty_devices_dir, add_devices, # pylint: disable=
@pytest.mark.parametrize("add_devices", [
["device_1"]
],indirect=True)
def test_sys_status_waiting(empty_devices_dir, add_devices, # pylint: disable=W0613
testrun, start_test): # pylint: disable=W0613
""" Test for system status 'Waiting for Device' (200) """
def test_sys_status_starting(empty_devices_dir, add_devices, # pylint: disable=W0613
testrun, start_test): # pylint: disable=W0613
""" Test for system status 'Starting' and 'Waiting for Device' (200) """

# Send the get request
r = requests.get(f"{API}/system/status", timeout=5)
Expand All @@ -741,6 +741,27 @@ def test_sys_status_waiting(empty_devices_dir, add_devices, # pylint: disable=W0
# Parse the json response
response = r.json()

# Check if system status is 'Starting'
assert response["status"] == "Starting"

# Add max 60 seconds delay to allow for status to change
max_retries = 60

# If status is "Starting" and max_retries didn't reach 0
while response["status"] == "Starting" and max_retries != 0:

# Add 1 second delay
time.sleep(1)

# Subtract 1 from max_retries
max_retries -= 1

# Resend the get request
r = requests.get(f"{API}/system/status", timeout=5)

# Parse the json response
response = r.json()

# Check if system status is 'Waiting for Device'
assert response["status"] == "Waiting for Device"

Expand Down
Loading