Merge pull request #27 from rabbitmq/rabbitmq-queues-helpers
Helpers for rabbitmq-queues cli tool
This commit is contained in:
		
						commit
						9aea3400c1
					
				|  | @ -40,6 +40,7 @@ | |||
| 
 | ||||
|     control_action/2, control_action/3, control_action/4, | ||||
|     rabbitmqctl/3, rabbitmqctl_list/3, | ||||
|     rabbitmq_queues/3, | ||||
| 
 | ||||
|     add_code_path_to_node/2, | ||||
|     add_code_path_to_all_nodes/2, | ||||
|  | @ -938,6 +939,29 @@ rabbitmqctl_list(Config, Node, Args) -> | |||
|      | Rows] = re:split(StdOut, <<"\n">>, [trim]), | ||||
|     [re:split(Row, <<"\t">>) || Row <- Rows]. | ||||
| 
 | ||||
| rabbitmq_queues(Config, Node, Args) -> | ||||
|     RabbitmqQueues = ?config(rabbitmq_queues_cmd, Config), | ||||
|     NodeConfig = rabbit_ct_broker_helpers:get_node_config(Config, Node), | ||||
|     Nodename = ?config(nodename, NodeConfig), | ||||
|     Env0 = [ | ||||
|       {"RABBITMQ_PID_FILE", ?config(pid_file, NodeConfig)}, | ||||
|       {"RABBITMQ_MNESIA_DIR", ?config(mnesia_dir, NodeConfig)}, | ||||
|       {"RABBITMQ_PLUGINS_DIR", ?config(plugins_dir, NodeConfig)}, | ||||
|       {"RABBITMQ_ENABLED_PLUGINS_FILE", | ||||
|         ?config(enabled_plugins_file, NodeConfig)} | ||||
|     ], | ||||
|     Ret = rabbit_ct_helpers:get_config( | ||||
|             NodeConfig, enabled_feature_flags_list_file), | ||||
|     Env = case Ret of | ||||
|               undefined -> | ||||
|                   Env0; | ||||
|               EnabledFeatureFlagsFile -> | ||||
|                   Env0 ++ | ||||
|                   [{"RABBITMQ_FEATURE_FLAGS_FILE", EnabledFeatureFlagsFile}] | ||||
|           end, | ||||
|     Cmd = [RabbitmqQueues, "-n", Nodename | Args], | ||||
|     rabbit_ct_helpers:exec(Cmd, [{env, Env}]). | ||||
| 
 | ||||
| %% ------------------------------------------------------------------- | ||||
| %% Other helpers. | ||||
| %% ------------------------------------------------------------------- | ||||
|  |  | |||
|  | @ -31,6 +31,7 @@ | |||
|     ensure_rabbitmqctl_cmd/1, | ||||
|     ensure_rabbitmqctl_app/1, | ||||
|     ensure_rabbitmq_plugins_cmd/1, | ||||
|     ensure_rabbitmq_queues_cmd/1, | ||||
|     start_long_running_testsuite_monitor/1, | ||||
|     stop_long_running_testsuite_monitor/1, | ||||
|     config_to_testcase_name/2, | ||||
|  | @ -375,7 +376,7 @@ ensure_rabbitmqctl_cmd(Config) -> | |||
|                 {error, 64, _} -> | ||||
|                     set_config(Config, {rabbitmqctl_cmd, Rabbitmqctl}); | ||||
|                 {error, Code, Reason} -> | ||||
|                     ct:pal(?LOW_IMPORTANCE, "Exec failed with exit code ~d: ~p", [Code, Reason]), | ||||
|                     ct:pal("Exec failed with exit code ~d: ~p", [Code, Reason]), | ||||
|                     Error; | ||||
|                 _ -> | ||||
|                     Error | ||||
|  | @ -436,6 +437,41 @@ ensure_rabbitmq_plugins_cmd(Config) -> | |||
|             end | ||||
|     end. | ||||
| 
 | ||||
| ensure_rabbitmq_queues_cmd(Config) -> | ||||
|     RabbitmqQueues = case get_config(Config, rabbitmq_queues_cmd) of | ||||
|                          undefined -> | ||||
|                              SrcDir = ?config(rabbit_srcdir, Config), | ||||
|                              R = filename:join(SrcDir, "scripts/rabbitmq-queues"), | ||||
|                              ct:pal(?LOW_IMPORTANCE, "Using rabbitmq-queues at ~p~n", [R]), | ||||
|                              case filelib:is_file(R) of | ||||
|                                  true  -> R; | ||||
|                                  false -> false | ||||
|                              end; | ||||
|                          R -> | ||||
|                              ct:pal(?LOW_IMPORTANCE, | ||||
|                                     "Using rabbitmq-queues from rabbitmq_queues_cmd: ~p~n", [R]), | ||||
|                              R | ||||
|                      end, | ||||
|     Error = {skip, "rabbitmq-queues required, " ++ | ||||
|              "please set 'rabbitmq_queues_cmd' in ct config"}, | ||||
|     case RabbitmqQueues of | ||||
|         false -> | ||||
|             Error; | ||||
|         _ -> | ||||
|             Cmd = [RabbitmqQueues], | ||||
|             case exec(Cmd, [drop_stdout]) of | ||||
|                 {error, 64, _} -> | ||||
|                     set_config(Config, | ||||
|                                {rabbitmq_queues_cmd, | ||||
|                                 RabbitmqQueues}); | ||||
|                 {error, Code, Reason} -> | ||||
|                     ct:pal("Exec failed with exit code ~d: ~p", [Code, Reason]), | ||||
|                     Error; | ||||
|                 _ -> | ||||
|                     Error | ||||
|             end | ||||
|     end. | ||||
| 
 | ||||
| ensure_ssl_certs(Config) -> | ||||
|     SrcDir = ?config(rabbitmq_ct_helpers_srcdir, Config), | ||||
|     CertsMakeDir = filename:join([SrcDir, "tools", "tls-certs"]), | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue