Skip to content

Commit

Permalink
fix missing merging both classes
Browse files Browse the repository at this point in the history
use separate package name to be able to understand which test fail in Jenkins

Signed-off-by: Olivier Lamy <olamy@apache.org>
  • Loading branch information
olamy committed Dec 26, 2022
1 parent 56af845 commit d02da58
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.gcloud.session;
package org.eclipse.jetty.ee10.gcloud.session;

import org.eclipse.jetty.ee10.session.AbstractClusteredOrphanedSessionTest;
import org.eclipse.jetty.session.SessionDataStoreFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.gcloud.session;
package org.eclipse.jetty.ee10.gcloud.session;

import org.eclipse.jetty.ee10.session.AbstractClusteredSessionScavengingTest;
import org.eclipse.jetty.session.SessionDataStoreFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.gcloud.session;
package org.eclipse.jetty.ee10.gcloud.session;

import org.eclipse.jetty.session.AbstractSessionDataStoreTest;
import org.eclipse.jetty.session.SessionData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.gcloud.session;
package org.eclipse.jetty.ee10.gcloud.session;

import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
Expand All @@ -38,7 +38,9 @@
import com.google.cloud.datastore.Query.ResultType;
import com.google.cloud.datastore.QueryResults;
import com.google.cloud.datastore.StructuredQuery.PropertyFilter;
import org.eclipse.jetty.gcloud.session.GCloudSessionDataStore;
import org.eclipse.jetty.gcloud.session.GCloudSessionDataStore.EntityDataModel;
import org.eclipse.jetty.gcloud.session.GCloudSessionDataStoreFactory;
import org.eclipse.jetty.session.SessionData;
import org.eclipse.jetty.session.SessionDataStore;
import org.eclipse.jetty.session.SessionManager;
Expand All @@ -65,7 +67,7 @@ public class GCloudSessionTestSupport
private static final Logger GCLOUD_LOG = LoggerFactory.getLogger("org.eclipse.jetty.gcloud.session.gcloudLogs");

public DatastoreEmulatorContainer emulator = new DatastoreEmulatorContainer(
DockerImageName.parse("gcr.io/google.com/cloudsdktool/cloud-sdk:316.0.0-emulators")
DockerImageName.parse("gcr.io/google.com/cloudsdktool/cloud-sdk:316.0.0-emulators")
).withLogConsumer(new Slf4jLogConsumer(GCLOUD_LOG))
.withFlags("--consistency=1.0");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.gcloud.session;
package org.eclipse.jetty.ee10.gcloud.session;

import org.eclipse.jetty.ee10.session.AbstractClusteredInvalidationSessionTest;
import org.eclipse.jetty.session.SessionDataStoreFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.slf4j.simpleLogger.defaultLogLevel=info
org.slf4j.simpleLogger.log.org.eclipse.jetty.gcloud.session=info
org.slf4j.simpleLogger.log.org.eclipse.jetty.gcloud.session.gcloudLogs=info
org.slf4j.simpleLogger.log.org.eclipse.jetty.ee10.gcloud.session=info
org.slf4j.simpleLogger.log.org.eclipse.jetty.ee10.gcloud.session.gcloudLogs=info
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.gcloud.session;
package org.eclipse.jetty.ee9.gcloud.session;

import org.eclipse.jetty.ee9.session.AbstractClusteredOrphanedSessionTest;
import org.eclipse.jetty.session.SessionDataStoreFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.gcloud.session;
package org.eclipse.jetty.ee9.gcloud.session;

import org.eclipse.jetty.ee9.session.AbstractClusteredSessionScavengingTest;
import org.eclipse.jetty.session.SessionDataStoreFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.gcloud.session;
package org.eclipse.jetty.ee9.gcloud.session;

import org.eclipse.jetty.session.AbstractSessionDataStoreTest;
import org.eclipse.jetty.session.SessionData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.gcloud.session;
package org.eclipse.jetty.ee9.gcloud.session;

