Skip to content

Commit

Permalink
Merge pull request #29 from JesseStimpson/lb-fdbcli
Browse files Browse the repository at this point in the history
Sandbox
  • Loading branch information
jessestimpson authored Dec 10, 2024
2 parents ec0844b + 4fd9740 commit d9df160
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 7 deletions.
27 changes: 27 additions & 0 deletions src/erlfdb_sandbox.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-module(erlfdb_sandbox).

-define(DOCATTRS, ?OTP_RELEASE >= 27).
-if(?DOCATTRS).
-moduledoc """
Creates a database that is to be used as a sandbox.
The sandbox database is contructed using a single
fdbserver process and some default settings are selected.
""".
-endif.

-export([open/0]).

-define(Options, [
{dir, <<".erlfdb_sandbox">>},
{cluster_name, <<"erlfdbsandbox">>},
{cluster_id, <<"erlfdbsandbox">>}
]).

-if(?DOCATTRS).
-doc """
Opens the sandbox database.
""".
-endif.
open() ->
erlfdb_util:get_test_db(?Options).
30 changes: 23 additions & 7 deletions src/erlfdb_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
-endif.

-export([
fdbcli/1,

get_test_db/0,
get_test_db/1,

Expand Down Expand Up @@ -285,14 +287,28 @@ get_monitor_path() ->
end,
filename:join(PrivDir, "monitor.py").

% Look for fdbcli on PATH, but also check /usr/local/bin explicitly
% since that is the common location.
fdbcli(Options) ->
case ?MODULE:get(Options, fdbcli_bin, false) of
false ->
case os:find_executable("fdbcli") of
false ->
case os:find_executable("fdbcli", "/usr/local/bin") of
false ->
erlang:error(fdbcli_not_found);
Exec ->
Exec
end;
_Exec ->
"fdbcli"
end;
C ->
C
end.

init_fdb_db(ClusterFile, Options) ->
DefaultFDBCli = os:find_executable("fdbcli"),
FDBCli =
case ?MODULE:get(Options, fdbcli_bin, DefaultFDBCli) of
false -> erlang:error(fdbcli_not_found);
DefaultFDBCli -> "fdbcli";
FDBCli0 -> FDBCli0
end,
FDBCli = fdbcli(Options),
Storage = get_storage(),
Fmt =
"~s -C ~s --exec \"configure new single ~s tenant_mode=optional_experimental\"",
Expand Down

0 comments on commit d9df160

Please sign in to comment.