geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject geode git commit: GEODE-2272: Fix Pulse data browser export
Date Mon, 16 Jan 2017 22:48:13 GMT
Repository: geode
Updated Branches:
  refs/heads/develop f1cebc2f0 -> f84cb808b


GEODE-2272: Fix Pulse data browser export

* Pulse no longer loads all results into the browser before generating a results file for
download.

This closes #339


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/f84cb808
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/f84cb808
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/f84cb808

Branch: refs/heads/develop
Commit: f84cb808bb304f44ca24cb6b265b746445f29119
Parents: f1cebc2
Author: Jared Stewart <jstewart@pivotal.io>
Authored: Mon Jan 16 13:58:28 2017 -0800
Committer: Kirk Lund <klund@apache.org>
Committed: Mon Jan 16 14:41:55 2017 -0800

----------------------------------------------------------------------
 .../dunit/rules/LocatorServerStartupRule.java   |  26 +++
 .../internal/controllers/PulseController.java   |  61 ++++---
 .../tools/pulse/internal/data/Cluster.java      |  59 ++++---
 .../tools/pulse/internal/data/Repository.java   |   4 +-
 .../pulsescript/pages/DataBrowserQuery.js       |  26 ++-
 .../tools/pulse/tests/PulseDataExportTest.java  | 173 +++++++++++++++++++
 .../tools/pulse/tests/rules/WebDriverRule.java  |  25 +--
 .../geode/tools/pulse/tests/ui/PulseBase.java   |  38 +---
 8 files changed, 308 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/f84cb808/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
index 300d75a..211a8c6 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
@@ -30,6 +30,7 @@ import org.junit.rules.TemporaryFolder;
 import java.io.File;
 import java.io.IOException;
 import java.io.Serializable;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
@@ -97,6 +98,31 @@ public class LocatorServerStartupRule extends ExternalResource implements
Serial
     return locator;
   }
 
