You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: versioned_docs/version-3.0.0/keploy-cloud/deduplication.md
+34-5Lines changed: 34 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,13 +45,42 @@ Add the following on top of your main application file : -
45
45
import _ "github.com/keploy/go-sdk/v3/keploy"
46
46
```
47
47
48
-
Update the go build command in Dockerfile to add new flags which is required for deduplication (use same flags for native builds)
48
+
**2. Build Configuration**
49
+
50
+
Update the `go build` command in your Dockerfile (or native build script) to include coverage flags. These are required for deduplication to calculate coverage accurately.
49
51
50
52
```bash
51
53
RUN go build -cover -covermode=atomic -coverpkg=./... -o /app/main .
52
54
```
53
55
54
-
**2. Run Deduplication**
56
+
**3. Dockerfile Configuration (Important for Docker Users)**
57
+
58
+
If you are using a multi-stage Docker build (e.g., building in one stage and running in a slim image), you **must** ensure the Go toolchain and `go.mod` files are preserved in the final runtime image. The deduplication feature requires access to the Go runtime to map coverage data correctly.
59
+
60
+
Update your final runtime stage in the `Dockerfile` to include the following:
61
+
62
+
```dockerfile
63
+
# ... inside your final runtime stage ...
64
+
65
+
# 1. Copy Go toolchain from the builder stage
66
+
COPY --from=builder /usr/local/go /usr/local/go
67
+
68
+
# 2. Set Go environment variables so the app can use internal go tools
69
+
ENV GOROOT=/usr/local/go
70
+
ENV PATH=/usr/local/go/bin:${PATH}
71
+
72
+
# 3. Copy go.mod and go.sum (Required for dependency resolution during coverage)
73
+
COPY --from=builder /src/go.mod /src/go.sum /app/
74
+
75
+
# 4. Set the GOMOD environment variable
76
+
ENV GOMOD=/app/go.mod
77
+
78
+
# ... rest of your dockerfile ...
79
+
```
80
+
81
+
> **Note:** If you face issues with toolchain downloads in restricted environments, you may also need to set `ENV GOTOOLCHAIN=local` and configure your `GOPROXY` in the Dockerfile.
82
+
83
+
**4. Run Deduplication**
55
84
56
85
For Docker, run:
57
86
@@ -65,15 +94,15 @@ For Native, run:
65
94
keploy test -c ./main --dedup
66
95
```
67
96
68
-
This will generate a dedupData.yaml file
97
+
This will generate a `dedupData.yaml` file.
69
98
70
-
After this Run
99
+
After this, run:
71
100
72
101
```bash
73
102
keploy dedup
74
103
```
75
104
76
-
This command will create a duplicates.yaml file which will contain all the test cases which was found to be duplicate.
105
+
This command will create a `duplicates.yaml` file which will contain all the test cases which were found to be duplicate.
77
106
78
107
In order to remove all the duplicate test cases, run the following command:
The Keploy CLI operates by capturing all network traffic between your application and its dependencies.
40
-
It meticulously records API calls, database queries, and any other interactions your application engages in.
39
+
```shell
40
+
go build -race -tags=viper_bind_struct -o keploy .
41
+
sudo mv keploy /usr/local/bin/
42
+
sudo chmod +x /usr/local/bin/keploy
43
+
```
41
44
42
-
Once the recording phase is complete, Keploy can effortlessly generate test cases and data mocks in YAML format.
45
+
**_Now we have successfully set up Keploy. Let’s test it with the sample app._**
43
46
44
47
#### Keploy operates in two modes:
45
48
46
49
-`record`: Capture Keploy test cases from API calls.
47
50
-`test`: Execute recorded test cases and validate assertions.
48
51
49
-
To dive into Keploy, you can use the [gin-mongo URL Shortener](https://github.com/keploy/samples-go/tree/main/gin-mongo) sample application:
52
+
The Keploy CLI operates by capturing all network traffic between your application and its dependencies.
53
+
54
+
It meticulously records API calls, database queries, and any other interactions your application engages in.
55
+
56
+
Once the recording phase is complete, Keploy can effortlessly generate test cases and data mocks in YAML format.
57
+
58
+
If you don't have any samples app, you can use the [gin-mongo URL Shortener](https://github.com/keploy/samples-go/tree/main/gin-mongo) sample application:
50
59
51
60
#### Let's clone sample app repo:
52
61
@@ -56,110 +65,50 @@ go mod download # Download dependencies:
56
65
go build -o gin-mongo-binary # Generate binary of the application:
57
66
```
58
67
59
-
### Now let's try running keploy:
60
-
61
-
#### Capturing Test Cases:
62
-
63
-
```shell
64
-
go run -exec "sudo -E env 'PATH=$PATH'" -tags=viper_bind_struct main.go record -c "path/to/go/binary/of/application"
65
-
```
66
-
67
-
After entering record mode, send requests to your application to generate test cases.
68
-
69
-
#### Running Test Cases:
70
-
71
-
```shell
72
-
go run -exec "sudo -E env 'PATH=$PATH'" -tags=viper_bind_struct main.go test -c "path/to/go/binary/of/application" --delay 10
73
-
```
74
-
75
-
Run Keploy server to expose test APIs:
76
-
77
-
```shell
78
-
go run -exec "sudo -E env 'PATH=$PATH'" -tags=viper_bind_struct main.go test -c "path/to/go/binary/of/application" --delay 10 --coverage
79
-
```
80
-
81
-
Generated test cases can be found inside the Keploy directory.
#### Remember setting up the Keploy binary. See [Setup Keploy using Binary](#5-setup-keploy-using-binary) for details.
94
+
#### Remember setting up the Keploy binary. See [Setup Keploy using Binary](#3-clone-keploy-repository) for details.
148
95
149
96
#### Capture Test Cases:
150
97
151
98
```shell
152
-
sudo -E env PATH="$PATH" keployV2 record -c "docker run -p 8080:8080 --name <containerName>--network keploy-network --rm <imageName>"" --containerName <containerName>
99
+
sudo keploy record -c "docker run -p -p <appPort>:<hostPort> --name <containerName> --network keploy-network --rm <imageName>"
153
100
```
154
101
155
102
#### Running Test Cases:
156
103
157
104
```shell
158
-
sudo -E env PATH="$PATH" keployV2 test --c "docker run -p 8080:8080 --name <containerName> --network keploy-network --rm <imageName>" --delay 10
105
+
sudo keploy test -c "docker run -p -p <appPort>:<hostPort> --name <containerName> --network keploy-network --rm <imageName>" --delay 10
159
106
```
160
107
161
-
There you have it! With this guide, you're all set to dive into Keploy development. Happy testing! 🧪🔍💻
108
+
There you have it! With this guide, you're all set to dive into Keploy development.
109
+
110
+
Happy testing! 🧪🔍💻
162
111
163
112
> **Note** :- Run `go run github.com/99designs/gqlgen generate --config pkg/graph/gqlgen.yml` to generate the graphql server stubs which can be used when working with unit testing libraries like JUnit, PyTest, etc..
164
113
165
-
Hope this helps you out, if you still have any questions, reach out to us .
114
+
Hope this helps you out, if you still have any questions, reach out to us on [slack](https://keploy.slack.com/join/shared_invite/zt-357qqm9b5-PbZRVu3Yt2rJIa6ofrwWNg).
Copy file name to clipboardExpand all lines: versioned_docs/version-3.0.0/keploy-explained/docs-dev-guide.md
+17-11Lines changed: 17 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,35 +1,41 @@
1
1
---
2
2
id: docs-dev-guide
3
-
title: docs-dev-guide
3
+
title: Keploy Docs Contribution Guide
4
4
sidebar_label: Docs Dev Guide
5
5
tags:
6
6
- dev guide
7
7
- explanation
8
8
- contributing
9
9
---
10
10
11
-
# How to contribute
11
+
We welcome and appreciate contributions from the community. There are several ways you can help improve the documentation:
12
12
13
-
We encourage contributions from the community.
13
+
### Ways to Contribute:
14
14
15
-
**Create a [GitHub issue](https://github.com/keploy/docs/issues) for any changes beyond typos and small fixes.**
15
+
**1. Code Contribution**.
16
16
17
-
If you do create a pull request (PR), please follow our style guidance.
17
+
**2. Report bugs or suggest improvements**.
18
18
19
-
We review GitHub issues and PRs on a regular schedule.
19
+
**3. Suggest UI/UX enhancements**.
20
+
21
+
**4. Contribute to translations**.
22
+
23
+
Your contributions help strengthen the documentation and support the Keploy community
24
+
25
+
**Note: Create a [GitHub issue](https://github.com/keploy/keploy/issues/new/choose) for any changes beyond typos and small fixes.**
26
+
27
+
If you do create a pull request (PR) or Github issues, please follow our style guidance.
20
28
21
-
To ensure that each change is relevant and properly peer reviewed, please adhere to best practices for open-source contributions.
22
-
This means that if you are outside the Keploy organization, you must fork the repository and create PRs from branches on your own fork.
23
29
The README in GitHub's [first-contributions repo](https://github.com/firstcontributions/first-contributions) provides an example.
24
30
25
31
## How to set up the docs website locally?
26
32
27
-
The Keploy documentation site uses Docusaurus 2 which is a static website generator.
33
+
The Keploy documentation site uses Docusaurus which is a static website generator.
28
34
29
35
You can make changes locally without previewing them in the browser.
30
-
However, if you want to build the site and preview changes in the browser, you need to have Docusaurus 2 dependencies installed.
36
+
However, if you want to build the site and preview changes in the browser, you need to have Docusaurus dependencies installed.
31
37
32
-
Initialize Docusaurus 2 in the repo by running [`yarn`](https://classic.yarnpkg.com/en/docs/cli/) or [`npm`](https://docs.npmjs.com/cli/v10) once in the root directory of the repo.
38
+
Initialize Docusaurus in the repo by running [`yarn`](https://classic.yarnpkg.com/en/docs/cli/) or [`npm`](https://docs.npmjs.com/cli/v10) once in the root directory of the repo.
0 commit comments