Open Closed

Cannot run all tests using MongoDB #1892


User avatar
0
Marten created

Version 4.4.2 Angular MongoDB

I am having problems running the tests in my project using MongoDB, the tests work fine when I run them one at a time, but when I try to run all tests I get connection problems:

System.Net.Sockets.SocketException: 'No connection could be made because the target machine actively refused it.'

System.TimeoutException
  HResult=0x80131505
  Message=A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "Direct", Type : "ReplicaSet", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "127.0.0.1:54282" }", EndPoint: "127.0.0.1:54282", ReasonChanged: "NotSpecified", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
 ---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Threading.Tasks.ValueTask.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
--- End of stack trace from previous location ---
   at MongoDB.Driver.Core.Connections.TcpStreamFactory.ConnectAsync(Socket socket, EndPoint endPoint, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Connections.TcpStreamFactory.CreateStreamAsync(EndPoint endPoint, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Servers.ServerMonitor.InitializeConnectionAsync(CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastHeartbeatTimestamp: "2021-09-23T12:15:05.9886939Z", LastUpdateTimestamp: "2021-09-23T12:15:05.9891692Z" }] }.
  Source=MongoDB.Driver.Core
  StackTrace:
   at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)

   System.TimeoutException
  HResult=0x80131505
  Message=Timed out connecting to 127.0.0.1:54282. Timeout was 00:00:30.
  Source=MongoDB.Driver.Core
  StackTrace:
   at MongoDB.Driver.Core.Connections.TcpStreamFactory.<ConnectAsync>d__7.MoveNext()

  This exception was originally thrown at this call stack:
    MongoDB.Driver.Core.Connections.TcpStreamFactory.ConnectAsync(System.Net.Sockets.Socket, System.Net.EndPoint, System.Threading.CancellationToken)

I have generated a first entity using ABP Suite which gives multiple tests for CRUD operations, and running all these tests at the same time cause the error.

Should this be working out of the box or is there some additional configuration needed?

Possibly related to https://github.com/Mongo2Go/Mongo2Go/issues/98


4 Answer(s)
  • User Avatar
    0
    Marten created

    Tried some more and the tests seem to work at first when a new project is generated but start failing after an entity has been generated.

  • User Avatar
    0
    Marten created

    Ok, so it seems the issue is that the test classes get generated by ABP Suite without being added to the test collection.

    After decorating the generated test-classes with [Collection(MyProjectTestConsts.CollectionDefinitionName)] all tests can be run together.

    Is this by design or a bug in the code generator?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I think this is a problem, I will feedback to the Team.

  • User Avatar
    1
    maliming created
    Support Team Fullstack Developer

    Your Question Credits is refunded.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 19, 2024, 12:56