Skip to content

Commit

Permalink
Revert "Fix test now that indexing is done in background (#135)"
Browse files Browse the repository at this point in the history
This reverts commit 51c6892.
  • Loading branch information
mangalaman93 committed Mar 25, 2020
1 parent 51c6892 commit 18b8ce5
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 146 deletions.
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,6 @@ Operation operation = Operation.newBuilder().setSchema(schema).build();
dgraphClient.alter(operation);
```

Starting Dgraph version `20.3.0`, indexes are computed in the background.
This requires that you wait for indexing to complete before running queries.
You could do that using following code.

```java
AlterUtils.waitForIndexing(dgraphClient, "name", Collections.singletonList("exact"), false, false);
```

`Operation` contains other fields as well, including drop predicate and
drop all. Drop all is useful if you wish to discard all the data, and start from
a clean slate, without bringing the instance down.
Expand Down
2 changes: 0 additions & 2 deletions samples/DgraphJavaSample/src/main/java/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ public static void main(final String[] args) {
String schema = "name: string @index(exact) .";
Operation operation = Operation.newBuilder().setSchema(schema).build();
dgraphClient.alter(operation);
// AlterUtils.waitForIndexing(
// dgraphClient, "name", Collections.singletonList("exact"), false, false);

Gson gson = new Gson(); // For JSON encode/decode
Transaction txn = dgraphClient.newTransaction();
Expand Down
5 changes: 0 additions & 5 deletions src/test/java/io/dgraph/AcctUpsertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ private void setup() {
+ " when: int .\n";
Operation op = Operation.newBuilder().setSchema(schema).build();
dgraphClient.alter(op);
AlterUtils.waitForIndexing(
dgraphClient, "first", Collections.singletonList("term"), false, false);
AlterUtils.waitForIndexing(
dgraphClient, "last", Collections.singletonList("hash"), false, false);
AlterUtils.waitForIndexing(dgraphClient, "age", Collections.singletonList("int"), false, false);
}

private void tryUpsert(Account account) {
Expand Down
3 changes: 0 additions & 3 deletions src/test/java/io/dgraph/AclTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.stream.Collectors;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand All @@ -33,8 +32,6 @@ public void setSchema() {
DgraphProto.Operation.newBuilder()
.setSchema(PREDICATE_TO_READ + ": string @index(exact) .")
.build());
AlterUtils.waitForIndexing(
dgraphClient, PREDICATE_TO_READ, Collections.singletonList("exact"), false, false);
}

@Test(groups = {"acl"})
Expand Down
102 changes: 0 additions & 102 deletions src/test/java/io/dgraph/AlterUtils.java

This file was deleted.

1 change: 1 addition & 0 deletions src/test/java/io/dgraph/BankTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.testng.annotations.Test;

public class BankTest extends DgraphIntegrationTest {

private final ArrayList<String> uids = new ArrayList<>();
private final AtomicInteger runs = new AtomicInteger();
private final AtomicInteger aborts = new AtomicInteger();
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/io/dgraph/DgraphAsyncClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ public void testMutationsInReadOnlyTransactions() {
public void testQueryInReadOnlyTransactions() {
Operation op = Operation.newBuilder().setSchema("name: string @index(exact) @upsert .").build();
dgraphAsyncClient.alter(op).join();
AlterUtils.waitForIndexing(
dgraphAsyncClient, "name", Collections.singletonList("exact"), false, false);

// Mutation
JsonObject jsonData = new JsonObject();
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/io/dgraph/DgraphClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ public void testTxnQueryVariables() {
// Set schema
Operation op = Operation.newBuilder().setSchema("name: string @index(exact) @upsert .").build();
dgraphClient.alter(op);
AlterUtils.waitForIndexing(
dgraphClient, "name", Collections.singletonList("exact"), false, false);

// Add data
JsonObject data = new JsonObject();
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/io/dgraph/MutatesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
import static org.testng.Assert.assertTrue;

import io.dgraph.DgraphProto.*;
import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.testng.annotations.Test;

Expand All @@ -32,8 +35,6 @@ public void testInsert3Quads() {
Operation op =
Operation.newBuilder().setSchema("name: string @index(fulltext) @upsert .").build();
dgraphClient.alter(op);
AlterUtils.waitForIndexing(
dgraphClient, "name", Collections.singletonList("fulltext"), false, false);

Transaction txn = dgraphClient.newTransaction();
uidsMap = new HashMap<>();
Expand Down
3 changes: 0 additions & 3 deletions src/test/java/io/dgraph/OpencensusJaegerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.opencensus.trace.config.TraceConfig;
import io.opencensus.trace.config.TraceParams;
import io.opencensus.trace.samplers.Samplers;
import java.util.Collections;
import java.util.concurrent.*;
import org.testng.annotations.Test;

Expand All @@ -24,8 +23,6 @@ private static void runTransactions() {
.setSchema("name: string @index(fulltext) @upsert .")
.build();
dgraphClient.alter(op);
AlterUtils.waitForIndexing(
dgraphClient, "name", Collections.singletonList("fulltext"), false, false);

// Add data
JsonObject jsonData = new JsonObject();
Expand Down
3 changes: 0 additions & 3 deletions src/test/java/io/dgraph/TypeSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import io.dgraph.DgraphProto.Operation;
import io.dgraph.DgraphProto.Request;
import io.dgraph.DgraphProto.Response;
import java.util.Arrays;
import java.util.List;
import org.testng.annotations.Test;

Expand All @@ -27,7 +26,6 @@ public class TypeSystemTest extends DgraphIntegrationTest {
public void testTypeFunction() {
Operation op = Operation.newBuilder().setSchema(schema).build();
dgraphClient.alter(op);
AlterUtils.waitForIndexing(dgraphClient, "name", Arrays.asList("term", "exact"), false, false);

String muStr =
"_:animesh <name> \"Animesh\" .\n"
Expand All @@ -51,7 +49,6 @@ public void testTypeFunction() {
public void testTypeDeletion() {
Operation op = Operation.newBuilder().setSchema(schema).build();
dgraphClient.alter(op);
AlterUtils.waitForIndexing(dgraphClient, "name", Arrays.asList("term", "exact"), false, false);

String muStr = "" + "_:animesh <name> \"Animesh\" .\n" + "_:animesh <age> \"24\" .";
Mutation mu =
Expand Down
13 changes: 0 additions & 13 deletions src/test/java/io/dgraph/UpsertBlockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.dgraph.DgraphProto.Mutation;
import io.dgraph.DgraphProto.Request;
import io.dgraph.DgraphProto.Response;
import java.util.Collections;
import java.util.List;
import org.testng.annotations.Test;

Expand All @@ -22,8 +21,6 @@ public void upsertBlockTest() {
.setSchema("email: string @index(exact) @upsert .")
.build();
dgraphClient.alter(op);
AlterUtils.waitForIndexing(
dgraphClient, "email", Collections.singletonList("exact"), false, false);

JsonArray jsonData1 = new JsonArray();
JsonObject person1 = new JsonObject();
Expand Down Expand Up @@ -100,10 +97,6 @@ public void upsertBlockTestMultipleUID() {
.setSchema("email: string @index(exact) @upsert .\nname: string @index(exact) .")
.build();
dgraphClient.alter(op);
AlterUtils.waitForIndexing(
dgraphClient, "email", Collections.singletonList("exact"), false, false);
AlterUtils.waitForIndexing(
dgraphClient, "name", Collections.singletonList("exact"), false, false);

JsonArray jsonData1 = new JsonArray();
JsonObject person1 = new JsonObject();
Expand Down Expand Up @@ -170,10 +163,6 @@ public void upsertBlockTestBulkDelete() {
.setSchema("email: string @index(exact) @upsert .\nname: string @index(exact) .")
.build();
dgraphClient.alter(op);
AlterUtils.waitForIndexing(
dgraphClient, "email", Collections.singletonList("exact"), false, false);
AlterUtils.waitForIndexing(
dgraphClient, "name", Collections.singletonList("exact"), false, false);

JsonArray jsonData1 = new JsonArray();
JsonObject person1 = new JsonObject();
Expand Down Expand Up @@ -249,8 +238,6 @@ public void upsertBlockTestBulkUpdate() {
.setSchema("name: string @index(exact) .\n" + "branch: string .\n" + "amount: float .")
.build();
dgraphClient.alter(op);
AlterUtils.waitForIndexing(
dgraphClient, "name", Collections.singletonList("exact"), false, false);

String muStr1 =
""
Expand Down

0 comments on commit 18b8ce5

Please sign in to comment.