Skip to content

Commit aec8467

Browse files
authored
Merge pull request #3 from loiclefevre/2
2 - ability to choose the connection string format between easy-connect and tns
2 parents f620f11 + e69c796 commit aec8467

8 files changed

Lines changed: 66 additions & 27 deletions

File tree

.github/workflows/cicd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
- uses: graalvm/setup-graalvm@v1
3939
with:
40-
java-version: '23'
40+
java-version: '25'
4141
distribution: 'graalvm'
4242
github-token: ${{ secrets.GITHUB_TOKEN }}
4343
# cache: 'maven'

README.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
:linkattrs:
33
:project-owner: oracle-actions
44
:project-name: setup-testpilot
5-
:project-tag: v1.0.23
5+
:project-tag: v1.0.24
66

77
ifdef::env-github[]
88
:tip-caption: :bulb:
@@ -37,6 +37,7 @@ Following inputs may be used as `step.with` keys:
3737
| oci-service | | autonomous-transaction-processing-serverless-26ai | A valid Oracle Cloud Infrastructure service to be tested.
3838
Valid OCI service are: `autonomous-transaction-processing-serverless-19c`, `autonomous-transaction-processing-serverless-26ai`, `base-database-service-19c`, `base-database-service-21c`, `base-database-service-23ai`, and `base-database-service-26ai`.
3939
| user | | | The database username to be used for database creation. If multiple users (up to 10) are required then enter a comma-separated list of usernames (no space). Limit usernames to 118 chars maximum. Accepted chars are: upper case letters, lower case letters, digits, colon, hyphen, underscore, and dot.
40+
| connection-string-format | | easy-connect | The resulting connection string format: `easy-connect` or `tns`.
4041
| prefix_list | | | A comma separated list of file(s) or folder(s) that if changed should not trigger any test (example: folder containing documentation).
4142
|===
4243

action.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ branding:
99
inputs:
1010
version:
1111
description: 'The version to use.'
12-
default: 'v1.0.23'
12+
default: 'v1.0.24'
1313
required: true
1414
action:
1515
description: 'The action to run (create*, delete, skip-testing).'
@@ -22,6 +22,10 @@ inputs:
2222
user:
2323
description: 'The database username to be used for database creation. If multiple users (up to 10) are required then enter a comma-separated list of usernames (no space). Limit usernames to 118 chars maximum. Accepted chars are: upper case letters, lower case letters, digits, colon, hyphen, underscore, and dot.'
2424
required: false
25+
connection-string-format:
26+
description: 'The resulting connection string format (easy-connect*, tns).'
27+
default: 'easy-connect'
28+
required: false
2529
prefix_list:
2630
description: 'A comma separated list of file(s) or folder(s) that if changed should not trigger any test (example: folder containing documentation).'
2731
required: false
@@ -74,5 +78,5 @@ runs:
7478
RUNID: ${{ github.run_number }}
7579
run: |
7680
${GITHUB_ACTION_PATH}/setup-testpilot --${{ inputs.action }} \
77-
--user "${{ inputs.user }}" --oci-service "${{ inputs.oci-service }}"
81+
--user "${{ inputs.user }}" --oci-service "${{ inputs.oci-service }}" --connection-string-format "${{ inputs.connection-string-format }}"
7882

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66

77
<groupId>com.oracle.testpilot</groupId>
88
<artifactId>testpilot-services</artifactId>
9-
<version>1.0.23</version>
9+
<version>1.0.24</version>
1010
<name>Oracle Test Pilot actions</name>
11-
<description>Actions offered by Oracle Test Pilot.</description>
11+
<description>Actions provided by Oracle Test Pilot.</description>
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<junit.version>5.8.1</junit.version>
1616
<maven.compiler.plugin.version>3.8.1</maven.compiler.plugin.version>
17-
<maven.compiler.source>23</maven.compiler.source>
18-
<maven.compiler.target>23</maven.compiler.target>
19-
<maven.compiler.release>23</maven.compiler.release>
17+
<maven.compiler.source>25</maven.compiler.source>
18+
<maven.compiler.target>25</maven.compiler.target>
19+
<maven.compiler.release>25</maven.compiler.release>
2020
<maven.plugin.validation>VERBOSE</maven.plugin.validation>
2121
<native.maven.plugin.version>0.10.3</native.maven.plugin.version>
2222
<imageName>setup-testpilot</imageName>
@@ -81,7 +81,7 @@
8181
<plugin>
8282
<groupId>org.apache.maven.plugins</groupId>
8383
<artifactId>maven-compiler-plugin</artifactId>
84-
<version>3.13.0</version>
84+
<version>3.15.0</version>
8585
<configuration>
8686
<source>${maven.compiler.source}</source>
8787
<target>${maven.compiler.source}</target>

