Skip to content

Commit 611b167

Browse files
authored
Adding Missing Test cases and test case refactoring (#144)
* working on cleaning up and adding missing tests * working on resourcestresser and tpch * fixed tpch * twitter test case broken until config refactor is merged * adding back mockbenchmark * in low SF runs here the entrySet size is only 1, then `this.max_value` is never set. think this is a bug * moving collection of procedure classes from HashSet back to List to preserve ordering; also reducing logging output * applyed custom SF to TPCHWorker only to improve run time down from 14 minutes to 6 seconds * toning down some logging * cleaning up logging. starting hsqldb on random port to avoid port rare but possible port conflicts; also waiting during stop incase there is a problem brining hsqldb down * fixing some test flakes * making change to NoOp based on feedback from @pavlo * updating logging to capture test name * fixing conflict * fixing conflict
1 parent 59a7a7d commit 611b167

File tree

68 files changed

+1586
-905
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1586
-905
lines changed

src/main/java/com/oltpbenchmark/api/TransactionTypes.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.apache.commons.collections4.map.ListOrderedMap;
2121

2222
import java.util.Collection;
23-
import java.util.Comparator;
2423
import java.util.Iterator;
2524
import java.util.List;
2625

@@ -29,14 +28,8 @@ public class TransactionTypes implements Collection<TransactionType> {
2928
private final ListOrderedMap<String, TransactionType> types = new ListOrderedMap<>();
3029

3130
public TransactionTypes(List<TransactionType> transactiontypes) {
32-
transactiontypes.sort(new Comparator<TransactionType>() {
33-
@Override
34-
public int compare(TransactionType o1, TransactionType o2) {
35-
return o1.compareTo(o2);
36-
}
37-
});
31+
transactiontypes.sort(TransactionType::compareTo);
3832
for (TransactionType tt : transactiontypes) {
39-
// System.err.println("Adding " + tt + " - " + this.types + " / " + transactiontypes);
4033
String key = tt.getName().toUpperCase();
4134
this.types.put(key, tt);
4235
}
@@ -68,7 +61,6 @@ public boolean add(TransactionType tt) {
6861

6962
@Override
7063
public boolean addAll(Collection<? extends TransactionType> c) {
71-
// TODO Auto-generated method stub
7264
return false;
7365
}
7466

@@ -79,7 +71,6 @@ public void clear() {
7971

8072
@Override
8173
public boolean contains(Object o) {
82-
// TODO Auto-generated method stub
8374
return false;
8475
}
8576

@@ -100,19 +91,16 @@ public Iterator<TransactionType> iterator() {
10091

10192
@Override
10293
public boolean remove(Object o) {
103-
// TODO Auto-generated method stub
10494
return false;
10595
}
10696

10797
@Override
10898
public boolean removeAll(Collection<?> c) {
109-
// TODO Auto-generated method stub
11099
return false;
111100
}
112101

113102
@Override
114103
public boolean retainAll(Collection<?> c) {
115-
// TODO Auto-generated method stub
116104
return false;
117105
}
118106

src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/ResourceStresserBenchmark.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ protected List<Worker<? extends BenchmarkModule>> makeWorkersImpl() {
4848
int keyRange = numKeys / workConf.getTerminals();
4949
LOG.warn("numkeys={}, keyRange={}", numKeys, keyRange);
5050
// TODO: check ranges
51-
for (int i = 0; i < workConf.getTerminals(); ++i) {
52-
workers.add(new ResourceStresserWorker(this, i, numKeys, keyRange));
51+
for (int i = 0; i < workConf.getTerminals(); i++) {
52+
workers.add(new ResourceStresserWorker(this, i + 1, numKeys, keyRange));
5353
}
5454

5555
return workers;

src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/Contention2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void run(Connection conn, int howManyKeys, int howManyUpdates, int sleepL
4242

4343

4444
for (int sel = 0; sel < howManyUpdates; ++sel) {
45-
int leftKey = ResourceStresserWorker.gen.nextInt(numKeys - howManyKeys);
45+
int leftKey = ResourceStresserWorker.gen.nextInt(Math.max(1, numKeys - howManyKeys));
4646
int rightKey = leftKey + howManyKeys;
4747
int salary = ResourceStresserWorker.gen.nextInt();
4848

src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/IO1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void run(Connection conn, int myId, int howManyColsPerRow, int howManyUpd
4949
int startingKey = myId * keyRange;
5050

5151
for (int up = 0; up < howManyUpdatesPerTransaction; ++up) {
52-
int leftKey = ResourceStresserWorker.gen.nextInt(keyRange - howManyRowsPerUpdate) + startingKey;
52+
int leftKey = ResourceStresserWorker.gen.nextInt(Math.max(1, keyRange - howManyRowsPerUpdate)) + startingKey;
5353
int rightKey = leftKey + howManyRowsPerUpdate;
5454

5555
try (PreparedStatement stmt = this.getPreparedStatement(conn, ioUpdate)) {

src/main/java/com/oltpbenchmark/benchmarks/seats/procedures/FindOpenSeats.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,26 @@ public Object[][] run(Connection conn, String f_id) throws SQLException {
8383
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
8484

8585

86-
double base_price;
87-
long seats_total;
88-
long seats_left;
89-
double seat_price;
86+
double base_price = 0.0;
87+
long seats_total = 0;
88+
long seats_left = 0;
89+
double seat_price = 0.0;
9090

9191
// First calculate the seat price using the flight's base price
9292
// and the number of seats that remaining
9393
try (PreparedStatement f_stmt = this.getPreparedStatement(conn, GetFlight)) {
9494
f_stmt.setString(1, f_id);
9595
try (ResultSet f_results = f_stmt.executeQuery()) {
96-
f_results.next();
97-
98-
// long status = results[0].getLong(0);
99-
base_price = f_results.getDouble(2);
100-
seats_total = f_results.getLong(3);
101-
seats_left = f_results.getLong(4);
102-
seat_price = f_results.getDouble(5);
96+
if (f_results.next()) {
97+
98+
// long status = results[0].getLong(0);
99+
base_price = f_results.getDouble(2);
100+
seats_total = f_results.getLong(3);
101+
seats_left = f_results.getLong(4);
102+
seat_price = f_results.getDouble(5);
103+
} else {
104+
LOG.warn("flight {} had no seats; this may be a data problem or a code problem. previously this threw an unhandled exception.", f_id);
105+
}
103106
}
104107
}
105108

src/main/java/com/oltpbenchmark/benchmarks/twitter/TwitterLoader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ protected void loadFollowData(Connection conn, int lo, int hi) throws SQLExcepti
287287

288288
total++;
289289
batchSize++;
290-
f++;
290+
291291

292292
if ((batchSize % workConf.getBatchSize()) == 0) {
293293
followsInsert.executeBatch();
@@ -300,6 +300,8 @@ protected void loadFollowData(Connection conn, int lo, int hi) throws SQLExcepti
300300
}
301301
}
302302
}
303+
304+
f++;
303305
}
304306
}
305307
if (batchSize > 0) {

src/main/java/com/oltpbenchmark/util/Histogram.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,6 @@ public Histogram(boolean keepZeroEntries) {
9595
this.keep_zero_entries = keepZeroEntries;
9696
}
9797

98-
@Override
99-
public boolean equals(Object obj) {
100-
if (obj instanceof Histogram<?>) {
101-
Histogram<?> other = (Histogram<?>) obj;
102-
return (this.histogram.equals(other.histogram));
103-
}
104-
return (false);
105-
}
106-
10798
public boolean hasDebugLabels() {
10899
return (this.debug_names != null && !this.debug_names.isEmpty());
109100
}
@@ -204,7 +195,9 @@ private synchronized void calculateInternalValues() {
204195
// Is this value the new min/max values?
205196
if (this.min_value == null || this.min_value.compareTo(value) > 0) {
206197
this.min_value = value;
207-
} else if (this.max_value == null || this.max_value.compareTo(value) < 0) {
198+
}
199+
200+
if (this.max_value == null || this.max_value.compareTo(value) < 0) {
208201
this.max_value = value;
209202
}
210203

@@ -215,6 +208,7 @@ private synchronized void calculateInternalValues() {
215208
this.min_count_values.add(value);
216209
this.min_count = cnt;
217210
}
211+
218212
if (cnt >= this.max_count) {
219213
if (cnt > this.max_count) {
220214
this.max_count_values.clear();
@@ -485,6 +479,23 @@ public boolean contains(X value) {
485479
return (this.histogram.containsKey(value));
486480
}
487481

482+
@Override
483+
public boolean equals(Object o) {
484+
if (this == o) {
485+
return true;
486+
}
487+
if (o == null || getClass() != o.getClass()) {
488+
return false;
489+
}
490+
Histogram<?> histogram1 = (Histogram<?>) o;
491+
return Objects.equals(histogram, histogram1.histogram);
492+
}
493+
494+
@Override
495+
public int hashCode() {
496+
return Objects.hash(histogram);
497+
}
498+
488499
// ----------------------------------------------------------------------------
489500
// DEBUG METHODS
490501
// ----------------------------------------------------------------------------

src/main/resources/benchmarks/auctionmark/ddl-generic.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CREATE TABLE config_profile (
2323
cfp_scale_factor FLOAT NOT NULL,
2424
cfp_loader_start TIMESTAMP NOT NULL,
2525
cfp_loader_stop TIMESTAMP NOT NULL,
26-
cfp_user_item_histogram TEXT NOT NULL
26+
cfp_user_item_histogram VARCHAR(1024) NOT NULL
2727
);
2828

2929
-- ================================================================

src/main/resources/benchmarks/chbenchmark/ddl-generic.sql

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
DROP TABLE IF EXISTS region;
2-
DROP TABLE IF EXISTS nation;
3-
DROP TABLE IF EXISTS supplier;
1+
DROP TABLE IF EXISTS region CASCADE;
2+
DROP TABLE IF EXISTS nation CASCADE;
3+
DROP TABLE IF EXISTS supplier CASCADE;
44

5-
create table region (
6-
r_regionkey int not null,
7-
r_name char(55) not null,
8-
r_comment char(152) not null,
9-
PRIMARY KEY ( r_regionkey )
5+
create table region
6+
(
7+
r_regionkey int not null,
8+
r_name char(55) not null,
9+
r_comment char(152) not null,
10+
PRIMARY KEY (r_regionkey)
1011
);
1112

12-
create table nation (
13-
n_nationkey int not null,
13+
create table nation
14+
(
15+
n_nationkey int not null,
1416
n_name char(25) not null,
1517
n_regionkey int not null references region(r_regionkey) ON DELETE CASCADE,
1618
n_comment char(152) not null,

src/main/resources/benchmarks/epinions/ddl-generic.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
DROP TABLE IF EXISTS trust;
2-
DROP TABLE IF EXISTS review;
3-
DROP TABLE IF EXISTS review_rating;
4-
DROP TABLE IF EXISTS useracct;
5-
DROP TABLE IF EXISTS item;
1+
DROP TABLE IF EXISTS trust CASCADE;
2+
DROP TABLE IF EXISTS review CASCADE;
3+
DROP TABLE IF EXISTS review_rating CASCADE;
4+
DROP TABLE IF EXISTS useracct CASCADE;
5+
DROP TABLE IF EXISTS item CASCADE;
66

77
CREATE TABLE useracct (
88
u_id int NOT NULL,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<dialects>
3+
<dialect type="HSQLDB">
4+
<procedure name="NoOp">
5+
<statement name="noopStmt">
6+
<![CDATA[SELECT 1]]>
7+
</statement>
8+
</procedure>
9+
</dialect>
10+
</dialects>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<dialects>
3+
<dialect type="HSQLDB">
4+
<procedure name="CPU1">
5+
<statement name="cpuSelect">
6+
<![CDATA[SELECT count(*) FROM (SELECT concat(concat(concat(concat(concat(passwd,?),?),?),?),?) FROM cputable WHERE empid >= 0 AND empid < 100) AS T1]]>
7+
</statement>
8+
</procedure>
9+
<procedure name="CPU2">
10+
<statement name="cpuSelect">
11+
<![CDATA[SELECT count(*) FROM (SELECT concat(concat(concat(concat(concat(passwd,?),?),?),?),?) FROM cputable WHERE empid >= 0 AND empid < 100) AS T2]]>
12+
</statement>
13+
</procedure>
14+
<procedure name="Contention1">
15+
<statement name="lockSleep">
16+
select 1 from locktable where empid = ?
17+
</statement>
18+
</procedure>
19+
<procedure name="Contention2">
20+
<statement name="lockSleep">
21+
select 1 from locktable where empid = ?
22+
</statement>
23+
</procedure>
24+
</dialect>
25+
</dialects>

0 commit comments

Comments
 (0)