21
21
22
22
import com .google .common .base .Strings ;
23
23
import com .google .gcloud .AuthCredentials ;
24
+ import com .google .gcloud .RetryParams ;
24
25
import com .google .gcloud .datastore .DatastoreOptions ;
25
26
26
27
import java .io .BufferedInputStream ;
@@ -75,7 +76,7 @@ public class LocalDatastoreHelper {
75
76
private static final String GCLOUD = "gcloud" ;
76
77
private static final Path INSTALLED_GCD_PATH ;
77
78
private static final String GCD_VERSION_PREFIX = "gcd-emulator " ;
78
- private static final String PROJECT_ID_PREFIX = "test-id -" ;
79
+ private static final String PROJECT_ID_PREFIX = "test-project -" ;
79
80
80
81
private final String projectId ;
81
82
private Path gcdPath ;
@@ -541,6 +542,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
541
542
}
542
543
543
544
private LocalDatastoreHelper (double consistency ) {
545
+ checkArgument (consistency >= 0.0 && consistency <= 1.0 , "Consistency must be between 0 and 1" );
544
546
projectId = PROJECT_ID_PREFIX + UUID .randomUUID ().toString ();
545
547
this .consistency = consistency ;
546
548
this .port = findAvailablePort ();
@@ -563,6 +565,7 @@ public DatastoreOptions options() {
563
565
.projectId (projectId )
564
566
.host ("localhost:" + Integer .toString (port ))
565
567
.authCredentials (AuthCredentials .noAuth ())
568
+ .retryParams (RetryParams .noRetries ())
566
569
.build ();
567
570
}
568
571
@@ -573,13 +576,6 @@ public String projectId() {
573
576
return projectId ;
574
577
}
575
578
576
- /**
577
- * Returns the port on localhost to which the local Datastore listens for requests.
578
- */
579
- public int port () {
580
- return port ;
581
- }
582
-
583
579
/**
584
580
* Returns the consistency setting for the local Datastore emulator.
585
581
*/
@@ -621,7 +617,6 @@ public static LocalDatastoreHelper create() {
621
617
*/
622
618
public void start () throws IOException , InterruptedException {
623
619
// send a quick request in case we have a hanging process from a previous run
624
- checkArgument (consistency >= 0.0 && consistency <= 1.0 , "Consistency must be between 0 and 1" );
625
620
sendQuitRequest (port );
626
621
// Each run is associated with its own folder that is deleted once test completes.
627
622
gcdPath = Files .createTempDirectory ("gcd" );
0 commit comments