Skip to content

Commit

Permalink
Adding Missing Test cases and test case refactoring (cmu-db#144)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
timveil authored Apr 12, 2022
1 parent 59a7a7d commit 611b167
Show file tree
Hide file tree
Showing 68 changed files with 1,586 additions and 905 deletions.
14 changes: 1 addition & 13 deletions src/main/java/com/oltpbenchmark/api/TransactionTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.commons.collections4.map.ListOrderedMap;

import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

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

public TransactionTypes(List<TransactionType> transactiontypes) {
transactiontypes.sort(new Comparator<TransactionType>() {
@Override
public int compare(TransactionType o1, TransactionType o2) {
return o1.compareTo(o2);
}
});
transactiontypes.sort(TransactionType::compareTo);
for (TransactionType tt : transactiontypes) {
// System.err.println("Adding " + tt + " - " + this.types + " / " + transactiontypes);
String key = tt.getName().toUpperCase();
this.types.put(key, tt);
}
Expand Down Expand Up @@ -68,7 +61,6 @@ public boolean add(TransactionType tt) {

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

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

@Override
public boolean contains(Object o) {
// TODO Auto-generated method stub
return false;
}

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

@Override
public boolean remove(Object o) {
// TODO Auto-generated method stub
return false;
}

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ protected List<Worker<? extends BenchmarkModule>> makeWorkersImpl() {
int keyRange = numKeys / workConf.getTerminals();
LOG.warn("numkeys={}, keyRange={}", numKeys, keyRange);
// TODO: check ranges
for (int i = 0; i < workConf.getTerminals(); ++i) {
workers.add(new ResourceStresserWorker(this, i, numKeys, keyRange));
for (int i = 0; i < workConf.getTerminals(); i++) {
workers.add(new ResourceStresserWorker(this, i + 1, numKeys, keyRange));
}

return workers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void run(Connection conn, int howManyKeys, int howManyUpdates, int sleepL


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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void run(Connection conn, int myId, int howManyColsPerRow, int howManyUpd
int startingKey = myId * keyRange;

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

try (PreparedStatement stmt = this.getPreparedStatement(conn, ioUpdate)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,26 @@ public Object[][] run(Connection conn, String f_id) throws SQLException {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};


double base_price;
long seats_total;
long seats_left;
double seat_price;
double base_price = 0.0;
long seats_total = 0;
long seats_left = 0;
double seat_price = 0.0;

// First calculate the seat price using the flight's base price
// and the number of seats that remaining
try (PreparedStatement f_stmt = this.getPreparedStatement(conn, GetFlight)) {
f_stmt.setString(1, f_id);
try (ResultSet f_results = f_stmt.executeQuery()) {
f_results.next();

// long status = results[0].getLong(0);
base_price = f_results.getDouble(2);
seats_total = f_results.getLong(3);
seats_left = f_results.getLong(4);
seat_price = f_results.getDouble(5);
if (f_results.next()) {

// long status = results[0].getLong(0);
base_price = f_results.getDouble(2);
seats_total = f_results.getLong(3);
seats_left = f_results.getLong(4);
seat_price = f_results.getDouble(5);
} else {
LOG.warn("flight {} had no seats; this may be a data problem or a code problem. previously this threw an unhandled exception.", f_id);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ protected void loadFollowData(Connection conn, int lo, int hi) throws SQLExcepti

total++;
batchSize++;
f++;


if ((batchSize % workConf.getBatchSize()) == 0) {
followsInsert.executeBatch();
Expand All @@ -300,6 +300,8 @@ protected void loadFollowData(Connection conn, int lo, int hi) throws SQLExcepti
}
}
}

f++;
}
}
if (batchSize > 0) {
Expand Down
31 changes: 21 additions & 10 deletions src/main/java/com/oltpbenchmark/util/Histogram.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,6 @@ public Histogram(boolean keepZeroEntries) {
this.keep_zero_entries = keepZeroEntries;
}

@Override
public boolean equals(Object obj) {
if (obj instanceof Histogram<?>) {
Histogram<?> other = (Histogram<?>) obj;
return (this.histogram.equals(other.histogram));
}
return (false);
}

public boolean hasDebugLabels() {
return (this.debug_names != null && !this.debug_names.isEmpty());
}
Expand Down Expand Up @@ -204,7 +195,9 @@ private synchronized void calculateInternalValues() {
// Is this value the new min/max values?
if (this.min_value == null || this.min_value.compareTo(value) > 0) {
this.min_value = value;
} else if (this.max_value == null || this.max_value.compareTo(value) < 0) {
}

if (this.max_value == null || this.max_value.compareTo(value) < 0) {
this.max_value = value;
}

Expand All @@ -215,6 +208,7 @@ private synchronized void calculateInternalValues() {
this.min_count_values.add(value);
this.min_count = cnt;
}

if (cnt >= this.max_count) {
if (cnt > this.max_count) {
this.max_count_values.clear();
Expand Down Expand Up @@ -485,6 +479,23 @@ public boolean contains(X value) {
return (this.histogram.containsKey(value));
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Histogram<?> histogram1 = (Histogram<?>) o;
return Objects.equals(histogram, histogram1.histogram);
}

@Override
public int hashCode() {
return Objects.hash(histogram);
}

// ----------------------------------------------------------------------------
// DEBUG METHODS
// ----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/benchmarks/auctionmark/ddl-generic.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CREATE TABLE config_profile (
cfp_scale_factor FLOAT NOT NULL,
cfp_loader_start TIMESTAMP NOT NULL,
cfp_loader_stop TIMESTAMP NOT NULL,
cfp_user_item_histogram TEXT NOT NULL
cfp_user_item_histogram VARCHAR(1024) NOT NULL
);

-- ================================================================
Expand Down
22 changes: 12 additions & 10 deletions src/main/resources/benchmarks/chbenchmark/ddl-generic.sql
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
DROP TABLE IF EXISTS region;
DROP TABLE IF EXISTS nation;
DROP TABLE IF EXISTS supplier;
DROP TABLE IF EXISTS region CASCADE;
DROP TABLE IF EXISTS nation CASCADE;
DROP TABLE IF EXISTS supplier CASCADE;

create table region (
r_regionkey int not null,
r_name char(55) not null,
r_comment char(152) not null,
PRIMARY KEY ( r_regionkey )
create table region
(
r_regionkey int not null,
r_name char(55) not null,
r_comment char(152) not null,
PRIMARY KEY (r_regionkey)
);

create table nation (
n_nationkey int not null,
create table nation
(
n_nationkey int not null,
n_name char(25) not null,
n_regionkey int not null references region(r_regionkey) ON DELETE CASCADE,
n_comment char(152) not null,
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/benchmarks/epinions/ddl-generic.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
DROP TABLE IF EXISTS trust;
DROP TABLE IF EXISTS review;
DROP TABLE IF EXISTS review_rating;
DROP TABLE IF EXISTS useracct;
DROP TABLE IF EXISTS item;
DROP TABLE IF EXISTS trust CASCADE;
DROP TABLE IF EXISTS review CASCADE;
DROP TABLE IF EXISTS review_rating CASCADE;
DROP TABLE IF EXISTS useracct CASCADE;
DROP TABLE IF EXISTS item CASCADE;

CREATE TABLE useracct (
u_id int NOT NULL,
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/benchmarks/noop/dialect-hsqldb.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<dialects>
<dialect type="HSQLDB">
<procedure name="NoOp">
<statement name="noopStmt">
<![CDATA[SELECT 1]]>
</statement>
</procedure>
</dialect>
</dialects>
25 changes: 25 additions & 0 deletions src/main/resources/benchmarks/resourcestresser/dialect-hsqldb.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<dialects>
<dialect type="HSQLDB">
<procedure name="CPU1">
<statement name="cpuSelect">
<![CDATA[SELECT count(*) FROM (SELECT concat(concat(concat(concat(concat(passwd,?),?),?),?),?) FROM cputable WHERE empid >= 0 AND empid < 100) AS T1]]>
</statement>
</procedure>
<procedure name="CPU2">
<statement name="cpuSelect">
<![CDATA[SELECT count(*) FROM (SELECT concat(concat(concat(concat(concat(passwd,?),?),?),?),?) FROM cputable WHERE empid >= 0 AND empid < 100) AS T2]]>
</statement>
</procedure>
<procedure name="Contention1">
<statement name="lockSleep">
select 1 from locktable where empid = ?
</statement>
</procedure>
<procedure name="Contention2">
<statement name="lockSleep">
select 1 from locktable where empid = ?
</statement>
</procedure>
</dialect>
</dialects>
Loading

0 comments on commit 611b167

Please sign in to comment.