Skip to content
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

Stub tests migration p3 #840

Merged
merged 1 commit into from
Mar 2, 2021
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 @@ -27,7 +27,6 @@

import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.TimeUnit;
Expand All @@ -48,10 +47,8 @@
import org.neo4j.driver.internal.cluster.RoutingSettings;
import org.neo4j.driver.internal.retry.RetrySettings;
import org.neo4j.driver.internal.security.SecurityPlanImpl;
import org.neo4j.driver.internal.util.DriverFactoryWithClock;
import org.neo4j.driver.internal.util.DriverFactoryWithFixedRetryLogic;
import org.neo4j.driver.internal.util.Futures;
import org.neo4j.driver.internal.util.SleeplessClock;
import org.neo4j.driver.net.ServerAddress;
import org.neo4j.driver.net.ServerAddressResolver;
import org.neo4j.driver.reactive.RxResult;
Expand All @@ -63,9 +60,7 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.junit.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
Expand Down Expand Up @@ -229,6 +224,8 @@ void shouldFailInitialDiscoveryWhenConfiguredResolverThrows()
verify( resolver ).resolve( ServerAddress.of( "my.server.com", 9001 ) );
}

// general error reporting and handling should be improved before this can be moved to testkit
// also, backend closes socket on general errors and it negatively impacts testkit's teardown process
@Test
void useSessionAfterDriverIsClosed() throws Exception
{
Expand Down Expand Up @@ -256,45 +253,6 @@ void useSessionAfterDriverIsClosed() throws Exception
}
}

@Test
void shouldServerWithBoltV4SupportMultiDb() throws Throwable
{
StubServer server = stubController.startStub( "support_multidb_v4.script", 9001 );
try ( Driver driver = GraphDatabase.driver( "neo4j://localhost:9001", INSECURE_CONFIG ) )
{
assertTrue( driver.supportsMultiDb() );
}
finally
{
assertEquals( 0, server.exitStatus() );
}
}

@Test
void shouldServerWithBoltV3NotSupportMultiDb() throws Throwable
{
StubServer server = stubController.startStub( "support_multidb_v3.script", 9001 );
try ( Driver driver = GraphDatabase.driver( "neo4j://localhost:9001", INSECURE_CONFIG ) )
{
assertFalse( driver.supportsMultiDb() );
}
finally
{
assertEquals( 0, server.exitStatus() );
}
}

private static Driver newDriverWithSleeplessClock( String uriString, Config config )
{
DriverFactory driverFactory = new DriverFactoryWithClock( new SleeplessClock() );
return newDriver( uriString, driverFactory, config );
}

private static Driver newDriverWithSleeplessClock( String uriString )
{
return newDriverWithSleeplessClock( uriString, INSECURE_CONFIG );
}

private static Driver newDriverWithFixedRetries( String uriString, int retries )
{
DriverFactory driverFactory = new DriverFactoryWithFixedRetryLogic( retries );
Expand All @@ -318,20 +276,6 @@ private static TransactionWork<List<Record>> queryWork( final String query, fina
};
}

private static List<String> readStrings( final String query, Session session )
{
return session.readTransaction( tx ->
{
List<Record> records = tx.run( query ).list();
List<String> names = new ArrayList<>( records.size() );
for ( Record record : records )
{
names.add( record.get( 0 ).asString() );
}
return names;
} );
}

static class PortBasedServerAddressComparator implements Comparator<ServerAddress>
{
@Override
Expand Down

This file was deleted.

16 changes: 0 additions & 16 deletions driver/src/test/resources/get_routing_table_with_context.script

This file was deleted.

17 changes: 0 additions & 17 deletions driver/src/test/resources/routing_context_in_hello_neo4j.script

This file was deleted.

13 changes: 0 additions & 13 deletions driver/src/test/resources/write_server_v3_write_tx.script

This file was deleted.

13 changes: 0 additions & 13 deletions driver/src/test/resources/write_tx_with_bookmarks.script

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed 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 neo4j.org.testkit.backend.messages.requests;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import neo4j.org.testkit.backend.TestkitState;
import neo4j.org.testkit.backend.messages.responses.MultiDBSupport;
import neo4j.org.testkit.backend.messages.responses.TestkitResponse;

@Setter
@Getter
@NoArgsConstructor
public class CheckMultiDBSupport implements TestkitRequest
{
private CheckMultiDBSupportBody data;

@Override
public TestkitResponse process( TestkitState testkitState )
{
String driverId = data.getDriverId();
boolean available = testkitState.getDrivers().get( driverId ).supportsMultiDb();
return MultiDBSupport.builder().data( MultiDBSupport.MultiDBSupportBody.builder().available( available ).build() ).build();
}

@Setter
@Getter
@NoArgsConstructor
public static class CheckMultiDBSupportBody
{
private String driverId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@JsonSubTypes.Type( TransactionRun.class ), @JsonSubTypes.Type( RetryablePositive.class ),
@JsonSubTypes.Type( SessionBeginTransaction.class ), @JsonSubTypes.Type( TransactionCommit.class ),
@JsonSubTypes.Type( SessionLastBookmarks.class ), @JsonSubTypes.Type( SessionWriteTransaction.class ),
@JsonSubTypes.Type( ResolverResolutionCompleted.class )
@JsonSubTypes.Type( ResolverResolutionCompleted.class ), @JsonSubTypes.Type( CheckMultiDBSupport.class )
} )
public interface TestkitRequest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed 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 neo4j.org.testkit.backend.messages.responses;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
@Builder
public class MultiDBSupport implements TestkitResponse
{
private final MultiDBSupportBody data;

@Override
public String testkitName()
{
return "MultiDBSupport";
}

@Setter
@Getter
@Builder
public static class MultiDBSupportBody
{
private final String id;

private final boolean available;
}
}