Skip to content

Commit b6bbd8f

Browse files
srozsnyaiolavloite
andauthored
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]>
1 parent 6881512 commit b6bbd8f

23 files changed

+1684
-0
lines changed

.github/workflows/quickperf.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# Github action job to test core java library features on
15+
# downstream client libraries before they are released.
16+
on:
17+
pull_request:
18+
name: quickperf
19+
jobs:
20+
quickperf:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-java@v4
25+
with:
26+
distribution: temurin
27+
java-version: 17
28+
- name: Run tests
29+
run: mvn test
30+
working-directory: samples/quickperf

samples/quickperf/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
target
2+
.vscode
3+
.DS_Store
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"project": "xxxx",
3+
"instance": "xxx",
4+
"database": "xxx",
5+
"threads": 1,
6+
"iterations": 100,
7+
"query": "SELECT 1",
8+
"writeMetricToFile": false
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"project": "xxx",
3+
"instance": "xxx",
4+
"database": "users",
5+
"threads": 4,
6+
"iterations": 250,
7+
"query": "INSERT INTO GroupMgmt (group_id, grpname) VALUES(?,?)",
8+
"writeMetricToFile": false,
9+
"queryParams": [
10+
{"order": 1, "value": "#i"},
11+
{"order": 2, "value": "#s"}
12+
]
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"project": "xxx",
3+
"instance": "xxx",
4+
"database": "users",
5+
"threads": 1,
6+
"iterations": 10,
7+
"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",
8+
"samplingQuery": "SELECT user_id FROM Users TABLESAMPLE RESERVOIR (100000 ROWS)",
9+
"writeMetricToFile": false,
10+
"queryParams": [
11+
{"order": 1, "value": "#pi"}
12+
]
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"project": "xxx",
3+
"instance": "xxx",
4+
"database": "users",
5+
"threads": 1,
6+
"iterations": 100,
7+
"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())",
8+
"writeMetricToFile": false
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Generate Data
4+
cd ../..
5+
6+
mvn -q compile
7+
8+
mvn -q exec:java -Dexec.args="-c exampleconfigs/users/users_config.json"
9+
10+
mvn -q exec:java -Dexec.args="-c exampleconfigs/users/groupmgt_config.json"
11+
12+
mvn -q exec:java -Dexec.args="-c exampleconfigs/users/membership_config.json"
13+
14+
# load test random users
15+
mvn -q exec:java -Dexec.args="-c exampleconfigs/users/loadtestusers.json"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CREATE TABLE GroupMgmt (
2+
group_id INT64,
3+
grpname STRING(MAX),
4+
) PRIMARY KEY(group_id);
5+
6+
CREATE TABLE Users (
7+
user_id INT64,
8+
name STRING(MAX),
9+
) PRIMARY KEY(user_id);
10+
11+
CREATE TABLE membership (
12+
user_id INT64,
13+
group_id INT64,
14+
enrolled TIMESTAMP NOT NULL OPTIONS (
15+
allow_commit_timestamp = true
16+
),
17+
) PRIMARY KEY(user_id, group_id);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"project": "xxx",
3+
"instance": "xxx",
4+
"database": "users",
5+
"threads": 1,
6+
"iterations": 1000,
7+
"query": "INSERT INTO Users (user_id, name) VALUES(?,?)",
8+
"writeMetricToFile": false,
9+
"queryParams": [
10+
{"order": 1, "value": "#i"},
11+
{"order": 2, "value": "#s"}
12+
]
13+
}

samples/quickperf/java.header

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
^/\*$
2+
^ \* Copyright \d\d\d\d,? Google (Inc\.|LLC)$
3+
^ \*$
4+
^ \* Licensed under the Apache License, Version 2\.0 \(the "License"\);$
5+
^ \* you may not use this file except in compliance with the License\.$
6+
^ \* You may obtain a copy of the License at$
7+
^ \*$
8+
^ \*[ ]+https?://www.apache.org/licenses/LICENSE-2\.0$
9+
^ \*$
10+
^ \* Unless required by applicable law or agreed to in writing, software$
11+
^ \* distributed under the License is distributed on an "AS IS" BASIS,$
12+
^ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.$
13+
^ \* See the License for the specific language governing permissions and$
14+
^ \* limitations under the License\.$
15+
^ \*/$

samples/quickperf/license-checks.xml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
4+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
5+
<module name="Checker">
6+
<module name="RegexpHeader">
7+
<property name="fileExtensions" value="java"/>
8+
<property name="headerFile" value="${checkstyle.header.file}"/>
9+
</module>
10+
</module>

samples/quickperf/pom.xml

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<groupId>com.google.cloud.jdbc.quickperf</groupId>
9+
<artifactId>jdbc-quickperf</artifactId>
10+
<version>1.0.0</version>
11+
<name>jdbc-quickperf</name>
12+
<parent>
13+
<groupId>com.google.cloud</groupId>
14+
<artifactId>sdk-platform-java-config</artifactId>
15+
<version>3.34.0</version>
16+
<relativePath/>
17+
</parent>
18+
19+
<properties>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
<maven.compiler.source>1.8</maven.compiler.source>
22+
<maven.compiler.target>1.8</maven.compiler.target>
23+
</properties>
24+
25+
<dependencyManagement>
26+
<dependencies>
27+
<dependency>
28+
<groupId>com.google.cloud</groupId>
29+
<artifactId>libraries-bom</artifactId>
30+
<version>26.43.0</version>
31+
<type>pom</type>
32+
<scope>import</scope>
33+
</dependency>
34+
</dependencies>
35+
</dependencyManagement>
36+
37+
<dependencies>
38+
<dependency>
39+
<groupId>net.datafaker</groupId>
40+
<artifactId>datafaker</artifactId>
41+
<version>2.3.1</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>com.google.cloud</groupId>
45+
<artifactId>google-cloud-spanner</artifactId>
46+
</dependency>
47+
<dependency>
48+
<groupId>commons-cli</groupId>
49+
<artifactId>commons-cli</artifactId>
50+
<version>1.5.0</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>com.google.cloud</groupId>
54+
<artifactId>google-cloud-spanner-jdbc</artifactId>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.apache.commons</groupId>
58+
<artifactId>commons-lang3</artifactId>
59+
<version>3.13.0</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>com.fasterxml.jackson.core</groupId>
63+
<artifactId>jackson-databind</artifactId>
64+
<version>2.13.4.1</version>
65+
</dependency>
66+
<!-- Required for unit tests -->
67+
<dependency>
68+
<groupId>org.testcontainers</groupId>
69+
<artifactId>testcontainers</artifactId>
70+
<version>1.20.1</version>
71+
<scope>test</scope>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.springframework.boot</groupId>
75+
<artifactId>spring-boot</artifactId>
76+
<version>3.2.5</version>
77+
<scope>test</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>junit</groupId>
81+
<artifactId>junit</artifactId>
82+
<version>4.13.1</version>
83+
<scope>test</scope>
84+
</dependency>
85+
</dependencies>
86+
87+
<build>
88+
<plugins>
89+
<plugin>
90+
<groupId>org.codehaus.mojo</groupId>
91+
<artifactId>exec-maven-plugin</artifactId>
92+
<version>3.1.0</version>
93+
<configuration>
94+
<mainClass>com.google.cloud.jdbc.quickperf.QuickPerf</mainClass>
95+
</configuration>
96+
</plugin>
97+
</plugins>
98+
</build>
99+
100+
</project>

0 commit comments

Comments
 (0)