Skip to content

Commit 086b7a9

Browse files
authored
Merge pull request keploy#16 from keploy/fastapi-readme
fix: Keploy installation method in readme
2 parents 6426975 + f05aab2 commit 086b7a9

File tree

14 files changed

+32
-2425
lines changed

14 files changed

+32
-2425
lines changed

django-postgres/README.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,11 @@ git clone https://github.com/keploy/samples-python.git && cd samples-python/djan
1919

2020
Keploy can be installed on Linux directly and on Windows with the help of WSL. Based on your system architecture, install the keploy latest binary release
2121

22-
**1. AMD Architecture**
23-
24-
```shell
25-
curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp
26-
27-
sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy
28-
```
29-
30-
<details>
31-
<summary> 2. ARM Architecture </summary>
32-
33-
```shell
34-
curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_arm64.tar.gz" | tar xz -C /tmp
35-
36-
sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy
22+
```bash
23+
curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh
24+
keploy
3725
```
3826

39-
</details>
40-
4127
### Starting the PostgreSQL Instance
4228

4329
```bash

fastapi-postgres/README.md

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,26 @@ pip3 install -r requirements.txt
2020

2121
Keploy can be installed on Linux directly and on Windows with the help of WSL. Based on your system architecture, install the keploy latest binary release
2222

23-
**1. AMD Architecture**
24-
25-
```shell
26-
curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp
27-
28-
sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy
29-
```
30-
31-
<details>
32-
<summary> 2. ARM Architecture </summary>
33-
34-
```shell
35-
curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_arm64.tar.gz" | tar xz -C /tmp
36-
37-
sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy
23+
```bash
24+
curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh
25+
keploy
3826
```
3927

40-
</details>
41-
4228
### Starting the PostgreSQL Instance
4329

4430
```bash
4531
# Start the application
4632
docker-compose up -d
4733
```
4834

35+
> Note: Update the `SQLALCHEMY_DATABASE_URL` in the `database.py` file if you want to use a keploy with docker.
36+
4937
### Capture the Testcases
5038

5139
This command will start the recording of API calls using ebpf:-
5240

5341
```shell
54-
sudo -E keploy record -c "uvicorn application.main:app --reload"
42+
sudo -E PATH=$PATH keploy record -c "uvicorn application.main:app --reload"
5543
```
5644

5745
Make API Calls using Hoppscotch, Postman or cURL command. Keploy with capture those calls to generate the test-suites containing testcases and data mocks.
@@ -118,7 +106,7 @@ Now all these API calls were captured as **editable** testcases and written to `
118106
Now let's run the application in test mode.
119107

120108
```shell
121-
sudo -E keploy test -c "uvicorn application.main:app --reload" --delay 10
109+
sudo -E PATH=$PATH keploy test -c "uvicorn application.main:app --reload" --delay 10
122110
```
123111

124112
So, no need to setup fake database/apis like Postgres or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to Postgres 😄**

fastapi-postgres/application/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sqlalchemy.orm import sessionmaker
44

55

6-
SQLALCHEMY_DATABASE_URL = "postgresql://postgres:postgres@0.0.0.0:5432/studentdb"
6+
SQLALCHEMY_DATABASE_URL = "postgresql://postgres:postgres@postgres:5432/studentdb"
77

88
engine = create_engine(SQLALCHEMY_DATABASE_URL)
99
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

fastapi-postgres/docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,19 @@ services:
1111
- "5432:5432" # Map the PostgreSQL port to the host machine
1212
volumes:
1313
- ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql
14+
networks:
15+
- keploy-network
16+
17+
app:
18+
container_name: fastapi-app
19+
image: fastapi
20+
build:
21+
context: .
22+
dockerfile: Dockerfile
23+
restart: unless-stopped
24+
ports:
25+
- 8000:8000
26+
depends_on:
27+
- postgres
28+
networks:
29+
- keploy-network

0 commit comments

Comments
 (0)