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:
0 commit comments