SkywardAI / kirin

Self-hosted and local-first application for inference and RAG on consumer grade hardware.
Apache License 2.0
8 stars 8 forks source link

[quality]: Add mock suit test framework #90

Closed Aisuko closed 4 months ago

Aisuko commented 7 months ago

As the process of development, we add vector db and others. It is hard for us to do the real test cases in CI. So, we need to add mock API behaviour test cases rather than trying to start the real instance.

Aisuko commented 6 months ago

Hi @Micost @jinronga guys. We need a mock test framework for FastAPI. It can enhance the confidence when we maintain the repo. E.g: merge the PR. Please keep in mind. Thank you.

For this task, I think we can do some research first. And then share some simple examples with the folks. The community call document is a good place for everyone. https://docs.google.com/document/d/1gsNNkQ5hFLBttZ4pSf01VHpF5K89Usl1yscr1J0afcc/edit?usp=sharing

CarterFaceySmith commented 6 months ago

@Aisuko is this not encompassed in existing pytest testing framework? It seems maybe expanding that from the backend/tests subfolder may be a good idea, or do we need something more?

Micost commented 6 months ago

@Aisuko @CarterFaceySmith I add this issue into milestone 0.1.8 , I think pytest is a good choice . It covers the unit test and end-to-end test.

Aisuko commented 6 months ago

Hi guys. We already have some test cases with Pytest framework. However, these test cases are needed we have the whole components were deployed, like pgsql, vector db. We can't do that in the CI pipeline. It is un-efficiency(it will take 5-10 minutes every time, and we need to boost all the components).

What we want to do now is that we want to use mock API framework to mock the API behaviour. It is make sure that every APIs behaviour got checked before the PR got merged.

So, here is my thinking. Feel free to edit, remove or add the backend/tests folder.

Aisuko commented 4 months ago
Aisuko commented 4 months ago

FastAPI's injection dependency feature doesn't work. So, the mock test framework can't be achieved. See https://github.com/tiangolo/fastapi/discussions/8127. And the PR https://github.com/SkywardAI/kirin/pull/270 includes test cases using FastAPI injection system. However, it doesn't work. We will not waste time in this issue.