geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [2/2] incubator-geode git commit: GEODE-448: Replace Tomcat with Jetty as test container
Date Tue, 23 Feb 2016 22:45:48 GMT
GEODE-448: Replace Tomcat with Jetty as test container


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

Branch: refs/heads/develop
Commit: 177f12c71e2383200ddc8ff4f6659202860b2607
Parents: 9028aa8
Author: Jens Deppe <jdeppe@pivotal.io>
Authored: Mon Feb 22 07:53:48 2016 -0800
Committer: Jens Deppe <jdeppe@pivotal.io>
Committed: Tue Feb 23 14:45:31 2016 -0800

----------------------------------------------------------------------
 geode-pulse/build.gradle                        |  4 +-
 .../tools/pulse/testbed/driver/PulseUITest.java | 93 +++++++++----------
 .../pulse/testbed/driver/TomcatHelper.java      | 77 ---------------
 .../gemfire/tools/pulse/tests/PulseTest.java    | 98 ++++++++------------
 .../gemfire/tools/pulse/tests/TomcatHelper.java | 97 -------------------
 5 files changed, 86 insertions(+), 283 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/177f12c7/geode-pulse/build.gradle
----------------------------------------------------------------------
diff --git a/geode-pulse/build.gradle b/geode-pulse/build.gradle
index 4879345..0cd1ef4 100755
--- a/geode-pulse/build.gradle
+++ b/geode-pulse/build.gradle
@@ -46,10 +46,8 @@ dependencies {
   provided 'com.google.guava:guava:' + project.'guava.version'
 
   testCompile project(':geode-junit')
+  testCompile project(':geode-core')
 
-  testCompile 'org.apache.tomcat.embed:tomcat-embed-core:' + project.'tomcat7.version'
-  testCompile 'org.apache.tomcat.embed:tomcat-embed-jasper:' + project.'tomcat7.version'
-  testCompile 'org.apache.tomcat.embed:tomcat-embed-logging-juli:' + project.'tomcat7.version'
   testCompile 'org.seleniumhq.selenium:selenium-firefox-driver:' + project.'selenium.version'
   testCompile 'org.seleniumhq.selenium:selenium-api:' + project.'selenium.version'
   testCompile 'org.seleniumhq.selenium:selenium-remote-driver:' + project.'selenium.version'

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/177f12c7/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/PulseUITest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/PulseUITest.java
b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/PulseUITest.java
index 53fc3bd..452a536 100644
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/PulseUITest.java
+++ b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/PulseUITest.java
@@ -16,16 +16,19 @@
  */
 package com.vmware.gemfire.tools.pulse.testbed.driver;
 
-import java.net.InetAddress;
-import java.util.List;
-
+import com.gemstone.gemfire.management.internal.JettyHelper;
 import com.gemstone.gemfire.test.junit.categories.UITest;
-import com.vmware.gemfire.tools.pulse.tests.PulseTest;
+import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Locator;
+import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Peer;
+import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Region;
+import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Server;
+import com.vmware.gemfire.tools.pulse.testbed.TestBed;
 import junit.framework.Assert;
-
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.startup.Tomcat;
-import org.junit.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.openqa.selenium.By;
 import org.openqa.selenium.WebDriver;
@@ -34,11 +37,10 @@ import org.openqa.selenium.firefox.FirefoxDriver;
 import org.openqa.selenium.support.ui.ExpectedCondition;
 import org.openqa.selenium.support.ui.WebDriverWait;
 
-import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Locator;
-import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Peer;
-import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Region;
-import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Server;
-import com.vmware.gemfire.tools.pulse.testbed.TestBed;
+import java.net.InetAddress;
+import java.util.List;
+
+import static com.vmware.gemfire.tools.pulse.tests.PulseTest.getPulseWarPath;
 
 /**
  * @author Sushant Rawal
@@ -53,6 +55,7 @@ public class PulseUITest {
   private static TestBed testBed;
   private static String pulseURL;
   private static String path;
+  private static org.eclipse.jetty.server.Server jetty = null;
 
   private static final String userName = "admin";
   private static final String pasword = "admin";
@@ -62,25 +65,37 @@ public class PulseUITest {
   private static final String CLUSTER_VIEW_SERVERS_ID = "clusterServersText";
   private static final String CLUSTER_VIEW_LOCATORS_ID = "clusterLocatorsText";
   private static final String CLUSTER_VIEW_REGIONS_ID = "clusterTotalRegionsText";
-  
-  private static Tomcat tomcat = null;
-  
+
   @BeforeClass
-  public static void setUpTomcat() throws Exception{
-      String host = InetAddress.getLocalHost().getHostAddress();
-      int port = 8080;      
-      String context = "/pulse";
-      path = PulseTest.getPulseWarPath();
-      //System.setProperty("pulse.propMockDataUpdaterClass", "com.vmware.gemfire.tools.pulse.testbed.PropMockDataUpdater");
     
-      tomcat = TomcatHelper.startTomcat(host, port, context, path);
-      pulseURL = "http://" + host  + ":" + port + context;
-      Thread.sleep(1000); //wait till tomcat settles down
-      driver = new FirefoxDriver();
-      driver.manage().window().maximize();//required to make all elements visible
+  public static void setUpJetty() throws Exception {
+    String host = InetAddress.getLocalHost().getHostAddress();
+    int port = 8080;
+    String context = "/pulse";
+    path = getPulseWarPath();
+    //System.setProperty("pulse.propMockDataUpdaterClass", "com.vmware.gemfire.tools.pulse.testbed.PropMockDataUpdater");
 
-      Thread.sleep(5000); //wait till pulse starts polling threads...
-      testBed = new TestBed();
-      loginToPulse(driver, userName, pasword);
+    jetty = JettyHelper.initJetty(host, port, false, false, null, null, null);
+    JettyHelper.addWebApplication(jetty, context, getPulseWarPath());
+    jetty.start();
+
+    pulseURL = "http://" + host + ":" + port + context;
+    Thread.sleep(1000); //wait till tomcat settles down
+    driver = new FirefoxDriver();
+    driver.manage().window().maximize();//required to make all elements visible
+
+    Thread.sleep(5000); //wait till pulse starts polling threads...
+    testBed = new TestBed();
+    loginToPulse(driver, userName, pasword);
+  }
+
+  @AfterClass
+  public static void stopJetty() throws Exception {
+    jetty.stop();
+  }
+
+  @After
+  public void closeSession() {
+    driver.close();
   }
 
   private static void loginToPulse(WebDriver driver, String userName,String password){
@@ -263,22 +278,4 @@ public class PulseUITest {
         });
     Assert.assertNotNull(memberNameOnPulsePage);    
   }  
-
-  @After
-  public void closeSession() {      
-    driver.close();
-  }
-  
-  @AfterClass
-  public static void stopTomcat(){
-    try {
-      if(tomcat!=null){
-        tomcat.stop();
-        tomcat.destroy();
-      }
-    } catch (LifecycleException e) {     
-      e.printStackTrace();
-    }
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/177f12c7/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/TomcatHelper.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/TomcatHelper.java
b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/TomcatHelper.java
deleted file mode 100644
index 860698f..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/TomcatHelper.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- *
- * 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 com.vmware.gemfire.tools.pulse.testbed.driver;
-
-import java.net.InetAddress;
-
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.core.StandardHost;
-import org.apache.catalina.startup.Tomcat;
-import org.apache.tomcat.util.IntrospectionUtils;
-
-public class TomcatHelper {
-  public static Tomcat startTomcat(String bindAddress, int port, String context, String path)
throws Exception {
-
-    Tomcat tomcat = new Tomcat();
-
-    // Set up logging - first we're going to remove all existing handlers. Don't do this
before Tomcat is
-    // instantiated otherwise there isn't anything to remove.
-    /*
-
-    Logger globalLogger = Logger.getLogger("");
-    for (Handler handler : globalLogger.getHandlers()) {
-      globalLogger.removeHandler(handler);
-    }
-
-    // Now let's add our handler
-    Handler gfHandler = new GemFireHandler((LogWriterImpl) log);
-    Logger logger = Logger.getLogger("");
-    logger.addHandler(gfHandler);
-    
-    */
-
-    // Set up for commons-logging which is used by Spring.
-    // This forces JCL to use the JDK logger otherwise it defaults to trying to use Log4J.
-    if (System.getProperty("org.apache.commons.logging.Log") == null) {
-      System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");
-    }
-
-    if (bindAddress != null && bindAddress.length() > 0) {
-      Connector c = tomcat.getConnector();
-      IntrospectionUtils.setProperty(c, "address", bindAddress);
-    }
-    tomcat.setPort(port);
-
-    // Working (scratch) dir
-    String scratch = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator")
+ "Pulse_"
-        + ((bindAddress == null || bindAddress.length() == 0) ? "0.0.0.0" : bindAddress)
+ "_" + port + "_"
-        + String.format("%x", path.hashCode());
-    
-    
-    tomcat.setBaseDir(scratch);
-    StandardHost stdHost = (StandardHost) tomcat.getHost();
-    //stdHost.setUnpackWARs(false);   
-    //tomcat.addContext(context, path);
-    tomcat.addWebapp(stdHost, context, path);
-    stdHost.setDeployOnStartup(true);    
-    tomcat.start();
-
-    return tomcat;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/177f12c7/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTest.java
b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTest.java
index e945156..3bf7ecc 100644
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTest.java
+++ b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTest.java
@@ -18,10 +18,14 @@
  */
 package com.vmware.gemfire.tools.pulse.tests;
 
+import com.gemstone.gemfire.management.internal.JettyHelper;
 import com.gemstone.gemfire.test.junit.categories.UITest;
 import junit.framework.Assert;
-import org.apache.catalina.startup.Tomcat;
-import org.junit.*;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.Ignore;
+import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.runners.MethodSorters;
 import org.openqa.selenium.By;
@@ -49,7 +53,7 @@ public class PulseTest {
   private static String jmxPropertiesFile;
   private static String path;
 
-  private static Tomcat tomcat = null;
+  private static org.eclipse.jetty.server.Server jetty = null;
   private static Server server = null;
   private static String pulseURL = null;
   public static WebDriver driver;
@@ -133,20 +137,22 @@ public class PulseTest {
 
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
-      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-      jmxPropertiesFile = classLoader.getResource("test.properties").getPath();
-      path = getPulseWarPath();
-      server = Server.createServer(9999, jmxPropertiesFile);
+    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+    jmxPropertiesFile = classLoader.getResource("test.properties").getPath();
+    path = getPulseWarPath();
+    server = Server.createServer(9999, jmxPropertiesFile);
 
-      String host = "localhost";// InetAddress.getLocalHost().getHostAddress();
-      int port = 8080;
-      String context = "/pulse";
-      
-      tomcat = TomcatHelper.startTomcat(host, port, context, path);
-      pulseURL = "http://" + host + ":" + port + context;
+    String host = "localhost";// InetAddress.getLocalHost().getHostAddress();
+    int port = 8080;
+    String context = "/pulse";
 
-      Thread.sleep(5000); // wait till tomcat settles down
+    jetty = JettyHelper.initJetty(host, port, false, false, null, null, null);
+    JettyHelper.addWebApplication(jetty, context, getPulseWarPath());
+    jetty.start();
 
+    pulseURL = "http://" + host + ":" + port + context;
+
+    Thread.sleep(5000); // wait till tomcat settles down
 
     driver = new FirefoxDriver();
     driver.manage().window().maximize();
@@ -171,19 +177,24 @@ public class PulseTest {
     Thread.sleep(7000);
   }
 
-    public static String getPulseWarPath() throws Exception{
-        String warPath = null;
-        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-        InputStream inputStream = classLoader
-                .getResourceAsStream("GemFireVersion.properties");
-        Properties properties = new Properties();
-        properties.load(inputStream);
-        String version = properties.getProperty("Product-Version");
-        warPath = "geode-pulse-"+version+".war";
-        String propFilePath = classLoader.getResource("GemFireVersion.properties").getPath();
-        warPath = propFilePath.substring(0, propFilePath.indexOf("generated-resources"))+"libs/"+warPath;
-        return warPath;
-    }
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+    driver.close();
+    jetty.stop();
+  }
+
+  public static String getPulseWarPath() throws Exception {
+    String warPath = null;
+    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+    InputStream inputStream = classLoader.getResourceAsStream("GemFireVersion.properties");
+    Properties properties = new Properties();
+    properties.load(inputStream);
+    String version = properties.getProperty("Product-Version");
+    warPath = "gemfire-pulse-" + version + ".war";
+    String propFilePath = classLoader.getResource("GemFireVersion.properties").getPath();
+    warPath = propFilePath.substring(0, propFilePath.indexOf("generated-resources")) + "libs/"
+ warPath;
+    return warPath;
+  }
 
   protected void searchByLinkAndClick(String linkText) {
     WebElement element = By.linkText(linkText).findElement(driver);
@@ -1015,40 +1026,11 @@ public class PulseTest {
 	  
 	  Assert.assertTrue(driver.findElement(By.id("historyIcon")).isDisplayed());
 	  
-	  //Acutal query execution
+	  //Actual query execution
 	  
 	  driver.findElement(By.id("dataBrowserQueryText")).sendKeys("Query1");
-	  
-	  
-	  
-	 
+
 	  // Assert data regions are displayed 
 	  Assert.assertTrue(driver.findElement(By.id("treeDemo_1")).isDisplayed());
-	
-	  
-  }
-
-  @AfterClass
-  public static void tearDownAfterClass() throws Exception {
-	  //Thread.sleep(200000000);
-    driver.close();
-    /*try {
-      if (tomcat != null) {
-        tomcat.stop();
-        tomcat.destroy();
-      }
-
-      System.out.println("Tomcat Stopped");
-
-      if (server != null) {
-        server.stop();
-      }
-
-      System.out.println("Server Stopped");
-    } catch (LifecycleException e) {
-      e.printStackTrace();
-    }
-*/
   }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/177f12c7/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/TomcatHelper.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/TomcatHelper.java
b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/TomcatHelper.java
deleted file mode 100644
index 0f320a3..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/TomcatHelper.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- *
- * 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 com.vmware.gemfire.tools.pulse.tests;
-
-import java.net.InetAddress;
-
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.core.StandardHost;
-import org.apache.catalina.startup.Tomcat;
-import org.apache.tomcat.util.IntrospectionUtils;
-
-public class TomcatHelper {
-  public static Tomcat startTomcat(String bindAddress, int port,
-      String context, String path) throws Exception {
-
-    Tomcat tomcat = new Tomcat();
-
-    // Set up logging - first we're going to remove all existing handlers. Don't do this
before Tomcat is
-    // instantiated otherwise there isn't anything to remove.
-    /*
-
-    Logger globalLogger = Logger.getLogger("");
-    for (Handler handler : globalLogger.getHandlers()) {
-      globalLogger.removeHandler(handler);
-    }
-
-    // Now let's add our handler
-    Handler gfHandler = new GemFireHandler((LogWriterImpl) log);
-    Logger logger = Logger.getLogger("");
-    logger.addHandler(gfHandler);
-    
-    */
-
-    // Set up for commons-logging which is used by Spring.
-    // This forces JCL to use the JDK logger otherwise it defaults to trying to
-    // use Log4J.
-    if (System.getProperty("org.apache.commons.logging.Log") == null) {
-      System.setProperty("org.apache.commons.logging.Log",
-          "org.apache.commons.logging.impl.Jdk14Logger");
-    }
-
-    if (bindAddress != null && bindAddress.length() > 0) {
-      Connector c = tomcat.getConnector();
-      IntrospectionUtils.setProperty(c, "address", bindAddress);
-    }
-    tomcat.setPort(port);
-
-    // Working (scratch) dir
-    String scratch = System.getProperty("java.io.tmpdir")
-        + System.getProperty("file.separator")
-        + "Pulse_"
-        + ((bindAddress == null || bindAddress.length() == 0) ? "0.0.0.0"
-            : bindAddress) + "_" + port + "_"
-        + String.format("%x", path.hashCode());
-
-    tomcat.setBaseDir(scratch);
-    StandardHost stdHost = (StandardHost) tomcat.getHost();
-    // stdHost.setUnpackWARs(false);
-    // tomcat.addContext(context, path);
-    tomcat.addWebapp(stdHost, context, path);
-    stdHost.setDeployOnStartup(true);
-    tomcat.start();
-
-    return tomcat;
-  }
-
-  public static void main(String[] args) throws Exception {
-    String host = InetAddress.getLocalHost().getHostAddress();
-    int port = 9090;
-    String path = "D:/springsource/springsourceWS/VMware-Pulse-cheetah-dev-jun13/build-artifacts/win/dist/pulse-7.0.1.war";
-    String context = "/pulse";
-    System.setProperty("pulse.propMockDataUpdaterClass",
-        "com.vmware.gemfire.tools.pulse.testbed.PropMockDataUpdater");
-    Tomcat tomcat = TomcatHelper.startTomcat("localhost", port, context, path);
-    Thread.sleep(30000);
-    System.out.println("Sleep completed");
-    System.out.println("Exiting ....");
-    tomcat.stop();
-    tomcat.destroy();
-  }
-}


Mime
View raw message