diff --git a/big_tests/tests/mam_SUITE.erl b/big_tests/tests/mam_SUITE.erl index 4172d9aa32d..f2ba8757508 100644 --- a/big_tests/tests/mam_SUITE.erl +++ b/big_tests/tests/mam_SUITE.erl @@ -15,143 +15,7 @@ %%============================================================================== -module(mam_SUITE). -%% CT callbacks --export([all/0, - groups/0, - suite/0, - init_per_suite/1, - end_per_suite/1, - init_per_group/2, - end_per_group/2, - init_per_testcase/2, - end_per_testcase/2]). - -%% Tests --export([no_elements/1, - only_stanzaid/1, - same_stanza_id/1, - muc_no_elements/1, - muc_only_stanzaid/1, - mam_service_discovery/1, - mam_service_discovery_to_client_bare_jid/1, - mam_service_discovery_to_different_client_bare_jid_results_in_error/1, - muc_service_discovery/1, - easy_archive_request/1, - easy_archive_request_for_the_receiver/1, - message_sent_to_yourself/1, - text_search_query_fails_if_disabled/1, - pagination_simple_enforced/1, - text_search_is_not_available/1, - easy_text_search_request/1, - long_text_search_request/1, - text_search_is_available/1, - muc_message_with_stanzaid/1, - retract_muc_message/1, - retract_muc_message_on_stanza_id/1, - retract_wrong_muc_message/1, - muc_text_search_request/1, - muc_archive_request/1, - muc_multiple_devices/1, - muc_protected_message/1, - muc_deny_protected_room_access/1, - muc_allow_access_to_owner/1, - muc_sanitize_x_user_in_non_anon_rooms/1, - muc_delete_x_user_in_anon_rooms/1, - muc_show_x_user_to_moderators_in_anon_rooms/1, - muc_show_x_user_for_your_own_messages_in_anon_rooms/1, - range_archive_request/1, - range_archive_request_not_empty/1, - limit_archive_request/1, - metadata_archive_request/1, - metadata_archive_request_empty/1, - metadata_archive_request_one_message/1, - muc_metadata_archive_request/1, - muc_metadata_archive_request_empty/1, - muc_metadata_archive_request_one_message/1, - prefs_set_request/1, - retrieve_form_fields/1, - retrieve_form_fields_extra_features/1, - prefs_set_cdata_request/1, - query_get_request/1, - pagination_first5/1, - pagination_last5/1, - pagination_offset5/1, - pagination_first0/1, - pagination_last0/1, - pagination_offset5_max0/1, - pagination_before10/1, - pagination_after10/1, - pagination_flipped_page/1, - pagination_simple_before10/1, - pagination_simple_before3/1, - pagination_simple_before6/1, - pagination_simple_before1_pagesize0/1, - pagination_simple_before2_pagesize0/1, - pagination_simple_after5/1, - pagination_simple_after10/1, - pagination_simple_after12/1, - pagination_last_after_id5/1, - pagination_last_after_id5_before_id11/1, - pagination_empty_rset/1, - pagination_first_page_after_id4/1, - pagination_last_page_after_id4/1, - pagination_border_flipped_page/1, - server_returns_item_not_found_for_before_filter_with_nonexistent_id/1, - server_returns_item_not_found_for_after_filter_with_nonexistent_id/1, - server_returns_item_not_found_for_after_filter_with_invalid_id/1, - server_returns_item_not_found_for_ids_filter_with_nonexistent_id/1, - muc_server_returns_item_not_found_for_ids_filter_with_nonexistent_id/1, - %% complete_flag_cases tests - before_complete_false_last5/1, - before_complete_false_before10/1, - before_complete_true_before1/1, - before_complete_true_before5/1, - before_complete_true_before6/1, - after_complete_false_first_page/1, - after_complete_false_after2/1, - after_complete_false_after9/1, - after_complete_true_after10/1, - after_complete_true_after11/1, - archived/1, - message_with_stanzaid/1, - retract_message/1, - retract_message_on_stanza_id/1, - retract_wrong_message/1, - ignore_bad_retraction/1, - filter_forwarded/1, - offline_message/1, - nostore_hint/1, - querying_for_all_messages_with_jid/1, - query_messages_by_ids/1, - simple_query_messages_by_ids/1, - muc_query_messages_by_ids/1, - muc_simple_query_messages_by_ids/1, - muc_querying_for_all_messages/1, - muc_querying_for_all_messages_with_jid/1, - muc_light_service_discovery_stored_in_pm/1, - muc_light_easy/1, - muc_light_shouldnt_modify_pm_archive/1, - muc_light_stored_in_pm_if_allowed_to/1, - muc_light_include_groupchat_filter/1, - muc_light_no_pm_stored_include_groupchat_filter/1, - muc_light_include_groupchat_messages_by_default/1, - muc_light_chat_markers_are_archived_if_enabled/1, - muc_light_chat_markers_are_not_archived_if_disabled/1, - muc_light_failed_to_decode_message_in_database/1, - pm_failed_to_decode_message_in_database/1, - messages_filtered_when_prefs_default_policy_is_always/1, - messages_filtered_when_prefs_default_policy_is_never/1, - messages_filtered_when_prefs_default_policy_is_roster/1, - run_set_and_get_prefs_cases/1, - check_user_exist/1, - metric_incremented_on_archive_request/1, - metric_incremented_when_store_message/1, - metrics_incremented_for_async_pools/1, - archive_chat_markers/1, - dont_archive_chat_markers/1, - save_unicode_messages/1, - unicode_messages_can_be_extracted/1, - stanza_id_is_appended_to_carbons/1]). +-compile([export_all, nowarn_export_all]). -import(distributed_helper, [mim/0, require_rpc_nodes/1, @@ -492,8 +356,10 @@ nostore_cases() -> nostore_hint]. muc_cases() -> - [muc_service_discovery, - muc_archive_request, + [muc_service_discovery | muc_cases_with_room()]. + +muc_cases_with_room() -> + [muc_archive_request, muc_multiple_devices, muc_protected_message, muc_deny_protected_room_access, @@ -503,8 +369,7 @@ muc_cases() -> muc_show_x_user_to_moderators_in_anon_rooms, muc_show_x_user_for_your_own_messages_in_anon_rooms, muc_querying_for_all_messages, - muc_querying_for_all_messages_with_jid - ]. + muc_querying_for_all_messages_with_jid]. muc_stanzaid_cases() -> [muc_message_with_stanzaid]. @@ -831,305 +696,157 @@ end_state(C, muc_light, Config) -> end_state(_, _, Config) -> Config. -init_per_testcase(C=metrics_incremented_for_async_pools, Config) -> - case ?config(configuration, Config) of - rdbms_async_pool -> - escalus:init_per_testcase(C, clean_archives(Config)); - _ -> - {skip, "Not an async-pool test"} - end; -init_per_testcase(C=metric_incremented_when_store_message, ConfigIn) -> - Config = case ?config(configuration, ConfigIn) of - rdbms_async_pool -> - MongooseMetrics = [ - {[global, data, rdbms, default], - [{recv_oct, '>'}, {send_oct, '>'}]} - ], - [{mongoose_metrics, MongooseMetrics} | ConfigIn]; - _ -> - ConfigIn - end, - escalus:init_per_testcase(C, clean_archives(Config)); -init_per_testcase(C=filter_forwarded, Config) -> - escalus:init_per_testcase(C, Config); -init_per_testcase(C=querying_for_all_messages_with_jid, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}, {carol, 1}]), - escalus:init_per_testcase(C, bootstrap_archive(Config1)); -init_per_testcase(C, Config) when C =:= query_messages_by_ids; - C =:= simple_query_messages_by_ids; - C =:= server_returns_item_not_found_for_ids_filter_with_nonexistent_id -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}, {carol, 1}]), - escalus:init_per_testcase(C, bootstrap_archive(Config1)); -init_per_testcase(C=archived, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, Config1); -init_per_testcase(C, Config) when C =:= retract_message; - C =:= retract_wrong_message; - C =:= ignore_bad_retraction -> - skip_if_retraction_not_supported(Config, fun() -> escalus:init_per_testcase(C, Config) end); -init_per_testcase(C=retract_message_on_stanza_id, Config) -> - Init = fun() -> - dynamic_modules:ensure_modules(host_type(), required_modules(C, Config)), - escalus:init_per_testcase(C, Config) - end, - skip_if_retraction_not_supported(Config, Init); -init_per_testcase(C=offline_message, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}, {carol, 1}]), - escalus:init_per_testcase(C, Config1); -init_per_testcase(C=nostore_hint, Config) -> - escalus:init_per_testcase(C, Config); -init_per_testcase(C, Config) when C =:= muc_query_messages_by_ids; - C =:= muc_simple_query_messages_by_ids; - C =:= muc_server_returns_item_not_found_for_ids_filter_with_nonexistent_id -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, muc_bootstrap_archive(start_alice_room(Config1))); -init_per_testcase(C=muc_querying_for_all_messages, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, - muc_bootstrap_archive(start_alice_room(Config1))); -init_per_testcase(C=muc_querying_for_all_messages_with_jid, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, - muc_bootstrap_archive(start_alice_room(Config1))); -init_per_testcase(C=muc_archive_request, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - Config2 = %% Check that metric is incremented on MUC flushed - case ?config(configuration, Config1) of - rdbms_async_pool -> - MongooseMetrics = [{['_', 'modMucMamFlushed'], changed}], - [{mongoose_metrics, MongooseMetrics} | Config1]; - _ -> - Config1 - end, - escalus:init_per_testcase(C, start_alice_room(Config2)); -init_per_testcase(C=muc_no_elements, Config) -> - dynamic_modules:ensure_modules(host_type(), required_modules(C, Config)), - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)); -init_per_testcase(C=muc_only_stanzaid, Config) -> - dynamic_modules:ensure_modules(host_type(), required_modules(C, Config)), - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)); -init_per_testcase(C=no_elements, Config) -> - dynamic_modules:ensure_modules(host_type(), required_modules(C, Config)), - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)); -init_per_testcase(C=only_stanzaid, Config) -> - dynamic_modules:ensure_modules(host_type(), required_modules(C, Config)), - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)); -init_per_testcase(C=same_stanza_id, Config) -> - dynamic_modules:ensure_modules(host_type(), required_modules(C, Config)), - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)); -init_per_testcase(C=muc_message_with_stanzaid, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)); -init_per_testcase(C, Config) when C =:= muc_light_failed_to_decode_message_in_database; - C =:= pm_failed_to_decode_message_in_database -> - case proplists:get_value(configuration, Config) of - elasticsearch -> - {skip, "elasticsearch does not support encodings"}; - _ -> - dynamic_modules:ensure_modules(host_type(), required_modules(C, Config)), - escalus:init_per_testcase(C, Config) - end; -init_per_testcase(C, Config) when C =:= retract_muc_message; - C =:= retract_muc_message_on_stanza_id; - C =:= retract_wrong_muc_message -> - Init = fun() -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)) - end, - skip_if_retraction_not_supported(Config, Init); -init_per_testcase(C=muc_multiple_devices, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)); -init_per_testcase(C=muc_protected_message, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)); -init_per_testcase(C=muc_deny_protected_room_access, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_protected_room(Config1)); -init_per_testcase(C=muc_allow_access_to_owner, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_protected_room(Config1)); -init_per_testcase(C=muc_sanitize_x_user_in_non_anon_rooms, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)); -init_per_testcase(C=muc_delete_x_user_in_anon_rooms, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_anonymous_room(Config1)); -init_per_testcase(C=muc_show_x_user_to_moderators_in_anon_rooms, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_anonymous_room(Config1)); -init_per_testcase(C=muc_show_x_user_for_your_own_messages_in_anon_rooms, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_anonymous_room(Config1)); -init_per_testcase(C=pagination_simple_enforced, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}, {carol, 1}]), - escalus:init_per_testcase(C, bootstrap_archive(Config1)); -init_per_testcase(C=range_archive_request_not_empty, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}, {carol, 1}]), - escalus:init_per_testcase(C, bootstrap_archive(Config1)); -init_per_testcase(C=limit_archive_request, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}, {carol, 1}]), - escalus:init_per_testcase(C, bootstrap_archive(Config1)); -init_per_testcase(C=metadata_archive_request, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}, {carol, 1}]), - escalus:init_per_testcase(C, bootstrap_archive(Config1)); -init_per_testcase(C=metadata_archive_request_empty, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, Config1); -init_per_testcase(C=metadata_archive_request_one_message, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, Config1); -init_per_testcase(C=muc_metadata_archive_request, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, - muc_bootstrap_archive(start_alice_room(Config1))); -init_per_testcase(C=muc_metadata_archive_request_empty, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)); -init_per_testcase(C=muc_metadata_archive_request_one_message, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)); -init_per_testcase(C, Config) when C =:= muc_light_include_groupchat_filter; - C =:= muc_light_no_pm_stored_include_groupchat_filter; - C =:= muc_light_include_groupchat_messages_by_default -> - Init = - fun() -> - dynamic_modules:ensure_modules(host_type(), required_modules(C, Config)), - escalus:init_per_testcase(C, Config) - end, - skip_if_include_groupchat_not_supported(Config, Init); -init_per_testcase(C=easy_text_search_request, Config) -> - skip_if_cassandra(Config, fun() -> escalus:init_per_testcase(C, Config) end); -init_per_testcase(C=long_text_search_request, Config) -> - skip_if_cassandra(Config, fun() -> escalus:init_per_testcase(C, Config) end); -init_per_testcase(C=save_unicode_messages, Config) -> - skip_if_cassandra(Config, fun() -> escalus:init_per_testcase(C, Config) end); -init_per_testcase(C=muc_text_search_request, Config) -> - Init = - fun() -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, start_alice_room(Config1)) - end, - - skip_if_cassandra(Config, Init); -init_per_testcase(C = muc_light_service_discovery_stored_in_pm, Config) -> - dynamic_modules:ensure_modules(host_type(), required_modules(C, Config)), - escalus:init_per_testcase(C, Config); -init_per_testcase(C = muc_light_stored_in_pm_if_allowed_to, Config) -> - dynamic_modules:ensure_modules(host_type(), required_modules(C, Config)), - escalus:init_per_testcase(C, Config); -init_per_testcase(C, Config) when C =:= muc_light_easy; - C =:= muc_light_shouldnt_modify_pm_archive; - C =:= muc_light_chat_markers_are_archived_if_enabled; - C =:= muc_light_chat_markers_are_not_archived_if_disabled-> - dynamic_modules:ensure_modules(host_type(), required_modules(C, Config)), - escalus:init_per_testcase(C, Config); -init_per_testcase(C=archive_chat_markers, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, Config1); -init_per_testcase(C=dont_archive_chat_markers, Config) -> - Config1 = escalus_fresh:create_users(Config, [{alice, 1}, {bob, 1}]), - escalus:init_per_testcase(C, Config1); init_per_testcase(CaseName, Config) -> - escalus:init_per_testcase(CaseName, Config). - -skip_if_include_groupchat_not_supported(Config, Init) -> - case ?config(configuration, Config) of - cassandra -> - {skip, "include_groupchat field is not supported for cassandra backend"}; - _ -> - Init() + case maybe_skip(CaseName, Config) of + ok -> + dynamic_modules:ensure_modules(host_type(), required_modules(CaseName, Config)), + lists:foldl(fun(StepF, ConfigIn) -> StepF(CaseName, ConfigIn) end, Config, init_steps()); + {skip, Msg} -> + {skip, Msg} end. -skip_if_retraction_not_supported(Config, Init) -> +init_steps() -> + [fun init_users/2, fun init_archive/2, fun start_room/2, fun init_metrics/2, + fun escalus:init_per_testcase/2]. + +maybe_skip(metrics_incremented_for_async_pools, Config) -> + skip_if(?config(configuration, Config) =/= rdbms_async_pool, + "Not an async-pool test"); +maybe_skip(C, Config) when C =:= retract_message; + C =:= retract_wrong_message; + C =:= ignore_bad_retraction; + C =:= retract_message_on_stanza_id; + C =:= retract_muc_message; + C =:= retract_muc_message_on_stanza_id; + C =:= retract_wrong_muc_message -> ConfList = rdbms_configs(true, ct_helper:get_internal_database()), - case lists:member(?config(configuration, Config), ConfList) of - false -> - {skip, "message retraction not supported"}; - true -> - Init() + skip_if(not lists:member(?config(configuration, Config), ConfList), + "message retraction not supported"); +maybe_skip(C, Config) when C =:= muc_light_failed_to_decode_message_in_database; + C =:= pm_failed_to_decode_message_in_database -> + skip_if(?config(configuration, Config) =:= elasticsearch, + "elasticsearch does not support encodings"); +maybe_skip(C, Config) when C =:= muc_light_include_groupchat_filter; + C =:= muc_light_no_pm_stored_include_groupchat_filter; + C =:= muc_light_include_groupchat_messages_by_default -> + skip_if(?config(configuration, Config) =:= cassandra, + "include_groupchat field is not supported for cassandra backend"); +maybe_skip(C, Config) when C =:= easy_text_search_request; + C =:= long_text_search_request; + C =:= save_unicode_messages; + C =:= muc_text_search_request -> + skip_if(?config(configuration, Config) =:= cassandra, + "full text search is not implemented for cassandra backend"); +maybe_skip(_C, _Config) -> + ok. + +skip_if(false, _Msg) -> ok; +skip_if(true, Msg) -> {skip, Msg}. + +init_users(CaseName, Config) -> + case fresh_users(CaseName) of + [] -> + Config; + UserSpecs -> + escalus_fresh:create_users(Config, UserSpecs) + end. + +-define(requires_pm_archive(C), + C =:= querying_for_all_messages_with_jid; + C =:= query_messages_by_ids; + C =:= simple_query_messages_by_ids; + C =:= server_returns_item_not_found_for_ids_filter_with_nonexistent_id; + C =:= pagination_simple_enforced; + C =:= range_archive_request_not_empty; + C =:= limit_archive_request; + C =:= metadata_archive_request). + +-define(requires_muc_archive(C), + C =:= muc_query_messages_by_ids; + C =:= muc_simple_query_messages_by_ids; + C =:= muc_server_returns_item_not_found_for_ids_filter_with_nonexistent_id; + C =:= muc_querying_for_all_messages; + C =:= muc_querying_for_all_messages_with_jid; + C =:= muc_metadata_archive_request). + +fresh_users(C) when ?requires_pm_archive(C) -> + [{alice, 1}, {bob, 1}, {carol, 1}]; +fresh_users(C) when C =:= offline_message; + C =:= archived; + C =:= no_elements; + C =:= only_stanzaid; + C =:= same_stanza_id; + C =:= metadata_archive_request_empty; + C =:= metadata_archive_request_one_message; + C =:= archive_chat_markers; + C =:= dont_archive_chat_markers -> + [{alice, 1}, {bob, 1}]; +fresh_users(C) -> + case lists:member(C, all_cases_with_room()) of + true -> [{alice, 1}, {bob, 1}]; + false -> [] + end. + +init_archive(C, Config) when C =:= metrics_incremented_for_async_pools; + C =:= metric_incremented_when_store_message -> + clean_archives(Config); +init_archive(C, Config) when ?requires_pm_archive(C) -> + bootstrap_archive(Config); +init_archive(C, Config) when ?requires_muc_archive(C) -> + muc_bootstrap_archive(start_alice_room(Config)); +init_archive(_CaseName, Config) -> + Config. + +start_room(C, Config) when C =:= muc_deny_protected_room_access; + C =:= muc_allow_access_to_owner -> + start_alice_protected_room(Config); +start_room(C, Config) when C =:= muc_delete_x_user_in_anon_rooms; + C =:= muc_show_x_user_to_moderators_in_anon_rooms; + C =:= muc_show_x_user_for_your_own_messages_in_anon_rooms -> + start_alice_anonymous_room(Config); +start_room(C, Config) -> + case lists:member(C, all_cases_with_room()) of + true -> start_alice_room(Config); + false -> Config end. -skip_if_cassandra(Config, Init) -> +init_metrics(metric_incremented_when_store_message, ConfigIn) -> + case ?config(configuration, ConfigIn) of + rdbms_async_pool -> + MongooseMetrics = [ + {[global, data, rdbms, default], + [{recv_oct, '>'}, {send_oct, '>'}]} + ], + [{mongoose_metrics, MongooseMetrics} | ConfigIn]; + _ -> + ConfigIn + end; +init_metrics(muc_archive_request, Config) -> + %% Check that metric is incremented on MUC flushed case ?config(configuration, Config) of - cassandra -> - {skip, "full text search is not implemented for cassandra backend"}; + rdbms_async_pool -> + MongooseMetrics = [{['_', 'modMucMamFlushed'], changed}], + [{mongoose_metrics, MongooseMetrics} | Config]; _ -> - Init() - end. + Config + end; +init_metrics(_CaseName, Config) -> + Config. -end_per_testcase(C=muc_text_search_request, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_archive_request, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_multiple_devices, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_protected_message, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_deny_protected_room_access, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_allow_access_to_owner, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_sanitize_x_user_in_non_anon_rooms, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_delete_x_user_in_anon_rooms, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_show_x_user_to_moderators_in_anon_rooms, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_show_x_user_for_your_own_messages_in_anon_rooms, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C, Config) when C =:= muc_query_messages_by_ids; - C =:= muc_simple_query_messages_by_ids; - C =:= muc_server_returns_item_not_found_for_ids_filter_with_nonexistent_id -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_querying_for_all_messages, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_querying_for_all_messages_with_jid, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_message_with_stanzaid, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C, Config) when C =:= retract_muc_message; - C =:= retract_muc_message_on_stanza_id; - C =:= retract_wrong_muc_message -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_no_elements, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_only_stanzaid, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_metadata_archive_request, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_metadata_archive_request_empty, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); -end_per_testcase(C=muc_metadata_archive_request_one_message, Config) -> - destroy_room(Config), - escalus:end_per_testcase(C, Config); end_per_testcase(CaseName, Config) -> + maybe_destroy_room(CaseName, Config), escalus:end_per_testcase(CaseName, Config). +maybe_destroy_room(CaseName, Config) -> + case lists:member(CaseName, all_cases_with_room()) of + true -> destroy_room(Config); + false -> ok + end. + +all_cases_with_room() -> + muc_cases_with_room() ++ muc_fetch_specific_msgs_cases() ++ muc_configurable_archiveid_cases() ++ + muc_stanzaid_cases() ++ muc_retract_cases() ++ muc_metadata_cases() ++ muc_text_search_cases(). + %% Module configuration per testcase required_modules(CaseName, Config) when CaseName =:= muc_light_service_discovery_stored_in_pm; diff --git a/big_tests/tests/mam_helper.erl b/big_tests/tests/mam_helper.erl index 80ad2f51433..01668a093ee 100644 --- a/big_tests/tests/mam_helper.erl +++ b/big_tests/tests/mam_helper.erl @@ -20,6 +20,8 @@ -include_lib("common_test/include/ct.hrl"). -include_lib("exml/include/exml_stream.hrl"). +-compile([export_all, nowarn_export_all]). + -import(distributed_helper, [mim/0, rpc/4]). @@ -30,104 +32,6 @@ stanza_to_room/2, start_room/5]). -%% TODO: Split into modules like mam_stanza, mam_pred etc. --export([ - prepare_for_suite/1, - backend/0, - rpc_apply/3, - get_prop/2, - is_cassandra_enabled/0, - is_cassandra_enabled/1, - is_elasticsearch_enabled/1, - is_mam_possible/1, - respond_iq/1, - print_configuration_not_supported/2, - start_alice_room/1, - destroy_room/1, - send_muc_rsm_messages/1, - send_rsm_messages/1, - clean_archives/1, - mam04_props/0, - mam06_props/0, - bootstrap_archive/1, - muc_bootstrap_archive/1, - start_alice_protected_room/1, - start_alice_anonymous_room/1, - maybe_wait_for_archive/1, - stanza_archive_request/2, - stanza_text_search_archive_request/3, - stanza_include_groupchat_request/3, - stanza_fetch_by_id_request/3, - stanza_fetch_by_id_request/4, - stanza_date_range_archive_request_not_empty/3, - wait_archive_respond/1, - wait_for_complete_archive_response/3, - assert_respond_size/2, - assert_respond_query_id/3, - parse_result_iq/1, - nick_to_jid/2, - stanza_filtered_by_jid_request/2, - nick/1, - respond_messages/1, - parse_forwarded_message/1, - login_send_presence/2, - assert_only_one_of_many_is_equal/2, - add_store_hint/1, - add_nostore_hint/1, - hint_elem/1, - assert_not_stored/2, - has_x_user_element/1, - stanza_date_range_archive_request/1, - make_iso_time/1, - stanza_retrieve_form_fields/2, - stanza_limit_archive_request/1, - rsm_send/3, - stanza_page_archive_request/3, - stanza_flip_page_archive_request/3, - stanza_metadata_request/0, - wait_empty_rset/2, - wait_message_range/2, - wait_message_range/3, - wait_message_range/5, - message_id/2, - get_pre_generated_msgs_ids/2, - get_received_msgs_ids/1, - stanza_prefs_set_request/4, - stanza_prefs_get_request/1, - stanza_query_get_request/1, - parse_prefs_result_iq/1, - namespaces/0, - mam_ns_binary/0, - mam_ns_binary_v04/0, - mam_ns_binary_v06/0, - mam_ns_binary_extended/0, - retract_ns/0, - retract_esl_ns/0, - retract_tombstone_ns/0, - groupchat_field_ns/0, - groupchat_available_ns/0, - data_validate_ns/0, - make_alice_and_bob_friends/2, - run_prefs_case/6, - prefs_cases2/0, - default_policy/1, - get_all_messages/2, - parse_messages/1, - run_set_and_get_prefs_case/4, - muc_light_host/0, - host/0, - host_type/0, - wait_for_archive_size/2, - wait_for_archive_size_with_host_type/3, - verify_archived_muc_light_aff_msg/3, - wait_for_room_archive_size/3, - generate_msg_for_date_user/3, - generate_msg_for_date_user/4, - random_text/0, - put_msg/1, - config_opts/1 - ]). - -import(config_parser_helper, [config/2, mod_config/2]). config_opts(ExtraOpts) ->