Skip to content

Commit

Permalink
feat(dev): added random_user.lua for benchamarking purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
zZHorizonZz committed Aug 8, 2024
1 parent 9daebd4 commit 2e5e0b9
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 19 deletions.
41 changes: 41 additions & 0 deletions collections/random_user.lua
Original file line number Diff line number Diff line change
@@ -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
38 changes: 19 additions & 19 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2e5e0b9

Please sign in to comment.