Fix MongoSocketOpenException-issue 06/126206/5
authorvasraz <vasyl.razinkov@est.tech>
Fri, 10 Dec 2021 20:47:01 +0000 (20:47 +0000)
committerMichael Morris <michael.morris@est.tech>
Fri, 17 Dec 2021 14:13:37 +0000 (14:13 +0000)
Change-Id: Iebeb7d8a67ddc397d833795cd20205a364709f11
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Issue-ID: SDC-3816

integration-tests/pom.xml
integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/api/ExtentManager.java
integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/api/ExtentTestManager.java
integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/ExtentManager.java
integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/setup/ExtentTestManager.java

index cf546a6..0af1242 100644 (file)
@@ -127,8 +127,18 @@ limitations under the License.
                     <groupId>org.apache.httpcomponents</groupId>
                     <artifactId>httpmime</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>org.mongodb</groupId>
+                    <artifactId>mongodb-driver</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <groupId>org.mongodb</groupId>
+            <artifactId>mongodb-driver</artifactId>
+            <version>3.12.10</version>
+        </dependency>
+
         <dependency>
             <groupId>org.janusgraph</groupId>
             <artifactId>janusgraph-core</artifactId>
index e1961a2..e3dc9d8 100644 (file)
@@ -22,7 +22,6 @@ package org.onap.sdc.backend.ci.tests.api;
 
 import com.aventstack.extentreports.ExtentReports;
 import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
-import com.aventstack.extentreports.reporter.ExtentXReporter;
 import com.aventstack.extentreports.reporter.configuration.Protocol;
 import com.aventstack.extentreports.reporter.configuration.Theme;
 import java.io.File;
