From 2e5e0b9d8f215c498bbdde62130d04e953868712 Mon Sep 17 00:00:00 2001 From: Daniel Fiala Date: Thu, 8 Aug 2024 14:38:03 +0200 Subject: [PATCH] feat(dev): added random_user.lua for benchamarking purposes --- collections/random_user.lua | 41 +++++++++++++++++++ docker/docker-compose.yml | 38 ++++++++--------- .../panache/UserRepositoryPanache.java | 1 + src/main/resources/application.properties | 2 + 4 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 collections/random_user.lua diff --git a/collections/random_user.lua b/collections/random_user.lua new file mode 100644 index 0000000..24279be --- /dev/null +++ b/collections/random_user.lua @@ -0,0 +1,41 @@ +-- wrk.lua + +-- Function to generate random strings +function getAlphaChar() + selection = math.random(1, 3) + if selection == 1 then return string.char(math.random(65, 90)) end + if selection == 2 then return string.char(math.random(97, 122)) end + return string.char(math.random(48, 57)) +end + +-- Function to generate random strings +function randomString(length) + length = length or 1 + if length < 1 then return nil end + local array = {} + for i = 1, length do + array[i] = getAlphaChar() + end + return table.concat(array) +end + +-- Function to remove trailing slashes +function removeTrailingSlash(s) + return (s:gsub("(.-)/*$", "%1")) +end + +-- Function to generate random emails +function randomEmail(domain) + return randomString(24) .. "@" .. domain +end + +request = function() + wrk.method = "POST" + wrk.body = "username=" .. randomString(24) .. + "&email=" .. randomEmail("example.com") .. + "&password=" .. randomString(12) .. + "&strategy=PASSWORD" + wrk.headers["Content-Type"] = "application/x-www-form-urlencoded" + + return wrk.format(nil, nil, wrk.headers, wrk.body) +end diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 4825a1b..05fef65 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,34 +1,34 @@ version: '3.8' services: + db: + image: postgres:15 + restart: always + environment: + - POSTGRES_DB=zenei_db + - POSTGRES_USER=zenei_user + - POSTGRES_PASSWORD=zenei_password + volumes: + - postgres_data:/var/lib/postgresql/data + zenei-auth: - image: ghcr.io/cloudeko/services/native/zenei:a494bcb + image: ghcr.io/cloudeko/services/native/zenei:9daebd4 restart: always + depends_on: + - db volumes: - - ./dev/dev-private-key.pem:/app/dev-private-key.pem - - ./dev/dev-public-key.pem:/app/dev-public-key.pem + - ./dev/dev-private-key.pem:/key/dev-private-key.pem + - ./dev/dev-public-key.pem:/key/dev-public-key.pem + ports: + - 8080:8080 environment: - - quarkus.application.name=cloudeko-zenei-auth-service - - quarkus.datasource.db-kind=postgresql - quarkus.datasource.jdbc.url=jdbc:postgresql://db:5432/zenei_db - - quarkus.datasource.jdbc.driver=org.postgresql.Driver - quarkus.datasource.username=zenei_user - quarkus.datasource.password=zenei_password - - quarkus.hibernate-orm.database.generation=update - - smallrye.jwt.sign.key.location=dev-private-key.pem - - mp.jwt.verify.publickey.location=dev-public-key.pem + - smallrye.jwt.sign.key.location=/key/dev-private-key.pem + - mp.jwt.verify.publickey.location=/key/dev-public-key.pem - mp.jwt.verify.issuer=https://example.com/issuer - quarkus.mailer.mock=true - db: - image: postgres:14 - restart: always - environment: - - POSTGRES_DB=zenei_db - - POSTGRES_USER=zenei_user - - POSTGRES_PASSWORD=zenei_password - volumes: - - postgres_data:/var/lib/postgresql/data - volumes: postgres_data: diff --git a/src/main/java/dev/cloudeko/zenei/infrastructure/repository/hibernate/panache/UserRepositoryPanache.java b/src/main/java/dev/cloudeko/zenei/infrastructure/repository/hibernate/panache/UserRepositoryPanache.java index a9abd6e..0daac3e 100644 --- a/src/main/java/dev/cloudeko/zenei/infrastructure/repository/hibernate/panache/UserRepositoryPanache.java +++ b/src/main/java/dev/cloudeko/zenei/infrastructure/repository/hibernate/panache/UserRepositoryPanache.java @@ -5,6 +5,7 @@ import dev.cloudeko.zenei.domain.model.user.UserRepository; import dev.cloudeko.zenei.infrastructure.repository.hibernate.entity.UserEntity; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.persistence.Cacheable; import lombok.AllArgsConstructor; import java.util.Optional; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 21b29c7..721f2ba 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,6 +2,8 @@ quarkus.application.name=cloudeko-zenei-auth-service # Database configuration quarkus.datasource.db-kind=postgresql +quarkus.datasource.jdbc.driver=org.postgresql.Driver + quarkus.hibernate-orm.database.generation=update %test.quarkus.hibernate-orm.database.generation=drop-and-create # JWT configuration