src/main/java/com/oracle/testpilot/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class Main {
2323
System.setProperty("java.net.useSystemProxies", "false");
2424
}
2525

26-
public static final String VERSION="1.0.23";
26+
public static final String VERSION="1.0.24";
2727

2828
public static void main(final String[] args) {
2929
int exitStatus = 0;
@@ -53,7 +53,7 @@ public static void main(final String[] args) {
5353
}
5454

5555
//System.out.println("Error: " + te.getMessage());
56-
te.printStackTrace();
56+
te.printStackTrace(System.err);
5757
}
5858

5959
System.exit(exitStatus);

src/main/java/com/oracle/testpilot/Session.java

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@
99
import com.oracle.testpilot.exception.TestPilotException;
1010
import com.oracle.testpilot.json.JSON;
1111
import com.oracle.testpilot.json.JSONArray;
12-
import com.oracle.testpilot.model.Action;
13-
import com.oracle.testpilot.model.Database;
14-
import com.oracle.testpilot.model.GitHubCommittedFiles;
15-
import com.oracle.testpilot.model.GitHubFilename;
16-
import com.oracle.testpilot.model.GitHubPullRequestCommits;
17-
import com.oracle.testpilot.model.OAuthToken;
18-
import com.oracle.testpilot.model.TechnologyType;
12+
import com.oracle.testpilot.model.*;
1913

