Skip to content

Commit d7cc081

Browse files
committed
Tests Yugabyte - see if everything else passes
1 parent 3351548 commit d7cc081

File tree

1 file changed

+74
-74
lines changed

1 file changed

+74
-74
lines changed

ebean-test/src/test/java/org/tests/basic/TestQueryForUpdate.java

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import io.ebean.*;
44
import io.ebean.annotation.Platform;
5-
import io.ebean.annotation.TxIsolation;
65
import io.ebean.test.LoggedSql;
76
import io.ebean.xtest.BaseTestCase;
87
import io.ebean.xtest.ForPlatform;
8+
import io.ebean.xtest.IgnorePlatform;
99
import org.junit.jupiter.api.Test;
1010
import org.slf4j.Logger;
1111
import org.slf4j.LoggerFactory;
@@ -44,86 +44,86 @@ public void testForUpdate() {
4444
}
4545
}
4646

47-
48-
@ForPlatform(Platform.YUGABYTE)
49-
@Test
50-
void concurrentForUpdate() throws InterruptedException {
51-
ResetBasicData.reset();
52-
53-
Database db = DB.getDefault();
54-
Thread t1 = new Thread() {
55-
@Override
56-
public void run() {
57-
try (final Transaction transaction = db.createTransaction(TxIsolation.REPEATABLE_READ)) {
58-
log2.info("(REPEATABLE_READ) Thread: before find");
59-
List<Country> list = DB.find(Country.class)
60-
.usingTransaction(transaction)
61-
.forUpdate()
62-
.findList();
63-
64-
Country first = list.get(0);
65-
db.markAsDirty(first);
66-
db.save(first, transaction);
67-
68-
log2.info("(REPEATABLE_READ) Thread: after find - size:{}", list.size());
69-
try {
70-
Thread.sleep(3000);
71-
} catch (InterruptedException e) {
72-
throw new RuntimeException(e);
73-
}
74-
log2.info("(REPEATABLE_READ) Thread: done");
75-
}
76-
}
77-
};
78-
79-
t1.start();
80-
Thread.sleep(300);
81-
82-
long start = System.currentTimeMillis();
83-
try (final Transaction transaction = db.createTransaction(TxIsolation.REPEATABLE_READ)) {
84-
log2.info("(REPEATABLE_READ) Main: before find, should wait ...");
85-
DB.find(Country.class)
86-
.usingTransaction(transaction)
87-
.forUpdate()
88-
.findList();
89-
90-
log2.info("(REPEATABLE_READ) Main: complete");
91-
}
92-
93-
long exeMillis = System.currentTimeMillis() - start;
94-
assertThat(exeMillis).isGreaterThan(2500);
95-
}
96-
47+
// Nah, nothing to do with repeatable read here
48+
// @ForPlatform(Platform.YUGABYTE)
49+
// @Test
50+
// void concurrentForUpdate() throws InterruptedException {
51+
// ResetBasicData.reset();
52+
//
53+
// Database db = DB.getDefault();
54+
// Thread t1 = new Thread() {
55+
// @Override
56+
// public void run() {
57+
// try (final Transaction transaction = db.createTransaction(TxIsolation.REPEATABLE_READ)) {
58+
// log2.info("(REPEATABLE_READ) Thread: before find");
59+
// List<Country> list = DB.find(Country.class)
60+
// .usingTransaction(transaction)
61+
// .forUpdate()
62+
// .findList();
63+
//
64+
// Country first = list.get(0);
65+
// db.markAsDirty(first);
66+
// db.save(first, transaction);
67+
//
68+
// log2.info("(REPEATABLE_READ) Thread: after find - size:{}", list.size());
69+
// try {
70+
// Thread.sleep(3000);
71+
// } catch (InterruptedException e) {
72+
// throw new RuntimeException(e);
73+
// }
74+
// log2.info("(REPEATABLE_READ) Thread: done");
75+
// }
76+
// }
77+
// };
78+
//
79+
// t1.start();
80+
// Thread.sleep(300);
81+
//
82+
// long start = System.currentTimeMillis();
83+
// try (final Transaction transaction = db.createTransaction(TxIsolation.REPEATABLE_READ)) {
84+
// log2.info("(REPEATABLE_READ) Main: before find, should wait ...");
85+
// DB.find(Country.class)
86+
// .usingTransaction(transaction)
87+
// .forUpdate()
88+
// .findList();
89+
//
90+
// log2.info("(REPEATABLE_READ) Main: complete");
91+
// }
92+
//
93+
// long exeMillis = System.currentTimeMillis() - start;
94+
// assertThat(exeMillis).isGreaterThan(2500);
95+
// }
96+
97+
@IgnorePlatform(Platform.YUGABYTE) // ignore this for yugabyte and see if everything else passes
9798
@Test
9899
public void testConcurrentForUpdate() throws InterruptedException {
99100
ResetBasicData.reset();
100101

101102
Database db = DB.getDefault();
102-
Thread t1 = new Thread() {
103-
@Override
104-
public void run() {
105-
try (final Transaction transaction = db.createTransaction()) {
106-
log.info("Thread: before find");
107-
List<Customer> list = DB.find(Customer.class)
108-
.usingTransaction(transaction)
109-
.forUpdate()
110-
// .orderBy().desc("1") // this would help by the locks in DB2
111-
.findList();
112-
113-
Customer first = list.get(0);
114-
db.markAsDirty(first);
115-
db.save(first, transaction);
116-
117-
log.info("Thread: after find - size:{}", list.size());
118-
try {
119-
Thread.sleep(3000);
120-
} catch (InterruptedException e) {
121-
throw new RuntimeException(e);
122-
}
123-
log.info("Thread: done");
103+
Thread t1 = new Thread(() -> {
104+
try (final Transaction transaction = db.createTransaction()) {
105+
log.info("Thread: before find");
106+
List<Customer> list = DB.find(Customer.class)
107+
.usingTransaction(transaction)
108+
.forUpdate()
109+
// .orderBy().desc("1") // this would help by the locks in DB2
110+
.findList();
111+
112+
// yugabyte: performing an update does not change the behaviour
113+
Customer first = list.get(0);
114+
db.markAsDirty(first);
115+
db.save(first, transaction);
116+
117+
log.info("Thread: after find - size:{}", list.size());
118+
try {
119+
// hold onto the locks for 3 seconds, and then end the transaction
120+
Thread.sleep(3000);
121+
} catch (InterruptedException e) {
122+
throw new RuntimeException(e);
124123
}
124+
log.info("Thread: done");
125125
}
126-
};
126+
});
127127

128128
t1.start();
129129

0 commit comments

Comments
 (0)