@@ -37,55 +36,23 @@ public class ExtentManager {
     private static final String VERSIONS_INFO_FILE_NAME = "versions.info";
     private static ExtentReports extent;
     private static ExtentHtmlReporter htmlReporter;
-    private static ExtentXReporter extentxReporter;
-
-    public enum suiteNameXml {
-
-        TESTNG_FAILED_XML_NAME("testng-failed.xml");
-
-        suiteNameXml(String value) {
-            this.value = value;
-        }
-
-        private String value;
-
-        public String getValue() {
-            return value;
-        }
-
-    }
-
-    public synchronized static ExtentReports setReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception {
-        String dbIp = Utils.getConfig().getReportDBhost();
-        int dbPort = Utils.getConfig().getReportDBport();
 
+    private static synchronized ExtentReports setReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception {
         if (extent == null) {
-            extentxReporter = new ExtentXReporter(dbIp, dbPort);
             extent = new ExtentReports();
             initAndSetExtentHtmlReporter(filePath, htmlFile, isAppend);
-
-            if (extentxReporter.config().getReportObjectId() != null) {
-                setExtentXReporter(isAppend);
-            } else {
-                extentxReporter.stop();
-            }
         }
         return extent;
     }
 
-    public synchronized static void setExtentXReporter(Boolean isAppend) {
-        extentxReporter.setAppendExisting(isAppend);
-        extent.attachReporter(extentxReporter);
-    }
-
-    public synchronized static void initAndSetExtentHtmlReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception {
+    private static synchronized void initAndSetExtentHtmlReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception {
         htmlReporter = new ExtentHtmlReporter(filePath + htmlFile);
         setConfiguration(htmlReporter);
         htmlReporter.setAppendExisting(isAppend);
         extent.attachReporter(htmlReporter);
     }
 
-    public synchronized static ExtentReports getReporter() {
+    public static synchronized ExtentReports getReporter() {
         return extent;
     }
 
@@ -98,9 +65,9 @@ public class ExtentManager {
         String suiteName = getSuiteName(context);
 
         if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) {
-                       if (config.isUseBrowserMobProxy()) {
-                               setTrafficCaptue(config);
-                       }
+            if (config.isUseBrowserMobProxy()) {
+                setTrafficCaptue(config);
+            }
 
             setReporter(filepath, htmlFile, true);
             String suiteNameFromVersionInfoFile = FileHandling.getKeyByValueFromPropertyFormatFile(filepath + VERSIONS_INFO_FILE_NAME, "suiteName");
@@ -115,16 +82,15 @@ public class ExtentManager {
 
     }
 
-    public static void reporterDataDefinition(String onboardVersion, String osVersion, String envData, String suiteNameFromVersionInfoFile)
+    private static void reporterDataDefinition(String onboardVersion, String osVersion, String envData, String suiteNameFromVersionInfoFile)
         throws Exception {
         extent.setSystemInfo("Onboard Version", onboardVersion);
         extent.setSystemInfo("OS Version", osVersion);
-//             extent.setSystemInfo("Host Name Address", RestCDUtils.getExecutionHostAddress());
         extent.setSystemInfo("ExecutedOn", envData);
         extent.setSystemInfo("SuiteName", suiteNameFromVersionInfoFile);
     }
 
-    public static String getSuiteName(ITestContext context) {
+    private static String getSuiteName(ITestContext context) {
         String suitePath = context.getSuite().getXmlSuite().getFileName();
         if (suitePath != null) {
             File file = new File(suitePath);
@@ -134,29 +100,38 @@ public class ExtentManager {
         return null;
     }
 
-    public synchronized static ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) throws Exception {
+    private static synchronized ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) throws Exception {
 
         htmlReporter.config().setTheme(Theme.STANDARD);
         htmlReporter.config().setEncoding("UTF-8");
         htmlReporter.config().setProtocol(Protocol.HTTPS);
         htmlReporter.config().setDocumentTitle("SDC Automation Report");
         htmlReporter.config().setChartVisibilityOnOpen(true);
-//     htmlReporter.config().setReportName(AutomationUtils.getATTVersion());
         htmlReporter.config().setReportName("SDC Automation Report");
         htmlReporter.config().setChartVisibilityOnOpen(false);
-//     htmlReporter.config().setJS(icon);
         return htmlReporter;
     }
 
-    public static void closeReporter() {
-        extent.flush();
-    }
-
-    public static void setTrafficCaptue(Config config) {
+    private static void setTrafficCaptue(Config config) {
         boolean mobProxyStatus = config.isUseBrowserMobProxy();
         if (mobProxyStatus) {
             config.setCaptureTraffic(true);
         }
     }
-}
 
+    enum suiteNameXml {
+
+        TESTNG_FAILED_XML_NAME("testng-failed.xml");
+
+        private String value;
+
+        suiteNameXml(String value) {
+            this.value = value;
+        }
+
+        public String getValue() {
+            return value;
+        }
+
+    }
+}
index a3fc563..00dd3fc 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,44 +22,32 @@ package org.onap.sdc.backend.ci.tests.api;
 
 import com.aventstack.extentreports.ExtentReports;
 import com.aventstack.extentreports.ExtentTest;
-
 import java.util.HashMap;
-public class ExtentTestManager implements SomeInterface{
+import java.util.Map;
 
-               private static HashMap<Long, ExtentTest> extentTestMap = new HashMap<Long, ExtentTest>();
-               private static ExtentReports extent = ExtentManager.getReporter();
-               
-               public ExtentTestManager(){                     
-               }
-        
-               @Override
-           public synchronized ExtentTest getTest() {
-               return extentTestMap.get(Thread.currentThread().getId());
-           }
+public class ExtentTestManager implements SomeInterface {
 
-           public static synchronized void endTest() {
-//             extent.endTest(extentTestMap.get(Thread.currentThread().getId()));
-               extent.flush();
-           }
+    private static final Map<Long, ExtentTest> extentTestMap = new HashMap<>();
+    private static final ExtentReports extent = ExtentManager.getReporter();
 
-           public static synchronized ExtentTest startTest(String testName) {
-               return startTest(testName, "");
-           }
+    public static synchronized void endTest() {
+        extent.flush();
+    }
 
-           public static synchronized ExtentTest startTest(String testName, String desc) {
-               ExtentTest test = extent.createTest(testName, desc);
-               extentTestMap.put(Thread.currentThread().getId(), test);
+    public static synchronized void startTest(String testName) {
+        extentTestMap.put(Thread.currentThread().getId(), extent.createTest(testName));
+    }
 
-               return test;
-           }
-           
-           public static synchronized <T> void assignCategory(Class<T> clazz){
-                       String[] parts = clazz.getName().split("\\.");
-                       String lastOne1 = parts[parts.length-1];
-                       String lastOne2 = parts[parts.length-2];
-                       extentTestMap.get(Thread.currentThread().getId()).assignCategory(lastOne2 + "-" + lastOne1);
-           }
-           
-               
-}
+    public static synchronized <T> void assignCategory(Class<T> clazz) {
+        String[] parts = clazz.getName().split("\\.");
+        String lastOne1 = parts[parts.length - 1];
+        String lastOne2 = parts[parts.length - 2];
+        extentTestMap.get(Thread.currentThread().getId()).assignCategory(lastOne2 + "-" + lastOne1);
+    }
 
+    @Override
+    public synchronized ExtentTest getTest() {
+        return extentTestMap.get(Thread.currentThread().getId());
+    }
+
+}
index 1d515da..cc524b6 100644 (file)
@@ -23,7 +23,6 @@ package org.onap.sdc.frontend.ci.tests.execute.setup;
 
 import com.aventstack.extentreports.ExtentReports;
 import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
-import com.aventstack.extentreports.reporter.ExtentXReporter;
 import com.aventstack.extentreports.reporter.configuration.Protocol;
 import com.aventstack.extentreports.reporter.configuration.Theme;
 import java.io.File;
@@ -44,46 +43,15 @@ public class ExtentManager {
     private static final String VERSIONS_INFO_FILE_NAME = "versions.info";
     private static ExtentReports extent;
     private static ExtentHtmlReporter htmlReporter;
-    private static ExtentXReporter extentxReporter;
-
-    public enum suiteNameXml {
-
-        TESTNG_FAILED_XML_NAME("testng-failed.xml");
-
-        suiteNameXml(String value) {
-            this.value = value;
-        }
-
-        private String value;
-
-        public String getValue() {
-            return value;
-        }
-
-    }
 
     private static synchronized ExtentReports setReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception {
-        String dbIp = DriverFactory.getConfig().getReportDBhost();
-        int dbPort = DriverFactory.getConfig().getReportDBport();
-
         if (extent == null) {
-            extentxReporter = new ExtentXReporter(dbIp, dbPort);
             extent = new ExtentReports();
             initAndSetExtentHtmlReporter(filePath, htmlFile, isAppend);
-            if (extentxReporter.config().getReportObjectId() != null) {
-                setExtentXReporter(isAppend);
-            } else {
-                extentxReporter.stop();
-            }
         }
         return extent;
     }
 
-    private static synchronized void setExtentXReporter(Boolean isAppend) {
-        extentxReporter.setAppendExisting(isAppend);
-        extent.attachReporter(extentxReporter);
-    }
-
     private static synchronized void initAndSetExtentHtmlReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception {
         htmlReporter = new ExtentHtmlReporter(filePath + htmlFile);
         setConfiguration(htmlReporter);
@@ -157,14 +125,26 @@ public class ExtentManager {
         return htmlReporter;
     }
 
-    public static void closeReporter() {
-        extent.flush();
-    }
-
     private static void setTrafficCaptue(Config config) {
         boolean mobProxyStatus = config.isUseBrowserMobProxy();
         if (mobProxyStatus) {
             config.setCaptureTraffic(true);
         }
     }
+
+    public enum suiteNameXml {
+
+        TESTNG_FAILED_XML_NAME("testng-failed.xml");
+
+        private String value;
+
+        suiteNameXml(String value) {
+            this.value = value;
+        }
+
+        public String getValue() {
+            return value;
+        }
+
+    }
 }
index 2d194ba..1d891e5 100644 (file)
@@ -22,18 +22,17 @@ package org.onap.sdc.frontend.ci.tests.execute.setup;
 
 import com.aventstack.extentreports.ExtentReports;
 import com.aventstack.extentreports.ExtentTest;
-import org.onap.sdc.backend.ci.tests.api.SomeInterface;
-
 import java.util.HashMap;
+import java.util.Map;
+import org.onap.sdc.backend.ci.tests.api.SomeInterface;
 
 public class ExtentTestManager implements SomeInterface {
 
-    private final HashMap<Long, ExtentTest> extentTestByThreadIdMap = new HashMap<>();
-    private final ExtentReports extent = ExtentManager.getReporter();
     private static final ExtentTestManager INSTANCE = new ExtentTestManager();
+    private final Map<Long, ExtentTest> extentTestByThreadIdMap = new HashMap<>();
+    private final ExtentReports extent = ExtentManager.getReporter();
 
     private ExtentTestManager() {
-
     }
 
     public static ExtentTestManager getInstance() {
@@ -49,15 +48,8 @@ public class ExtentTestManager implements SomeInterface {
         extent.flush();
     }
 
-    public synchronized ExtentTest startTest(final String testName) {
-        return startTest(testName, "");
-    }
-
-    public synchronized ExtentTest startTest(final String testName, final String desc) {
-        final ExtentTest test = extent.createTest(testName, desc);
-        extentTestByThreadIdMap.put(Thread.currentThread().getId(), test);
-
-        return test;
+    public synchronized void startTest(final String testName) {
+        extentTestByThreadIdMap.put(Thread.currentThread().getId(), extent.createTest(testName));
     }
 
     public synchronized <T> void assignCategory(Class<T> clazz) {
@@ -67,4 +59,3 @@ public class ExtentTestManager implements SomeInterface {
         extentTestByThreadIdMap.get(Thread.currentThread().getId()).assignCategory(lastOne2 + "-" + lastOne1);
     }
 }
-