Skip to content

API hangs when dev errors are not handled correctly #794

@Jaap-Neven

Description

@Jaap-Neven

Problem description

With BOPTEST v0.7, the API was changed such that a testcase should be selected in the Python code itself instead of through a powershell command. I think this is mentioned in Issue #617.

When developing a controller, two types of errors can occur.
1: A buggy request to the API which gives an error in Docker.
2: An error in your own Python code.

When developing with the current BOPTEST version, both types of errors cause the API to hang (not returning anything while the python code still runs) if not handled correctly. These problems are caused by not correctly stopping the testcase through the PUT stop/{testid} command, when a bug causes your own code to crash.

Error reproduction

Step 1: Adding a buggy line to produce an error. For example I added control_step = error_test between lines 165 and 166 in interface.py, where error_test doesn't exist. Then, run testcase1.py.

Step 2: Remove the buggy line and run testcase1.py again. In my case, the service hangs without returning an error.

Solution proposition

These types of errors will occur during development, so we should adapt the examples such that they are able to deal with these. This way, we set a good example for new developers. First idea for this:

  1. Include the PUT stop/{testid} within the check_response()-function in interface.py. This handles API request errors.
  2. Wrap the control_test function is all examples in a try-expect statement. If it crashes, execute PUT stop/{testid} in the except part. This handles your own python errors.

I would happily implement such a solution. Feel free to share any remarks about this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions