Commit 1fccca37 authored by Johannes Unterstein's avatar Johannes Unterstein
Browse files

push-to-cloud: fix behavior when to delete a dump

parent b8ae9b11
Showing with 22 additions and 15 deletions
+22 -15
......@@ -155,9 +155,10 @@ public class PushToCloudCommand implements AdminCommand
String bearerToken = copier.authenticate( verbose, consoleURL, username, password, "true".equals( confirmationViaArgument ) );
Path source = initiateSource( arguments );
boolean sourceProvided = arguments.get( ARG_DUMP ) != null;
// only mark dump to delete after processing, if we just created it
boolean deleteDump = arguments.get( ARG_DUMP ) == null;
copier.copy( verbose, consoleURL, boltURI, source, sourceProvided, bearerToken );
copier.copy( verbose, consoleURL, boltURI, source, deleteDump, bearerToken );
}
catch ( Exception e )
{
......
......@@ -41,6 +41,7 @@ import org.neo4j.test.rule.TestDirectory;
import static java.lang.String.format;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
......@@ -90,7 +91,7 @@ public class PushToCloudCommandTest
// then
verify( targetCommunicator ).authenticate( anyBoolean(), any(), eq( username ), eq( password ), anyBoolean() );
verify( targetCommunicator ).copy( anyBoolean(), any(), any(), any(), anyBoolean(), any() );
verify( targetCommunicator ).copy( anyBoolean(), any(), any(), any(), eq( false ), any() );
}
@Test
......@@ -116,7 +117,7 @@ public class PushToCloudCommandTest
// then
verify( targetCommunicator ).authenticate( anyBoolean(), any(), eq( username ), eq( password ), eq( true ) );
verify( targetCommunicator ).copy( anyBoolean(), any(), any(), any(), anyBoolean(), any() );
verify( targetCommunicator ).copy( anyBoolean(), any(), any(), any(), eq( false ), any() );
}
@Test
......@@ -142,7 +143,7 @@ public class PushToCloudCommandTest
// then
verify( targetCommunicator ).authenticate( anyBoolean(), any(), eq( username ), eq( password ), eq( true ) );
verify( targetCommunicator ).copy( anyBoolean(), any(), any(), any(), anyBoolean(), any() );
verify( targetCommunicator ).copy( anyBoolean(), any(), any(), any(), eq( false ), any() );
}
@Test
......@@ -159,7 +160,7 @@ public class PushToCloudCommandTest
arg( ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI ) ) );
// then
verify( targetCommunicator ).copy( anyBoolean(), any(), any(), eq( dump ), anyBoolean(), any() );
verify( targetCommunicator ).copy( anyBoolean(), any(), any(), eq( dump ), eq( false ), any() );
}
@Test
......@@ -181,7 +182,7 @@ public class PushToCloudCommandTest
// then
verify( dumpCreator ).dumpDatabase( eq( databaseName ), any() );
verify( targetCommunicator ).copy( anyBoolean(), any(), any(), any(), anyBoolean(), any() );
verify( targetCommunicator ).copy( anyBoolean(), any(), any(), any(), eq( true ), any() );
}
@Test
......@@ -205,7 +206,7 @@ public class PushToCloudCommandTest
// then
verify( dumpCreator ).dumpDatabase( databaseName, dumpFile );
verify( targetCommunicator ).copy( anyBoolean(), any(), any(), any(), anyBoolean(), any() );
verify( targetCommunicator ).copy( anyBoolean(), any(), any(), any(), eq( true ), any() );
}
@Test
......@@ -302,18 +303,23 @@ public class PushToCloudCommandTest
.outsideWorld( outsideWorld )
.build();
Path dump = createSimpleDatabaseDump();
// when
command.execute( array(
arg( ARG_DUMP, createSimpleDatabaseDump().toString() ),
arg( ARG_DUMP, dump.toString() ),
arg( ARG_USERNAME, "user" ),
arg( ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI ) ) );
assertTrue( dump.toFile().exists() );
environmentVariables.set("NEO4J_USERNAME", "neo4j");
environmentVariables.set("NEO4J_PASSWORD", null);
command.execute( array(
arg( ARG_DUMP, createSimpleDatabaseDump().toString() ),
arg( ARG_DUMP, dump.toString() ),
arg( ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI ) ) );
assertTrue( dump.toFile().exists() );
}
@Test
......@@ -358,7 +364,7 @@ public class PushToCloudCommandTest
// then
String defaultDatabase = new Database().defaultValue();
verify( dumpCreator ).dumpDatabase( eq( defaultDatabase ), any() );
verify( copier ).copy( anyBoolean(), any(), any(), any(), anyBoolean(), any() );
verify( copier ).copy( anyBoolean(), any(), any(), any(), eq( true ), any() );
}
@Test
......@@ -398,7 +404,7 @@ public class PushToCloudCommandTest
// then
verify( copier ).copy( anyBoolean(), eq( "https://console-testenvironment.neo4j.io/v1/databases/mydbid" ),
eq( "bolt+routing://mydbid-testenvironment.databases.neo4j.io" ), any(), anyBoolean(), any() );
eq( "bolt+routing://mydbid-testenvironment.databases.neo4j.io" ), any(), eq( false ), any() );
}
@Test
......@@ -415,7 +421,7 @@ public class PushToCloudCommandTest
// then
verify( copier ).copy( anyBoolean(), eq( "https://console.neo4j.io/v1/databases/mydbid" ),
eq( "bolt+routing://mydbid.databases.neo4j.io" ), any(), anyBoolean(), any() );
eq( "bolt+routing://mydbid.databases.neo4j.io" ), any(), eq( false ), any() );
}
@Test
......@@ -431,10 +437,10 @@ public class PushToCloudCommandTest
// then
InOrder inOrder = inOrder( copier, dumper );
inOrder.verify( copier ).authenticate( anyBoolean(), anyString(), anyString(), any(), anyBoolean() );
inOrder.verify( copier ).authenticate( anyBoolean(), anyString(), anyString(), any(), eq( false ) );
inOrder.verify( dumper ).dumpDatabase( anyString(), any() );
inOrder.verify( copier ).copy( anyBoolean(), anyString(), eq( "bolt+routing://mydbid.databases.neo4j.io" ), any(),
anyBoolean(), anyString() );
eq( true ), anyString() );
}
private Copier mockedTargetCommunicator() throws CommandFailed
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment