Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
7668-snmp-agent-test-Be-more-informative-during...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 7668-snmp-agent-test-Be-more-informative-during-end-per-g.patch of Package erlang
From 39e4c798d03f540bf980d8e3191b68d7c38d1ac7 Mon Sep 17 00:00:00 2001 From: Micael Karlberg <bmk@erlang.org> Date: Fri, 21 Jan 2022 20:26:08 +0100 Subject: [PATCH 08/12] [snmp|agent|test] Be more informative during end per group|testcase --- lib/snmp/test/snmp_agent_SUITE.erl | 120 ++++++++++++++++++++++++----- lib/snmp/test/snmp_test_lib.erl | 20 +++++ 2 files changed, 122 insertions(+), 18 deletions(-) diff --git a/lib/snmp/test/snmp_agent_SUITE.erl b/lib/snmp/test/snmp_agent_SUITE.erl index e2ff145d37..408ba53a92 100644 --- a/lib/snmp/test/snmp_agent_SUITE.erl +++ b/lib/snmp/test/snmp_agent_SUITE.erl @@ -1330,21 +1330,64 @@ stop_agent(Config) -> create_tables(SaNode) -> - ?line {atomic, ok} = mnesia:create_table([{name, friendsTable2}, - {ram_copies, [SaNode]}, - {snmp, [{key, integer}]}, - {attributes, [a1,a2,a3]}]), - ?line {atomic, ok} = mnesia:create_table([{name, kompissTable2}, - {ram_copies, [SaNode]}, - {snmp, [{key, integer}]}, - {attributes, [a1,a2,a3]}]), - ?line {atomic, ok} = mnesia:create_table([{name, snmp_variables}, - {attributes, [a1,a2]}]). + %% ?line {atomic, ok} = mnesia:create_table([{name, friendsTable2}, + %% {ram_copies, [SaNode]}, + %% {snmp, [{key, integer}]}, + %% {attributes, [a1,a2,a3]}]), + mnesia_create_table_or_skip([{name, friendsTable2}, + {ram_copies, [SaNode]}, + {snmp, [{key, integer}]}, + {attributes, [a1,a2,a3]}]), + %% ?line {atomic, ok} = mnesia:create_table([{name, kompissTable2}, + %% {ram_copies, [SaNode]}, + %% {snmp, [{key, integer}]}, + %% {attributes, [a1,a2,a3]}]), + mnesia_create_table_or_skip([{name, kompissTable2}, + {ram_copies, [SaNode]}, + {snmp, [{key, integer}]}, + {attributes, [a1,a2,a3]}]), + %% ?line {atomic, ok} = mnesia:create_table([{name, snmp_variables}, + %% {attributes, [a1,a2]}]), + mnesia_create_table_or_skip([{name, snmp_variables}, + {attributes, [a1,a2]}]), + ok. + +mnesia_create_table_or_skip(Args) -> + case mnesia:create_table(Args) of + {atomic, ok} -> + ok; + {aborted, {already_exists, Table}} -> + ?SKIP({table_already_exist, Table}); + {aborted, Error} -> + ?FAIL({failed_create_table, Error}) + end. + delete_tables() -> - mnesia:delete_table(friendsTable2), - mnesia:delete_table(kompissTable2), - mnesia:delete_table(snmp_variables). + %% mnesia:delete_table(friendsTable2), + mnesia_delete_table(friendsTable2), + %% mnesia:delete_table(kompissTable2), + mnesia_delete_table(kompissTable2), + %% mnesia:delete_table(snmp_variables). + mnesia_delete_table(snmp_variables). + +mnesia_delete_table(Tab) -> + try mnesia:delete_table(Tab) of + {atomic, ok} -> + ok; + {aborted, Reason} -> + ?EPRINT("Table delete aborted:" + "~n Table: ~w: " + "~n Reason: ~p", [Tab, Reason]), + {error, Reason} + catch + C:E:S -> + ?EPRINT("Failed delete table ~w: " + "~n Class: ~p" + "~n Error: ~p" + "~n Stack: ~p", [Tab, C, E, S]), + {error, {C, E, S}} + end. %% Tables are created in runtime! delete_mib_storage_mnesia_tables() -> @@ -1590,44 +1633,61 @@ init_varm_mib_storage_mnesia(Config) when is_list(Config) -> [{vsn, v1}, {agent_opts, Opts} | Config]. finish_mib_storage_ets(Config) when is_list(Config) -> - ?IPRINT("finish_mib_storage_ets -> entry"), + ?IPRINT("finish_mib_storage_ets -> try delete mnesia tables"), delete_tables(), + ?IPRINT("finish_mib_storage_ets -> try stop agent"), C1 = stop_agent(Config), + ?IPRINT("finish_mib_storage_ets -> try delete files"), delete_files(C1), + ?IPRINT("finish_mib_storage_ets -> done"), C2 = lists:keydelete(vsn, 1, C1), lists:keydelete(agent_opts, 1, C2). finish_mib_storage_dets(Config) when is_list(Config) -> - ?IPRINT("finish_mib_storage_dets -> entry"), + ?IPRINT("finish_mib_storage_dets -> try delete mnesia tables"), delete_tables(), + ?IPRINT("finish_mib_storage_dets -> try stop agent"), C1 = stop_agent(Config), + ?IPRINT("finish_mib_storage_dets -> try delete files"), delete_files(C1), + ?IPRINT("finish_mib_storage_dets -> done"), C2 = lists:keydelete(vsn, 1, C1), lists:keydelete(agent_opts, 1, C2). finish_mib_storage_mnesia(Config) when is_list(Config) -> - ?IPRINT("finish_mib_storage_mnesia -> entry"), + ?IPRINT("finish_mib_storage_mnesia -> try delete mnesia tables"), delete_tables(), + ?IPRINT("finish_mib_storage_mnesia -> " + "try delete (mib storage) mnesia tables"), delete_mib_storage_mnesia_tables(), + ?IPRINT("finish_mib_storage_mnesia -> try stop agent"), C1 = stop_agent(Config), + ?IPRINT("finish_mib_storage_mnesia -> try delete files"), delete_files(C1), + ?IPRINT("finish_mib_storage_mnesia -> done"), C2 = lists:keydelete(vsn, 1, C1), lists:keydelete(agent_opts, 1, C2). finish_varm_mib_storage_dets(Config) when is_list(Config) -> - ?IPRINT("finish_varm_mib_storage_dets -> entry"), + ?IPRINT("finish_varm_mib_storage_dets -> try delete mnesia tables"), delete_tables(), %% C1 = stop_agent(Config), % In case something went wrong... + ?IPRINT("finish_varm_mib_storage_dets -> try delete files"), delete_files(Config), + ?IPRINT("finish_varm_mib_storage_dets -> done"), C2 = lists:keydelete(vsn, 1, Config), lists:keydelete(agent_opts, 1, C2). finish_varm_mib_storage_mnesia(Config) when is_list(Config) -> - ?IPRINT("finish_varm_mib_storage_mnesia -> entry"), + ?IPRINT("finish_varm_mib_storage_mnesia -> try delete mnesia tables"), delete_tables(), + ?IPRINT("finish_varm_mib_storage_mnesia -> " + "try delete (mib storage) mnesia tables"), delete_mib_storage_mnesia_tables(), %% C1 = stop_agent(Config), % In case something went wrong... + ?IPRINT("finish_varm_mib_storage_mnesia -> try delete files"), delete_files(Config), + ?IPRINT("finish_varm_mib_storage_mnesia -> done"), C2 = lists:keydelete(vsn, 1, Config), lists:keydelete(agent_opts, 1, C2). @@ -1641,9 +1701,13 @@ finish_size_check_msm(Config) when is_list(Config) -> finish_size_check_ms(Config). finish_size_check_ms(Config) when is_list(Config) -> + ?IPRINT("finish_size_check_ms -> try delete mnesia tables"), delete_tables(), + ?IPRINT("finish_size_check_ms -> try stop agent"), C1 = stop_agent(Config), + ?IPRINT("finish_size_check_ms -> try delete files"), delete_files(C1), + ?IPRINT("finish_size_check_ms -> done"), lists:keydelete(vsn, 1, C1). @@ -2194,9 +2258,13 @@ init_v1(Config) when is_list(Config) -> [{vsn, v1} | start_v1_agent(Config)]. finish_v1(Config) when is_list(Config) -> + ?IPRINT("finish_v1 -> try delete mnesia tables"), delete_tables(), + ?IPRINT("finish_v1 -> try stop agent"), C1 = stop_agent(Config), + ?IPRINT("finish_v1 -> try delete files"), delete_files(C1), + ?IPRINT("finish_v1 -> done"), lists:keydelete(vsn, 1, C1). @@ -2267,9 +2335,13 @@ init_v2(Config) when is_list(Config) -> [{vsn, v2} | start_v2_agent(Config)]. finish_v2(Config) when is_list(Config) -> + ?IPRINT("finish_v2 -> try delete mnesia tables"), delete_tables(), + ?IPRINT("finish_v2 -> try stop agent"), C1 = stop_agent(Config), + ?IPRINT("finish_v2 -> try delete files"), delete_files(C1), + ?IPRINT("finish_v2 -> done"), lists:keydelete(vsn, 1, C1). @@ -2288,9 +2360,13 @@ init_v1_v2(Config) when is_list(Config) -> [{vsn, bilingual} | start_bilingual_agent(Config)]. finish_v1_v2(Config) when is_list(Config) -> + ?IPRINT("finish_v1_v2 -> try delete mnesia tables"), delete_tables(), + ?IPRINT("finish_v1_v2 -> try stop agent"), C1 = stop_agent(Config), + ?IPRINT("finish_v1_v2 -> try delete files"), delete_files(C1), + ?IPRINT("finish_v1_v2 -> done"), lists:keydelete(vsn, 1, C1). @@ -2389,9 +2465,13 @@ init_v3(Config) when is_list(Config) -> [{vsn, v3} | start_v3_agent(Config, Opts)]. finish_v3(Config) when is_list(Config) -> + ?IPRINT("finish_v3 -> try delete mnesia tables"), delete_tables(), + ?IPRINT("finish_v3 -> try stop agent"), C1 = stop_agent(Config), + ?IPRINT("finish_v3 -> try delete files"), delete_files(C1), + ?IPRINT("finish_v3 -> done"), lists:keydelete(vsn, 1, C1). @@ -2412,9 +2492,13 @@ init_mt(Config, MT) when is_list(Config) -> [{vsn, v2} | start_multi_threaded_agent(Config, MT)]. finish_mt(Config) when is_list(Config) -> + ?IPRINT("finish_mt -> try delete mnesia tables"), delete_tables(), + ?IPRINT("finish_mt -> try stop agent"), C1 = stop_agent(Config), + ?IPRINT("finish_mt -> try delete files"), delete_files(C1), + ?IPRINT("finish_mt -> done"), lists:keydelete(vsn, 1, C1). %% This one *must* be run first in each case. diff --git a/lib/snmp/test/snmp_test_lib.erl b/lib/snmp/test/snmp_test_lib.erl index 6b272abdff..15d1817c01 100644 --- a/lib/snmp/test/snmp_test_lib.erl +++ b/lib/snmp/test/snmp_test_lib.erl @@ -469,6 +469,26 @@ display_app_version(MI) -> %% Conditional skip of testcases %% +%% maybe_skip([]) -> +%% ok; +%% maybe_skip([{Desc, F}|Funs]) when is_function(F, 0) -> +%% iprint("Check skip condition: ~s", [Desc]), +%% try F() of +%% {skip, _} = SKIP -> +%% iprint("Skip condition fulfilled: SKIP", [Desc]), +%% SKIP; +%% _ -> +%% maybe_skip(Funs) +%% catch +%% C:E:S -> +%% iprint("Skip condition failed - ignoring" +%% "~n Class: ~p" +%% "~n Error: ~p" +%% "~n Stack: ~p", [C, E, S]), +%% maybe_skip(Funs) +%% end. + + non_pc_tc_maybe_skip(Config, Condition, File, Line) when is_list(Config) andalso is_function(Condition) -> %% Check if we shall skip the skip -- 2.34.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor