|
| 1 | +# How to run RAFT on your local machine |
| 2 | + |
| 3 | +There are times where you might want to test your service on your development machine before |
| 4 | +committing the changes to run in a CI/CD pipeline with your Azure deployment of RAFT. The |
| 5 | +`raft_local.py` script is your way to do that. |
| 6 | + |
| 7 | +Because RAFT uses containers for the testing tools, this script will pull down the tools needed |
| 8 | +and run them using docker on your local machine. |
| 9 | + |
| 10 | +### Requirements |
| 11 | + |
| 12 | +This script has been tested with these versions of these tools. |
| 13 | +* Python (3.8) |
| 14 | +* Docker (20.10) |
| 15 | + |
| 16 | +### Limitations |
| 17 | + |
| 18 | +This script only supports the **job create** command. See `raft_local.py --help` for details. |
| 19 | + |
| 20 | +### Getting Started |
| 21 | + |
| 22 | +Run `raft_local.py local init` to auto-create required directories. |
| 23 | + |
| 24 | +These are the directories that will be created and are expected by the script. |
| 25 | +```Text |
| 26 | +CLI //root folder where you downloaded the CLI |
| 27 | +|- raft_local.py // raft_local.py script |
| 28 | +|- local // folder named local located at the same level as raft_local.py |
| 29 | + |- secrets // folder named secrets located inside of local folder |
| 30 | + |- storage // folder names storage located inside of local folder |
| 31 | + |- events_sink // folder used to synchronize test tool events |
| 32 | +``` |
| 33 | + |
| 34 | + |
| 35 | +* The `storage` folder will contain all of the data produced by RAFT job runs. |
| 36 | +* The `secrets` folder is a user maintained folder. </br> |
| 37 | + The files in this folder are the names of the secret used in the job definition file. |
| 38 | + These files should not have an extension. |
| 39 | + |
| 40 | + For example if my RAFT job configuration requires a text token. |
| 41 | + I can store the token in file `MyToken` under `CLI/local/secrets/MyToken` and use `MyToken` |
| 42 | + as the secret name in RAFT job configuration. |
| 43 | + |
| 44 | + ``` |
| 45 | + "authenticationMethod": { |
| 46 | + "TxtToken": "MyToken" |
| 47 | + } |
| 48 | + ``` |
| 49 | + |
| 50 | +### Running raft_local.py |
| 51 | + |
| 52 | +Once you have completed the getting started portion you can use `raft_local.py` to |
| 53 | +run a job on your local machine. |
| 54 | + |
| 55 | +Here is an example job definition that runs RESTler and ZAP on a |
| 56 | +deployed instance of [PetStore](https://petstore3.swagger.io) that can be launched with |
| 57 | +`raft_local.py` |
| 58 | + |
| 59 | + |
| 60 | +```text |
| 61 | +{ |
| 62 | + "testTasks": { |
| 63 | + "targetConfiguration": { |
| 64 | + "apiSpecifications": [ "https://petstore3.swagger.io/api/v3/openapi.json" ], |
| 65 | + "endpoint": "https://petstore3.swagger.io" |
| 66 | + }, |
| 67 | + "tasks": [ |
| 68 | + { |
| 69 | + "toolName": "RESTler", |
| 70 | + "outputFolder": "restler-logs", |
| 71 | + "toolConfiguration": { |
| 72 | + "tasks": [ |
| 73 | + { |
| 74 | + "task": "compile" |
| 75 | + }, |
| 76 | + { |
| 77 | + "task": "Fuzz", |
| 78 | + "runConfiguration": { |
| 79 | + "Duration": "00:10:00" |
| 80 | + } |
| 81 | + } |
| 82 | + ] |
| 83 | + } |
| 84 | + }, |
| 85 | + { |
| 86 | + "toolName": "ZAP", |
| 87 | + "outputFolder": "zap-logs" |
| 88 | + } |
| 89 | + ] |
| 90 | + } |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +Example command line to create a local job:</br> |
| 95 | +`python raft_local.py job create --file <jobdefinitionfile>` |
0 commit comments