Abrupt termination of program execution if ExtentX server is down.
Summary
If ExtentX server is down, com.mongodb.MongoSocketOpenException: Exception opening socket exception is thrown and program terminates.
Expected Behavior
Connection to ExtentX server should be silent so that if the ExtentX server is down, program does not terminate and other tasks like saving HTML report and sending mails can be done.
Current Behavior
com.mongodb.MongoSocketOpenException: Exception opening socket exception is thrown and program terminates.
Stack Trace of Exception:
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63)
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115)
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:116)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.NoRouteToHostException: No route to host (Host unreachable)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50)
at com.mongodb.connection.SocketStream.open(SocketStream.java:58)
... 3 more
[TestNG] Reporter com.****.automation.framework.listener.SOTestNGListener@42721fe failed
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=172.16.2.121:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.NoRouteToHostException: No route to host (Host unreachable)}}]
at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:375)
at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:104)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71)
at com.mongodb.binding.ClusterBinding.getReadConnectionSource(ClusterBinding.java:63)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:212)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:483)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:80)
at com.mongodb.Mongo.execute(Mongo.java:818)
at com.mongodb.Mongo$2.execute(Mongo.java:805)
at com.mongodb.FindIterableImpl$FindOperationIterable.first(FindIterableImpl.java:207)
at com.mongodb.FindIterableImpl.first(FindIterableImpl.java:148)
at com.aventstack.extentreports.reporter.ExtentXReporter.setupProject(ExtentXReporter.java:206)
at com.aventstack.extentreports.reporter.ExtentXReporter.start(ExtentXReporter.java:174)
at com.aventstack.extentreports.Report.attach(Report.java:54)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at com.aventstack.extentreports.ExtentReports.attachReporter(ExtentReports.java:66)
at com.****.automation.framework.utils.AutomationReport.initExtentReports(AutomationReport.java:76)
at com.****.automation.framework.utils.AutomationReport.<init>(AutomationReport.java:47)
at com.****.automation.framework.listener.SOTestNGListener.generateReport(SOTestNGListener.java:137)
at org.testng.TestNG.generateReports(TestNG.java:1192)
at org.testng.TestNG.run(TestNG.java:1120)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Environment Details
- Extent report Version used: ExtentReports version: 3.0.6, ExtentX version: 1.0.2
- Operating System and version: Windows 10
- JDK Version: JDK8
Screenshots
Rwplacement for ExtentX will be available very soon, this fix/feature will also be included.
Tou can watch this space for updates. https://github.com/anshooarora/maetri
Thanks Anshoo, will be waiting for this replacement. Please also have a mechanism in place so that we can push the report to ExtentX as well as Maetri so that we can compare both with same data.
To make it work now, you can try...catch the exception and in the catch block, you can set the flag to represent the ExtentX unavailability. Based on the flag, you can ignore the extentx attachment and the further actions.