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
32 changes: 20 additions & 12 deletions .github/workflows/k6-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@ jobs:
k6-perf:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_DB: performance_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres" --health-interval=10s --health-timeout=5s --health-retries=5

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Start PostgreSQL with Docker Compose
run: docker compose up -d
env:
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}

- name: Wait for PostgreSQL to be ready
run: |
for i in {1..30}; do
if docker compose exec -T postgres pg_isready -U postgres > /dev/null 2>&1; then
echo "PostgreSQL is ready";
exit 0;
fi;
echo "Waiting for PostgreSQL...";
sleep 2;
done
echo "PostgreSQL did not start in time" && exit 1

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
Expand Down Expand Up @@ -75,3 +80,6 @@ jobs:
kill $(cat app.pid) || true
fi

- name: Stop Docker Compose
if: always()
run: docker compose down -v
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ build/

### VS Code ###
.vscode/

### Environment Variables ###
.env

23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3.8'

services:
postgres:
image: postgres:17-alpine
container_name: performance-postgres
environment:
POSTGRES_DB: performance_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5

volumes:
postgres_data:

51 changes: 12 additions & 39 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,45 +32,33 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-graphql</artifactId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc</artifactId>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-liquibase</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-graphql-test</artifactId>
<scope>test</scope>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

Expand Down Expand Up @@ -100,21 +88,6 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<configuration>
<propertyFile>src/main/resources/application.properties</propertyFile>
<changeLogFile>src/main/resources/db/changelog/db.changelog-master.yaml</changeLogFile>
</configuration>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Expand Down
9 changes: 4 additions & 5 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ spring.application.name=k6-performance-test-poc
# PostgreSQL Configuration
spring.datasource.url=jdbc:postgresql://localhost:5432/performance_db
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.datasource.password=${POSTGRES_PASSWORD:postgres}
spring.datasource.driver-class-name=org.postgresql.Driver

# JPA Configuration
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.format_sql=true

# Liquibase Configuration
spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.yaml
spring.liquibase.enabled=true
spring.liquibase.drop-first=false
spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml

# Logging
logging.level.liquibase=INFO
logging.level.liquibase=info
logging.level.org.hibernate=INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd">

<changeSet id="001-create-products-table" author="performance-poc">
<createTable tableName="products">
<column name="id" type="BIGSERIAL">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="name" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="description" type="TEXT"/>
<column name="price" type="DECIMAL(19,2)">
<constraints nullable="false"/>
</column>
<column name="quantity" type="INTEGER">
<constraints nullable="false"/>
</column>
<column name="created_at" type="TIMESTAMP">
<constraints nullable="false"/>
</column>
<column name="updated_at" type="TIMESTAMP">
<constraints nullable="false"/>
</column>
</createTable>

<createIndex indexName="idx_products_name" tableName="products">
<column name="name"/>
</createIndex>

<rollback>
<dropIndex indexName="idx_products_name" tableName="products"/>
<dropTable tableName="products"/>
</rollback>
</changeSet>

</databaseChangeLog>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd">

<changeSet id="002-insert-sample-products" author="performance-poc">
<sqlFile path="db/sql/002-insert-sample-products.sql"
relativeToChangelogFile="false"
splitStatements="true"
stripComments="true"/>

<rollback>
<delete tableName="products">
<where>name IN ('Laptop', 'Wireless Mouse', 'Mechanical Keyboard')</where>
</delete>
</rollback>
</changeSet>

</databaseChangeLog>

This file was deleted.

11 changes: 11 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd">

<include file="db/changelog/changes/001-create-products-table.xml"/>
<include file="db/changelog/changes/002-insert-sample-products.xml"/>

</databaseChangeLog>
6 changes: 0 additions & 6 deletions src/main/resources/db/changelog/db.changelog-master.yaml

This file was deleted.

Loading