Skip to content
Open
15 changes: 12 additions & 3 deletions versioned_docs/version-4.0.0/quickstart/csharp-dotnet-postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,20 @@ This section runs on Linux or WSL. On macOS, run it inside a [Lima VM](/docs/ins
### Clone a sample user authentication app 🧪

```bash
git clone https://github.com/keploy/samples-csharp.git && cd samples-csharp
git clone https://github.com/keploy/samples-csharp.git && cd samples-csharp/crud-app

```

### Prerequisites

- Install the [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0).
- Install the EF Core tool, using version 8 to match the project (the latest `dotnet-ef` does not work with the .NET 8 SDK):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch on pinning dotnet-ef to 8, the latest one doesn't run on .NET 8. two things nearby that'll still break this flow though:

  1. line 72 does cd samples-csharp, but the project and compose file moved to crud-app/ (samples-csharp a192656). from the repo root docker-compose up and both dotnet ef commands fail. should be cd samples-csharp/crud-app
  2. crud-app/Migrations/ already has InitialMigration committed, so dotnet ef migrations add InitialMigration (around line 98) errors out with a duplicate name. i think only dotnet ef database update is needed

optional: after a global tool install people often need export PATH="$PATH:$HOME/.dotnet/tools", the sample readme mentions it

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed all three: cd samples-csharp/crud-app, dropped migrations add since InitialMigration is already committed, and added the PATH export.


```bash
dotnet tool install --global dotnet-ef --version "8.*"
export PATH="$PATH:$HOME/.dotnet/tools"
```

### start the database instance

```bash
Expand All @@ -83,10 +93,9 @@ We'll be running our sample application right on Linux, but just to make things

### 📼 Roll the Tape - Recording Time!

We need to run the migration command before starting our application:
The project already ships an `InitialMigration`, so we only need to apply it before starting our application:

```bash
dotnet ef migrations add InitialMigration
dotnet ef database update
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Server is listening at PORT 3000
API Docs: http://localhost:3000/api/docs
```

The above command will start recording the API calls made to the application and will generate a test case in the `testcases/` directory.
The above command will start recording the API calls made to the application and will generate a test case in the `keploy/` directory.

> 💡 You can use Postman or any other API testing tool to test the API calls. Additionally, the application will run a swagger UI on `http://localhost:3000/api/docs` to visualize the API calls.

Expand Down Expand Up @@ -253,10 +253,10 @@ npm install
cp .env.example .env
```

We will be using Docker compose to run the application as well as PostreSql on Docker container.
We will be using Docker compose to run the application as well as PostgreSQL on Docker container.

Lights, Camera, Record! 🎥
Fire up the application and mongoDB instance with Keploy. Keep an eye on the two key flags: -c: Command to run the app (e.g., docker compose up).
Fire up the application and PostgreSQL instance with Keploy. Keep an eye on the two key flags: -c: Command to run the app (e.g., docker compose up).

--container-name: The container name in the docker-compose.yml for traffic interception.

Expand Down Expand Up @@ -378,7 +378,7 @@ Using `curl`

```bash
curl -X 'PUT' \
'http://localhost:3000/api/v1/task/update/2' \
'http://localhost:3000/api/v1/task/update/1' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
Expand Down Expand Up @@ -424,24 +424,22 @@ Node.js v22.7.0

<=========================================>
COMPLETE TESTRUN SUMMARY.
Total tests: 7
Total test passed: 7
Total tests: 6
Total test passed: 6
Total test failed: 0
Total time taken: "5.66 s"

Test Suite Name Total Test Passed Failed Time Taken

"test-set-0" 7 7 0 "5.66 s"
"test-set-0" 6 6 0 "5.66 s"
<=========================================>

🐰 Keploy: 2024-08-28T10:14:14+05:30 INFO calculating coverage for the test run and inserting it into the report
🐰 Keploy: 2024-08-28T10:14:14+05:30 INFO [Total Coverage Percentage: 86.16%]
🐰 Keploy: 2024-08-28T10:14:14+05:30 INFO stopping Keploy {"reason": "replay completed successfully"}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing the coverage lines is right for this run btw, keploy skips coverage by default when the command isn't native (cli/provider/cmd.go in keploy). but the line right after this block still says "Keploy also generates coverage reports for the test-suites", which now contradicts it. i'd just drop that sentence

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, dropped that sentence so it matches the run.

🐰 Keploy: 2024-08-28T10:14:14+05:30 INFO proxy stopped...
🐰 Keploy: 2024-08-28T10:14:17+05:30 INFO eBPF resources released successfully...
```

Voila! 🎉 You have successfully tested the application using Keploy. Keploy also generates coverage reports for the test-suites.
Voila! 🎉 You have successfully tested the application using Keploy.

## Related

Expand Down
16 changes: 13 additions & 3 deletions versioned_docs/version-4.0.0/quickstart/flask-redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,24 @@ git clone https://github.com/keploy/samples-python.git && cd samples-python/flas

## Using Docker Compose 🐳

We will be using Docker compose to run the application as well as Mongo on Docker container.
We will be using Docker compose to run the application as well as Redis on Docker container.

### Lights, Camera, Record! 🎥

:::note macOS
Port `5000` is used by the AirPlay Receiver on macOS, so the app fails to start with `address already in use`. Turn it off under **System Settings → General → AirDrop & Continuity → AirPlay Receiver** before recording.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked this on macOS 26: the pane really is called AirDrop & Continuity there, so your fix is right. on macOS 13 to 15 it's still AirDrop & Handoff though, and a lot of people are still on those. maybe name both:

Suggested change
Port `5000` is used by the AirPlay Receiver on macOS, so the app fails to start with `address already in use`. Turn it off under **System Settings → General → AirDrop & Continuity → AirPlay Receiver** before recording.
Port `5000` is used by the AirPlay Receiver on macOS, so the app fails to start with `address already in use`. Turn it off under **System Settings → General → AirDrop & Continuity → AirPlay Receiver** (called **AirDrop & Handoff** on macOS 15 and earlier) before recording.

:::

The `docker-compose.yml` attaches the services to an external `keploy-network`, so create it once:

```bash
docker network create keploy-network
```

Capture the test-cases-

```shell
keploy record -c "docker compose up" --container-name "flask-web" --buildDelay 50
keploy record -c "docker compose up" --container-name "flask-web" --build-delay 50
```

🔥**Make some API calls**. Postman, Hoppscotch or even curl - take your pick!
Expand Down Expand Up @@ -148,7 +158,7 @@ spec:
### **Time to run the testcases**

```bash
keploy test -c 'sudo docker compose up' --containerName "flask-web" --delay 10
keploy test -c 'docker compose up' --container-name "flask-web" --delay 10
```

You can also check the test summary from your cli
Expand Down
14 changes: 12 additions & 2 deletions versioned_docs/version-4.0.0/quickstart/go-gin-redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Start the Redis instance using the `docker-compose` file-
docker compose up redis
```

Since the application runs in a container, `localhost` would point to the container itself. In `helpers/redis/redisConnect.go`, change `Addr: "localhost:6379"` to `Addr: "myredis:6379"`.

Now, we will create the docker image of our application:-

```bash
Expand All @@ -92,7 +94,7 @@ docker build -t gin-app:1.0 .
### Capture the test-cases-

```shell
keploy record -c "docker run -p 3001:3001 --network <networkName> --name ginRedisApp gin-app:1.0"
keploy record -c "docker run -p 3001:3001 --network gin-redis_default --name ginRedisApp gin-app:1.0"
```

🔥**Make some API calls**. Postman, Hoppscotch or even curl - take your pick!
Expand Down Expand Up @@ -248,8 +250,12 @@ Want to see if everything works as expected?

Time to put things to the test 🧪

:::note
The OTP changes on every request, so mark it as noise before replaying. Add `body.otp` under `assertions.noise` in the recorded OTP test (the `GET` test in `keploy/test-set-0/tests/`).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you actually need this on 3.9.3? asking because of what you found in samples-java. when you stop keploy record, it runs an auto-replay by default ("auto-replay: recording stopped ... now replaying what was just recorded to check for noise") and writes any response-body diff it sees into the test file as noise (sandbox_auto_noise_hooks.go in enterprise). that same pass should mark body.otp on its own, the same way it marked body.timestamp for you there. the example test yaml right above (line 180) also already shows body.otp under noise, so the note reads a bit like a step that's already done.

if the GET test really did fail on otp for you, could you paste the diff? in that case two more things:

  • the POST /api/verifyCode response has a token that changes on every run too (helpers/token/token.go:22 sets exp from time.Now()), so it would need the same treatment
  • keploy now writes noise as a map, so the snippet should look like this:
assertions:
  noise:
    body.otp: []

if not, i'd reword it for the case where it's actually needed, which is when someone skips the auto-replay with a second Ctrl+C:

Suggested change
The OTP changes on every request, so mark it as noise before replaying. Add `body.otp` under `assertions.noise` in the recorded OTP test (the `GET` test in `keploy/test-set-0/tests/`).
If you skipped Keploy's automatic noise check by pressing `Ctrl+C` a second time when stopping the recording, the OTP will show up as a diff, since it changes on every request. Mark it as noise by adding `body.otp: []` under `assertions.noise` in the recorded `GET` test in `keploy/test-set-0/tests/`.

same note at line 471 in the local section.

:::

```bash
keploy test -c "docker run -p 3001:3001 --rm --network <networkName> --name ginRedisApp gin-app:1.0" --delay 10
keploy test -c "docker run -p 3001:3001 --rm --network gin-redis_default --name ginRedisApp gin-app:1.0" --delay 10
```

> The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking.
Expand Down Expand Up @@ -461,6 +467,10 @@ Want to see if everything works as expected?

Time to put things to the test 🧪

:::note
The OTP changes on every request, so mark it as noise before replaying. Add `body.otp` under `assertions.noise` in the recorded OTP test (the `GET` test in `keploy/test-set-0/tests/`).
:::

```shell
sudo -E env PATH="$PATH" keploy test -c "./gin-redis" --delay 10
```
Expand Down
10 changes: 9 additions & 1 deletion versioned_docs/version-4.0.0/quickstart/go-mux-mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,18 @@ We will be using Docker compose to run the application as well as MySQL on Docke

### Start MySQL Instance

Create the `keploy-network` Docker network that both containers use:

```bash
docker network create keploy-network
```

```bash
docker run -p 3306:3306 --rm --name mysql --network keploy-network -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest
```

MySQL can take a while to start on its first run. Wait until `docker logs mysql` shows `ready for connections` with `port: 3306` (the earlier `port: 0` line is MySQL's temporary init server) before moving on.

### Capture the Testcases

Build the Docker image of our application:
Expand Down Expand Up @@ -111,7 +119,7 @@ curl --request POST \
}'
```

this will return the shortened url. The ts would automatically be ignored during testing because it'll always be different.
this will return the shortened url.

```bash
{
Expand Down
15 changes: 14 additions & 1 deletion versioned_docs/version-4.0.0/quickstart/go-mux-sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,18 @@ git clone https://github.com/keploy/samples-go.git && cd samples-go/mux-sql
go mod download
```

#### First things first, update the postgres host in main.go to postgres from localhost.

The application runs in a container, where `localhost` does not reach the Postgres container. In `main.go`, change the host `"localhost"` to `"postgres"`.

### Lights, Camera, Record! 🎥

The `docker-compose.yml` attaches both services to an external `keploy-network`, so create it once:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is right for the docker flow 👍 the local section uses the same compose file though (docker compose up postgres around line 283), so someone who skips straight to running locally will hit the same "network keploy-network declared as external, but could not be found" error. worth adding the network create there as well.

also while you're in there, line 276 still says the host is on line 10 of main.go, it's on line 18 now

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed both: added the network create to the local section and corrected the line number to 18.


```bash
docker network create keploy-network
```

Fire up the application and Postgres instance with Keploy. Keep an eye on the two key flags:
`-c`: Command to run the app (e.g., `docker compose up`).

Expand Down Expand Up @@ -263,13 +273,16 @@ go mod download

We'll be running our sample application right on Linux, but just to make things a tad more thrilling, we'll have the database (Postgres) chill on Docker. Ready? Let's get the party started!🎉

First things first, update the postgres host on **line 10** in `main.go` to `localhost`.
First things first, update the postgres host on **line 18** in `main.go` to `localhost`.

#### 🍃 Kickstart PostgresDB

Let's breathe life into your Postgres container. A simple spell should do the trick:

The `docker-compose.yml` attaches the services to an external `keploy-network`, so create it once.
Comment on lines 280 to +282

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this one didn't land: "A simple spell should do the trick:" still ends in a colon and is followed by another sentence instead of the command. merging the two:

Suggested change
Let's breathe life into your Postgres container. A simple spell should do the trick:
The `docker-compose.yml` attaches the services to an external `keploy-network`, so create it once.
Let's breathe life into your Postgres container. The `docker-compose.yml` attaches the services to an external `keploy-network`, so create it once and then start Postgres:


```bash
docker network create keploy-network
docker compose up postgres
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ mvn clean install -DskipTests=true
docker compose up
```

Note: If you face any issues while setting up the database, please try running docker compose up again. The issue should not occur the second time.
Note: `docker compose up` keeps running in the foreground, so run it in its own terminal (or add `-d`) and continue the next steps in another one. If the first run fails while the database is being initialised (for example with `ERROR 1064` from MySQL), run `docker compose up` again. The issue should not occur the second time.

## Setup the Backend

Expand Down Expand Up @@ -137,6 +137,8 @@ Now you can start interacting with the UI and Keploy will automatically create t

## Running the testcases using Keploy

Stop the recording with `Ctrl+C` first. The database and the UI do not need to be running for `keploy test`, as Keploy replays the recorded mocks.

```bash
keploy test -c "java -cp "target/openhospital-api-0.1.0.jar:rsc/:static/" org.springframework.boot.loader.launch.JarLauncher" --delay 40

Expand Down
12 changes: 9 additions & 3 deletions versioned_docs/version-4.0.0/quickstart/java-spring-boot-xml.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ This runs natively on Linux, macOS (Apple Silicon) and Windows (x86-64) — see

```bash
git clone https://github.com/keploy/samples-java.git
cd spring-boot-xml/naive-spring-boot
cd samples-java/spring-boot-xml/naive-spring-boot
mvn clean install
```

Expand All @@ -92,6 +92,8 @@ Start the Spring Boot application with:
mvn spring-boot:run
```

Once you have confirmed the application starts, stop it (`Ctrl+C`) so that port `8080` is free for Keploy to record on.

### Record Test Cases

```bash
Expand All @@ -111,7 +113,7 @@ Then, invoke the API using `curl` or your favorite API testing tool.
Make a request using `curl`:

```bash
curl -X GET -H \"Accept: application/xml\" http://localhost:8080/api/user
curl -X GET -H "Accept: application/xml" http://localhost:8080/api/user
```

- **Endpoint**: `GET /api/users`
Expand Down Expand Up @@ -148,7 +150,11 @@ Execute recorded tests:
keploy test -c "java -jar target/XML-0.0.1-SNAPSHOT.jar" --delay 10
```

Review generated test reports in `Keploy/reports`.
Review generated test reports in `keploy/reports`.

:::note
No `mocks.yaml` is created for this sample: the app makes no outbound calls (no database or external API), so there is nothing to mock. That is expected.
:::

## Handling Failing Tests ⚠️

Expand Down
10 changes: 9 additions & 1 deletion versioned_docs/version-4.0.0/quickstart/java-spring-postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ keploy record -c "java -jar target/spring-petclinic-rest-3.0.2.jar"

<img src="https://keploy-devrel.s3.us-west-2.amazonaws.com/docs/webp-s3/img/pet-record.webp" alt="Sample Keploy Test Result Node JWT" width="100%" style={{ borderRadius: '5px' }} />

Now you can start interacting with the UI and Keploy will automatically create the testcases and mocks for it in a folder named 'keploy'.
Now you can start interacting with the UI and Keploy will automatically create the testcases and mocks for it in a folder named 'keploy'. The database starts empty, so create a pet type under **Pet Types** first, then add an owner and a pet; the lists stay empty until you do.

## Running the testcases using Keploy

Expand Down Expand Up @@ -192,12 +192,20 @@ Prerequisites For API backend Binary:

## Recording the testcases with Keploy

The `docker-compose.yaml` of this sample attaches both services to an external `keploy-network`, so create it once before recording:

```bash
docker network create keploy-network
```

```bash
keploy record -c "docker compose up" --container-name javaApp --build-delay 100
```

<img src="https://keploy-devrel.s3.us-west-2.amazonaws.com/docs/webp-s3/img/pet-record.webp" alt="Sample Keploy Record Java" width="100%" style={{ borderRadius: '5px' }} />

Once the backend is running under Keploy, start interacting with the UI. The database starts empty, so create a pet type under **Pet Types** first, then add an owner and a pet; the lists stay empty until you do.

## Running the testcases using Keploy

```bash
Expand Down
Loading
Loading