Skip to content

Commit

Permalink
GEODE-2901: Adding integration tests of session replication
Browse files Browse the repository at this point in the history
Adding integration tests that test both session replications
frameworks shipped with geode. These tests use cargo to download
and launch different J2EE containers, so the tests can run
against many different containers.

This closes apache#584
  • Loading branch information
DivineEnder authored and upthewaterspout committed Jun 30, 2017
1 parent 52fe793 commit aa68f04
Show file tree
Hide file tree
Showing 26 changed files with 2,683 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build-eclipse/
/tags
out/


.DS_store
*.iml
*.ipr
*.iws
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
*/
package org.apache.geode.modules.session.catalina;

import java.io.IOException;

import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.Pipeline;
import org.apache.catalina.session.StandardSession;

import java.io.IOException;

public class Tomcat8DeltaSessionManager extends DeltaSessionManager {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
out.write(val);
}
break;

case INVALIDATE:
session = request.getSession();
session.invalidate();
Expand Down
27 changes: 27 additions & 0 deletions extensions/session-testing-war/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.
*/
apply plugin: 'war'

dependencies {
provided 'javax.servlet:javax.servlet-api:' + project.'javax.servlet-api.version'
}

war {
version = ''
}

disableMavenPublishing()
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* 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.modules.session;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
*
*/
public class CommandServlet extends HttpServlet {

private ServletContext context;

/**
* The standard servlet method overridden.
*
* @param request
* @param response
* @throws IOException
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {

QueryCommand cmd = QueryCommand.UNKNOWN;
String param = request.getParameter("param");
String value = request.getParameter("value");
PrintWriter out = response.getWriter();

String cmdStr = request.getParameter("cmd");
if (cmdStr != null) {
cmd = QueryCommand.valueOf(cmdStr);
}

HttpSession session;

switch (cmd) {
case SET:
session = request.getSession();
session.setAttribute(param, value);
break;
case SET_MAX_INACTIVE:
session = request.getSession();
session.setMaxInactiveInterval(Integer.valueOf(value));
break;
case GET:
session = request.getSession();
String val = (String) session.getAttribute(param);
if (val != null) {
out.write(val);
}
break;
case REMOVE:
session = request.getSession();
session.removeAttribute(param);
break;
case INVALIDATE:
session = request.getSession();
session.invalidate();
break;
}
}

/**
* Save a reference to the ServletContext for later use.
*
* @param config
*/
@Override
public void init(ServletConfig config) {
this.context = config.getServletContext();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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.modules.session;

/**
* Basic commands to pass to our test servlet
*/
public enum QueryCommand {

SET,

SET_MAX_INACTIVE,

GET,

REMOVE,

INVALIDATE,

UNKNOWN;

}
43 changes: 43 additions & 0 deletions extensions/session-testing-war/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">

<display-name>Geode Test war</display-name>

<description>
Test war file for geode session management
</description>

<servlet>
<description>
Some test servlet
</description>
<servlet-name>cmd-servlet</servlet-name>
<servlet-class>org.apache.geode.modules.session.CommandServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>cmd-servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

</web-app>
15 changes: 15 additions & 0 deletions geode-assembly/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ dependencies {
testCompile 'org.apache.httpcomponents:httpclient:' + project.'httpclient.version'
testCompile 'org.apache.httpcomponents:httpcore:' + project.'httpcore.version'
testCompile 'com.google.guava:guava:' + project.'guava.version'
testCompile 'org.apache.commons:commons-exec:' + project.'commons-exec.version'

testCompile group: 'org.codehaus.cargo', name: 'cargo-core-uberjar', version: '1.6.3'

testCompile (project(':extensions/geode-modules')) {
// Remove everything related to Tomcat
exclude group: 'org.apache.tomcat'
}
testCompile (project(':extensions/geode-modules-session-internal')) {
// Remove everything related to Tomcat
exclude group: 'org.apache.tomcat'
}

testCompile project(':extensions/session-testing-war')

testRuntime files("${System.getProperty('java.home')}/../lib/tools.jar")
testRuntime files("$buildDir/install/${distributions.main.baseName}/lib/geode-dependencies.jar")
Expand Down Expand Up @@ -404,6 +418,7 @@ flakyTest dependOnInstalledProduct
build.dependsOn installDist

installDist.dependsOn ':extensions/geode-modules-assembly:dist'
distributedTest.dependsOn ':extensions/session-testing-war:war'

/**Print the names of all jar files in a fileTree */
def printJars(tree) {
Expand Down
Loading

0 comments on commit aa68f04

Please sign in to comment.