Skip to content

Commit

Permalink
test: add IT test case for refresh of indexed views
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Feb 1, 2023
1 parent f0ef788 commit 3743c34
Showing 1 changed file with 57 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ public void testBigDataParallelRefresh() throws InterruptedException {
String viewName = "testUpdateDelete";
db.createClass(className);

for (int i = 0; i < 10002; i++) {
OElement elem = db.newElement(className);
elem.setProperty("name", "name" + i);
elem.setProperty("surname", "surname" + i);
elem.setProperty("toChange", "data");
elem.save();
}

for (int i = 0; i < 20; i++) {
String statement =
"CREATE VIEW "
Expand All @@ -159,32 +167,76 @@ public void testBigDataParallelRefresh() throws InterruptedException {
db.command(statement);
}

for (int i = 0; i < 100002; i++) {
Thread.sleep(20000);

for (int i = 0; i < 20; i++) {
System.out.println("checking " + viewName + i);
OResultSet result = db.query("SELECT FROM " + viewName + i);
Assert.assertEquals(10002, result.stream().count());
result.close();
}

db.command(
"update " + className + " set toChange=\"other\" where name in [\"name2\",\"name6\"]")
.close();

Thread.sleep(15000);
for (int i = 0; i < 20; i++) {
System.out.println("checking after update " + viewName + i);
OResultSet result = db.query("SELECT FROM " + viewName + i);
Assert.assertEquals(10000, result.stream().count());
result.close();
}
}
}

@Test
public void testBigDataParallelIndexRefresh() throws InterruptedException {
try (ODatabaseSession db = orientDB.open(this.getClass().getSimpleName(), "admin", "admpwd")) {
String className = "testUpdateDeleteClass";
String viewName = "testUpdateDelete";
db.createClass(className);

for (int i = 0; i < 10002; i++) {
OElement elem = db.newElement(className);
elem.setProperty("name", "name" + i);
elem.setProperty("surname", "surname" + i);
elem.setProperty("toChange", "data");
elem.save();
}

Thread.sleep(40000);
for (int i = 0; i < 20; i++) {
String statement =
"CREATE VIEW "
+ viewName
+ i
+ " FROM (SELECT name FROM "
+ className
+ " where toChange=\"data\") metadata {\"updateIntervalSeconds\":5, indexes:[{type:\"NOTUNIQUE\", properties:{name:\"String\"}}] } ";

db.command(statement);
}

Thread.sleep(20000);

for (int i = 0; i < 20; i++) {
System.out.println("checking " + viewName + i);
OResultSet result = db.query("SELECT FROM " + viewName + i);
Assert.assertEquals(100002, result.stream().count());
System.out.println("plan" + result.getExecutionPlan().get().prettyPrint(0, 0));
Assert.assertEquals(10002, result.stream().count());
result.close();
}

db.command(
"update " + className + " set toChange=\"other\" where name in [\"name2\",\"name6\"]")
.close();

Thread.sleep(30000);
Thread.sleep(15000);
for (int i = 0; i < 20; i++) {
System.out.println("checking after update " + viewName + i);
OResultSet result = db.query("SELECT FROM " + viewName + i);
Assert.assertEquals(100000, result.stream().count());
System.out.println("plan" + result.getExecutionPlan().get().prettyPrint(0, 0));
Assert.assertEquals(10000, result.stream().count());
result.close();
}
}
Expand Down

0 comments on commit 3743c34

Please sign in to comment.