Skip to content

[Enhancement]: test examples in github action #126

@hnwyllmm

Description

@hnwyllmm

Description

Background

We provide some examples to help developers to understand pyseekdb easily. However we don't test them when we push new code.

The solution we expect

We can take examples as integration_tests and execute them making sure the return value is 0, for example:

python3 examples/complete_example.py
if [[ $? -eq 0 ]]; then
   echo "complete_example return error"
fi

Problems exist now

It only execute one scenario in one example. For example, in examples/complete_example.py, it would create an embedded client as default and you must uncomment some code to execute other scenario such seekdb server and oceanbase server mode.

Candidate solution

I think we can create a .env file to record some environment and load it in example.py ( refer to dotenv ). The .env file may look like this:

MODE=embedded
# MODE=server
PATH=seekdb.db
DATABASE=test
HOST=127.0.0.1
PORT=2881
TENANT=sys

If so, when users execute examples on their own system, the example python files would load .env file. They also can use environment in bash, for example:

MODE=embedded HOST=127.0.0.1 PORT=10202 python3 examples/complete_example.py

If we use this solution, we can test the examples for all modes:

for example_file in `ls examples/*_example.py`
do
    echo testing $example_file
    MODE=xxx HOST=127.0.0.1 PORT=2881 python3 $example_file
    if [[ $? -eq 0 ]]
        echo $example_file failed.
        .... do something let github action know.
    fi
done

Other

Please feel free to discuss if you have any other ideas and you're welcomed to create a pull request.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions