Commit d52562fc authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Added Interrupt Exception

parent dc1d0940
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
#!/bin/bash
timestamp=$(date +"%Y%m%d_%H%M%S")

DOCKER_ROBOT_IMAGE=dockerhub.hi.inet/5ghacking/5gnow-robot-test-image
DOCKER_ROBOT_IMAGE_VERSION=4.0
cd ..
REPOSITORY_BASE_FOLDER=${PWD}
TEST_FOLDER=$REPOSITORY_BASE_FOLDER/tests
RESULT_FOLDER=$REPOSITORY_BASE_FOLDER/results
RESULT_FOLDER=$REPOSITORY_BASE_FOLDER/results/$timestamp
ROBOT_DOCKER_FILE_FOLDER=$REPOSITORY_BASE_FOLDER/tools/robot

# nginx Hostname and http port (80 by default) to reach for tests
+24 −0
Original line number Diff line number Diff line
import signal
from robot.libraries.BuiltIn import BuiltIn

class InterruptListener:
    ROBOT_LISTENER_API_VERSION = 3

    def __init__(self):
        signal.signal(signal.SIGINT, self._handle_interrupt)
        self.builtin = BuiltIn()

    def _handle_interrupt(self, signum, frame):
        print("Execution interrupted! Running cleanup keyword...")
        try:
            self.builtin.run_keyword('Reset Testing Environment')
        except Exception as e:
            print(f"Error during cleanup: {e}")
        finally:
            exit(0)
    
    def start_suite(self, name, attrs):
        print(f"Starting suite: {name}")

    def end_suite(self, name, attrs):
        print(f"Ending suite: {name}")
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
*** Settings ***
Library         /opt/robot-tests/tests/libraries/helpers.py
Library         /opt/robot-tests/tests/libraries/interrupt_listener.py
Library    Process
Library    Collections
Variables       /opt/robot-tests/tests/libraries/environment.py