2014
import java.io.BufferedOutputStream;
2115
import java.io.FileNotFoundException;
@@ -61,6 +55,8 @@ public class Session {
6155
private String users;
6256
private String technologyType;
6357

58+
private ConnectionStringFormat connectionStringFormat;
59+
6460
private String prefixList;
6561
private String owner;
6662
private String repository;
@@ -165,6 +161,21 @@ private void analyzeCommandLineParameters(final String[] args) {
165161
}
166162
break;
167163

164+
case "--connection-string-format":
165+
if (i + 1 < args.length) {
166+
final String temp = args[++i];
167+
168+
if("tns".equalsIgnoreCase(temp)) {
169+
connectionStringFormat = ConnectionStringFormat.TNS;
170+
} else {
171+
connectionStringFormat = ConnectionStringFormat.EASY_CONNECT;
172+
}
173+
}
174+
else {
175+
throw new TestPilotException(CONNECTION_STRING_FORMAT_MISSING_PARAMETER, new IllegalArgumentException("Missing value for --connection-string-format parameter"));
176+
}
177+
break;
178+
168179
case "--skip-testing":
169180
action = SKIP_TESTING;
170181
break;
@@ -216,15 +227,16 @@ private void analyzeCommandLineParameters(final String[] args) {
216227
private void displayUsage() {
217228
System.out.println("""
218229
Usage: setup-testpilot <action> <options...>
219-
230+
220231
Action:
221232
--create: to provision the requested Oracle Cloud Infrastructure service to test
222233
Options:
223-
--oci-service <value> OCI service type (autonomous-transaction-processing-serverless, base-database-service-19c, base-database-service-21c, base-database-service-23ai)
234+
--oci-service <value> OCI service type (autonomous-transaction-processing-serverless, base-database-service-19c, base-database-service-21c, base-database-service-26ai)
224235
--user <user> user name to be used (if several, then comma separated list without any space)
236+
--connection-string-format requested connection string format (easy-connect*, or tns)
225237
--delete: to de-provision the Oracle Cloud Infrastructure service
226238
Options:
227-
--oci-service <value> OCI service type (autonomous-transaction-processing-serverless, base-database-service-19c, base-database-service-21c, base-database-service-23ai)
239+
--oci-service <value> OCI service type (autonomous-transaction-processing-serverless, base-database-service-19c, base-database-service-21c, base-database-service-26ai)
228240
--user <user> user name to be used (if several, then comma separated list without any space)
229241
--skip-testing
230242
Options:
@@ -310,7 +322,10 @@ runID, type, buildUserList(users,true))
310322
Database database = new JSON<>(Database.class).parse(jsonInformation);
311323
database = new JSON<>(Database.class).parse(database.getDatabase());
312324

313-
final String connectionString = String.format("(description=(retry_count=5)(retry_delay=1)(address=(protocol=tcps)(port=1521)(host=%s.oraclecloud.com))(connect_data=(USE_TCP_FAST_OPEN=ON)(service_name=%s_tp.adb.oraclecloud.com))(security=(ssl_server_dn_match=no)))", database.getHost(), database.getService());
325+
final String connectionString = connectionStringFormat == ConnectionStringFormat.TNS ?
326+
String.format("(description=(retry_count=5)(retry_delay=1)(address=(protocol=tcps)(port=1521)(host=%s.oraclecloud.com))(connect_data=(USE_TCP_FAST_OPEN=ON)(service_name=%s_tp.adb.oraclecloud.com))(security=(ssl_server_dn_match=no)))", database.getHost(), database.getService())
327+
:
328+
String.format("tcps://%s.oraclecloud.com:1521/%s_tp.adb.oraclecloud.com?retry_count=5&retry_delay=1&oracle.net.useTcpFastOpen=true&ssl_server_dn_match=false", database.getHost(), database.getService());
314329

315330
writeDatabaseInformationToGitHubOutput(database, connectionString);
316331
}
@@ -322,7 +337,10 @@ runID, type, buildUserList(users,true))
322337
Database database = new JSON<>(Database.class).parse(jsonInformation);
323338
database = new JSON<>(Database.class).parse(database.getDatabase());
324339

325-
final String connectionString = String.format("%s:1521/%s", database.getHost(), database.getService());
340+
final String connectionString = connectionStringFormat == ConnectionStringFormat.TNS ?
341+
String.format("(description=(address=(protocol=tcp)(port=1521)(host=%s))(connect_data=(service_name=%s)))", database.getHost(), database.getService())
342+
:
343+
String.format("%s:1521/%s", database.getHost(), database.getService());
326344

327345
writeDatabaseInformationToGitHubOutput(database, connectionString);
328346
}
@@ -520,15 +538,15 @@ private String buildUserList(final String users, boolean create) {
520538
return sb.toString();
521539
}
522540

523-
private String getInternalTechnologyType(String technologyType) {
541+
private String getInternalTechnologyType(final String technologyType) {
524542
return switch (technologyType) {
525543
case "autonomous-transaction-processing-serverless-19c" -> TechnologyType.AUTONOMOUS19C;
526544
case "autonomous-transaction-processing-serverless", "autonomous-transaction-processing-serverless-26ai" -> TechnologyType.AUTONOMOUS26AI;
527545
case "base-database-service-19c" -> TechnologyType.DB19C;
528546
case "base-database-service-21c" -> TechnologyType.DB21C;
529547
case "base-database-service-23ai" -> TechnologyType.DB23AI;
530548
case "base-database-service-26ai" -> TechnologyType.DB26AI;
531-
default -> null;
549+
default -> throw new TestPilotException(CREATE_DATABASE_MISSING_DB_TYPE);
532550
};
533551
}
534552

src/main/java/com/oracle/testpilot/exception/TestPilotException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class TestPilotException extends RuntimeException {
2121
public static final int RETRIEVE_OAUTH2_TOKEN = 8;
2222
public static final int TOO_MANY_USERS_PROVIDED = 9;
2323
public static final int CREATE_DATABASE_MISSING_USER_NAME = 10;
24-
public static final int CREATE_DATABASE_MISSING_PASSWORD = 11;
24+
public static final int CONNECTION_STRING_FORMAT_MISSING_PARAMETER = 11;
2525
public static final int CREATE_DATABASE_MISSING_DB_TYPE = 12;
2626
public static final int SKIP_TESTING_MISSING_OWNER = 13;
2727
public static final int SKIP_TESTING_MISSING_REPOSITORY = 14;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
** Oracle Test Pilot
3+
**
4+
** Copyright (c) 2025-2026 Oracle
5+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
6+
*/
7+
package com.oracle.testpilot.model;
8+
9+
/**
10+
* @author LLEFEVRE
11+
* @since 1.0.24
12+
*/
13+
public enum ConnectionStringFormat {
14+
EASY_CONNECT,
15+
TNS
16+
}

0 commit comments

Comments
 (0)