+  public Locator startLocatorVMWithPulse(int index, Properties locatorProperties)
+      throws IOException {
+    String name = "locator-" + index;
+    locatorProperties.setProperty(NAME, name);
+    File workingDir = createWorkingDirForMember(name);
+
+    // Setting gemfire.home to this value allows locators started by the rule to run Pulse
+    String geodeInstallDir = new File(".").getAbsoluteFile().getParentFile().getParentFile()
+        .toPath().resolve("geode-assembly").resolve("build").resolve("install")
+        .resolve("apache-geode").toString();
+
+    VM locatorVM = getHost(0).getVM(index);
+    int locatorPort = locatorVM.invoke(() -> {
+      System.setProperty("user.dir", workingDir.getCanonicalPath());
+      System.setProperty("gemfire.home", geodeInstallDir);
+      locatorStarter = new LocatorStarterRule(locatorProperties);
+      locatorStarter.startLocator();
+      return locatorStarter.locator.getPort();
+    });
+    Locator locator = new Locator(locatorVM, locatorPort, workingDir);
+    members.add(index, locator);
+    return locator;
+  }
+
+
   public Locator startLocatorVM(int index) throws IOException {
     return startLocatorVM(index, new Properties());
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/f84cb808/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java
index 1fd2361..9b24393 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java
@@ -28,6 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.sun.net.httpserver.Headers;
 import org.apache.geode.tools.pulse.internal.data.Cluster;
 import org.apache.geode.tools.pulse.internal.data.PulseConstants;
 import org.apache.geode.tools.pulse.internal.data.PulseVersion;
@@ -91,6 +92,7 @@ public class PulseController {
 
     JsonNode requestMap = null;
 
+
     try {
       requestMap = mapper.readTree(pulseData);
       Iterator<?> keys = requestMap.fieldNames();
@@ -416,46 +418,55 @@ public class PulseController {
       }
     }
     response.getOutputStream().write(responseJSON.toString().getBytes());
+
+
   }
 
-  @RequestMapping(value = "/dataBrowserExport", method = RequestMethod.POST)
+
+  @RequestMapping(value = "/dataBrowserExport", method = RequestMethod.GET)
   public void dataBrowserExport(HttpServletRequest request, HttpServletResponse response)
       throws IOException {
-
     // get query string
-    String filename = request.getParameter("filename");
-    String resultContent = request.getParameter("content");
-
-    response.setHeader("Cache-Control", "");
-    response.setHeader("Content-type", "text/plain");
-    if (StringUtils.isNotNullNotEmptyNotWhiteSpace(filename)) {
-      response.setHeader("Content-Disposition", "attachment; filename=" + filename);
-    } else {
-      response.setHeader("Content-Disposition", "attachment; filename=" + DEFAULT_EXPORT_FILENAME);
-    }
+    String query = request.getParameter("query");
+    String members = request.getParameter("members");
+    int limit = 0;
 
-    if (!StringUtils.isNotNullNotEmptyNotWhiteSpace(resultContent)) {
-      resultContent = "";
+    try {
+      limit = Integer.valueOf(request.getParameter("limit"));
+    } catch (NumberFormatException e) {
+      limit = 0;
+      if (LOGGER.finerEnabled()) {
+        LOGGER.finer(e.getMessage());
+      }
     }
 
-    response.getOutputStream().write(resultContent.getBytes());
-  }
+    ObjectNode queryResult = mapper.createObjectNode();
+    try {
 
-  @RequestMapping(value = "/pulseProductSupport", method = RequestMethod.GET)
-  public void getConfiguredPulseProduct(HttpServletRequest request, HttpServletResponse response)
-      throws IOException {
-    ObjectNode responseJSON = mapper.createObjectNode();
+      if (StringUtils.isNotNullNotEmptyNotWhiteSpace(query)) {
+        // get cluster object
+        Cluster cluster = Repository.get().getCluster();
+        String userName = request.getUserPrincipal().getName();
 
-    try {
-      responseJSON.put("product", pulseProductSupport);
+        // Call execute query method
+        queryResult = cluster.executeQuery(query, members, limit);
 
-      // Send json response
-      response.getOutputStream().write(responseJSON.toString().getBytes());
+        // Add query in history if query is executed successfully
+        if (!queryResult.has("error")) {
+          // Add html escaped query to history
+          String escapedQuery = StringEscapeUtils.escapeHtml(query);
+          cluster.addQueryInHistory(escapedQuery, userName);
+        }
+      }
     } catch (Exception e) {
       if (LOGGER.fineEnabled()) {
-        LOGGER.fine("Exception Occurred : " + e.getMessage());
+        LOGGER.fine("Exception Occured : " + e.getMessage());
       }
     }
+
+    response.setContentType("application/json");
+    response.setHeader("Content-Disposition", "attachment; filename=results.json");
+    response.getOutputStream().write(queryResult.toString().getBytes());
   }
 
   @RequestMapping(value = "/getQueryStatisticsGridModel", method = RequestMethod.GET)

http://git-wip-us.apache.org/repos/asf/geode/blob/f84cb808/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
index afb913c..d68e416 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
@@ -51,6 +51,8 @@ import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.TimeZone;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
@@ -73,6 +75,8 @@ public class Cluster extends Thread {
   private String port;
   private int stale = 0;
   private double loadPerSec;
+  private CountDownLatch clusterHasBeenInitialized;
+
 
   // start: fields defined in System MBean
   private IClusterUpdater updater = null;
@@ -2258,11 +2262,6 @@ public class Cluster extends Thread {
     }
   }
 
-  /**
-   * Default constructor only used for testing
-   */
-  public Cluster() {}
-
 
   /**
    * This function is used for calling getUpdator function of ClusterDataFactory and starting
the
@@ -2282,39 +2281,49 @@ public class Cluster extends Thread {
     this.jmxUserPassword = userPassword;
 
     this.updater = ClusterDataFactory.getUpdater(this, host, port);
+    this.clusterHasBeenInitialized = new CountDownLatch(1);
     // start();
   }
 
+  public void waitForInitialization(long timeout, TimeUnit unit) throws InterruptedException
{
+    clusterHasBeenInitialized.await(timeout, unit);
+  }
+
   /**
    * thread run method for updating the cluster data
    */
   @Override
   public void run() {
-    while (!this.stopUpdates) {
-      try {
-        if (!this.updateData()) {
-          this.stale++;
-        } else {
-          this.stale = 0;
-        }
-      } catch (Exception e) {
-        if (LOGGER.infoEnabled()) {
-          LOGGER.info("Exception Occurred while updating cluster data : " + e.getMessage());
+    try {
+      while (!this.stopUpdates) {
+        try {
+          if (!this.updateData()) {
+            this.stale++;
+          } else {
+            this.stale = 0;
+          }
+        } catch (Exception e) {
+          if (LOGGER.infoEnabled()) {
+            LOGGER.info("Exception Occurred while updating cluster data : " + e.getMessage());
+          }
         }
-      }
 
-      try {
-        Thread.sleep(POLL_INTERVAL);
-      } catch (InterruptedException e) {
-        if (LOGGER.infoEnabled()) {
-          LOGGER.info("InterruptedException Occurred : " + e.getMessage());
+        clusterHasBeenInitialized.countDown();
+        try {
+          Thread.sleep(POLL_INTERVAL);
+        } catch (InterruptedException e) {
+          if (LOGGER.infoEnabled()) {
+            LOGGER.info("InterruptedException Occurred : " + e.getMessage());
+          }
         }
       }
-    }
 
-    if (LOGGER.infoEnabled()) {
-      LOGGER.info(resourceBundle.getString("LOG_MSG_STOP_THREAD_UPDATES") + " :: " + this.serverName
-          + ":" + this.port);
+      if (LOGGER.infoEnabled()) {
+        LOGGER.info(resourceBundle.getString("LOG_MSG_STOP_THREAD_UPDATES") + " :: "
+            + this.serverName + ":" + this.port);
+      }
+    } finally {
+      clusterHasBeenInitialized.countDown();
     }
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f84cb808/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
index e6208f9..61e967b 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
@@ -27,6 +27,7 @@ import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
 import java.util.ResourceBundle;
+import java.util.concurrent.TimeUnit;
 
 /**
  * A Singleton instance of the memory cache for clusters.
@@ -191,8 +192,9 @@ public class Repository {
               PulseConstants.APP_NAME + "-" + this.jmxHost + ":" + this.jmxPort + ":" + username);
           // Start Thread
           data.start();
+          data.waitForInitialization(15, TimeUnit.SECONDS);
           this.clusterMap.put(key, data);
-        } catch (ConnectException e) {
+        } catch (ConnectException | InterruptedException e) {
           data = null;
           if (LOGGER.fineEnabled()) {
             LOGGER.fine(e.getMessage());

http://git-wip-us.apache.org/repos/asf/geode/blob/f84cb808/geode-pulse/src/main/webapp/scripts/pulsescript/pages/DataBrowserQuery.js
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/webapp/scripts/pulsescript/pages/DataBrowserQuery.js b/geode-pulse/src/main/webapp/scripts/pulsescript/pages/DataBrowserQuery.js
index 39aae57..534f5c8 100644
--- a/geode-pulse/src/main/webapp/scripts/pulsescript/pages/DataBrowserQuery.js
+++ b/geode-pulse/src/main/webapp/scripts/pulsescript/pages/DataBrowserQuery.js
@@ -954,11 +954,25 @@ function generateEntryUID(prefixForId, type, len) {
 // Function that posts the query result response received to backend in order
 // export it into file
 function exportResult() {
-  if(responseResult != undefined && responseResult !== null){
-    $.generateFile({
-      filename : 'export.json',
-      content : JSON.stringify(responseResult),
-      script : 'dataBrowserExport'
-    });
+ var queryText = $('#dataBrowserQueryText').val();
+  var selectedMemberNames = "";
+
+  if(isEmpty(queryText)){
+    alert("Please enter query to execute..");
+    return;
   }
+
+  // Determine selected members query to be execute on
+  if($("#membersList").html() != ""){
+    var selectedMembers = $( "input[type=checkbox][name=Member]:checked" );
+    for(var i=0; i< selectedMembers.length; i++){
+      if(selectedMemberNames == ""){
+        selectedMemberNames = selectedMembers[i].value;
+      }else{
+        selectedMemberNames += ","+selectedMembers[i].value;
+      }
+    }
+  }
+
+     window.open("dataBrowserExport?query=" + encodeURIComponent(queryText) + "&members="
+ encodeURIComponent(selectedMemberNames), "_blank");
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f84cb808/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseDataExportTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseDataExportTest.java
b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseDataExportTest.java
new file mode 100644
index 0000000..e55d4d6
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseDataExportTest.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information
regarding
+ * copyright ownership. The ASF licenses this file to You 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. See the License for the specific language governing permissions and limitations
under
+ * the License.
+ *
+ */
+
+package org.apache.geode.tools.pulse.tests;
+
+import static com.jayway.awaitility.Awaitility.await;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.geode.cache.client.ClientRegionShortcut;
+import org.apache.geode.test.dunit.IgnoredException;
+import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.Locator;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.http.Consts;
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.CookieStore;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.cookie.Cookie;
+import org.apache.http.impl.client.BasicCookieStore;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.EntityUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+@Category(DistributedTest.class)
+public class PulseDataExportTest extends JUnit4DistributedTestCase {
+
+  @Rule
+  public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+
+  private Locator locator;
+  private org.apache.geode.test.dunit.rules.Server server;
+  private GfshShellConnectionRule gfshConnector;
+  private HttpClient httpClient;
+  private CookieStore cookieStore;
+
+
+  @Before
+  public void before() throws Throwable {
+    IgnoredException
+        .addIgnoredException("Failed to properly release resources held by the HTTP service:");
+    IgnoredException.addIgnoredException("!STOPPED");
+
+    locator = lsRule.startLocatorVMWithPulse(0, new Properties());
+
+    gfshConnector = new GfshShellConnectionRule(locator);
+    gfshConnector.connect();
+    assertThat(gfshConnector.isConnected()).isTrue();
+
+    server = lsRule.startServerVM(1, locator.getPort());
+
+    gfshConnector.executeAndVerifyCommand("create region --name=regionA --type=REPLICATE");
+    org.apache.geode.cache.Region<String, String> region = new ClientCacheFactory()
+        .addPoolLocator("localhost", locator.getPort()).create()
+        .<String, String>createClientRegionFactory(ClientRegionShortcut.PROXY).create("regionA");
+
+    region.put("key1", "value1");
+    region.put("key2", "value2");
+    region.put("key3", "value3");
+    cookieStore = new BasicCookieStore();
+    httpClient = HttpClientBuilder.create().setDefaultCookieStore(cookieStore).build();
+
+    await().atMost(2, TimeUnit.MINUTES).until(this::pulseServerHasStarted);
+  }
+
+
+  @Test
+  public void dataBrowserExportWorksAsExpected() throws Throwable {
+    getAuthenticatedJSESSIONID();
+    HttpContext authenticatedHttpContext = buildAuthenticatedHttpContext();
+
+    HttpGet dataExportGET = buildDataExportGET();
+
+    HttpResponse response = httpClient.execute(dataExportGET, authenticatedHttpContext);
+    assertThat(response.getStatusLine().getStatusCode()).describedAs(response.toString())
+        .isEqualTo(200);
+
+    String responseBody = EntityUtils.toString(response.getEntity(), "UTF-8");
+    assertThat(responseBody).describedAs(response.toString()).isEqualTo(
+        "{\"result\":[[\"java.lang.String\",\"value1\"],[\"java.lang.String\",\"value2\"],[\"java.lang.String\",\"value3\"]]}");
+  }
+
+  private HttpPost buildLoginPOST() {
+    HttpPost httpPost = new HttpPost("http://localhost:7070/pulse/login");
+
+    List<NameValuePair> formData = new ArrayList<>();
+    formData.add(new BasicNameValuePair("username", "admin"));
+    formData.add(new BasicNameValuePair("password", "admin"));
+
+    httpPost.setEntity(new UrlEncodedFormEntity(formData, Consts.UTF_8));
+
+    return httpPost;
+  }
+
+  private HttpGet buildDataExportGET() throws URISyntaxException {
+    URIBuilder builder = new URIBuilder();
+    builder.setScheme("http").setHost("localhost").setPort(7070).setPath("/pulse/dataBrowserExport")
+        .setParameter("query", "select * from /regionA a order by a");
+    return new HttpGet(builder.build());
+  }
+
+  private HttpContext buildAuthenticatedHttpContext() throws Throwable {
+    HttpContext localContext = new BasicHttpContext();
+    localContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);
+
+    return localContext;
+  }
+
+  public void getAuthenticatedJSESSIONID() throws Throwable {
+    HttpResponse loginResponse = httpClient.execute(buildLoginPOST());
+    assertThat(loginResponse.getStatusLine().getStatusCode()).describedAs(loginResponse.toString())
+        .isEqualTo(302);
+
+    String JSESSIONIDFromSetCookieHeader = Arrays.stream(loginResponse.getHeaders("SET-COOKIE"))
+        .map(Header::getValue).filter(setCookie -> setCookie.contains("JSESSIONID")).findAny()
+        .orElseThrow(() -> new AssertionError(
+            "No JSESSIONID cookie was set in the login response: " + loginResponse.toString()));
+
+    Cookie JESSIONIDFromCookieStore = cookieStore.getCookies().stream()
+        .filter(cookie -> cookie.getName().equalsIgnoreCase("JSESSIONID")).findFirst()
+        .orElseThrow(() -> new AssertionError("No JSESSIONID cookie was set in the cookie
store"));
+
+    assertThat(JSESSIONIDFromSetCookieHeader).contains(JESSIONIDFromCookieStore.getValue());
+  }
+
+  private boolean pulseServerHasStarted() {
+    try {
+      httpClient.execute(buildLoginPOST());
+    } catch (IOException e) {
+      e.printStackTrace();
+      return false;
+    }
+
+    return true;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/f84cb808/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/WebDriverRule.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/WebDriverRule.java
b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/WebDriverRule.java
index 4215615..ca4646b 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/WebDriverRule.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/rules/WebDriverRule.java
@@ -57,7 +57,7 @@ public class WebDriverRule extends ExternalResource {
   }
 
   @Override
-  protected void before() throws Throwable {
+  public void before() throws Throwable {
     setUpWebDriver();
     driver.get(getPulseURL() + "Login.html");
     if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
@@ -67,12 +67,12 @@ public class WebDriverRule extends ExternalResource {
   }
 
   @Override
-  protected void after() {
+  public void after() {
     driver.quit();
   }
 
   private void login() {
-    WebElement userNameElement = waitForElementById("user_name");
+    WebElement userNameElement = waitForElementById("user_name", 60);
     WebElement passwordElement = waitForElementById("user_password");
     userNameElement.sendKeys(username);
     passwordElement.sendKeys(password);
@@ -80,7 +80,7 @@ public class WebDriverRule extends ExternalResource {
 
     driver.get(getPulseURL() + "clusterDetail.html");
     WebElement userNameOnPulsePage =
-        (new WebDriverWait(driver, 10)).until(new ExpectedCondition<WebElement>() {
+        (new WebDriverWait(driver, 30)).until(new ExpectedCondition<WebElement>() {
           @Override
           public WebElement apply(WebDriver d) {
             return d.findElement(By.id("userName"));
@@ -103,12 +103,17 @@ public class WebDriverRule extends ExternalResource {
   }
 
   public WebElement waitForElementById(final String id) {
-    WebElement element = (new WebDriverWait(driver, 10)).until(new ExpectedCondition<WebElement>()
{
-      @Override
-      public WebElement apply(WebDriver d) {
-        return d.findElement(By.id(id));
-      }
-    });
+    return waitForElementById(id, 10);
+  }
+
+  public WebElement waitForElementById(final String id, int timeoutInSeconds) {
+    WebElement element =
+        (new WebDriverWait(driver, timeoutInSeconds)).until(new ExpectedCondition<WebElement>()
{
+          @Override
+          public WebElement apply(WebDriver d) {
+            return d.findElement(By.id(id));
+          }
+        });
     assertNotNull(element);
     return element;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/f84cb808/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseBase.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseBase.java
b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseBase.java
index 9754839..90c56ce 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseBase.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ui/PulseBase.java
@@ -838,47 +838,11 @@ public abstract class PulseBase {
     }
   }
 
-  @Ignore("WIP")
-  @Test
-  public void testDataBrowser() {
-
-    getWebDriver().findElement(By.linkText("Data Browser")).click();
-    // WebElement dataBrowserLabel = getWebDriver().findElement(By.xpath(""));
-    WebDriverWait wait = new WebDriverWait(getWebDriver(), 20);
-    wait.until(ExpectedConditions
-        .visibilityOf(getWebDriver().findElement(By.xpath("//label[text()='Data Browser']"))));
-
-    // Verify all elements must be displayed on data browser screen
-    assertTrue(getWebDriver().findElement(By.xpath("//a[text()='Data Regions']")).isDisplayed());
-    assertTrue(getWebDriver().findElement(By.id("linkColocatedRegions")).isDisplayed());
-    assertTrue(getWebDriver().findElement(By.linkText("All Regions")).isDisplayed());
-
-    assertTrue(getWebDriver().findElement(By.xpath("//a[text()='Region Members']")).isDisplayed());
-
-    assertTrue(getWebDriver().findElement(By.xpath("//a[text()='Queries']")).isDisplayed());
-    assertTrue(
-        getWebDriver().findElement(By.xpath("//label[text()='Query Editor']")).isDisplayed());
-    assertTrue(getWebDriver().findElement(By.xpath("//label[text()='Result']")).isDisplayed());
-    assertTrue(
-        getWebDriver().findElement(By.xpath("//input[@value='Export Result']")).isDisplayed());
-    assertTrue(getWebDriver().findElement(By.id("btnExecuteQuery")).isDisplayed());
-    assertTrue(getWebDriver().findElement(By.xpath("//input[@value='Clear']")).isDisplayed());
-    assertTrue(getWebDriver().findElement(By.id("dataBrowserQueryText")).isDisplayed());
-
-    assertTrue(getWebDriver().findElement(By.id("historyIcon")).isDisplayed());
-
-    // Actual query execution
-
-    getWebDriver().findElement(By.id("dataBrowserQueryText")).sendKeys("Query1");
-
-    // Assert data regions are displayed
-    assertTrue(getWebDriver().findElement(By.id("treeDemo_1")).isDisplayed());
-  }
-
   @Test
   public void userCanGetToPulseDetails() {
     getWebDriver().get(getPulseURL() + "pulseVersion");
 
     assertTrue(getWebDriver().getPageSource().contains("sourceRevision"));
   }
+
 }


Mime
View raw message