Bläddra i källkod

Pin emqx-ct-helpers v1.1 (#2495)

* Pin emqx-ct-helpers v1.1.1

* Fix loaded_plugins touch command
spring2maz 6 år sedan
förälder
incheckning
d0131ec663
5 ändrade filer med 25 tillägg och 37 borttagningar
  1. 1 0
      .gitignore
  2. 4 26
      Makefile
  3. 1 1
      rebar.config
  4. 19 1
      test/emqx_listeners_SUITE.erl
  5. 0 9
      vars

+ 1 - 0
.gitignore

@@ -39,3 +39,4 @@ rebar.lock
 xrefr
 xrefr
 erlang.mk
 erlang.mk
 *.coverdata
 *.coverdata
+etc/emqx.conf.rendered

+ 4 - 26
Makefile

@@ -24,31 +24,11 @@ clean: gen-clean
 
 
 .PHONY: gen-clean
 .PHONY: gen-clean
 gen-clean:
 gen-clean:
-	@rm -f etc/gen.emqx.conf
-
-## 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
+	@rm -f etc/emqx.conf.rendered
 
 
 ## 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

+ 1 - 1
rebar.config

@@ -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"}}}
             ]}
             ]}
         ]}
         ]}
     ]}.
     ]}.

+ 19 - 1
test/emqx_listeners_SUITE.erl

@@ -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}) ->

+ 0 - 9
vars

@@ -1,9 +0,0 @@
-%% vars here are for test only, not intended for release
-
-{platform_bin_dir,  "bin"}.
-{platform_data_dir, "data"}.
-{platform_etc_dir,  "etc"}.
-{platform_lib_dir,  "lib"}.
-{platform_log_dir,  "log"}.
-{platform_plugins_dir,  "plugins"}.
-