| 4736 |
rpuchmay |
1 |
import java.io.ByteArrayOutputStream;
|
|
|
2 |
import java.io.PrintStream;
|
|
|
3 |
import java.sql.Connection;
|
|
|
4 |
import java.sql.DriverManager;
|
|
|
5 |
import java.sql.SQLException;
|
|
|
6 |
import java.util.List;
|
|
|
7 |
|
|
|
8 |
import releaseManager.TeamCity;
|
|
|
9 |
import releaseManager.ReleaseManager;
|
|
|
10 |
import releaseManager.VixPackage;
|
|
|
11 |
|
|
|
12 |
public class Aggregator
|
|
|
13 |
{
|
|
|
14 |
private static final String DB_HOST = "auperaprm01";
|
|
|
15 |
private static final String DB_PORT = "1521";
|
|
|
16 |
private static final String DB_USER = "RM_READONLY";
|
|
|
17 |
private static final String DB_PASSWORD = "RM_READONLY";
|
|
|
18 |
private static final String DB_SERVICE = "RELEASEM";
|
|
|
19 |
|
|
|
20 |
/**
|
|
|
21 |
* @param args - the first and only arguments should be the rtag_id as
|
|
|
22 |
* found in the Release Manager URL.
|
|
|
23 |
* E.g. java Aggregator 30083
|
|
|
24 |
*/
|
|
|
25 |
public static void main(String[] args)
|
|
|
26 |
{
|
|
|
27 |
TeamCity teamCity = new TeamCity(System.out);
|
|
|
28 |
|
|
|
29 |
if (args.length < 1) {
|
|
|
30 |
teamCity.error("Please supply an rtag_id.", "No argument supplied");
|
|
|
31 |
System.exit(-1);
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
String releaseVersion = args[0];
|
|
|
35 |
|
|
|
36 |
try
|
|
|
37 |
{
|
|
|
38 |
int rtagId = Integer.parseInt(releaseVersion);
|
|
|
39 |
|
|
|
40 |
// Load ORACLE DB driver class
|
|
|
41 |
// Available at: http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
|
|
|
42 |
// Filename: ojdbc6.jar
|
|
|
43 |
// See https://sites.google.com/a/vixtechnology.com/vixwiki/home/staff-wiki-s/richard-puchmayer/passwords-to-update
|
|
|
44 |
// for username and password to use.
|
|
|
45 |
Class.forName("oracle.jdbc.driver.OracleDriver");
|
|
|
46 |
|
|
|
47 |
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@"+DB_HOST+":"+DB_PORT+":"+DB_SERVICE, DB_USER, DB_PASSWORD);
|
|
|
48 |
ReleaseManager releaseManager = new ReleaseManager(connection);
|
|
|
49 |
|
|
|
50 |
List<VixPackage> packages = releaseManager.getTestedPackages(rtagId);
|
|
|
51 |
|
|
|
52 |
if (packages.size() == 0) // Cannot be null
|
|
|
53 |
{
|
|
|
54 |
teamCity.error("This project/release does not have any tests", "Release = " + releaseVersion);
|
|
|
55 |
System.exit(-1);
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
teamCity.startSuite(releaseVersion);
|
|
|
59 |
for (VixPackage pkg : packages)
|
|
|
60 |
{
|
|
|
61 |
teamCity.startSuite(pkg.packageName);
|
|
|
62 |
teamCity.startSuite(pkg.packageVersion);
|
|
|
63 |
teamCity.startTest("<none>");
|
|
|
64 |
teamCity.finishTest("<none>");
|
|
|
65 |
teamCity.finishSuite(pkg.packageVersion);
|
|
|
66 |
teamCity.finishSuite(pkg.packageName);
|
|
|
67 |
}
|
|
|
68 |
teamCity.finishSuite(releaseVersion);
|
|
|
69 |
}
|
|
|
70 |
catch (SQLException e)
|
|
|
71 |
{
|
|
|
72 |
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
|
73 |
PrintStream output = new PrintStream(buffer);
|
|
|
74 |
e.printStackTrace(output);
|
|
|
75 |
teamCity.error("Could not retrieve any packages for this release: " + releaseVersion, buffer.toString());
|
|
|
76 |
System.exit(-1);
|
|
|
77 |
}
|
|
|
78 |
catch (ClassNotFoundException e)
|
|
|
79 |
{
|
|
|
80 |
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
|
81 |
PrintStream output = new PrintStream(buffer);
|
|
|
82 |
e.printStackTrace(output);
|
|
|
83 |
teamCity.error("Could not load the Oracle jdbc jar", buffer.toString());
|
|
|
84 |
System.exit(-1);
|
|
|
85 |
}
|
|
|
86 |
catch (NumberFormatException e)
|
|
|
87 |
{
|
|
|
88 |
teamCity.error("Please supply a valid rtag_id.", "Argument: " + releaseVersion);
|
|
|
89 |
System.exit(-1);
|
|
|
90 |
}
|
|
|
91 |
}
|
|
|
92 |
}
|