Implement scavenging and more tests.

This commit is contained in:
Jan Bartel 2015-10-01 16:39:16 +10:00
parent 005d0f2ab8
commit 98c0570474
16 changed files with 954 additions and 40 deletions

View File

@ -49,6 +49,7 @@ import com.google.gcloud.datastore.Blob;
import com.google.gcloud.datastore.Datastore; import com.google.gcloud.datastore.Datastore;
import com.google.gcloud.datastore.DatastoreFactory; import com.google.gcloud.datastore.DatastoreFactory;
import com.google.gcloud.datastore.Entity; import com.google.gcloud.datastore.Entity;
import com.google.gcloud.datastore.GqlQuery;
import com.google.gcloud.datastore.Key; import com.google.gcloud.datastore.Key;
import com.google.gcloud.datastore.KeyFactory; import com.google.gcloud.datastore.KeyFactory;
import com.google.gcloud.datastore.Query; import com.google.gcloud.datastore.Query;
@ -97,7 +98,7 @@ public class GCloudSessionManager extends AbstractSessionManager
private SessionEntityConverter _converter; private SessionEntityConverter _converter;
private int _maxResults; private int _maxResults = DEFAULT_MAX_QUERY_RESULTS;
/** /**
@ -702,7 +703,7 @@ public class GCloudSessionManager extends AbstractSessionManager
else if (!_scheduler.isStarted()) else if (!_scheduler.isStarted())
throw new IllegalStateException("Shared scheduler not started"); throw new IllegalStateException("Shared scheduler not started");
setScavengeInterval(getScavengeInterval()); setScavengeIntervalSec(getScavengeIntervalSec());
super.doStart(); super.doStart();
} }
@ -736,44 +737,52 @@ public class GCloudSessionManager extends AbstractSessionManager
*/ */
public void scavenge () public void scavenge ()
{ {
//scavenge in the database every so often try
//TODO
//always scavenge in memory
scavengeMemory();
}
protected void scavengeMemory()
{
long now = System.currentTimeMillis();
for (Session s:_sessions.values())
{ {
if (s.isExpiredAt(now)) //scavenge in the database every so often
s.timeout(); scavengeGCloudDataStore();
}
catch (Exception e)
{
LOG.warn("Problem scavenging", e);
} }
} }
protected void scavengeGCloudDataStore() protected void scavengeGCloudDataStore()
throws Exception throws Exception
{ {
//query the datastore for sessions that have expired //query the datastore for sessions that have expired
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
Query<Entity> query = Query.gqlQueryBuilder(ResultType.ENTITY, "select * from "+KIND+" where expiry < @1 LIMIT "+_maxResults) //give a bit of leeway so we don't immediately something that has only just expired a nanosecond ago
.setBinding("1", now) now = now - (_scavengeIntervalMs/2);
.build();
if (LOG.isDebugEnabled())
LOG.debug("Scavenging for sessions expired before "+now);
GqlQuery.Builder builder = Query.gqlQueryBuilder(ResultType.ENTITY, "select * from "+KIND+" where expiry < @1 limit "+_maxResults);
builder.allowLiteral(true);
builder.addBinding(now);
Query<Entity> query = builder.build();
QueryResults<Entity> results = _datastore.run(query); QueryResults<Entity> results = _datastore.run(query);
while (results.hasNext()) while (results.hasNext())
{ {
Entity sessionEntity = results.next(); Entity sessionEntity = results.next();
scavengeSession(sessionEntity); scavengeSession(sessionEntity);
} }
} }
/**
* Scavenge a session that has expired
* @param e
* @throws Exception
*/
protected void scavengeSession (Entity e) protected void scavengeSession (Entity e)
throws Exception throws Exception
{ {
@ -782,17 +791,19 @@ public class GCloudSessionManager extends AbstractSessionManager
if (session == null) if (session == null)
return; return;
if (LOG.isDebugEnabled())
LOG.debug("Scavenging session: {}",session.getId());
//if the session isn't in memory already, put it there so we can do a normal timeout call //if the session isn't in memory already, put it there so we can do a normal timeout call
Session memSession =_sessions.get(session.getId()); Session memSession = _sessions.putIfAbsent(session.getId(), session);
if (memSession == null) if (memSession == null)
memSession = _sessions.putIfAbsent(session.getId(), memSession); memSession = session;
//final check //final check
if (memSession.isExpiredAt(now)) if (memSession.isExpiredAt(now))
memSession.timeout(); memSession.timeout();
} }
public long getScavengeInterval () public long getScavengeIntervalSec ()
{ {
return _scavengeIntervalMs/1000; return _scavengeIntervalMs/1000;
} }
@ -806,7 +817,7 @@ public class GCloudSessionManager extends AbstractSessionManager
* *
* @param sec * @param sec
*/ */
public void setScavengeInterval (long sec) public void setScavengeIntervalSec (long sec)
{ {
long old_period=_scavengeIntervalMs; long old_period=_scavengeIntervalMs;

View File

@ -19,6 +19,9 @@
package org.eclipse.jetty.gcloud.session; package org.eclipse.jetty.gcloud.session;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -31,15 +34,28 @@ import java.net.URL;
import java.nio.channels.Channels; import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.util.ArrayList;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.resource.JarResource; import org.eclipse.jetty.util.resource.JarResource;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import com.google.api.client.util.Strings; import com.google.api.client.util.Strings;
import com.google.gcloud.datastore.Key;
import com.google.gcloud.datastore.Datastore;
import com.google.gcloud.datastore.DatastoreFactory;
import com.google.gcloud.datastore.DatastoreOptions; import com.google.gcloud.datastore.DatastoreOptions;
import com.google.gcloud.datastore.Entity;
import com.google.gcloud.datastore.GqlQuery;
import com.google.gcloud.datastore.ProjectionEntity;
import com.google.gcloud.datastore.Query;
import com.google.gcloud.datastore.Query.ResultType;
import com.google.gcloud.datastore.QueryResults;
import com.google.gcloud.datastore.StructuredQuery;
import com.google.gcloud.datastore.StructuredQuery.Projection;
/** /**
* GCloudSessionTestSupport * GCloudSessionTestSupport
@ -94,10 +110,9 @@ public class GCloudSessionTestSupport
String line; String line;
while ((line = _reader.readLine()) != (null) && !line.contains(_startupSentinel)) while ((line = _reader.readLine()) != (null) && !line.contains(_startupSentinel))
{ {
System.err.println(line); //System.err.println(line);
} }
} }
System.err.println("SENTINEL FOUND");
} }
@ -133,6 +148,7 @@ public class GCloudSessionTestSupport
File _datastoreDir; File _datastoreDir;
File _gcdInstallDir; File _gcdInstallDir;
File _gcdUnpackedDir; File _gcdUnpackedDir;
Datastore _ds;
public GCloudSessionTestSupport (String projectId, int port, File gcdInstallDir) public GCloudSessionTestSupport (String projectId, int port, File gcdInstallDir)
{ {
@ -221,9 +237,6 @@ public class GCloudSessionTestSupport
processBuilder.command("bash", new File(_gcdUnpackedDir, "gcd.sh").getAbsolutePath(), "create", "-p",_projectId, _projectId); processBuilder.command("bash", new File(_gcdUnpackedDir, "gcd.sh").getAbsolutePath(), "create", "-p",_projectId, _projectId);
} }
for (String s:processBuilder.command())
System.err.println(s);
Process temp = processBuilder.start(); Process temp = processBuilder.start();
System.err.println("Create outcome: "+temp.waitFor()); System.err.println("Create outcome: "+temp.waitFor());
} }
@ -287,4 +300,70 @@ public class GCloudSessionTestSupport
stopDatastore(); stopDatastore();
clearDatastore(); clearDatastore();
} }
public void ensureDatastore()
throws Exception
{
if (_ds == null)
_ds = DatastoreFactory.instance().get(getConfiguration().getDatastoreOptions());
}
public void listSessions () throws Exception
{
ensureDatastore();
GqlQuery.Builder builder = Query.gqlQueryBuilder(ResultType.ENTITY, "select * from "+GCloudSessionManager.KIND);
Query<Entity> query = builder.build();
QueryResults<Entity> results = _ds.run(query);
assertNotNull(results);
while (results.hasNext())
{
Entity e = results.next();
System.err.println(e.getString("clusterId")+" expires at "+e.getLong("expiry"));
}
}
public void assertSessions(int count) throws Exception
{
ensureDatastore();
StructuredQuery<ProjectionEntity> keyOnlyProjectionQuery = Query.projectionEntityQueryBuilder()
.kind(GCloudSessionManager.KIND)
.projection(Projection.property("__key__"))
.limit(100)
.build();
QueryResults<ProjectionEntity> results = _ds.run(keyOnlyProjectionQuery);
assertNotNull(results);
int actual = 0;
while (results.hasNext())
{
results.next();
++actual;
}
assertEquals(count, actual);
}
public void deleteSessions () throws Exception
{
ensureDatastore();
StructuredQuery<ProjectionEntity> keyOnlyProjectionQuery = Query.projectionEntityQueryBuilder()
.kind(GCloudSessionManager.KIND)
.projection(Projection.property("__key__"))
.limit(100)
.build();
QueryResults<ProjectionEntity> results = _ds.run(keyOnlyProjectionQuery);
if (results != null)
{
List<Key> keys = new ArrayList<Key>();
while (results.hasNext())
{
ProjectionEntity pe = results.next();
keys.add(pe.key());
}
_ds.delete(keys.toArray(new Key[keys.size()]));
}
assertSessions(0);
}
} }

View File

@ -24,6 +24,9 @@ import org.eclipse.jetty.server.SessionManager;
import org.eclipse.jetty.server.session.AbstractTestServer; import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.server.session.SessionHandler; import org.eclipse.jetty.server.session.SessionHandler;
import com.google.gcloud.datastore.Datastore;
import com.google.gcloud.datastore.DatastoreFactory;
/** /**
* GCloudTestServer * GCloudTestServer
* *
@ -76,7 +79,7 @@ public class GCloudTestServer extends AbstractTestServer
GCloudSessionManager sessionManager = new GCloudSessionManager(); GCloudSessionManager sessionManager = new GCloudSessionManager();
sessionManager.setSessionIdManager((GCloudSessionIdManager)_sessionIdManager); sessionManager.setSessionIdManager((GCloudSessionIdManager)_sessionIdManager);
sessionManager.setStaleIntervalSec(1); sessionManager.setStaleIntervalSec(1);
sessionManager.setScavengeInterval(_scavengePeriod); sessionManager.setScavengeIntervalSec(_scavengePeriod);
return sessionManager; return sessionManager;
} }

View File

@ -0,0 +1,70 @@
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractLastAccessTimeTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* LastAccessTimeTest
*
*
*/
public class LastAccessTimeTest extends AbstractLastAccessTimeTest
{
static GCloudSessionTestSupport _testSupport;
@BeforeClass
public static void setup () throws Exception
{
String projectId = System.getProperty("test.projectId", null);
String port = System.getProperty("test.port","0");
_testSupport = new GCloudSessionTestSupport(projectId,
Integer.parseInt(port),
null);
_testSupport.setUp();
}
@AfterClass
public static void teardown () throws Exception
{
_testSupport.tearDown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractLastAccessTimeTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
}
@Test
@Override
public void testLastAccessTime() throws Exception
{
super.testLastAccessTime();
}
}

View File

@ -0,0 +1,71 @@
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractLocalSessionScavengingTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* LocalSessionScavengingTest
*
*
*/
public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTest
{
static GCloudSessionTestSupport _testSupport;
@BeforeClass
public static void setup () throws Exception
{
String projectId = System.getProperty("test.projectId", null);
String port = System.getProperty("test.port","0");
_testSupport = new GCloudSessionTestSupport(projectId,
Integer.parseInt(port),
null);
_testSupport.setUp();
}
@AfterClass
public static void teardown () throws Exception
{
_testSupport.tearDown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractLocalSessionScavengingTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
}
@Test
@Override
public void testLocalSessionsScavenging() throws Exception
{
super.testLocalSessionsScavenging();
}
}

View File

@ -0,0 +1,75 @@
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractOrphanedSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* OrphanedSessionTest
*
*
*/
public class OrphanedSessionTest extends AbstractOrphanedSessionTest
{
static GCloudSessionTestSupport _testSupport;
@BeforeClass
public static void setup () throws Exception
{
String projectId = System.getProperty("test.projectId", null);
String port = System.getProperty("test.port","0");
_testSupport = new GCloudSessionTestSupport(projectId,
Integer.parseInt(port),
null);
_testSupport.setUp();
}
@AfterClass
public static void teardown () throws Exception
{
_testSupport.tearDown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractOrphanedSessionTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
}
@Test
@Override
public void testOrphanedSession() throws Exception
{
super.testOrphanedSession();
_testSupport.assertSessions(0);
}
}

View File

@ -0,0 +1,72 @@
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* ReentrantRequestSessionTest
*
*
*/
public class ReentrantRequestSessionTest extends AbstractReentrantRequestSessionTest
{
static GCloudSessionTestSupport _testSupport;
@BeforeClass
public static void setup () throws Exception
{
String projectId = System.getProperty("test.projectId", null);
String port = System.getProperty("test.port","0");
_testSupport = new GCloudSessionTestSupport(projectId,
Integer.parseInt(port),
null);
_testSupport.setUp();
}
@AfterClass
public static void teardown () throws Exception
{
_testSupport.tearDown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractReentrantRequestSessionTest#createServer(int)
*/
@Override
public AbstractTestServer createServer(int port)
{
return new GCloudTestServer(port, _testSupport.getConfiguration());
}
@Test
@Override
public void testReentrantRequestSession() throws Exception
{
super.testReentrantRequestSession();
}
}

View File

@ -67,7 +67,6 @@ public class RemoveSessionTest extends AbstractRemoveSessionTest
@Override @Override
public void testRemoveSession() throws Exception public void testRemoveSession() throws Exception
{ {
// TODO Auto-generated method stub
super.testRemoveSession(); super.testRemoveSession();
} }

View File

@ -0,0 +1,71 @@
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractSameNodeLoadTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* SameNodeLoadTest
*
*
*/
public class SameNodeLoadTest extends AbstractSameNodeLoadTest
{
static GCloudSessionTestSupport _testSupport;
@BeforeClass
public static void setup () throws Exception
{
String projectId = System.getProperty("test.projectId", null);
String port = System.getProperty("test.port","0");
_testSupport = new GCloudSessionTestSupport(projectId,
Integer.parseInt(port),
null);
_testSupport.setUp();
}
@AfterClass
public static void teardown () throws Exception
{
_testSupport.tearDown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSameNodeLoadTest#createServer(int)
*/
@Override
public AbstractTestServer createServer(int port)
{
return new GCloudTestServer(port, _testSupport.getConfiguration());
}
@Test
@Override
public void testLoad() throws Exception
{
super.testLoad();
}
}

View File

@ -0,0 +1,71 @@
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractServerCrossContextSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* ServerCrossContextSessionTest
*
*
*/
public class ServerCrossContextSessionTest extends AbstractServerCrossContextSessionTest
{
static GCloudSessionTestSupport _testSupport;
@BeforeClass
public static void setup () throws Exception
{
String projectId = System.getProperty("test.projectId", null);
String port = System.getProperty("test.port","0");
_testSupport = new GCloudSessionTestSupport(projectId,
Integer.parseInt(port),
null);
_testSupport.setUp();
}
@AfterClass
public static void teardown () throws Exception
{
_testSupport.tearDown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractServerCrossContextSessionTest#createServer(int)
*/
@Override
public AbstractTestServer createServer(int port)
{
return new GCloudTestServer(port, _testSupport.getConfiguration());
}
@Test
@Override
public void testCrossContextDispatch() throws Exception
{
super.testCrossContextDispatch();
}
}

View File

@ -69,13 +69,18 @@ public class SessionExpiryTest extends AbstractSessionExpiryTest
public void testSessionNotExpired() throws Exception public void testSessionNotExpired() throws Exception
{ {
super.testSessionNotExpired(); super.testSessionNotExpired();
_testSupport.deleteSessions();
} }
/**
* @see org.eclipse.jetty.server.session.AbstractSessionExpiryTest#testSessionExpiry()
*/
@Test @Test
@Override @Override
public void testSessionExpiry() throws Exception public void testSessionExpiry() throws Exception
{ {
super.testSessionExpiry(); super.testSessionExpiry();
_testSupport.assertSessions(0);
} }
} }

View File

@ -0,0 +1,73 @@
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractSessionInvalidateAndCreateTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* SessionInvalidateAndCreateTest
*
*
*/
public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAndCreateTest
{
static GCloudSessionTestSupport _testSupport;
@BeforeClass
public static void setup () throws Exception
{
String projectId = System.getProperty("test.projectId", null);
String port = System.getProperty("test.port","0");
_testSupport = new GCloudSessionTestSupport(projectId,
Integer.parseInt(port),
null);
_testSupport.setUp();
}
@AfterClass
public static void teardown () throws Exception
{
_testSupport.tearDown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionInvalidateAndCreateTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
}
@Test
@Override
public void testSessionScavenge() throws Exception
{
super.testSessionScavenge();
}
}

View File

@ -0,0 +1,72 @@
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractSessionMigrationTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* SessionMigrationTest
*
*
*/
public class SessionMigrationTest extends AbstractSessionMigrationTest
{
static GCloudSessionTestSupport _testSupport;
@BeforeClass
public static void setup () throws Exception
{
String projectId = System.getProperty("test.projectId", null);
String port = System.getProperty("test.port","0");
_testSupport = new GCloudSessionTestSupport(projectId,
Integer.parseInt(port),
null);
_testSupport.setUp();
}
@AfterClass
public static void teardown () throws Exception
{
_testSupport.tearDown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionMigrationTest#createServer(int)
*/
@Override
public AbstractTestServer createServer(int port)
{
return new GCloudTestServer(port, _testSupport.getConfiguration());
}
@Test
@Override
public void testSessionMigration() throws Exception
{
super.testSessionMigration();
}
}

View File

@ -0,0 +1,71 @@
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractSessionRenewTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* SessionRenewTest
*
*
*/
public class SessionRenewTest extends AbstractSessionRenewTest
{
static GCloudSessionTestSupport _testSupport;
@BeforeClass
public static void setup () throws Exception
{
String projectId = System.getProperty("test.projectId", null);
String port = System.getProperty("test.port","0");
_testSupport = new GCloudSessionTestSupport(projectId,
Integer.parseInt(port),
null);
_testSupport.setUp();
}
@AfterClass
public static void teardown () throws Exception
{
_testSupport.tearDown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionRenewTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
{
return new GCloudTestServer(port,max, scavenge, _testSupport.getConfiguration());
}
@Test
@Override
public void testSessionRenewal() throws Exception
{
super.testSessionRenewal();
}
}

View File

@ -0,0 +1,72 @@
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.gcloud.session;
import org.eclipse.jetty.server.session.AbstractSessionValueSavingTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* SessionValueSavingTest
*
*
*/
public class SessionValueSavingTest extends AbstractSessionValueSavingTest
{
static GCloudSessionTestSupport _testSupport;
@BeforeClass
public static void setup () throws Exception
{
String projectId = System.getProperty("test.projectId", null);
String port = System.getProperty("test.port","0");
_testSupport = new GCloudSessionTestSupport(projectId,
Integer.parseInt(port),
null);
_testSupport.setUp();
}
@AfterClass
public static void teardown () throws Exception
{
_testSupport.tearDown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractSessionValueSavingTest#createServer(int, int, int)
*/
@Override
public AbstractTestServer createServer(int port, int max, int scavenge)
{
return new GCloudTestServer(port, max, scavenge, _testSupport.getConfiguration());
}
@Test
@Override
public void testSessionValueSaving() throws Exception
{
super.testSessionValueSaving();
}
}

View File

@ -0,0 +1,99 @@
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.gcloud.session;
import static org.junit.Assert.fail;
import org.eclipse.jetty.server.session.AbstractStopSessionManagerPreserveSessionTest;
import org.eclipse.jetty.server.session.AbstractTestServer;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* StopSessionManagerPreserveSessionTest
*
*
*/
public class StopSessionManagerPreserveSessionTest extends AbstractStopSessionManagerPreserveSessionTest
{
static GCloudSessionTestSupport _testSupport;
@BeforeClass
public static void setup () throws Exception
{
String projectId = System.getProperty("test.projectId", null);
String port = System.getProperty("test.port","0");
_testSupport = new GCloudSessionTestSupport(projectId,
Integer.parseInt(port),
null);
_testSupport.setUp();
}
@AfterClass
public static void teardown () throws Exception
{
_testSupport.tearDown();
}
/**
* @see org.eclipse.jetty.server.session.AbstractStopSessionManagerPreserveSessionTest#checkSessionPersisted(boolean)
*/
@Override
public void checkSessionPersisted(boolean expected)
{
try
{
_testSupport.assertSessions(1);
}
catch (Exception e)
{
fail(e.getMessage());
}
}
/**
* @see org.eclipse.jetty.server.session.AbstractStopSessionManagerPreserveSessionTest#createServer(int)
*/
@Override
public AbstractTestServer createServer(int port)
{
return new GCloudTestServer(port, _testSupport.getConfiguration());
}
/**
* @see org.eclipse.jetty.server.session.AbstractStopSessionManagerPreserveSessionTest#configureSessionManagement(org.eclipse.jetty.servlet.ServletContextHandler)
*/
@Override
public void configureSessionManagement(ServletContextHandler context)
{
}
@Test
@Override
public void testStopSessionManagerPreserveSession() throws Exception
{
super.testStopSessionManagerPreserveSession();
}
}