diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_feature_flags.erl | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/src/rabbit_feature_flags.erl b/src/rabbit_feature_flags.erl index b8554cc9d6..db13b7347e 100644 --- a/src/rabbit_feature_flags.erl +++ b/src/rabbit_feature_flags.erl @@ -129,7 +129,8 @@ do_sync_feature_flags_with_node/1]). -ifdef(TEST). --export([initialize_registry/3, +-export([inject_test_feature_flags/1, + initialize_registry/3, query_supported_feature_flags/0, mark_as_enabled_remotely/2, mark_as_enabled_remotely/4]). @@ -967,37 +968,22 @@ do_initialize_registry(AllFeatureFlags, %% @private -ifdef(TEST). +-define(PT_TESTSUITE_ATTRS, {?MODULE, testsuite_feature_flags_attrs}). + +inject_test_feature_flags(AttributesFromTestsuite) -> + rabbit_log_feature_flags:debug( + "Feature flags: injecting feature flags from testsuite: ~p", + [AttributesFromTestsuite]), + ok = persistent_term:put(?PT_TESTSUITE_ATTRS, AttributesFromTestsuite), + initialize_registry(). + module_attributes_from_testsuite() -> - try - throw(force_exception) - catch - throw:force_exception:Stacktrace -> - Modules = lists:filter( - fun({Mod, _, _, _}) -> - ModS = atom_to_list(Mod), - re:run(ModS, "_SUITE$", [{capture, none}]) - =:= - match - end, Stacktrace), - case Modules of - [{Module, _, _, _} | _] -> - ModInfo = Module:module_info(attributes), - Attrs = lists:append( - [Attr || {Name, Attr} <- ModInfo, - Name =:= rabbit_feature_flag]), - case Attrs of - [] -> []; - _ -> [{Module, Module, Attrs}] - end; - _ -> - [] - end - end. + persistent_term:get(?PT_TESTSUITE_ATTRS, []). query_supported_feature_flags() -> rabbit_log_feature_flags:debug( - "Feature flags: query feature flags in loaded applications + test " - "module"), + "Feature flags: query feature flags in loaded applications " + "+ testsuite"), T0 = erlang:timestamp(), AttributesPerApp = rabbit_misc:rabbitmq_related_module_attributes( rabbit_feature_flag), |
