File tree Expand file tree Collapse file tree
src/test/java/com/taosdata/jdbc Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828 maven : [ '3.6.3' ]
2929 runs-on : ${{ matrix.os }}
3030 steps :
31+ # 设置系统级时区为 UTC
32+ - name : Set system timezone to UTC
33+ run : |
34+ sudo timedatectl set-timezone UTC
35+ echo "Current system timezone: $(timedatectl | grep "Time zone")"
36+
3137 - name : checkout TDengine
3238 uses : actions/checkout@v3
3339 with :
@@ -67,11 +73,21 @@ jobs:
6773 java-version : ${{ matrix.java }}
6874 java-package : jdk
6975
76+ # 设置 JVM 时区为 UTC
7077 - name : Test
7178 working-directory : jdbc-workspace
7279 env :
7380 TDENGINE_CLOUD_URL : ${{ secrets.TDENGINE_CLOUD_URL }}
74- run : mvn -B clean verify --file pom.xml
81+ # 设置 JVM 时区参数
82+ MAVEN_OPTS : " -Duser.timezone=UTC"
83+ run : |
84+ # 验证系统时区
85+ echo "System timezone: $(date +'%Z %z')"
86+ # 验证 Java 时区
87+ java -XshowSettings:properties -version 2>&1 | grep user.timezone
88+ # 运行测试
89+ mvn -B clean verify --file pom.xml
90+
7591
7692 - name : Upload coverage to Codecov
7793 uses : codecov/codecov-action@v4
Original file line number Diff line number Diff line change 2828 maven : [ '3.6.3' ]
2929 runs-on : ${{ matrix.os }}
3030 steps :
31+ # 设置系统级时区为 UTC
32+ - name : Set system timezone to UTC
33+ run : |
34+ sudo timedatectl set-timezone UTC
35+ echo "Current system timezone: $(timedatectl | grep "Time zone")"
36+
3137 - name : get TDengine
3238 run : |
3339 wget https://github.com/taosdata/TDengine/releases/download/ver-3.3.6.0/TDengine-server-3.3.6.0-Linux-x64.tar.gz
@@ -62,11 +68,18 @@ jobs:
6268 java-version : ${{ matrix.java }}
6369 java-package : jdk
6470
71+ # 设置 JVM 时区为 UTC
6572 - name : Test
6673 working-directory : jdbc-workspace
6774 env :
6875 TDENGINE_CLOUD_URL : ${{ secrets.TDENGINE_CLOUD_URL }}
69- run : mvn -B clean verify --file pom.xml
70-
71-
76+ # 设置 JVM 时区参数
77+ MAVEN_OPTS : " -Duser.timezone=UTC"
78+ run : |
79+ # 验证系统时区
80+ echo "System timezone: $(date +'%Z %z')"
81+ # 验证 Java 时区
82+ java -XshowSettings:properties -version 2>&1 | grep user.timezone
83+ # 运行测试
84+ mvn -B clean verify --file pom.xml
7285
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ public void getColumnsColumn() throws SQLException {
121121 tables .add (columns .getString ("TABLE_NAME" ));
122122 count ++;
123123 }
124- Assert .assertEquals ( 3 , count );
124+ Assert .assertTrue ( count >= 3 );
125125 Assert .assertTrue (dbs .contains ("information_schema" ));
126126 Assert .assertTrue (tables .contains ("ins_tables" ));
127127 Assert .assertFalse (dbs .contains ("performance_schema" ));
Original file line number Diff line number Diff line change @@ -37,6 +37,26 @@ private static void testInsert() throws SQLException {
3737 statement .close ();
3838 }
3939
40+ @ Test
41+ public void testGetTZ () throws SQLException {
42+ String url = "jdbc:TAOS-WS://" + host + ":" + port + "/?user=root&password=taosdata" ;
43+
44+ Properties properties = new Properties ();
45+ try ( Connection connection = DriverManager .getConnection (url , properties );
46+ Statement statement = connection .createStatement ();
47+ ResultSet resultSet = statement .executeQuery ("show variables" )) {
48+
49+ while (resultSet .next ()) {
50+ System .out .println ("name: " + resultSet .getString ("name" ));
51+ System .out .println ("value: " + resultSet .getString ("value" ));
52+ }
53+
54+ // print the timezone of jvm
55+ String jvmTimeZone = System .getProperty ("user.timezone" );
56+ System .out .println ("JVM Time Zone: " + jvmTimeZone );
57+ }
58+ }
59+
4060 @ Test
4161 public void testWSSelect () throws SQLException {
4262 Statement statement = connection .createStatement ();
You can’t perform that action at this time.
0 commit comments