Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/spring-boot-product-catalog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# spring-boot-product-catalog sample CI — build + end-to-end smoke test.
#
# Scoped with `paths:` to this sample only, so unrelated samples don't pay for
# it (same convention as restheart-mongo.yml). Deliberately Keploy-independent:
# record/replay needs eBPF privileges that are awkward on hosted runners, so CI
# proves the app builds and serves the traffic the recorded suite was captured
# from. The committed test set under keploy/products-crud/ is the regression
# gate, exercised locally and in the Keploy pipelines.
name: spring-boot-product-catalog sample

on:
pull_request:
paths:
- 'spring-boot-product-catalog/**'
- '.github/workflows/spring-boot-product-catalog.yml'
push:
branches: [main]
paths:
- 'spring-boot-product-catalog/**'
- '.github/workflows/spring-boot-product-catalog.yml'
workflow_dispatch: {}

concurrency:
group: spring-boot-product-catalog-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: build (JDK 21)
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven

- name: Build with Maven
working-directory: spring-boot-product-catalog
run: ./mvnw -B -DskipTests clean package

smoke:
name: end-to-end smoke test
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4

- name: Start app + Postgres
working-directory: spring-boot-product-catalog
run: docker compose up -d --build --wait

- name: Drive the recorded workload
working-directory: spring-boot-product-catalog
run: ./seed.sh

- name: Assert the catalog responds
working-directory: spring-boot-product-catalog
run: |
set -Eeuo pipefail
curl -fsS http://localhost:8080/api/products >/dev/null
curl -fsS http://localhost:8080/api/products/summary >/dev/null
# The 404 path must stay a clean 404, not a 500 — the recorded suite
# asserts the structured error body.
code=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:8080/api/products/99999)
[ "$code" = "404" ] || { echo "::error::expected 404 for a missing product, got $code"; exit 1; }
echo "OK — catalog, summary, and not-found paths all behave."

- name: Dump app logs on failure
if: failure()
working-directory: spring-boot-product-catalog
run: docker compose logs --no-color app

- name: Tear down
if: always()
working-directory: spring-boot-product-catalog
run: docker compose down -v
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This repo contains the sample for [Keploy's](https://keploy.io) Java Application
8. [Dropwizard Dynamic Deduplication](https://github.com/keploy/samples-java/tree/main/dropwizard-dedup) - A Dropwizard/Jersey sample used by Enterprise CI to validate that Java dynamic dedup works outside Spring Boot with the runtime Java agent, checked-in HTTP fixtures, native launch, classpath launch, Docker, distroless, and restricted Docker.
9. [Simple Java Dynamic Deduplication](https://github.com/keploy/samples-java/tree/main/simple-java-dedup) - A minimal plain-Java HTTP server used to smoke-test Java dynamic dedup on Java 8 and Java 17 in native and Docker launch modes.
10. [MySQL CRUD](https://github.com/keploy/samples-java/tree/main/mysql-crud) - A minimal Spring Boot + JDBC CRUD app used by Enterprise CI to validate the self-hosted cloud-replay pipeline's JDBC secret-obfuscation and object-storage mock upload/download paths against a real MySQL 8 backend.
11. [Springboot Product Catalog](https://github.com/keploy/samples-java/tree/main/spring-boot-product-catalog) - A Spring Boot + PostgreSQL product-catalog REST API shipping a committed 57-case Keploy test set and 190 Postgres mocks. Includes an app-only docker-compose with no database service at all, so the whole suite replays green with Postgres absent.

## Community Support ❤️

Expand Down
6 changes: 6 additions & 0 deletions spring-boot-product-catalog/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
target/
keploy/
.git/
.idea/
*.iml
HELP.md
2 changes: 2 additions & 0 deletions spring-boot-product-catalog/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/mvnw text eol=lf
*.cmd text eol=crlf
37 changes: 37 additions & 0 deletions spring-boot-product-catalog/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
target/
.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

# keploy runtime artifacts
agent-debug.log
**/agent-debug.log
docker-compose-tmp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.16/apache-maven-3.9.16-bin.zip
24 changes: 24 additions & 0 deletions spring-boot-product-catalog/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# syntax=docker/dockerfile:1

# ---- Build stage: compile & package with a pinned JDK 21 (reproducible on any host) ----
FROM eclipse-temurin:21-jdk AS build
WORKDIR /app

# Copy the Maven wrapper first so dependency resolution can be cached.
COPY .mvn/ .mvn/
COPY mvnw pom.xml ./
RUN ./mvnw -B -q dependency:go-offline

# Now copy sources and build the fat jar (skip tests — they need a live DB).
COPY src ./src
RUN ./mvnw -B -q -DskipTests clean package

# ---- Run stage: slim JRE image ----
FROM eclipse-temurin:21-jre
WORKDIR /app
# curl is used by the docker-compose healthcheck.
Comment thread
dhananjay6561 marked this conversation as resolved.
RUN apt-get update && apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /app/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
Loading
Loading