File 0568-megaco-test-Tweaked-mib-related-test-cases.patch of Package erlang

From be2310533f30c5401ba7cf8caa5570b4775ef83d Mon Sep 17 00:00:00 2001
From: Micael Karlberg <bmk@erlang.org>
Date: Fri, 27 Oct 2023 16:20:39 +0200
Subject: [PATCH] [megaco|test] Tweaked mib related test cases

A test run caused the (mib-suite) traffic test case
to enter an infinit loop. A syntax error was detected
(*not* part of the test case) and this resultet
in the test code enter a infinit loop (sending
syntax errors between (one of the) mg and mgc).
Attempted to brake out of this by cancel and then
disconnect.

A following test case failure, in another test suite,
because the nodes, with apps and config, where left running
after the failure. Causing the next test case to fail.
---
 lib/megaco/test/megaco_mib_SUITE.erl  | 23 ++++++++++++++++++++---
 lib/megaco/test/megaco_mreq_SUITE.erl |  2 +-
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/lib/megaco/test/megaco_mib_SUITE.erl b/lib/megaco/test/megaco_mib_SUITE.erl
index c5b3f7f198..f236825e44 100644
--- a/lib/megaco/test/megaco_mib_SUITE.erl
+++ b/lib/megaco/test/megaco_mib_SUITE.erl
@@ -48,6 +48,7 @@
          handle_trans_ack/5
         ]).
 
+-include_lib("common_test/include/ct.hrl").
 -include_lib("megaco/include/megaco.hrl").
 -include_lib("megaco/include/megaco_message_v1.hrl").
 -include("megaco_test_lib.hrl").
@@ -190,6 +191,7 @@ plain(suite) ->
 plain(doc) ->
     ["Test case for the basic statistics counter handling. "];
 plain(Config) when is_list(Config) ->
+    ct:timetrap(?SECS(10)),
     io:format("create test table 1~n", []),
     Tab1 = megaco_test_cnt1,
     megaco_stats:init(Tab1),
@@ -292,6 +294,8 @@ connect(suite) ->
 connect(doc) ->
     [];
 connect(Config) when is_list(Config) ->
+    Factor = ?config(megaco_factor, Config),
+    ct:timetrap(?SECS(10) + Factor * ?SECS(1)),
     Pre = fun() ->
                   progress("start nodes"),
                   MgcNode = make_node_name(mgc),
@@ -408,6 +412,8 @@ traffic(suite) ->
 traffic(doc) ->
     [];
 traffic(Config) when is_list(Config) ->
+    Factor = ?config(megaco_factor, Config),
+    ct:timetrap(?MINS(1) + Factor * ?SECS(10)),
     Pre = fun() ->
                   progress("start nodes"),
                   MgcNode = make_node_name(mgc),
@@ -1112,7 +1118,9 @@ mgc_handle_request({handle_disconnect, CH, _PV, R}) ->
     megaco:cancel(CH, R), % Cancel the outstanding messages
     ok;
 mgc_handle_request({handle_syntax_error, _RH, _PV, _ED}) ->
-    reply;
+    %% There is no point in this test where this is expected.
+    %% There if it *does* happen; stop 
+    no_reply;
 mgc_handle_request({handle_message_error, _CH, _PV, _ED}) ->
     no_reply;
 mgc_handle_request({handle_trans_request, CH, PV, ARs}) ->
@@ -1509,8 +1517,17 @@ mg_handle_request({handle_connect, CH, _PV},
 mg_handle_request({handle_disconnect, CH, _PV, _R}, S) ->
     {ok, S#mg{conn_handle = CH}};
 
-mg_handle_request({handle_syntax_error, _RH, _PV, _ED}, S) ->
-    {reply, S};
+mg_handle_request({handle_syntax_error, RH, PV, ED}, S) ->
+    %% There is no point in this test where this is expected.
+    %% But if it *does* happen; stop
+    %% But can we do that from here? Spawn?
+    p("Received unexpected syntax error: cancel connection"
+      "~n   RH: ~p"
+      "~n   PV: ~p"
+      "~n   ED: ~p", [RH, PV, ED]),
+    megaco:cancel(S#mg.conn_handle, ED),
+    megaco:disconnect(S#mg.conn_handle, {syntax_error, ED}),
+    {no_reply, S};
 
 mg_handle_request({handle_message_error, CH, _PV, _ED}, S) ->
     {no_reply, S#mg{conn_handle = CH}};
diff --git a/lib/megaco/test/megaco_mreq_SUITE.erl b/lib/megaco/test/megaco_mreq_SUITE.erl
index 4771a49842..c304409f8f 100644
--- a/lib/megaco/test/megaco_mreq_SUITE.erl
+++ b/lib/megaco/test/megaco_mreq_SUITE.erl
@@ -255,7 +255,7 @@ req_and_rep(Config) when is_list(Config) ->
                     "~n      Mg4Node: ~p", 
                     [MgcNode, Mg1Node, Mg2Node, Mg3Node, Mg4Node]),
                   Nodes = [MgcNode, Mg1Node, Mg2Node, Mg3Node, Mg4Node],
-                  ok    = ?START_NODES(Nodes),
+                  ok    = ?START_NODES(Nodes, true),
                   Nodes
           end,
     Case = fun(X) ->
-- 
2.35.3

openSUSE Build Service is sponsored by