docs/content/ftest/tests.md

51 lines
2 KiB
Markdown
Raw Permalink Normal View History

2023-10-02 00:27:41 +05:30
+++
title = "Tests"
insert_anchor_links = "right"
weight = 6
+++
Tests are Docker containers that test
[specimens](@/ftest/terminology.md#specimen) a very specific protocol
or a feature. They integrate with ftest by accepting configuration
parameters through environment variables and uploading results through a
REST API.
## Configuration (Environment Variables)
### Auto-generated
Some environment variables are automatically generated by ftest
| Name | Purpose |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `FTEST_AUTH` | Authentication token that should be used when uploading results to ftest server. It is ephemeral, and randomly generated for each test. |
| `FTEST_HOST` | The hostname of the ftest server. Results must be uploaded to here. Will be in format http://ftest:9000 |
| `FTEST_TARGET_HOST` | The hostname of the specimen server. Tests must be run against this hostname. Will be in format http://specimen:8080 |
### User provided
There's option to fetch custom environment variables also. Please
specify them in your test's documentation clearly. The README file of
the test is recommended.
## Results API:
A formal OpenAPI specification for the ftest server is yet to be
created. For now, this command should upload test results to the ftest
server:
```python
def upload_logs_to_ftest(auth, success: bool, logs: str):
ftest = f"http://ftest.example.org/api/v1/{auth}/results"
payload = {"success": success, "logs": logs}
res = requests.post(
ftest, json=payload, headers={"Origin": "http://example.org"}
)
if res.status_code == 200:
logger.info("Upload successful")
else:
print(res)
upload_logs_to_ftest("supersecretauthtoekn_provided_by_ftest", True, "")
```