Skip to content
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: 5 additions & 1 deletion cmd/package
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# Creates a package for Testrun

MAKE_SRC_DIR=make
TESTRUN_VER="1-2-1-alpha"

# Delete existing make files
rm -rf $MAKE_SRC_DIR/usr
Expand Down Expand Up @@ -56,4 +57,7 @@ cp -r {framework,modules} $MAKE_SRC_DIR/usr/local/testrun
dpkg-deb --build --root-owner-group make

# Rename the .deb file
mv make.deb testrun_1-2_amd64.deb
mv make.deb testrun_${TESTRUN_VER}_amd64.deb

# Echo package version
echo Created installation package at testrun_${TESTRUN_VER}_amd64.deb
24 changes: 24 additions & 0 deletions framework/python/src/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import os
import psutil
import requests
import signal
import threading
import uvicorn
from urllib.parse import urlparse
Expand Down Expand Up @@ -66,6 +67,9 @@ def __init__(self, test_run):
methods=["POST"])
self._router.add_api_route("/system/status",
self.get_status)
self._router.add_api_route("/system/shutdown",
self.shutdown,
methods=["POST"])

self._router.add_api_route("/system/version",
self.get_version)
Expand Down Expand Up @@ -243,6 +247,26 @@ async def stop_test_run(self):
async def get_status(self):
return self._test_run.get_session().to_json()

def shutdown(self, response: Response):

LOGGER.debug("Received request to shutdown Testrun")

# Check that Testrun is not currently running
if (self._session.get_status() not in [
"Cancelled",
"Compliant",
"Non-Compliant",
"Idle"]):
LOGGER.debug("Unable to shutdown Testrun as Testrun is in progress")
response.status_code = 400
return self._generate_msg(
False,
"Unable to shutdown. A test is currently in progress."
)

self._test_run.shutdown()
os.kill(os.getpid(), signal.SIGTERM)

async def get_version(self, response: Response):
json_response = {}

Expand Down
2 changes: 1 addition & 1 deletion framework/python/src/common/testreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self,
self._report_url = ''
self._cur_page = 0
# Placeholder until available in json report
self._version = 'v1.2'
self._version = 'v1.2.1-alpha'

def add_module_reports(self, module_reports):
self._module_reports = module_reports
Expand Down
8 changes: 6 additions & 2 deletions framework/python/src/core/testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,16 @@ def _register_exits(self):
signal.signal(signal.SIGABRT, self._exit_handler)
signal.signal(signal.SIGQUIT, self._exit_handler)

def shutdown(self):
LOGGER.info('Shutting down Testrun')
self.stop()
self._stop_ui()

def _exit_handler(self, signum, arg): # pylint: disable=unused-argument
LOGGER.debug('Exit signal received: ' + str(signum))
if signum in (2, signal.SIGTERM):
LOGGER.info('Exit signal received.')
self.stop()
self._stop_ui()
self.shutdown()
sys.exit(1)

def _get_config_abs(self, config_file=None):
Expand Down
2 changes: 1 addition & 1 deletion make/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: Testrun
Version: 1.2
Version: 1.2.1-alpha
Architecture: amd64
Maintainer: Google <boddey@google.com>
Homepage: https://github.com/google/testrun
Expand Down