Writing Autests

Traffic Server has two types of developer tests: (1) Catch2 tests for unit tests and (2) AuTest framework tests for end-to-end testing. The Catch tests reside next the the associated source code being tested while AuTests are located in tests/gold_tests/ with .test.py extensions.

This document focuses on AuTest framework tests because they are rather unique to the Traffic Server project while Catch2 documentation can be found elsewhere.

File Structure and Naming

Here is a summary of the file structure and naming conventions for AuTest tests:

  • AuTest tests are placed in appropriate subdirectories under tests/gold_tests/ (e.g., cache/, pluginTest/<plugin_name>, tls/, etc.)

  • AuTest test files have a descriptive name with a .test.py extension (e.g., cache-auth.test.py, stats_over_http.test.py). When the tests are run, be aware that their names, sans the .test.py extension, are used to identify the test.

  • The .test.py typically are thin and reference the associated replay.yaml file that describes the test via the Test.ATSReplayTest() method.

  • tests/gold_tests/autest-site is a special directory. AuTest, a general testing framework, is extended to add domain specific support, Traffic Server in this case, via .test.ext extension files. The files in here customize the command line arguments recognized by the autest command, the functions availabe to the Test and TestRun AuTest objects, specific Process objects available to test, Skip conditions for individual tests, etc.

Running Autests

If Traffic Server cmake build is configured via -DENABLE_AUTEST=ON, tests can be run with:

cmake --build build
cmake --install build
cd build/tests
pipenv install
./autest.sh --sandbox /tmp/sbcursor --clean=none -f <test_name_without_test_py_extension>

For example, to run cache-auth.test.py:

./autest.sh --sandbox /tmp/sbcursor --clean=none -f cache-auth