Skip to content

Commit 3b19929

Browse files
CopilotSkafteNicki
andauthored
Fix terminology: API testing for inference endpoints is functional/load testing, not integration testing (#550)
* Initial plan * Clarify API testing terminology: functional and load/performance testing vs integration testing Co-authored-by: SkafteNicki <24896311+SkafteNicki@users.noreply.github.com> * Address code review: add definitions and improve example Co-authored-by: SkafteNicki <24896311+SkafteNicki@users.noreply.github.com> * small change --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: SkafteNicki <24896311+SkafteNicki@users.noreply.github.com> Co-authored-by: Nicki Skafte Detlefsen <skaftenicki@gmail.com>
1 parent c9c3104 commit 3b19929

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

reports/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,15 @@ will check the repositories and the code to verify your answers.
472472

473473
### Question 25
474474

475-
> **Did you perform any unit testing and load testing of your API? If yes, explain how you did it and what results for**
476-
> **the load testing did you get. If not, explain how you would do it.**
475+
> **Did you perform any functional testing and load testing of your API? If yes, explain how you did it and what**
476+
> **results for the load testing did you get. If not, explain how you would do it.**
477477
>
478478
> Recommended answer length: 100-200 words.
479479
>
480480
> Example:
481-
> *For unit testing we used ... and for load testing we used ... . The results of the load testing showed that ...*
482-
> *before the service crashed.*
481+
> *For functional testing we used pytest with httpx to test our API endpoints and ensure they returned the correct*
482+
> *responses. For load testing we used locust with 100 concurrent users. The results of the load testing showed that*
483+
> *our API could handle approximately 500 requests per second before the service crashed.*
483484
>
484485
> Answer:
485486

s7_deployment/testing_apis.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@
77
API testing, similar to unit testing, is a type of software testing that involves testing the application programming
88
interface (API) directly to ensure it meets requirements for functionality, reliability, performance, and security.
99
The core difference from the unit testing we have been implementing until now is that instead of testing the individual
10-
functions, we are testing the entire API as a whole. API testing is therefore a form of
11-
[integration testing](https://en.wikipedia.org/wiki/Integration_testing). Additionally, another difference is that we
12-
need to simulate API calls that should be as similar as possible to the ones that will be made by the users of the API.
10+
functions, we are testing the entire API as a whole.
11+
12+
!!! note "API testing vs integration testing"
13+
14+
While API testing can sometimes be a form of [integration testing](https://en.wikipedia.org/wiki/Integration_testing),
15+
it is not always the case. Integration testing specifically tests how multiple components or services work together,
16+
such as testing that your API correctly integrates with a database, external APIs, or other services. However, for
17+
the simple inference APIs we typically build in this course (load model → convert input → run inference → return
18+
output), we are not really integrating with other services. Therefore, the kind of testing we do in this module
19+
is better described as **functional testing** (testing that individual API endpoints work correctly and return the
20+
expected outputs for given inputs) and **load/performance testing** (testing how the API handles many concurrent
21+
requests) rather than integration testing.
1322

1423
There are in general two things that we want to test when working with APIs:
1524

@@ -37,7 +46,7 @@ my_project
3746
| |-- unittests/
3847
| | |-- test_train.py
3948
| | |-- test_data.py
40-
| |-- integrationtests/
49+
| |-- apitests/
4150
| | |-- test_apis.py
4251
```
4352

@@ -63,7 +72,7 @@ to change.
6372

6473
2. If you have already done the module on [unittesting](../s5_continuous_integration/unittesting.md) then you should
6574
already have a `tests/` folder. If not then create one. Inside the `tests/` folder create a new folder called
66-
`integrationtests/`. Inside the `integrationtests/` folder create a file called `test_apis.py` and write the
75+
`apitests/`. Inside the `apitests/` folder create a file called `test_apis.py` and write the
6776
following code:
6877

6978
```python
@@ -105,8 +114,8 @@ to change.
105114
4. To run the tests, you can use the following command:
106115

107116
```bash
108-
pytest tests/integrationtests/test_apis.py
109-
```
117+
pytest tests/apitests/test_apis.py
118+
ffffffff ```
110119

111120
Make sure that all your tests pass.
112121

0 commit comments

Comments
 (0)