Run your first scenario
This guide runs one scenario against the mock agent on your machine. You finish with a verdict, an exit code and a report file. Every step gives the command for PowerShell and for bash.
Before you start
- A clone of the repository, and a shell opened in its root.
- Go, to build the
roboteloscommand (see the Quickstart for the version). - Docker, because
robotelos dev upruns PostgreSQL in a container. See Local stack and database. - Two terminals. The first one stays busy with the stack.
Step 1: Build the command
PowerShell:
go build -o robotelos.exe ./runtime/cmd/robotelos
bash:
go build -o robotelos ./runtime/cmd/robotelos
The command succeeds when it prints nothing and the file exists. The commands below use .\robotelos.exe in PowerShell and ./robotelos in bash.
Step 2: Start the stack
In the first terminal, PowerShell:
.\robotelos.exe dev up
bash:
./robotelos dev up
dev up starts PostgreSQL, applies the migrations and runs the gateway. It serves the mock agent, which answers with You said: followed by your message. The gateway listens on 127.0.0.1:8787 for HTTP. The local stack tells clients that it is the local environment with sandbox effects, and it turns the inspection on. Leave this terminal open.
Step 3: Read the token
In the second terminal, in the repository root. The token goes into an environment variable and is not printed.
PowerShell:
$env:ROBOTELOS_E2E_TOKEN = (Get-Content -Raw "$HOME\.robotelos\dev\token").Trim()
bash:
export ROBOTELOS_E2E_TOKEN="$(tr -d '\r\n' < "$HOME/.robotelos/dev/token")"
robotelos test run reads the token from ROBOTELOS_E2E_TOKEN. --token-env NAME names another variable.
Step 4: Put the spec in a folder
robotelos test run takes a folder, and runs every .json file in it. It does not take a single file. Make a folder that holds only chat-greeting.json.
PowerShell:
New-Item -ItemType Directory first-scenario | Out-Null
Copy-Item runtime/internal/e2e/testdata/specs/chat-greeting.json first-scenario/
bash:
mkdir first-scenario
cp runtime/internal/e2e/testdata/specs/chat-greeting.json first-scenario/
The spec says hello and expects one or two replies, no work started, and no internal id in the reply. Write a scenario explains every field.
Step 5: Run it
PowerShell:
.\robotelos.exe test run first-scenario --url http://127.0.0.1:8787 --agent mock --inspect-url http://127.0.0.1:8787 --out report.json
echo $LASTEXITCODE
bash:
./robotelos test run first-scenario --url http://127.0.0.1:8787 --agent mock --inspect-url http://127.0.0.1:8787 --out report.json
echo $?
--urlis the HTTP address of the gateway. The runner also reads the target’s own statement of its environment from it.--agent mockis the id of the mock agent.--inspect-urllets the runner read the system’s counters. The spec checksrunswithstate_equals. Without the inspection that criterion is not judged, and a required criterion that is not judged makes the runINCOMPLETE.--outwrites the full report as JSON when the run has finished.
Step 6: Read the result
The runner prints, in this order:
- A line
target states environment local, effects sandbox. - A header with the target, the agent, the profile, the evidence level, the channel and
k. - One line per spec: the verdict (
PASS,FAIL,ERROR,INCOMPLETE,UNRUNNABLEorUNKNOWN), the spec id, how many runs passed, and how many criteria were not checked or not applicable. - Under a spec that did not pass, one line per failed criterion with its kind and a detail, and an
error:line when the run could not be made. - A last line: how many specs passed in every run, and the counts of runs that failed, were incomplete, were unrunnable or could not be made.
Success is a PASS line and exit code 0. Check the exit code, not the text.
| Exit code | Meaning |
|---|---|
| 0 | Every spec passed. |
| 1 | A spec failed, or a budget or baseline check failed. |
| 2 | Wrong usage, or an input that cannot be used. |
| 3 | Nothing failed, but a run was unrunnable, or a required criterion could not be judged. |
| 4 | Nothing failed, but a run could not be made, or a trial is UNKNOWN. |
| 5 | The run was cancelled. |
| 6 | Another runner holds the --job-dir. |
UNKNOWN means an attempt started and left no result, so what it did to the target is not known. It is never a pass.
Open report.json to see the same result with every finding. Reference lists its fields.
Step 7: Stop
In the first terminal press Ctrl-C to stop the gateway. Then remove the database container, in the second terminal.
PowerShell:
.\robotelos.exe dev down
bash:
./robotelos dev down
dev down --volumes also deletes the data. Delete the first-scenario folder and report.json if you do not need them.
If something goes wrong
| What you see | Cause and fix |
|---|---|
the environment variable ROBOTELOS_E2E_TOKEN holds no token, exit 2 | Step 3 was skipped in this terminal. Run it again. A new terminal does not keep the variable. |
e2e: no specs in ..., exit 2 | The path is a file, or a folder without .json files. Pass the folder. |
--url and --agent are required, exit 2 | Add both flags. |
ask the target for its environment: ..., exit 4 | The runner could not reach the gateway. Check that dev up is still running and that --url is http://127.0.0.1:8787. |
... has no address to ask for its environment: give --discovery-url | The runner needs an http:// or https:// address, or a ws:// one, to ask the target what it is. A bare host:port for gRPC has none. Use the HTTP address. |
dev up cannot start because a port is in use | Another program holds 8787, 8788 or 5433. Stop it, or give dev up other addresses with --http, --grpc and --postgres-port. Then use the same HTTP address in --url and --inspect-url. |
INCOMPLETE and exit 3 | A required criterion was not judged. Add --inspect-url. |
robotelos dev doctor lists problems with Docker, the configuration folder and the ports. For more, see Common problems.
Next steps
- Write a scenario of your own and lint it.
- Run against a real agent with a live model.
- Reference for every flag of
robotelos test run.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.