Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bpaquet committed Dec 3, 2024
1 parent 9df28da commit eec112b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 50 deletions.
58 changes: 18 additions & 40 deletions load_test/config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,35 @@ config :logger, :console,
format: "$time $metadata[$level] $message\n",
level: String.to_atom(System.get_env("LOG_LEVEL") || "info")

config :load_test, port: String.to_integer(System.get_env("PORT") || "2999")
config :load_test, nb_user: String.to_integer(System.get_env("NB_USER") || "1")

config :load_test, sse_user_agent: System.get_env("SSE_USER_AGENT") || "neurow_load_test/1.0"
config :load_test, sse_timeout: String.to_integer(System.get_env("SSE_TIMEOUT") || "900000")
config :load_test, sse_url: System.get_env("SSE_URL") || "http://localhost:4000/v1/subscribe"
config :load_test, sse_jwt_issuer: System.get_env("SSE_JWT_ISSUER") || "test_issuer1"

config :load_test,
sse_jwt_expiration: String.to_integer(System.get_env("SSE_JWT_EXPIRATION") || "86400")

config :load_test,
sse_jwt_secret:
System.get_env("SSE_JWT_SECRET") || "966KljJz--KyzyBnMOrFXfAkq9XMqWwPgdBV3cKTxsc"

config :load_test,
sse_jwt_audience: System.get_env("SSE_JWT_AUDIENCE") || "public_api"

config :load_test,
publish_url: System.get_env("PUBLISH_URL") || "http://localhost:3000/v1/publish"

config :load_test, publish_timeout: String.to_integer(System.get_env("PUBLISH_TIMEOUT") || "5000")
port: String.to_integer(System.get_env("PORT") || "2999"),
nb_user: String.to_integer(System.get_env("NB_USER") || "1")

config :load_test,
publish_http_pool_size: String.to_integer(System.get_env("PUBLISH_HTTP_POOL_SIZE") || "2000")

config :load_test, publish_jwt_issuer: System.get_env("PUBLISH_JWT_ISSUER") || "test_issuer1"
sse_user_agent: System.get_env("SSE_USER_AGENT") || "neurow_load_test/1.0",
sse_timeout: String.to_integer(System.get_env("SSE_TIMEOUT") || "900000")

config :load_test,
publish_jwt_secret:
System.get_env("PUBLISH_JWT_SECRET") || "nLjJdNLlpdv3W4Xk7MyVCAZKD-hvza6FQ4yhUUFnjmg"
sse_url: System.get_env("SSE_URL") || "http://localhost:4000/v1/subscribe",
sse_jwt_issuer: System.get_env("SSE_JWT_ISSUER") || "test_issuer1",
sse_jwt_expiration: String.to_integer(System.get_env("SSE_JWT_EXPIRATION") || "86400"),
sse_jwt_secret: System.get_env("SSE_JWT_SECRET") || "966KljJz--KyzyBnMOrFXfAkq9XMqWwPgdBV3cKTxsc",
sse_jwt_audience: System.get_env("SSE_JWT_AUDIENCE") || "public_api",
sse_auto_reconnect: String.to_atom(System.get_env("SSE_AUTO_RECONNECT") || "false")

config :load_test,
publish_url: System.get_env("PUBLISH_URL") || "http://localhost:3000/v1/publish",
publish_timeout: String.to_integer(System.get_env("PUBLISH_TIMEOUT") || "5000"),
publish_http_pool_size: String.to_integer(System.get_env("PUBLISH_HTTP_POOL_SIZE") || "2000"),
publish_jwt_issuer: System.get_env("PUBLISH_JWT_ISSUER") || "test_issuer1",
publish_jwt_secret: System.get_env("PUBLISH_JWT_SECRET") || "nLjJdNLlpdv3W4Xk7MyVCAZKD-hvza6FQ4yhUUFnjmg",
publish_jwt_audience: System.get_env("PUBLISH_JWT_AUDIENCE") || "internal_api"

config :load_test,
delay_between_messages_min:
String.to_integer(System.get_env("DELAY_BETWEEN_MESSAGES_MIN") || "500")

config :load_test,
delay_between_messages_max:
String.to_integer(System.get_env("DELAY_BETWEEN_MESSAGES_MAX") || "5000")

config :load_test,
number_of_messages_min: String.to_integer(System.get_env("NUMBER_OF_MESSAGES_MIN") || "10")

config :load_test,
delay_between_messages_min: String.to_integer(System.get_env("DELAY_BETWEEN_MESSAGES_MIN") || "500"),
delay_between_messages_max: String.to_integer(System.get_env("DELAY_BETWEEN_MESSAGES_MAX") || "5000"),
number_of_messages_min: String.to_integer(System.get_env("NUMBER_OF_MESSAGES_MIN") || "10"),
number_of_messages_max: String.to_integer(System.get_env("NUMBER_OF_MESSAGES_MAX") || "50")

config :load_test,
initial_delay_max: String.to_integer(System.get_env("INITIAL_DELAY_MAX") || "5000")

