Skip to content

Build, Load and Test

💡 TL;DR - rebuild, local install, run tests

The Build Load and Test Run Configuration:

  1. Rebuilds the project locally
  2. Installs it from the local build

    • At: ApiLogicServer/ApiLogicServer-dev/build_and_test/ApiLogicServer
  3. Runs a series of tests

    • Tests are configurable, which can reduce setup.

The resultant install provides a venv which is used in unit testing as the default venv. A Run Configuration is provided for build-only, to enable such unit testing.

As of version 6.02.20, test automation provides automated regression testing. These have been verified on Mac, Linux (Ubuntu) and Windows.

 

Best Practice: Smoke Test First

The tests take several minutes, and errors can be slightly difficult to diagnose.

The bulk of the tests are in the Sample Projects's Behave tests. These reveal most of the errors, and are simplest to debug using a created project.

We therefore recommend that, before you run the full regression, first:

  1. Create the BLT venv (useful for running the smoke test app - see here)

BLT Hold Tomato

  1. Verify the smoke test with the Sample App

Optional Docker Setup

Full testing requires Docker:

You can reduce or completely eliminate docker requirements by configuring the tests as described in the next section.

 

Install SetupTools

As of release, the system uses setuptools.

You may need verify build is installed. You can install it manually:

python -m pip install build
python -m pip install setuptools

 

Configuring the Tests

The automated test (use the launch configuration Build Load & Test) performs a number of steps. You can configure the test to run some or all of these by editing the env_xxx.py files shown here:

Test env files

Key aspects are described in the sub-sections below.

 

do_install_api_logic_server

This:

  1. Runs the standard Python build: python3 setup.py sdist bdist_wheel
  2. Installs it into a Python environment

    • ApiLogicServer/ApiLogicServer-dev/build_and_test/ApiLogicServer
  3. Installs pyodbc. Note this requires you have installed odbc, but install failures are intentionally ignored (instead, skip the Sql/Server database withdo_docker_sqlserver = False )

💡 venv can be used for created projects

You will find it helpful to use this as a shared venv.

 

do_create_api_logic_project...

This creates the sample project, runs the server, and tests the logic using the behave tests. It produces quite a lot of output which you can ignore. The test is designed to terminate if the tests fail.

These are extensive tests which verify project creation, server startup, logic and some minimal API testing (the Behave tests issue APIs to read/write data).

 

do_allocation_test

This is a complex rule example.

 

do_docker_<database>

These create projects from docker databases (see here) which are expected to be running. They perform minimal validation to ensure the server starts by executing the hello world API.

This in fact verifies that the `models.py` file is created and runs.

If you don't wish to install or run the docker databases, edit your tests/build_and_test/env.py to disable do_docker_creation_tests.