Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Neo4jsource
Commits
1fccca37
Commit
1fccca37
authored
5 years ago
by
Johannes Unterstein
Browse files
Options
Download
Email Patches
Plain Diff
push-to-cloud: fix behavior when to delete a dump
parent
b8ae9b11
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
community/push-to-cloud/src/main/java/org/neo4j/pushtocloud/PushToCloudCommand.java
+3
-2
...c/main/java/org/neo4j/pushtocloud/PushToCloudCommand.java
community/push-to-cloud/src/test/java/org/neo4j/pushtocloud/PushToCloudCommandTest.java
+19
-13
...st/java/org/neo4j/pushtocloud/PushToCloudCommandTest.java
with
22 additions
and
15 deletions
+22
-15
community/push-to-cloud/src/main/java/org/neo4j/pushtocloud/PushToCloudCommand.java
+
3
-
2
View file @
1fccca37
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
community/push-to-cloud/src/test/java/org/neo4j/pushtocloud/PushToCloudCommandTest.java
+
19
-
13
View file @
1fccca37
...
...
@@ -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
,
createSimpleDatabaseD
ump
()
.
toString
()
),
arg
(
ARG_DUMP
,
d
ump
.
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
,
createSimpleDatabaseD
ump
()
.
toString
()
),
arg
(
ARG_DUMP
,
d
ump
.
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
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment