Skip to content

Commit 8ecc8ba

Browse files
authored
remove index creation to fix a Datastore test (spring-attic#2192)
* remove index creation
1 parent d6e03d0 commit 8ecc8ba

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

spring-cloud-gcp-data-datastore/src/test/java/org/springframework/cloud/gcp/data/datastore/it/DatastoreIntegrationTests.java

+5-28
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616

1717
package org.springframework.cloud.gcp.data.datastore.it;
1818

19-
import java.io.File;
20-
import java.io.IOException;
21-
import java.net.URISyntaxException;
22-
import java.net.URL;
23-
import java.nio.file.Paths;
2419
import java.util.ArrayList;
2520
import java.util.Arrays;
2621
import java.util.Collection;
@@ -851,38 +846,20 @@ public void testPageableGqlEntityProjectionsSlice() {
851846
}
852847

853848
@Test(timeout = 10000L)
854-
public void testSliceString() throws IOException, URISyntaxException, InterruptedException {
855-
createIndexAndRun(() -> {
849+
public void testSliceString() {
850+
try {
856851
Slice<String> slice = this.testEntityRepository.getSliceStringBySize(2L, PageRequest.of(0, 3));
857852

858853
List<String> testEntityProjections = slice.get().collect(Collectors.toList());
859854

860855
assertThat(testEntityProjections).hasSize(1);
861856
assertThat(testEntityProjections.get(0)).isEqualTo("blue");
862-
});
863-
}
864-
865-
private void createIndexAndRun(Runnable runnable) throws URISyntaxException, IOException, InterruptedException {
866-
URL resource = this.getClass().getResource("/index.yaml");
867-
File file = Paths.get(resource.toURI()).toFile();
868-
869-
Process process = new ProcessBuilder("gcloud", "datastore", "indexes", "create", file.getAbsolutePath(), "-q")
870-
.start();
871-
872-
if (process.waitFor() != 0) {
873-
throw new RuntimeException("Error while creating index.");
874-
}
875-
876-
try {
877-
runnable.run();
878857
}
879858
catch (DatastoreException e) {
880859
if (e.getMessage().contains("no matching index found")) {
881-
throw new RuntimeException(
882-
"The required index is not found. "
883-
+ "This test attempts to create it, but it might take a few minutes. "
884-
+ "Retry this test later.",
885-
e);
860+
throw new RuntimeException("The required index is not found. " +
861+
"The index could be created by running this command from 'resources' directory: " +
862+
"'gcloud datastore indexes create index.yaml'");
886863
}
887864
throw e;
888865
}

0 commit comments

Comments
 (0)