Related to issue 38888: Failing SS Build
authorMartin Taal <martin.taal@openbravo.com>
Thu, 15 Nov 2018 21:20:31 +0100
changeset 7872 87e2237bd1d4
parent 7871 46967a762c9e
child 7873 0f682f0cdf5e
Related to issue 38888: Failing SS Build
Try to get less wait time in transitioning, solve unclear number of plus-clicks
src-test/org/openbravo/test/mobile/retail/multiserver/MultiserverOfflineUtils.java
src-test/org/openbravo/test/mobile/retail/multiserver/selenium/terminals/WebPOSCentralOfflineTerminalHelper.java
src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMS006_LAWa010_CreateLayaway.java
src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/store1/MS011_LAWa010_CreateLayaway.java
--- a/src-test/org/openbravo/test/mobile/retail/multiserver/MultiserverOfflineUtils.java	Tue Nov 13 15:39:15 2018 -0500
+++ b/src-test/org/openbravo/test/mobile/retail/multiserver/MultiserverOfflineUtils.java	Thu Nov 15 21:20:31 2018 +0100
@@ -25,9 +25,10 @@
 
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.ArrayList;
 
 import org.openbravo.test.mobile.core.utils.OBOfflineUtils;
-import org.openbravo.test.mobile.core.utils.OBUtils;
+import org.openbravo.test.mobile.core.utils.OBWait;
 import org.openbravo.test.mobile.core.utils.TestLogger;
 import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect;
 import org.openbravo.test.mobile.retail.pack.database.ServerType;
@@ -60,7 +61,6 @@
     waitForTransitioningOnline();
     checkStatus("ON");
     TestLogger.getLogger().info("ONLINE MODE ENABLED");
-
   }
 
 
@@ -77,16 +77,44 @@
   }
 
   public static void waitForTransitioningOffline() {
-    OBUtils.pause(180000);
+    waitForStatus("OFF");
   }
 
   public static void waitForTransitioningOnline() {
-    OBUtils.pause(120000);
+    waitForStatus("ON");
+  }
+
+  public static void waitForStatus(final String status) {
+    TestLogger.getLogger().info(String.format("Waiting for transition to status %s", status));
+    new OBWait(5000, 180 / 5) {
+      @Override
+      protected boolean until(final int currentIteration) {
+        final ArrayList<String> statusVar = new ArrayList<String>();
+        statusVar.add("");
+
+        final String sql = "select status from obmobc_server_definition where MOBILE_SERVER_KEY='Store1'";
+        new DatabaseHelperSelect() {
+          @Override
+          protected void yieldResultSet(final ResultSet rs) throws SQLException {
+            if (rs.next()) {
+
+            }
+            statusVar.set(0, rs.getString(1));
+          }
+        }.execute(sql, 1, ServerType.STORE1);
+        return status.equals(statusVar.get(0));
+      }
+
+      @Override
+      protected void timeout() {
+        // do nothing, will fail later anyway
+      }
+    };
   }
 
   public static void checkStatus(final String serverStatus) {
     // are we really online
-    final String sql = "select status, offline_log from obmobc_server_definition where iscurrent='Y'";
+    final String sql = "select status, offline_log from obmobc_server_definition where MOBILE_SERVER_KEY='Store1'";
     new DatabaseHelperSelect() {
       @Override
       protected void yieldResultSet(final ResultSet rs) throws SQLException {
--- a/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/terminals/WebPOSCentralOfflineTerminalHelper.java	Tue Nov 13 15:39:15 2018 -0500
+++ b/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/terminals/WebPOSCentralOfflineTerminalHelper.java	Thu Nov 15 21:20:31 2018 +0100
@@ -19,7 +19,6 @@
 
 package org.openbravo.test.mobile.retail.multiserver.selenium.terminals;
 
-import org.junit.Before;
 import org.junit.Rule;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
@@ -30,7 +29,6 @@
 import org.openbravo.test.mobile.core.utils.TestLogger;
 import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdConstructor;
 import org.openbravo.test.mobile.retail.multiserver.MultiserverOfflineUtils;
-import org.openbravo.test.mobile.retail.multiserver.MultiserverUtils;
 import org.openbravo.test.mobile.retail.multiserver.selenium.TestIdMultiserver;
 
 public class WebPOSCentralOfflineTerminalHelper extends WebPOSStore1TerminalHelper {
@@ -46,15 +44,6 @@
   }
 
   /**
-   * Also remove all errors from the central server database
-   */
-  @Before
-  public void before() {
-    MultiserverUtils.clearCentralServerErrors();
-    super.before();
-  }
-
-  /**
    * Stop Apache to enable Offline Mode in central server
    */
   public void goCentralOffline() {
--- a/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMS006_LAWa010_CreateLayaway.java	Tue Nov 13 15:39:15 2018 -0500
+++ b/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/offline/OfflineMS006_LAWa010_CreateLayaway.java	Thu Nov 15 21:20:31 2018 +0100
@@ -21,6 +21,7 @@
 
 import org.junit.Test;
 import org.openbravo.test.mobile.core.utils.OBOfflineUtils;
+import org.openbravo.test.mobile.core.utils.OBUtils;
 import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
 import org.openbravo.test.mobile.retail.mobilecore.javascript.BackboneHelper;
 import org.openbravo.test.mobile.retail.multiserver.MultiserverUtils;
@@ -41,9 +42,11 @@
     tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
     tap(TestIdPack.BUTTON_SEARCHPRODUCT_ALPINESKIING);
     for (int i = 0; i < 5; i++) {
+      // wait somewhat to give the UI change to add the product
+      OBUtils.pause(2000);
       tap(TestIdPack.BUTTON_KEYPAD_PLUS);
     }
-    verify(TestIdPack.LABEL_TOTALTOPAY, "549.50");
+    verify(TestIdPack.LABEL_TOTALTOPAY, "659.40");
     tap(TestIdPack.BUTTON_MENU);
     tap(TestIdPack.BUTTON_MENU_LAYAWAYTHISRECEIPT);
     final String receiptNo = BackboneHelper.getDocumentNo();
--- a/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/store1/MS011_LAWa010_CreateLayaway.java	Tue Nov 13 15:39:15 2018 -0500
+++ b/src-test/org/openbravo/test/mobile/retail/multiserver/selenium/tests/store1/MS011_LAWa010_CreateLayaway.java	Thu Nov 15 21:20:31 2018 +0100
@@ -21,6 +21,7 @@
 package org.openbravo.test.mobile.retail.multiserver.selenium.tests.store1;
 
 import org.junit.Test;
+import org.openbravo.test.mobile.core.utils.OBUtils;
 import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
 import org.openbravo.test.mobile.retail.multiserver.selenium.terminals.WebPOSStore1TerminalHelper;
 import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
@@ -34,6 +35,8 @@
     tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
     tap(TestIdPack.BUTTON_SEARCHPRODUCT_ALPINESKIING);
     for (int i = 0; i < 5; i++) {
+      // wait somewhat to give the UI change to add the product
+      OBUtils.pause(2000);
       tap(TestIdPack.BUTTON_KEYPAD_PLUS);
     }
     verify(TestIdPack.LABEL_TOTALTOPAY, "659.40");