Pin emqx-ct-helpers v1.1 (#2495)
* Pin emqx-ct-helpers v1.1.1 * Fix loaded_plugins touch command
This commit is contained in:
parent
97476b8bde
commit
d0131ec663
|
@ -39,3 +39,4 @@ rebar.lock
|
||||||
xrefr
|
xrefr
|
||||||
erlang.mk
|
erlang.mk
|
||||||
*.coverdata
|
*.coverdata
|
||||||
|
etc/emqx.conf.rendered
|
||||||
|
|
30
Makefile
30
Makefile
|
@ -24,31 +24,11 @@ clean: gen-clean
|
||||||
|
|
||||||
.PHONY: gen-clean
|
.PHONY: gen-clean
|
||||||
gen-clean:
|
gen-clean:
|
||||||
@rm -f etc/gen.emqx.conf
|
@rm -f etc/emqx.conf.rendered
|
||||||
|
|
||||||
## bbmustache is a mustache template library used to render templated config files
|
|
||||||
## for common tests.
|
|
||||||
BBMUSTACHE := _build/test/lib/bbmustache
|
|
||||||
$(BBMUSTACHE):
|
|
||||||
@rebar3 as test compile
|
|
||||||
|
|
||||||
## Cuttlefish escript is built by default when cuttlefish app (as dependency) was built
|
## Cuttlefish escript is built by default when cuttlefish app (as dependency) was built
|
||||||
CUTTLEFISH_SCRIPT := _build/default/lib/cuttlefish/cuttlefish
|
CUTTLEFISH_SCRIPT := _build/default/lib/cuttlefish/cuttlefish
|
||||||
|
|
||||||
app.config: etc/gen.emqx.conf
|
|
||||||
$(verbose) $(CUTTLEFISH_SCRIPT) -l info -e etc/ -c etc/gen.emqx.conf -i priv/emqx.schema -d data/
|
|
||||||
|
|
||||||
## NOTE: Mustache templating was resolved by relx overlay when building a release.
|
|
||||||
## This is only to generate a conf file for testing,
|
|
||||||
etc/gen.emqx.conf: $(BBMUSTACHE) etc/emqx.conf
|
|
||||||
@$(verbose) erl -noshell -pa _build/test/lib/bbmustache/ebin -eval \
|
|
||||||
"{ok, Temp} = file:read_file('etc/emqx.conf'), \
|
|
||||||
{ok, Vars0} = file:consult('vars'), \
|
|
||||||
Vars = [{atom_to_list(N), list_to_binary(V)} || {N, V} <- Vars0], \
|
|
||||||
Targ = bbmustache:render(Temp, Vars), \
|
|
||||||
ok = file:write_file('etc/gen.emqx.conf', Targ), \
|
|
||||||
halt(0)."
|
|
||||||
|
|
||||||
.PHONY: cover
|
.PHONY: cover
|
||||||
cover:
|
cover:
|
||||||
@rebar3 cover
|
@rebar3 cover
|
||||||
|
@ -69,17 +49,15 @@ deps:
|
||||||
eunit:
|
eunit:
|
||||||
@rebar3 eunit -v
|
@rebar3 eunit -v
|
||||||
|
|
||||||
## 'ct-setup' is a pre hook for 'rebar3 ct',
|
|
||||||
## but not the makefile target ct's dependency
|
|
||||||
## because 'ct-setup' requires test dependencies to be compiled first
|
|
||||||
.PHONY: ct-setup
|
.PHONY: ct-setup
|
||||||
ct-setup:
|
ct-setup:
|
||||||
@rebar3 as test compile
|
@mkdir -p data
|
||||||
|
@if [ ! -f data/loaded_plugins ]; then touch data/loaded_plugins; fi
|
||||||
@ln -s -f '../../../../etc' _build/test/lib/emqx/
|
@ln -s -f '../../../../etc' _build/test/lib/emqx/
|
||||||
@ln -s -f '../../../../data' _build/test/lib/emqx/
|
@ln -s -f '../../../../data' _build/test/lib/emqx/
|
||||||
|
|
||||||
.PHONY: ct
|
.PHONY: ct
|
||||||
ct: app.config ct-setup
|
ct: ct-setup
|
||||||
@rebar3 ct -v --readable=false --name $(CT_NODE_NAME) --suite=$(shell echo $(foreach var,$(CT_SUITES),test/$(var)_SUITE) | tr ' ' ',')
|
@rebar3 ct -v --readable=false --name $(CT_NODE_NAME) --suite=$(shell echo $(foreach var,$(CT_SUITES),test/$(var)_SUITE) | tr ' ' ',')
|
||||||
|
|
||||||
## Run one single CT with rebar3
|
## Run one single CT with rebar3
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
[{deps,
|
[{deps,
|
||||||
[ {meck, "0.8.13"} % hex
|
[ {meck, "0.8.13"} % hex
|
||||||
, {bbmustache, "1.7.0"} % hex
|
, {bbmustache, "1.7.0"} % hex
|
||||||
, {emqx_ct_helpers, {git, "https://github.com/emqx/emqx-ct-helpers", {tag, "v1.0"}}}
|
, {emqx_ct_helpers, {git, "https://github.com/emqx/emqx-ct-helpers", {tag, "v1.1.1"}}}
|
||||||
]}
|
]}
|
||||||
]}
|
]}
|
||||||
]}.
|
]}.
|
||||||
|
|
|
@ -49,9 +49,27 @@ restart_listeners(_) ->
|
||||||
ok = emqx_listeners:restart(),
|
ok = emqx_listeners:restart(),
|
||||||
ok = emqx_listeners:stop().
|
ok = emqx_listeners:stop().
|
||||||
|
|
||||||
|
render_config_file() ->
|
||||||
|
Path = local_path(["etc", "emqx.conf"]),
|
||||||
|
{ok, Temp} = file:read_file(Path),
|
||||||
|
Vars0 = mustache_vars(),
|
||||||
|
Vars = [{atom_to_list(N), iolist_to_binary(V)} || {N, V} <- Vars0],
|
||||||
|
Targ = bbmustache:render(Temp, Vars),
|
||||||
|
NewName = Path ++ ".rendered",
|
||||||
|
ok = file:write_file(NewName, Targ),
|
||||||
|
NewName.
|
||||||
|
|
||||||
|
mustache_vars() ->
|
||||||
|
[{platform_data_dir, local_path(["data"])},
|
||||||
|
{platform_etc_dir, local_path(["etc"])},
|
||||||
|
{platform_log_dir, local_path(["log"])},
|
||||||
|
{platform_plugins_dir, local_path(["plugins"])}
|
||||||
|
].
|
||||||
|
|
||||||
generate_config() ->
|
generate_config() ->
|
||||||
Schema = cuttlefish_schema:files([local_path(["priv", "emqx.schema"])]),
|
Schema = cuttlefish_schema:files([local_path(["priv", "emqx.schema"])]),
|
||||||
Conf = conf_parse:file([local_path(["etc", "gen.emqx.conf"])]),
|
ConfFile = render_config_file(),
|
||||||
|
Conf = conf_parse:file(ConfFile),
|
||||||
cuttlefish_generator:map(Schema, Conf).
|
cuttlefish_generator:map(Schema, Conf).
|
||||||
|
|
||||||
set_app_env({App, Lists}) ->
|
set_app_env({App, Lists}) ->
|
||||||
|
|
Loading…
Reference in New Issue