import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
Expand All @@ -38,7 +38,9 @@
import com.google.cloud.datastore.Query.ResultType;
import com.google.cloud.datastore.QueryResults;
import com.google.cloud.datastore.StructuredQuery.PropertyFilter;
import org.eclipse.jetty.gcloud.session.GCloudSessionDataStore;
import org.eclipse.jetty.gcloud.session.GCloudSessionDataStore.EntityDataModel;
import org.eclipse.jetty.gcloud.session.GCloudSessionDataStoreFactory;
import org.eclipse.jetty.session.SessionData;
import org.eclipse.jetty.session.SessionDataStore;
import org.eclipse.jetty.session.SessionManager;
Expand All @@ -47,7 +49,6 @@
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.DatastoreEmulatorContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -65,28 +66,10 @@ public class GCloudSessionTestSupport
private static final Logger LOGGER = LoggerFactory.getLogger(GCloudSessionTestSupport.class);
private static final Logger GCLOUD_LOG = LoggerFactory.getLogger("org.eclipse.jetty.gcloud.session.gcloudLogs");

public DatastoreEmulatorContainer emulator = new CustomDatastoreEmulatorContainer(
DockerImageName.parse("gcr.io/google.com/cloudsdktool/cloud-sdk:316.0.0-emulators")
).withLogConsumer(new Slf4jLogConsumer(GCLOUD_LOG));

private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("gcr.io/google.com/cloudsdktool/cloud-sdk");

private static final String CMD = "gcloud beta emulators datastore start --project test-project --host-port 0.0.0.0:8081 --consistency=1.0";
private static final int HTTP_PORT = 8081;

public static class CustomDatastoreEmulatorContainer extends DatastoreEmulatorContainer
{
public CustomDatastoreEmulatorContainer(DockerImageName dockerImageName)
{
super(dockerImageName);

dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);

withExposedPorts(HTTP_PORT);
setWaitStrategy(Wait.forHttp("/").forStatusCode(200));
withCommand("/bin/sh", "-c", CMD);
}
}
public DatastoreEmulatorContainer emulator = new DatastoreEmulatorContainer(
DockerImageName.parse("gcr.io/google.com/cloudsdktool/cloud-sdk:316.0.0-emulators")
).withLogConsumer(new Slf4jLogConsumer(GCLOUD_LOG))
.withFlags("--consistency=1.0");

public static class TestGCloudSessionDataStoreFactory extends GCloudSessionDataStoreFactory
{
Expand Down Expand Up @@ -118,7 +101,7 @@ public GCloudSessionTestSupport()
}

public void setUp()
throws Exception
throws Exception
{
emulator.start();
String host;
Expand All @@ -127,20 +110,20 @@ public void setUp()
String endPoint = emulator.getEmulatorEndpoint();
InetAddress hostAddr = InetAddress.getByName(new URL("http://" + endPoint).getHost());
LOGGER.info("endPoint: {} ,hostAddr.isAnyLocalAddress(): {},hostAddr.isLoopbackAddress(): {}",
endPoint,
hostAddr.isAnyLocalAddress(),
hostAddr.isLoopbackAddress());
endPoint,
hostAddr.isAnyLocalAddress(),
hostAddr.isLoopbackAddress());
if (hostAddr.isAnyLocalAddress() || hostAddr.isLoopbackAddress())
host = endPoint;
else
host = "http://" + endPoint;

DatastoreOptions options = DatastoreOptions.newBuilder()
.setHost(host)
.setCredentials(NoCredentials.getInstance())
.setRetrySettings(ServiceOptions.getNoRetrySettings())
.setProjectId("test-project")
.build();
.setHost(host)
.setCredentials(NoCredentials.getInstance())
.setRetrySettings(ServiceOptions.getNoRetrySettings())
.setProjectId("test-project")
.build();
_ds = options.getService();
_keyFactory = _ds.newKeyFactory().setKind(EntityDataModel.KIND);
}
Expand All @@ -151,7 +134,7 @@ public Datastore getDatastore()
}

