|
| 1 | +# Steps to use Test-agent Command Line Interface |
| 2 | +`test-agent-cli` lets you write TestSys test using Bash and help in receiving and sending information from/to the TestSys cluster. |
| 3 | + |
| 4 | +## Prerequisites: |
| 5 | +* kind: https://kind.sigs.k8s.io/docs/user/quick-start/ |
| 6 | +* Kubectl: https://kubernetes.io/docs/tasks/tools/ |
| 7 | +* Docker : https://docs.docker.com/get-started/ |
| 8 | + |
| 9 | +## Steps to install TestSys |
| 10 | +Set the TESTSYS_DIR variable to point to the directory in which you have cloned the project. For example: |
| 11 | +```shell |
| 12 | +export TESTSYS_DIR="${HOME}/repos/bottlerocket-test-system" |
| 13 | +``` |
| 14 | +Set alias |
| 15 | +```shell |
| 16 | +alias cli="${TESTSYS_DIR}/.cargo/bin/cli" |
| 17 | +``` |
| 18 | +Install the `cli` command line tool into the local CARGO_HOME as: |
| 19 | + ```shell |
| 20 | + cd "${TESTSYS_DIR}" |
| 21 | + cargo install --path "${TESTSYS_DIR}/cli" --force |
| 22 | + ``` |
| 23 | + |
| 24 | +## Steps to create Bash based TestAgent: |
| 25 | + |
| 26 | +The following commands can be used to communicate with a TestSys cluster. Create a bash script like [Example test](../examples/example_test_agent_cli/example-test.sh). |
| 27 | +```shell |
| 28 | +# Get the configuration details and set the task state running |
| 29 | +test-agent-cli init |
| 30 | + |
| 31 | +# Get the number of retires allowed in case of failing tests |
| 32 | +test-agent-cli retry-count |
| 33 | + |
| 34 | +# Get the secret value using the secret key |
| 35 | +test-agent-cli get-secret secret-key |
| 36 | + |
| 37 | +# Send the result of every test run to test object in Controller |
| 38 | +test-agent-cli send-result -o pass -p 1 -f 0 -s 0 |
| 39 | + |
| 40 | +# Send any error encountered in test |
| 41 | +test-agent-cli send-error error-message |
| 42 | + |
| 43 | +# Mark the test as completed |
| 44 | +test-agent-cli terminate --results-dir results_directory |
| 45 | +``` |
| 46 | +Create a [Dockerfile](../examples/example_test_agent_cli/Dockerfile).\ |
| 47 | +Remember to set the ENTRYPOINT to the test Bash script and install the required packages. |
| 48 | + |
| 49 | +Create the docker image.\ |
| 50 | +**Note**: Add a target to the `Makefile` to create the new image. |
| 51 | + ```shell |
| 52 | + make example-test-agent-cli |
| 53 | + docker image tag example-test-agent-cli example-test-agent-cli:bash |
| 54 | + ``` |
| 55 | + |
| 56 | +Create and tag the controller image. |
| 57 | + ```shell |
| 58 | + make controller |
| 59 | + docker image tag controller controller:bash |
| 60 | + ``` |
| 61 | + |
| 62 | +## Steps to use Bash based TestAgent: |
| 63 | + |
| 64 | +Check if the cluster already exists: |
| 65 | + ```shell |
| 66 | + kind get clusters |
| 67 | + ``` |
| 68 | +If the cluster already exists, it should be deleted. |
| 69 | + ```shell |
| 70 | + kind delete cluster --name <testsys_cluster_name> |
| 71 | + ``` |
| 72 | +Create the new cluster. |
| 73 | + ```shell |
| 74 | + kind create cluster --name <testsys_cluster_name> |
| 75 | + ``` |
| 76 | +Now the images created earlier need to be added to the cluster. |
| 77 | + ```shell |
| 78 | + kind load docker-image controller:bash example-test-agent-cli:bash --name <testsys_cluster_name> |
| 79 | + ``` |
| 80 | +Install TestSys to the cluster. |
| 81 | + ```shell |
| 82 | + cli install --controller-uri controller:bash |
| 83 | + ``` |
| 84 | + |
| 85 | +Create a [yaml file](../tests/data/deploy_test.yaml) for Test. |
| 86 | + |
| 87 | +Run the test. |
| 88 | + ```shell |
| 89 | + cli run file <filename> |
| 90 | + ``` |
| 91 | +Check the status of the test. |
| 92 | + ```shell |
| 93 | + cli status -c |
| 94 | + ``` |
| 95 | +Cleanup all the resources. |
| 96 | + ```shell |
| 97 | + cli delete |
| 98 | + ``` |
| 99 | + |
0 commit comments