From 87c6fcac63316e7651a55ccc03fd930829384566 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Fri, 1 Sep 2023 12:06:35 -0400 Subject: [PATCH] Revise failing tests in engine For the first test, the connection comparison was removed since we are expecting an error from the constructor. The second one has been removed, because there is no way to compare 2 instances of rpcclient.RPCClient from engine. It will probably be added back when an Equal function will be implemented for RPCClient. --- engine/libengine_test.go | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/engine/libengine_test.go b/engine/libengine_test.go index fe38ff445..2aec67a7c 100644 --- a/engine/libengine_test.go +++ b/engine/libengine_test.go @@ -94,15 +94,8 @@ func TestLibengineNewRPCConnection(t *testing.T) { expectedErr1 := "dial tcp [::1]:6012: connect: connection refused" expectedErr2 := "dial tcp 127.0.0.1:6012: connect: connection refused" cM := NewConnManager(config.NewDefaultCGRConfig(), nil) - exp, err := rpcclient.NewRPCClient(context.Background(), utils.TCP, cfg.Address, cfg.TLS, cfg.ClientKey, - cM.cfg.TLSCfg().ClientCerificate, cM.cfg.TLSCfg().CaCertificate, cfg.ConnectAttempts, cfg.Reconnects, - cfg.MaxReconnectInterval, utils.FibDuration, cfg.ConnectTimeout, cfg.ReplyTimeout, cfg.Transport, nil, false, nil) - if err.Error() != expectedErr1 && err.Error() != expectedErr2 { - t.Errorf("Expected %v or %v \n but received \n %v", expectedErr1, expectedErr2, err) - } - - conn, err := NewRPCConnection(context.Background(), cfg, + _, err := NewRPCConnection(context.Background(), cfg, cM.cfg.TLSCfg().ClientKey, cM.cfg.TLSCfg().ClientCerificate, cM.cfg.TLSCfg().CaCertificate, @@ -115,9 +108,6 @@ func TestLibengineNewRPCConnection(t *testing.T) { if err.Error() != expectedErr1 && err.Error() != expectedErr2 { t.Errorf("Expected %v or %v \n but received \n %v", expectedErr1, expectedErr2, err) } - if !reflect.DeepEqual(exp, conn) { - t.Error("Connections don't match") - } } func TestLibengineNewRPCConnectionInternal(t *testing.T) { @@ -214,31 +204,6 @@ func TestLibengineNewRPCClientSet(t *testing.T) { } } -func TestLibengineAddInternalRPCClientSuccess(t *testing.T) { - s := RPCClientSet{} - name := "testName" - connChan := make(chan birpc.ClientConnector) - - expClient, err := rpcclient.NewRPCClient(context.Background(), utils.EmptyString, utils.EmptyString, false, - utils.EmptyString, utils.EmptyString, utils.EmptyString, - config.CgrConfig().GeneralCfg().ConnectAttempts, config.CgrConfig().GeneralCfg().Reconnects, - config.CgrConfig().GeneralCfg().MaxReconnectInterval, utils.FibDuration, - config.CgrConfig().GeneralCfg().ConnectTimeout, config.CgrConfig().GeneralCfg().ReplyTimeout, - rpcclient.InternalRPC, connChan, true, nil) - - if err != nil { - t.Fatal(err) - } - exp := RPCClientSet{ - "testName": expClient, - } - s.AddInternalRPCClient(name, connChan) - - if !reflect.DeepEqual(s, exp) { - t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", exp, s) - } -} - func TestLibengineAddInternalRPCClientLoggerErr(t *testing.T) { s := RPCClientSet{} name := "testName"