public void tearDown()
throws Exception
throws Exception
{
emulator.stop();
}
Expand All @@ -167,7 +150,7 @@ public void createSession(String id, String contextPath, String vhost,
long lastAccessed, long maxIdle, long expiry,
long cookieset, long lastSaved,
Map<String, Object> attributes)
throws Exception
throws Exception
{
//serialize the attribute map
try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
Expand All @@ -181,17 +164,17 @@ public void createSession(String id, String contextPath, String vhost,

//turn a session into an entity
Entity.Builder builder = Entity.newBuilder(_keyFactory.newKey(contextPath + "_" + vhost + "_" + id))
.set(EntityDataModel.ID, id)
.set(EntityDataModel.CONTEXTPATH, contextPath)
.set(EntityDataModel.VHOST, vhost)
.set(EntityDataModel.ACCESSED, accessed)
.set(EntityDataModel.LASTACCESSED, lastAccessed)
.set(EntityDataModel.CREATETIME, created)
.set(EntityDataModel.COOKIESETTIME, cookieset)
.set(EntityDataModel.LASTNODE, lastNode)
.set(EntityDataModel.EXPIRY, expiry)
.set(EntityDataModel.MAXINACTIVE, maxIdle)
.set(EntityDataModel.LASTSAVED, lastSaved);
.set(EntityDataModel.ID, id)
.set(EntityDataModel.CONTEXTPATH, contextPath)
.set(EntityDataModel.VHOST, vhost)
.set(EntityDataModel.ACCESSED, accessed)
.set(EntityDataModel.LASTACCESSED, lastAccessed)
.set(EntityDataModel.CREATETIME, created)
.set(EntityDataModel.COOKIESETTIME, cookieset)
.set(EntityDataModel.LASTNODE, lastNode)
.set(EntityDataModel.EXPIRY, expiry)
.set(EntityDataModel.MAXINACTIVE, maxIdle)
.set(EntityDataModel.LASTSAVED, lastSaved);
if (attributes != null)
builder.set(EntityDataModel.ATTRIBUTES, BlobValue.newBuilder(Blob.copyFrom(baos.toByteArray())).setExcludeFromIndexes(true).build());
Entity entity = builder.build();
Expand All @@ -201,7 +184,7 @@ public void createSession(String id, String contextPath, String vhost,
}

public boolean checkSessionPersisted(SessionData data)
throws Exception
throws Exception
{
Entity entity = _ds.get(_keyFactory.newKey(data.getContextPath() + "_" + data.getVhost() + "_" + data.getId()));
if (entity == null)
Expand All @@ -222,11 +205,11 @@ public boolean checkSessionPersisted(SessionData data)
Blob blob = (Blob)entity.getBlob(EntityDataModel.ATTRIBUTES);

SessionData tmp = new SessionData(data.getId(), entity.getString(EntityDataModel.CONTEXTPATH),
entity.getString(EntityDataModel.VHOST),
entity.getLong(EntityDataModel.CREATETIME),
entity.getLong(EntityDataModel.ACCESSED),
entity.getLong(EntityDataModel.LASTACCESSED),
entity.getLong(EntityDataModel.MAXINACTIVE));
entity.getString(EntityDataModel.VHOST),
entity.getLong(EntityDataModel.CREATETIME),
entity.getLong(EntityDataModel.ACCESSED),
entity.getLong(EntityDataModel.LASTACCESSED),
entity.getLong(EntityDataModel.MAXINACTIVE));

try (ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(blob.asInputStream()))
{
Expand All @@ -247,12 +230,12 @@ public boolean checkSessionPersisted(SessionData data)
}

public boolean checkSessionExists(String id)
throws Exception
throws Exception
{
Query<Entity> query = Query.newEntityQueryBuilder()
.setKind(EntityDataModel.KIND)
.setFilter(PropertyFilter.eq(EntityDataModel.ID, id))
.build();
.setKind(EntityDataModel.KIND)
.setFilter(PropertyFilter.eq(EntityDataModel.ID, id))
.build();

QueryResults<Entity> results = _ds.run(query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.gcloud.session;
package org.eclipse.jetty.ee9.gcloud.session;

import org.eclipse.jetty.ee9.session.AbstractClusteredInvalidationSessionTest;
import org.eclipse.jetty.session.SessionDataStoreFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.slf4j.simpleLogger.defaultLogLevel=info
org.slf4j.simpleLogger.log.org.eclipse.jetty.gcloud.session=info
org.slf4j.simpleLogger.log.org.eclipse.jetty.gcloud.session.gcloudLogs=info
org.slf4j.simpleLogger.log.org.eclipse.jetty.ee9.gcloud.session=info
org.slf4j.simpleLogger.log.org.eclipse.jetty.ee9.gcloud.session.gcloudLogs=info

0 comments on commit d02da58

Please sign in to comment.