config :load_test,
auto_reconnect: String.to_atom(System.get_env("AUTO_RECONNECT") || "false")
8 changes: 4 additions & 4 deletions load_test/lib/load_test/main.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defmodule LoadTest.Main do
:sse_jwt_audience,
:sse_jwt_expiration,
:sse_user_agent,
:sse_auto_reconnect,
:publish_url,
:publish_timeout,
:publish_jwt_issuer,
Expand All @@ -20,7 +21,6 @@ defmodule LoadTest.Main do
:delay_between_messages_max,
:number_of_messages_min,
:number_of_messages_max,
:auto_reconnect
]
end

Expand All @@ -39,7 +39,7 @@ defmodule LoadTest.Main do
{:ok, sse_jwt_secret} = Application.fetch_env(:load_test, :sse_jwt_secret)
{:ok, sse_jwt_audience} = Application.fetch_env(:load_test, :sse_jwt_audience)
{:ok, sse_jwt_expiration} = Application.fetch_env(:load_test, :sse_jwt_expiration)
{:ok, auto_reconnect} = Application.fetch_env(:load_test, :auto_reconnect)
{:ok, sse_auto_reconnect} = Application.fetch_env(:load_test, :sse_auto_reconnect)

{:ok, publish_url} = Application.fetch_env(:load_test, :publish_url)
{:ok, publish_timeout} = Application.fetch_env(:load_test, :publish_timeout)
Expand All @@ -66,6 +66,7 @@ defmodule LoadTest.Main do
sse_jwt_secret: JOSE.JWK.from_oct(sse_jwt_secret),
sse_jwt_audience: sse_jwt_audience,
sse_jwt_expiration: sse_jwt_expiration,
sse_auto_reconnect: sse_auto_reconnect,
publish_url: publish_url,
publish_timeout: publish_timeout,
publish_jwt_issuer: publish_jwt_issuer,
Expand All @@ -75,14 +76,13 @@ defmodule LoadTest.Main do
delay_between_messages_max: delay_between_messages_max,
number_of_messages_min: number_of_messages_min,
number_of_messages_max: number_of_messages_max,
auto_reconnect: auto_reconnect
}

Logger.warning("SSE base url: #{sse_url}")
Logger.warning("SSE Auto reconnect: #{sse_auto_reconnect}")
Logger.warning("Publish base url: #{publish_url}")
Logger.warning("User agent: #{sse_user_agent}")
Logger.warning("Starting load test with #{nb_user} users")
Logger.warning("Auto reconnect: #{auto_reconnect}")

Enum.map(1..nb_user, fn _ ->
Task.Supervisor.async(LoadTest.TaskSupervisor, fn ->
Expand Down
2 changes: 1 addition & 1 deletion load_test/lib/load_test/user/sse.ex
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ defmodule SseUser do
state
end

reconnect = if context.auto_reconnect, do: 0, else: -1
reconnect = if context.sse_auto_reconnect, do: 0, else: -1

state = %SseState{
user_name: user_name,
Expand Down
2 changes: 1 addition & 1 deletion load_test/terraform/instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ docker run --rm -d \
-e DELAY_BETWEEN_MESSAGES_MAX \
-e NUMBER_OF_MESSAGES_MIN \
-e NUMBER_OF_MESSAGES_MAX \
-e AUTO_RECONNECT \
-e SSE_AUTO_RECONNECT \
-e SSE_TIMEOUT \
-e INITIAL_DELAY_MAX \
-e PUBLISH_HTTP_POOL_SIZE \
Expand Down
7 changes: 3 additions & 4 deletions neurow/config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@ config :neurow,
public_api_context_path: System.get_env("PUBLIC_API_CONTEXT_PATH") || "",
sse_timeout: String.to_integer(System.get_env("SSE_TIMEOUT") || "900000"),
sse_keepalive: String.to_integer(System.get_env("SSE_KEEPALIVE") || "600000"),
max_header_value_length: String.to_integer(System.get_env("MAX_HEADER_VALUE_LENGTH") || "8192")
max_header_value_length: String.to_integer(System.get_env("MAX_HEADER_VALUE_LENGTH") || "8192"),
ssl_keyfile: System.get_env("SSL_KEYFILE"),
ssl_certfile: System.get_env("SSL_CERTFILE")

# Internal API configuration
config :neurow,
internal_api_port: String.to_integer(System.get_env("INTERNAL_API_PORT") || "3000"),
internal_api_jwt_max_lifetime:
String.to_integer(System.get_env("INTERNAL_API_JWT_MAX_LIFETIME") || "1500")

config :neurow, ssl_keyfile: System.get_env("SSL_KEYFILE")
config :neurow, ssl_certfile: System.get_env("SSL_CERTFILE")

config :neurow,
history_min_duration: String.to_integer(System.get_env("HISTORY_MIN_DURATION") || "30")

Expand Down

0 comments on commit eec112b

Please sign in to comment.