Add config option for enabling local_random_exchange
This commit is contained in:
		
							parent
							
								
									febcdbb1b8
								
							
						
					
					
						commit
						8a323b1888
					
				|  | @ -2594,9 +2594,9 @@ end}. | |||
| 
 | ||||
| %% Enable or disable local random exchange | ||||
| %% | ||||
| %% {enable_local_random_exchange, false}, | ||||
| %% {exchange_types.local_random.enabled, false}, | ||||
| 
 | ||||
| {mapping, "enable_local_random_exchange", "rabbit.enable_local_random_exchange", [ | ||||
| {mapping, "exchange_types.local_random.enabled", "rabbit.local_random_exchange_enabled", [ | ||||
|     {datatype, {enum, [true, false]}} | ||||
| ]}. | ||||
| 
 | ||||
|  |  | |||
|  | @ -59,13 +59,21 @@ info(_X, _) -> []. | |||
| serialise_events() -> false. | ||||
| validate(_X) -> | ||||
|     case rabbit_feature_flags:is_enabled(?MODULE) andalso | ||||
|          rabbit_misc:get_env(rabbit, enable_local_random_exchange, true) of | ||||
|          rabbit_misc:get_env(rabbit, enable_local_random_exchange, false) of | ||||
|         true -> | ||||
|             ok; | ||||
|             case application:get_env(rabbit, local_random_exchange_enabled, true) of | ||||
|                 true -> | ||||
|                     ok; | ||||
|                 false -> | ||||
|                     rabbit_misc:protocol_error( | ||||
|                       precondition_failed, | ||||
|                       "x-local-random exchange is disabled by configuration", [], | ||||
|                       'exchange.declare') | ||||
|             end; | ||||
|         false -> | ||||
|             rabbit_misc:protocol_error( | ||||
|               precondition_failed, | ||||
|               "x-local-random exchange feature not available", [], | ||||
|               "x-local-random exchange feature flag is disabled", [], | ||||
|               'exchange.declare') | ||||
|     end. | ||||
| 
 | ||||
|  |  | |||
|  | @ -23,6 +23,8 @@ groups() -> | |||
|                                routed_to_one_local_queue_test, | ||||
|                                no_route, | ||||
|                                enable_local_random_exchange_config_test | ||||
|                                no_route, | ||||
|                                enable_local_random_exchange_config_test | ||||
|                               ]} | ||||
|     ]. | ||||
| 
 | ||||
|  | @ -202,7 +204,7 @@ enable_local_random_exchange_config_test(Config) -> | |||
|      | ||||
|     %% Disable the config flag | ||||
|     rabbit_ct_broker_helpers:rpc(Config, 0, application, set_env, | ||||
|                                  [rabbit, enable_local_random_exchange, false]), | ||||
|                                  [rabbit, local_random_exchange_enabled, false]), | ||||
|      | ||||
|     %% Try to create exchange - should fail | ||||
|     ?assertExit({{shutdown, {server_initiated_close, 406, _}}, _}, | ||||
|  | @ -210,7 +212,7 @@ enable_local_random_exchange_config_test(Config) -> | |||
|      | ||||
|     %% Re-enable the config flag | ||||
|     rabbit_ct_broker_helpers:rpc(Config, 0, application, set_env, | ||||
|                                  [rabbit, enable_local_random_exchange, true]), | ||||
|                                  [rabbit, local_random_exchange_enabled, true]), | ||||
|      | ||||
|     %% Now exchange creation should succeed | ||||
|     declare_exchange(Config, E), | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue