-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Quickperf for simple performance testing with JDBC (#1619)
* feat:Adding Quickperf for simple performance testing with JDBC * Update samples/quickperf/src/main/java/com/google/cloud/jdbc/quickperf/ProgressTracker.java Co-authored-by: Knut Olav Løite <[email protected]> * Update samples/quickperf/src/main/java/com/google/cloud/jdbc/quickperf/QuickPerf.java Co-authored-by: Knut Olav Løite <[email protected]> * Update samples/quickperf/src/main/java/com/google/cloud/jdbc/quickperf/QuickPerf.java Co-authored-by: Knut Olav Løite <[email protected]> * Update samples/quickperf/readme.md Co-authored-by: Knut Olav Løite <[email protected]> * Update samples/quickperf/src/main/java/com/google/cloud/jdbc/quickperf/ProgressTracker.java Co-authored-by: Knut Olav Løite <[email protected]> * Update samples/quickperf/src/main/java/com/google/cloud/jdbc/quickperf/ProgressTracker.java Co-authored-by: Knut Olav Løite <[email protected]> * Update samples/quickperf/src/main/java/com/google/cloud/jdbc/quickperf/ProgressTracker.java Co-authored-by: Knut Olav Løite <[email protected]> * Updating based on review comments #1619 * Updating based on review comments * Incorporating additional changes from review #1619 * Split app into two classes to separate app driver and app following review feedback #1619 * fixed compilation issues * Update readme.md fixed markdown issues for indented bullet points * Update readme.md removed -Dexec.args from readme * Update QuickPerf.java separated thread init (for sampling) from thread execution * Update ProgressTracker.java added InterruptedException handling * chore: add parent pom and run code formatter * chore: cleanup some warnings + simplify test setup * test: add test runner for quickperf * chore: remove some more warnings * fix: include empty test file --------- Co-authored-by: Knut Olav Løite <[email protected]>
- Loading branch information
Showing
23 changed files
with
1,684 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# Github action job to test core java library features on | ||
# downstream client libraries before they are released. | ||
on: | ||
pull_request: | ||
name: quickperf | ||
jobs: | ||
quickperf: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
- name: Run tests | ||
run: mvn test | ||
working-directory: samples/quickperf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
target | ||
.vscode | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"project": "xxxx", | ||
"instance": "xxx", | ||
"database": "xxx", | ||
"threads": 1, | ||
"iterations": 100, | ||
"query": "SELECT 1", | ||
"writeMetricToFile": false | ||
} |
13 changes: 13 additions & 0 deletions
13
samples/quickperf/exampleconfigs/users/groupmgt_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"project": "xxx", | ||
"instance": "xxx", | ||
"database": "users", | ||
"threads": 4, | ||
"iterations": 250, | ||
"query": "INSERT INTO GroupMgmt (group_id, grpname) VALUES(?,?)", | ||
"writeMetricToFile": false, | ||
"queryParams": [ | ||
{"order": 1, "value": "#i"}, | ||
{"order": 2, "value": "#s"} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"project": "xxx", | ||
"instance": "xxx", | ||
"database": "users", | ||
"threads": 1, | ||
"iterations": 10, | ||
"query": "SELECT users.user_id, membership.enrolled, GroupMgmt.grpname FROM users, GroupMgmt, membership WHERE users.user_id = ? AND users.user_id = membership.user_id AND GroupMgmt.group_id = membership.group_id", | ||
"samplingQuery": "SELECT user_id FROM Users TABLESAMPLE RESERVOIR (100000 ROWS)", | ||
"writeMetricToFile": false, | ||
"queryParams": [ | ||
{"order": 1, "value": "#pi"} | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
samples/quickperf/exampleconfigs/users/membership_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"project": "xxx", | ||
"instance": "xxx", | ||
"database": "users", | ||
"threads": 1, | ||
"iterations": 100, | ||
"query": "INSERT INTO membership(user_id, group_id, enrolled) VALUES((SELECT user_id FROM Users TABLESAMPLE RESERVOIR (1 ROWS)), (SELECT group_id FROM GroupMgmt TABLESAMPLE RESERVOIR (1 ROWS)), CURRENT_TIMESTAMP())", | ||
"writeMetricToFile": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# Generate Data | ||
cd ../.. | ||
|
||
mvn -q compile | ||
|
||
mvn -q exec:java -Dexec.args="-c exampleconfigs/users/users_config.json" | ||
|
||
mvn -q exec:java -Dexec.args="-c exampleconfigs/users/groupmgt_config.json" | ||
|
||
mvn -q exec:java -Dexec.args="-c exampleconfigs/users/membership_config.json" | ||
|
||
# load test random users | ||
mvn -q exec:java -Dexec.args="-c exampleconfigs/users/loadtestusers.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CREATE TABLE GroupMgmt ( | ||
group_id INT64, | ||
grpname STRING(MAX), | ||
) PRIMARY KEY(group_id); | ||
|
||
CREATE TABLE Users ( | ||
user_id INT64, | ||
name STRING(MAX), | ||
) PRIMARY KEY(user_id); | ||
|
||
CREATE TABLE membership ( | ||
user_id INT64, | ||
group_id INT64, | ||
enrolled TIMESTAMP NOT NULL OPTIONS ( | ||
allow_commit_timestamp = true | ||
), | ||
) PRIMARY KEY(user_id, group_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"project": "xxx", | ||
"instance": "xxx", | ||
"database": "users", | ||
"threads": 1, | ||
"iterations": 1000, | ||
"query": "INSERT INTO Users (user_id, name) VALUES(?,?)", | ||
"writeMetricToFile": false, | ||
"queryParams": [ | ||
{"order": 1, "value": "#i"}, | ||
{"order": 2, "value": "#s"} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
^/\*$ | ||
^ \* Copyright \d\d\d\d,? Google (Inc\.|LLC)$ | ||
^ \*$ | ||
^ \* Licensed under the Apache License, Version 2\.0 \(the "License"\);$ | ||
^ \* you may not use this file except in compliance with the License\.$ | ||
^ \* You may obtain a copy of the License at$ | ||
^ \*$ | ||
^ \*[ ]+https?://www.apache.org/licenses/LICENSE-2\.0$ | ||
^ \*$ | ||
^ \* Unless required by applicable law or agreed to in writing, software$ | ||
^ \* distributed under the License is distributed on an "AS IS" BASIS,$ | ||
^ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.$ | ||
^ \* See the License for the specific language governing permissions and$ | ||
^ \* limitations under the License\.$ | ||
^ \*/$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE module PUBLIC | ||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN" | ||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> | ||
<module name="Checker"> | ||
<module name="RegexpHeader"> | ||
<property name="fileExtensions" value="java"/> | ||
<property name="headerFile" value="${checkstyle.header.file}"/> | ||
</module> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.google.cloud.jdbc.quickperf</groupId> | ||
<artifactId>jdbc-quickperf</artifactId> | ||
<version>1.0.0</version> | ||
<name>jdbc-quickperf</name> | ||
<parent> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>sdk-platform-java-config</artifactId> | ||
<version>3.34.0</version> | ||
<relativePath/> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>libraries-bom</artifactId> | ||
<version>26.43.0</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>net.datafaker</groupId> | ||
<artifactId>datafaker</artifactId> | ||
<version>2.3.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>google-cloud-spanner</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-cli</groupId> | ||
<artifactId>commons-cli</artifactId> | ||
<version>1.5.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>google-cloud-spanner-jdbc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.13.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.13.4.1</version> | ||
</dependency> | ||
<!-- Required for unit tests --> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>testcontainers</artifactId> | ||
<version>1.20.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot</artifactId> | ||
<version>3.2.5</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>3.1.0</version> | ||
<configuration> | ||
<mainClass>com.google.cloud.jdbc.quickperf.QuickPerf</mainClass> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Oops, something went wrong.