From 8ce37b68286f80185f191e166365e6d79d94fa14 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:24:57 -0600 Subject: [PATCH 1/3] Bump actions/setup-java from 3 to 4 in /.github/workflows (#400) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3 to 4. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/maven.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4036e97bf..291b849a2 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -44,7 +44,7 @@ jobs: uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{env.JAVA_VERSION}} cache: 'maven' @@ -64,7 +64,7 @@ jobs: uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{env.JAVA_VERSION}} cache: 'maven' @@ -105,7 +105,7 @@ jobs: rm -rf benchbase-sqlite.tgz - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{env.JAVA_VERSION}} distribution: 'temurin' @@ -175,7 +175,7 @@ jobs: rm -rf benchbase-mariadb.tgz - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{env.JAVA_VERSION}} distribution: 'temurin' @@ -243,7 +243,7 @@ jobs: rm -rf benchbase-mysql.tgz - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{env.JAVA_VERSION}} distribution: 'temurin' @@ -310,7 +310,7 @@ jobs: rm -rf benchbase-postgres.tgz - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{env.JAVA_VERSION}} distribution: 'temurin' @@ -370,7 +370,7 @@ jobs: rm -rf benchbase-cockroachdb.tgz - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{env.JAVA_VERSION}} distribution: 'temurin' @@ -427,7 +427,7 @@ jobs: rm -rf benchbase-sqlserver.tgz - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: ${{env.JAVA_VERSION}} distribution: 'temurin' From 1f57a5c996725a70c079adc9c1250fe8947f3ce8 Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Sat, 2 Dec 2023 08:08:39 +1000 Subject: [PATCH 2/3] Splitting otmetrics fix from #379 (#396) * Splitting otmetrics close stmt from #379 * Add CONTRIBUTORS for traceable copyright attribution --------- Co-authored-by: Brian Kroth --- CONTRIBUTORS.md | 3 ++- .../benchmarks/otmetrics/procedures/GetSessionRange.java | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9a4cbeb43..f7b337852 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -19,4 +19,5 @@ We also acknowledge contributions from the following collaborators: + [Florian Funke](http://www3.in.tum.de/~funkef/) -+ [Michael Seibold](http://www3.in.tum.de/~seibold/) \ No newline at end of file ++ [Michael Seibold](http://www3.in.tum.de/~seibold/) ++ [Oracle](https://github.com/oracle) (Copyright (c) 2023, Oracle and/or its affiliates.) diff --git a/src/main/java/com/oltpbenchmark/benchmarks/otmetrics/procedures/GetSessionRange.java b/src/main/java/com/oltpbenchmark/benchmarks/otmetrics/procedures/GetSessionRange.java index 171d543db..e79877ba2 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/otmetrics/procedures/GetSessionRange.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/otmetrics/procedures/GetSessionRange.java @@ -70,6 +70,8 @@ public List run(Connection conn, int source_id, int session_low, int s finalResults.add(arr); } } + stmt.close(); + return (finalResults); } From ba2ac513b2385ac2c762d0c9f45265c3dadb869d Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Wed, 6 Dec 2023 01:36:11 +1000 Subject: [PATCH 3/3] After load functionality with test (#397) Splitting after load functionality needed for Oracle config from PR https://github.com/cmu-db/benchbase/pull/379. Add an after load option for benchmark configs. Benchmark configs can add an afterload tag specifying a path to an SQL file in resources. This file will be executed after loading database. Tested in `AbstractTestLoad.testLoadWithAfterLoad()` --------- Co-authored-by: Brian Kroth --- .../java/com/oltpbenchmark/DBWorkload.java | 7 ++++- .../oltpbenchmark/api/BenchmarkModule.java | 26 ++++++++++++++++- .../oltpbenchmark/api/AbstractTestLoader.java | 29 ++++++++++++++++--- src/test/resources/after-load.sql | 8 +++++ 4 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 src/test/resources/after-load.sql diff --git a/src/main/java/com/oltpbenchmark/DBWorkload.java b/src/main/java/com/oltpbenchmark/DBWorkload.java index 15b05fddc..46231c0e7 100644 --- a/src/main/java/com/oltpbenchmark/DBWorkload.java +++ b/src/main/java/com/oltpbenchmark/DBWorkload.java @@ -214,6 +214,11 @@ public static void main(String[] args) throws Exception { postExecutionWait = xmlConfig.getLong(key + "/postExecutionWait"); } + // After load + if (xmlConfig.containsKey("afterload")) { + bench.setAfterLoadScriptPath(xmlConfig.getString("afterload")); + } + TransactionType tmpType = bench.initTransactionType(txnName, txnId + txnIdOffset, preExecutionWait, postExecutionWait); // Keep a reference for filtering @@ -626,7 +631,7 @@ private static void runCreator(BenchmarkModule bench) throws SQLException, IOExc bench.createDatabase(); } - private static void runLoader(BenchmarkModule bench) throws SQLException, InterruptedException { + private static void runLoader(BenchmarkModule bench) throws IOException, SQLException, InterruptedException { LOG.debug(String.format("Loading %s Database", bench)); bench.loadDatabase(); } diff --git a/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java b/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java index 247546483..dcac10cf6 100644 --- a/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java +++ b/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java @@ -104,6 +104,16 @@ public final Connection makeConnection() throws SQLException { } } + private String afterLoadScriptPath = null; + + public final void setAfterLoadScriptPath(String scriptPath) { + this.afterLoadScriptPath = scriptPath; + } + + public String getAfterLoadScriptPath() { + return this.afterLoadScriptPath; + } + // -------------------------------------------------------------------------- // IMPLEMENTING CLASS INTERFACE // -------------------------------------------------------------------------- @@ -248,11 +258,19 @@ public final void createDatabase(DatabaseType dbType, Connection conn) throws SQ } } + public final void runScript(String scriptPath) throws SQLException, IOException { + try (Connection conn = this.makeConnection()) { + DatabaseType dbType = this.workConf.getDatabaseType(); + ScriptRunner runner = new ScriptRunner(conn, true, true); + LOG.debug("Executing script [{}] for database type [{}]", scriptPath, dbType); + runner.runScript(scriptPath); + } + } /** * Invoke this benchmark's database loader */ - public final Loader loadDatabase() throws SQLException, InterruptedException { + public final Loader loadDatabase() throws IOException, SQLException, InterruptedException { Loader loader; loader = this.makeLoaderImpl(); @@ -275,6 +293,12 @@ public final Loader loadDatabase() throws SQLExceptio } } + if (this.afterLoadScriptPath != null) { + LOG.debug("Running script after load for {} benchmark...", this.workConf.getBenchmarkName().toUpperCase()); + runScript(this.afterLoadScriptPath); + LOG.debug("Finished running script after load for {} benchmark...", this.workConf.getBenchmarkName().toUpperCase()); + } + return loader; } diff --git a/src/test/java/com/oltpbenchmark/api/AbstractTestLoader.java b/src/test/java/com/oltpbenchmark/api/AbstractTestLoader.java index 9e17fb305..cbfc7bc75 100644 --- a/src/test/java/com/oltpbenchmark/api/AbstractTestLoader.java +++ b/src/test/java/com/oltpbenchmark/api/AbstractTestLoader.java @@ -17,10 +17,6 @@ package com.oltpbenchmark.api; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import com.oltpbenchmark.catalog.Table; import com.oltpbenchmark.util.Histogram; import com.oltpbenchmark.util.SQLUtil; @@ -28,11 +24,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.List; +import static org.junit.Assert.*; +import static org.junit.Assert.fail; + public abstract class AbstractTestLoader extends AbstractTestCase { private static final Logger LOG = LoggerFactory.getLogger(AbstractTestLoader.class); @@ -58,6 +58,27 @@ public void testLoad() throws Exception { } + /** + * testLoad with after load script + */ + @Test + public void testLoadWithAfterLoad() throws Exception { + this.benchmark.setAfterLoadScriptPath("/after-load.sql"); + + this.benchmark.loadDatabase(); + + // A table called extra is added with after-load, with one entry zero + try (PreparedStatement stmt = conn.prepareStatement("SELECT * FROM extra"); ResultSet rs = stmt.executeQuery()) { + while (rs.next()) { + assertEquals("Table 'extra' from after-load.sql has value different than 0", rs.getInt(1), 0); + } + } catch (Exception e) { + fail("Table 'extra' from after-load.sql was not created"); + } + + validateLoad(); + } + private void validateLoad() throws SQLException { assertFalse("Failed to get table names for " + benchmark.getBenchmarkName().toUpperCase(), this.catalog.getTables().isEmpty()); diff --git a/src/test/resources/after-load.sql b/src/test/resources/after-load.sql new file mode 100644 index 000000000..56183925a --- /dev/null +++ b/src/test/resources/after-load.sql @@ -0,0 +1,8 @@ +DROP TABLE IF EXISTS extra CASCADE; + +CREATE TABLE extra ( + extra_pk int NOT NULL, + PRIMARY KEY (extra_pk) +); + +INSERT INTO extra VALUES (0);