# Test Case Execution

In the home folder of the logged-in user, there is a Python script name "qjob.py". This script handles test scheduling.

Following is a brief usage of the script:

```bash
oper@ftasvm:~$ ./qjob.py -h
usage: qjob.py [-h] [-a {add,remove,show,kill_job} | -S {running,paused}] [-s SUITEFILE] [-V]

Test Job Queue Submitter

optional arguments:
  -h, --help            show this help message and exit
  -a {add,remove,show,kill_job}, --action {add,remove,show,kill_job}
                        add: Add job to queue; remove: remove job from queue; show: show queue; kill_job: kill running job
  -S {running,paused}, --status {running,paused}
                        Set queue execution status. ["running" or "paused"]
  -s SUITEFILE, --suitefile SUITEFILE
                        Yaml testsuite file to send to the execution queue
  -V, --version         Show FTAS VM version
oper@ftasvm:~$ 
```

The script can take the following actions:

* Show the current queue

```bash
oper@ftasvm:~$ ./qjob.py -a show
Job_Queue:  []
Queue Status:  paused
oper@ftasvm:~$ 
```

When no tests are scheduled the script will show an empty queue.

* Adding test suite to the queue

```bash
oper@ftasvm:~$ ./qjob.py -a add -s testsuites/data_2dut.suite   
oper@ftasvm:~$ ./qjob.py -a add -s testsuites/data_4dut.suite  

oper@ftasvm:~$ ./qjob.py -a show
Job_Queue:  ['/home/oper/testsuites/data_2dut.suite', '/home/oper/testsuites/data_4dut.suite']
Queue Status:  paused
oper@ftasvm:~$ 
```

we can add multiple test suits to the queue at any time to be executed.

* Removing the test suite from the queue

```bash
oper@ftasvm:~$ ./qjob.py -a remove -s /home/oper/testsuites/data_4dut.suite 
[INFO]: Test job removed /home/oper/testsuites/data_4dut.suite
oper@ftasvm:~$ 

oper@ftasvm:~$ ./qjob.py -a show
Job_Queue:  ['/home/oper/testsuites/data_2dut.suite']
Queue Status:  paused
oper@ftasvm:~$ 
```

* Changing queue status

There are two statuses in the job queue:&#x20;

When the job queue is in "<mark style="background-color:red;">paused</mark>" status, the test\_*runner service does not pick any job in the queue for execution.*&#x20;

*When the job queue is in "<mark style="background-color:green;">running</mark>" status, the test*\_*runner service picks the oldest job in the queue for execution. After the test case execution is complete the queue test\_*&#x72;unner service changes the queue status to "<mark style="background-color:yellow;">paused</mark>".

```bash
oper@linux:~$ ./qjob.py -S running
```

{% hint style="info" %}
Changing the queue status from running to paused when there is a running job, won't stop the running job but the test\_*runner service won't pick the next job for execution.*
{% endhint %}

* Kill or terminate a running job

After terminating the running job test\_runner service pauses the queue.

```bash
oper@linux:~$ ./qjob.py -a kill_job
Trying to terminate running job...done
[INFO]: The queue is paused. Please update its status after your debugging

oper@linux:~$ ./qjob.py -a remove -s /home/oper/testsuites/data_2dut.suite 
[INFO]: Test job removed /home/oper/testsuites/data_2dut.suite
oper@ftasvm:~$ 
```

&#x20;
