Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/test/JDJSTPTestcase.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.sql.CallableStatement;
import java.sql.Connection;
Expand Down
2 changes: 1 addition & 1 deletion src/test/JDRunit.java
Original file line number Diff line number Diff line change
Expand Up @@ -2267,7 +2267,7 @@ public JDRunitGoOutput go() throws Exception {
if (JTOpenTestEnvironment.isWindows && (vmInitials.endsWith("3") || vmInitials.endsWith("6"))) {
runNativeTestFromWindows = true;
testcaseHome="/home/jdbctest";
testcaseClasspath="/home/jdbctest";
testcaseClasspath="/home/jdbctest:/home/jdbctest/JTOpen-test.jar";
}


Expand Down
66 changes: 36 additions & 30 deletions src/test/JTOpenDownloadDevJars.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@
//
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
//
// JTOpen (IBM Toolbox for Java - OSS version)
//
// Filename: JTOpenDownloadDevJars
//
// The source code contained herein is licensed under the IBM Public License
// Version 1.0, which has been approved by the Open Source Initiative.
// Copyright (C) 1997-2023 International Business Machines Corporation and
// others. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//
// File Name: JTOpenDownloadDevJars.java
Expand All @@ -34,6 +22,8 @@
// This class is designed to run on an IBM i and download the latest development
// toolbox jar files from git and install them on the system.
//
// This tool requires a GITHUB token to be set in ini/netrc.ini to prevent problems with rate limiting.
//
//
// This can be automated using the following.
// ADDJOBSCDE JOB(JDUPDJAR) CMD(JAVA CLASS(test.JTOpenDownloadDevJars) CLASSPATH('/home/jdbctest')) FRQ(*WEEKLY) SCDDATE(*NONE) SCDDAY(*ALL) SCDTIME('19:00')
Expand Down Expand Up @@ -147,11 +137,21 @@ public static void main(String args[]) {
// run the query to show the possible URLS.
String sql;
Statement stmt = connection.createStatement();
Properties iniProperties = getIniProperties();
githubAuth=iniProperties.getProperty("GITHUBTOKEN");
if (githubAuth == null) {
stmt.close();
connection.close();
throw new Exception("Unable to get GITHUBTOKEN from ini/netrc.ini");
}
System.out.println("Authorization set to "+githubAuth);

sql = "SELECT URL,"
+ "TIMESTAMP( SUBSTRING(UPDATED_AT,1,10) || ' ' || SUBSTRING(UPDATED_AT,12,8)) + CURRENT TIMEZONE AS UPDATED , "
+ "CURRENT TIMEZONE as CURRENT_TIMEZONE, "
+ " NAME, BRANCH"
+ " FROM JSON_TABLE( HTTP_GET('"+artifactsUrl+"','{\"headers\":{\"Accept\":\"application/vnd.github+json\"}, \"sslTolerate\":true}'), '$.artifacts[*]' "
+ " FROM JSON_TABLE( HTTP_GET('"+artifactsUrl+"','{\"headers\":{\"Accept\":\"application/vnd.github+json\""
+ ",\"authorization\":\""+githubAuth+"\"}, \"sslTolerate\":true}'), '$.artifacts[*]' "
+ "COLUMNS ( "
+ "URL VARCHAR(200) CCSID 1208 PATH '$.url', "
+ "UPDATED_AT VARCHAR(40) PATH '$.updated_at', "
Expand All @@ -172,20 +172,20 @@ public static void main(String args[]) {
}
if (branch == null) {
sql = "SELECT * FROM JSON_TABLE( HTTP_GET('"+artifactsUrl+"',"
+ "'{\"headers\":{\"Accept\":\"application/vnd.github+json\"}, \"sslTolerate\":true}'), "
+ "'{\"headers\":{\"Accept\":\"application/vnd.github+json\",\"authorization\":\""+githubAuth+"\"}, \"sslTolerate\":true}'), "
+ "'$.artifacts[*]' "
+ "COLUMNS ( "
+ "URL VARCHAR(200) CCSID 1208 PATH '$.url', "
+ "UPDATED_AT VARCHAR(40) PATH '$.updated_at', "
+ "NAME VARCHAR(40) PATH '$.name',"
+ "BRANCH VARCHAR(120) PATH '$.workflow_run.head_branch' )) WHERE BRANCH='main' AND NAME='Package' ORDER BY UPDATED_AT desc FETCH FIRST 1 ROWS ONLY";
} else if ("ANY".equalsIgnoreCase(branch)) {
sql = "SELECT * FROM JSON_TABLE( HTTP_GET('"+artifactsUrl+"','{\"headers\":{\"Accept\":\"application/vnd.github+json\"}, \"sslTolerate\":true}'), '$.artifacts[*]' "
sql = "SELECT * FROM JSON_TABLE( HTTP_GET('"+artifactsUrl+"','{\"headers\":{\"Accept\":\"application/vnd.github+json\",\"authorization\":\""+githubAuth+"\"}, \"sslTolerate\":true}'), '$.artifacts[*]' "
+ "COLUMNS ( URL VARCHAR(200) CCSID 1208 PATH '$.url', UPDATED_AT VARCHAR(40) PATH '$.updated_at', "
+ "NAME VARCHAR(40) PATH '$.name',"
+ "BRANCH VARCHAR(120) PATH '$.workflow_run.head_branch' )) WHERE NAME='Package' ORDER BY UPDATED_AT desc FETCH FIRST 1 ROWS ONLY";
} else {
sql = "SELECT * FROM JSON_TABLE( HTTP_GET('"+artifactsUrl+"','{\"headers\":{\"Accept\":\"application/vnd.github+json\"}, \"sslTolerate\":true}'), '$.artifacts[*]' "
sql = "SELECT * FROM JSON_TABLE( HTTP_GET('"+artifactsUrl+"','{\"headers\":{\"Accept\":\"application/vnd.github+json\",\"authorization\":\""+githubAuth+"\"}, \"sslTolerate\":true}'), '$.artifacts[*]' "
+ "COLUMNS ( URL VARCHAR(200) CCSID 1208 PATH '$.url', UPDATED_AT VARCHAR(40) PATH '$.updated_at', "
+ "NAME VARCHAR(40) PATH '$.name',"
+ "BRANCH VARCHAR(120) PATH '$.workflow_run.head_branch' )) WHERE NAME='Package' and BRANCH='"+branch+"' ORDER BY UPDATED_AT desc FETCH FIRST 1 ROWS ONLY";
Expand Down Expand Up @@ -236,7 +236,7 @@ public static void main(String args[]) {
//
// Repeat for the test jar files
//
sql = "SELECT * FROM JSON_TABLE( HTTP_GET('"+artifactsTestUrl+"','{\"headers\":{\"Accept\":\"application/vnd.github+json\"}, \"sslTolerate\":true}'), '$.artifacts[*]' COLUMNS ( URL VARCHAR(200) CCSID 1208 PATH '$.url', UPDATED_AT VARCHAR(40) PATH '$.updated_at', BRANCH VARCHAR(40) PATH '$.workflow_run.head_branch' )) WHERE BRANCH='main' ORDER BY UPDATED_AT desc FETCH FIRST 1 ROWS ONLY";
sql = "SELECT * FROM JSON_TABLE( HTTP_GET('"+artifactsTestUrl+"','{\"headers\":{\"Accept\":\"application/vnd.github+json\",\"authorization\":\""+githubAuth+"\"}, \"sslTolerate\":true}'), '$.artifacts[*]' COLUMNS ( URL VARCHAR(200) CCSID 1208 PATH '$.url', UPDATED_AT VARCHAR(40) PATH '$.updated_at', BRANCH VARCHAR(40) PATH '$.workflow_run.head_branch' )) WHERE BRANCH='main' ORDER BY UPDATED_AT desc FETCH FIRST 1 ROWS ONLY";
stmt = connection.createStatement();
System.out.println("Running to get latest artifact: "+sql);
rs = stmt.executeQuery(sql);
Expand Down Expand Up @@ -361,6 +361,23 @@ private static void unzip(String zipFile, String targetDir) throws IOException {

}

public static Properties getIniProperties() throws Exception {
/* Github requires authorization to download a non-release artifacte */
Properties iniProperties = new Properties();

{
String filename = "ini/netrc.ini";
File file = new File(filename);
if (!file.exists()) {
throw new Exception("Unable to load ini/netrc.ini to get GITHUB token");
}
InputStream fileInputStream= new FileInputStream(filename);
iniProperties.load(fileInputStream);
fileInputStream.close();
}

return iniProperties;
}

public static void fetchFile(String destinationDirectory,
String fileName,
Expand All @@ -371,19 +388,8 @@ public static void fetchFile(String destinationDirectory,
URL url = new URL(urlPath);
URLConnection connection = url.openConnection();

/* Github requires authorization to download a non-release artifacte */
Properties iniProperties = new Properties();

{
String filename = "ini/netrc.ini";
File file = new File(filename);
if (!file.exists()) {
throw new Exception("Unable to load ini/netrc.ini to get GITHUB token");
}
InputStream fileInputStream= new FileInputStream(filename);
iniProperties.load(fileInputStream);
fileInputStream.close();
}
Properties iniProperties = getIniProperties();

githubAuth=iniProperties.getProperty("GITHUBTOKEN");
if (githubAuth == null) {
throw new Exception("Unable to get GITHUBTOKEN from ini/netrc.ini");
Expand Down
Loading