mirror of
https://github.com/bonfire-networks/bonfire-app.git
synced 2024-05-16 16:12:41 +00:00
config for federation testing
This commit is contained in:
parent
f70978fe2d
commit
dac4079b06
|
@ -59,13 +59,8 @@ config :bonfire,
|
|||
encryption_salt: encryption_salt,
|
||||
signing_salt: signing_salt
|
||||
|
||||
start_server? =
|
||||
if config_env() == :test,
|
||||
do: System.get_env("START_SERVER", "true"),
|
||||
else: System.get_env("START_SERVER", "true")
|
||||
|
||||
config :bonfire, Bonfire.Web.Endpoint,
|
||||
server: String.to_existing_atom(start_server?),
|
||||
server: config_env() == :test and System.get_env("TEST_INSTANCE") == "yes" or System.get_env("START_SERVER") == "yes",
|
||||
url: [
|
||||
host: host,
|
||||
port: public_port
|
||||
|
@ -89,7 +84,8 @@ end
|
|||
|
||||
pool_size = String.to_integer(System.get_env("POOL_SIZE", "10"))
|
||||
|
||||
config :bonfire, :ecto_repos, [Bonfire.Common.Repo, Beacon.Repo]
|
||||
config :bonfire, :ecto_repos, [Bonfire.Common.Repo]
|
||||
# config :bonfire, :ecto_repos, [Bonfire.Common.Repo, Beacon.Repo]
|
||||
config :bonfire, Bonfire.Common.Repo, repo_connection_config
|
||||
config :beacon, Beacon.Repo, repo_connection_config
|
||||
config :beacon, Beacon.Repo, pool_size: pool_size
|
||||
|
|
|
@ -28,11 +28,19 @@ config :bonfire, Bonfire.Common.Repo,
|
|||
# database: db,
|
||||
slow_query_ms: 500
|
||||
|
||||
# We don't run a server during test. If one is required,
|
||||
# you can enable the server option below.
|
||||
config :bonfire, Bonfire.Web.Endpoint,
|
||||
http: [port: 4001],
|
||||
server: false
|
||||
# Optionally run a 2nd endpoint for testing federation
|
||||
config :bonfire, Bonfire.Web.FakeRemoteEndpoint,
|
||||
server: true,
|
||||
url: [
|
||||
host: "localhost",
|
||||
port: 4002
|
||||
],
|
||||
http: [
|
||||
port: 4002
|
||||
],
|
||||
secret_key_base: System.get_env("SECRET_KEY_BASE"),
|
||||
live_view: [signing_salt: System.get_env("SIGNING_SALT")],
|
||||
render_errors: [view: Bonfire.UI.Common.ErrorView, accepts: ~w(html json), layout: false]
|
||||
|
||||
config :bonfire, Oban, testing: :manual
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ config :bonfire, Bonfire.Common.Repo,
|
|||
|
||||
# These defaults are overriden in runtime.exs
|
||||
config :bonfire, Bonfire.Web.Endpoint,
|
||||
http: [port: 4001],
|
||||
http: [port: 4000],
|
||||
server: if(System.get_env("TEST_INSTANCE") == "yes", do: true, else: false)
|
||||
|
||||
# Run a 2nd endpoint for testing federation (not currently used)
|
||||
|
|
2
justfile
2
justfile
|
@ -140,7 +140,7 @@ recompile:
|
|||
just mix "compile --force"
|
||||
|
||||
dev-test:
|
||||
@MIX_ENV=test START_SERVER=true just dev-run
|
||||
@MIX_ENV=test START_SERVER=yes just dev-run
|
||||
|
||||
# Run the app in dev mode, as a background service
|
||||
dev-bg: init
|
||||
|
|
|
@ -10,6 +10,54 @@ defmodule Bonfire.Application do
|
|||
@config Mix.Project.config()
|
||||
@deps_loaded Bonfire.Common.Extensions.loaded_deps(:nested)
|
||||
@deps_loaded_flat Bonfire.Common.Extensions.loaded_deps(deps_loaded: @deps_loaded)
|
||||
# 6 hours
|
||||
@default_cache_ttl 1_000 * 60 * 60 * 6
|
||||
|
||||
@apps_before [
|
||||
# Metrics
|
||||
Bonfire.Web.Telemetry,
|
||||
# Database
|
||||
@repo_module,
|
||||
EctoSparkles.AutoMigrator,
|
||||
# behaviour modules are already prepared as part of `Bonfire.Common.Config.LoadExtensionsConfig`
|
||||
# Bonfire.Common.ExtensionBehaviour,
|
||||
# Bonfire.Common.Config.LoadExtensionsConfig,
|
||||
# load instance Settings from DB into Config
|
||||
Bonfire.Me.Settings.LoadInstanceConfig,
|
||||
# PubSub
|
||||
{Phoenix.PubSub, [name: Bonfire.PubSub, adapter: Phoenix.PubSub.PG2]},
|
||||
# Persistent Data Services
|
||||
Pointers.Tables
|
||||
# Bonfire.Data.AccessControl.Accesses,
|
||||
## these populate on first call, so no need to run on startup:
|
||||
# Bonfire.Common.ContextModule,
|
||||
# Bonfire.Common.QueryModule,
|
||||
# Bonfire.Federate.ActivityPub.FederationModules
|
||||
# {PhoenixProfiler, name: Bonfire.Web.Profiler}
|
||||
]
|
||||
|
||||
# Stuff that depends on the Endpoint and/or the above
|
||||
@apps_after [
|
||||
# Job Queue
|
||||
{Oban, Application.fetch_env!(:bonfire, Oban)},
|
||||
%{
|
||||
id: :bonfire_cache,
|
||||
start:
|
||||
{Cachex, :start_link,
|
||||
[
|
||||
:bonfire_cache,
|
||||
[
|
||||
expiration:
|
||||
Cachex.Spec.expiration(
|
||||
default: @default_cache_ttl,
|
||||
interval: 1000
|
||||
),
|
||||
# increase for instances with more users (at least num. of users*2+1)
|
||||
limit: 5000
|
||||
]
|
||||
]}
|
||||
}
|
||||
]
|
||||
|
||||
def config, do: @config
|
||||
def name, do: Application.get_env(:bonfire, :app_name) || config()[:name]
|
||||
|
@ -35,6 +83,7 @@ defmodule Bonfire.Application do
|
|||
# |> IO.inspect
|
||||
applications(
|
||||
@env,
|
||||
System.get_env("TEST_INSTANCE") == "yes",
|
||||
Bonfire.Common.Extend.module_enabled?(Bonfire.API.GraphQL) and
|
||||
Bonfire.Common.Extend.module_enabled?(Bonfire.API.GraphQL.Schema)
|
||||
)
|
||||
|
@ -42,82 +91,33 @@ defmodule Bonfire.Application do
|
|||
end
|
||||
|
||||
# include GraphQL API
|
||||
def applications(env, true = _with_graphql?) do
|
||||
def applications(env, test_instance?, true = _with_graphql?) do
|
||||
IO.puts("Enabling the GraphQL API...")
|
||||
|
||||
[
|
||||
# use persistent_term backend for Absinthe
|
||||
{Absinthe.Schema, Bonfire.API.GraphQL.Schema}
|
||||
] ++
|
||||
applications(env, :default) ++
|
||||
applications(env, test_instance?, nil) ++
|
||||
[
|
||||
{Absinthe.Subscription, @endpoint_module}
|
||||
]
|
||||
end
|
||||
|
||||
@apps_before [
|
||||
# Metrics
|
||||
Bonfire.Web.Telemetry,
|
||||
# Database
|
||||
@repo_module,
|
||||
EctoSparkles.AutoMigrator,
|
||||
# behaviour modules are already prepared as part of `Bonfire.Common.Config.LoadExtensionsConfig`
|
||||
# Bonfire.Common.ExtensionBehaviour,
|
||||
# Bonfire.Common.Config.LoadExtensionsConfig,
|
||||
# load instance Settings from DB into Config
|
||||
Bonfire.Me.Settings.LoadInstanceConfig,
|
||||
# PubSub
|
||||
{Phoenix.PubSub, [name: Bonfire.PubSub, adapter: Phoenix.PubSub.PG2]},
|
||||
# Persistent Data Services
|
||||
Pointers.Tables
|
||||
# Bonfire.Data.AccessControl.Accesses,
|
||||
## these populate on first call, so no need to run on startup:
|
||||
# Bonfire.Common.ContextModule,
|
||||
# Bonfire.Common.QueryModule,
|
||||
# Bonfire.Federate.ActivityPub.FederationModules
|
||||
# {PhoenixProfiler, name: Bonfire.Web.Profiler}
|
||||
]
|
||||
|
||||
# 6 hours
|
||||
@default_cache_ttl 1_000 * 60 * 60 * 6
|
||||
|
||||
# Stuff that depends on the Endpoint and/or the above
|
||||
@apps_after [
|
||||
# Job Queue
|
||||
{Oban, Application.fetch_env!(:bonfire, Oban)},
|
||||
%{
|
||||
id: :bonfire_cache,
|
||||
start:
|
||||
{Cachex, :start_link,
|
||||
[
|
||||
:bonfire_cache,
|
||||
[
|
||||
expiration:
|
||||
Cachex.Spec.expiration(
|
||||
default: @default_cache_ttl,
|
||||
interval: 1000
|
||||
),
|
||||
# increase for instances with more users (at least num. of users*2+1)
|
||||
limit: 5000
|
||||
]
|
||||
]}
|
||||
}
|
||||
]
|
||||
|
||||
def applications(:test, _any) do
|
||||
# ++ [Bonfire.Web.FakeRemoteEndpoint] # NOTE: enable for tests that require two running instances
|
||||
def applications(:test, true = _test_instance?, _any) do
|
||||
@apps_before ++
|
||||
[@endpoint_module] ++
|
||||
@apps_after
|
||||
[@endpoint_module, Bonfire.Web.FakeRemoteEndpoint] ++
|
||||
@apps_after
|
||||
end
|
||||
|
||||
# default apps
|
||||
def applications(_env, _any) do
|
||||
def applications(_env, _test_instance?, _any) do
|
||||
@apps_before ++
|
||||
[@endpoint_module] ++
|
||||
@apps_after
|
||||
[@endpoint_module] ++
|
||||
@apps_after
|
||||
end
|
||||
|
||||
|
||||
# Tell Phoenix to update the endpoint configuration
|
||||
# whenever the application is updated.
|
||||
def config_change(changed, _new, removed) do
|
||||
|
|
|
@ -19,7 +19,7 @@ ExUnit.start(
|
|||
|
||||
# Ecto.Adapters.SQL.Sandbox.mode(Bonfire.Common.Repo, :manual)
|
||||
|
||||
# if System.get_env("START_SERVER") !="true" do
|
||||
# if System.get_env("START_SERVER") !="yes" do
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Bonfire.Common.Repo, :auto)
|
||||
# end
|
||||
|
||||
|
|
Loading…
Reference in a new issue