Skip to content

Enable encryption for cluster stress test if test with a remote cluster. #691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,12 @@ void setUp()
System.setProperty( DRIVER_METRICS_ENABLED_KEY, "true" );
logging = new LoggerNameTrackingLogging();

Config config = Config.builder()
.withoutEncryption()
Config.ConfigBuilder builder = Config.builder()
.withLogging( logging )
.withMaxConnectionPoolSize( 100 )
.withConnectionAcquisitionTimeout( 1, MINUTES )
.build();
.withConnectionAcquisitionTimeout( 1, MINUTES );

driver = (InternalDriver) GraphDatabase.driver( databaseUri(), authToken(), config );
driver = (InternalDriver) GraphDatabase.driver( databaseUri(), authToken(), config( builder ) );
System.setProperty( DRIVER_METRICS_ENABLED_KEY, "false" );

ThreadFactory threadFactory = new DaemonThreadFactory( getClass().getSimpleName() + "-worker-" );
Expand Down Expand Up @@ -186,6 +184,8 @@ private void runStressTest( Function<C,List<Future<?>>> threadLauncher ) throws

abstract AuthToken authToken();

abstract Config config( Config.ConfigBuilder builder );

abstract C createContext();

abstract List<BlockingCommand<C>> createTestSpecificBlockingCommands();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.neo4j.driver.internal.BoltServerAddress;
import org.neo4j.driver.internal.util.ServerVersion;
import org.neo4j.driver.v1.AuthToken;
import org.neo4j.driver.v1.Config;
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.exceptions.SessionExpiredException;
import org.neo4j.driver.v1.summary.ResultSummary;
Expand Down Expand Up @@ -66,6 +67,12 @@ AuthToken authToken()
return clusterRule.getAuthToken();
}

@Override
Config config( Config.ConfigBuilder builder )
{
return clusterRule.getDriverConfig( builder );
}

@Override
Context createContext()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.concurrent.atomic.AtomicLong;

import org.neo4j.driver.v1.AuthToken;
import org.neo4j.driver.v1.Config;
import org.neo4j.driver.v1.summary.ResultSummary;
import org.neo4j.driver.v1.util.DatabaseExtension;
import org.neo4j.driver.v1.util.ParallelizableIT;
Expand All @@ -52,6 +53,12 @@ AuthToken authToken()
return neo4j.authToken();
}

@Override
Config config( Config.ConfigBuilder builder )
{
return builder.build();
}

@Override
Context createContext()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.neo4j.driver.internal.util.DriverFactoryWithOneEventLoopThread;
import org.neo4j.driver.v1.AuthToken;
import org.neo4j.driver.v1.AuthTokens;
import org.neo4j.driver.v1.Config;
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.util.TestUtil;

Expand Down Expand Up @@ -62,6 +63,20 @@ public AuthToken getAuthToken()
return localClusterExtension.getDefaultAuthToken();
}

public Config getDriverConfig( Config.ConfigBuilder builder )
{
if ( remoteClusterExists() )
{
builder.withEncryption();
}
else
{
builder.withoutEncryption();
}

return builder.build();
}

@Override
public void beforeAll( ExtensionContext context ) throws Exception
{
Expand Down