Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit 5b3cd52

Browse files
Merge pull request #148 from reactome/feature/post-step-tests-stid-history
Feature/post step tests stid history
2 parents e0c4e16 + 0fbc6c7 commit 5b3cd52

File tree

5 files changed

+595
-0
lines changed

5 files changed

+595
-0
lines changed

Diff for: ortho-stable-id-history/Jenkinsfile

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// This Jenkinsfile is used by Jenkins to run the OrthoinferenceStableIdentifierHistory step of Reactome's release.
2+
// It requires that the Orthoinference step has been run successfully before it can be run.
3+
4+
import org.reactome.release.jenkins.utilities.Utilities
5+
6+
// Shared library maintained at 'release-jenkins-utils' repository.
7+
def utils = new Utilities()
8+
9+
pipeline {
10+
agent any
11+
12+
stages {
13+
// This stage checks that an upstream project, Orthoinference, was run successfully for its last build.
14+
stage('Check if Orthoinference build succeeded'){
15+
steps{
16+
script{
17+
utils.checkUpstreamBuildsSucceeded("Relational-Database-Updates/job/Orthoinference")
18+
}
19+
}
20+
}
21+
// Backs up the release_current and stable_identifiers databases.
22+
stage('Setup: Back up DBs'){
23+
steps{
24+
script{
25+
dir('ortho-stable-id-history'){
26+
withCredentials([usernamePassword(credentialsId: 'mySQLUsernamePassword', passwordVariable: 'pass', usernameVariable: 'user')]){
27+
utils.takeDatabaseDumpAndGzip("${env.RELEASE_CURRENT_DB}", "ortho_stable_id_history", "before", "${env.RELEASE_SERVER}")
28+
utils.takeDatabaseDumpAndGzip("${env.STABLE_IDENTIFIERS_DB}", "ortho_stable_id_history", "before", "${env.RELEASE_SERVER}")
29+
}
30+
}
31+
}
32+
}
33+
}
34+
// Builds the jar file that will be used.
35+
stage('Setup: Build jar file'){
36+
steps{
37+
script{
38+
dir('ortho-stable-id-history'){
39+
utils.buildJarFile()
40+
}
41+
}
42+
}
43+
}
44+
// Runs the perl 'save_stable_id_history.pl' script.
45+
stage('Main: Save StableIdentifier History'){
46+
steps{
47+
script{
48+
dir('ortho-stable-id-history'){
49+
withCredentials([usernamePassword(credentialsId: 'mySQLUsernamePassword', passwordVariable: 'pass', usernameVariable: 'user')]){
50+
def releaseVersion = utils.getReleaseVersion()
51+
sh "perl ${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/save_stable_id_history.pl -db ${env.RELEASE_CURRENT_DB} -sdb ${env.STABLE_IDENTIFIERS_DB} -host localhost -user $user -pass $pass -release ${releaseVersion}"
52+
}
53+
}
54+
}
55+
}
56+
}
57+
// Runs the perl 'old_stable_id_mapping.pl' script.
58+
stage('Main: Old StableIdentifier Mapping'){
59+
steps{
60+
script{
61+
dir('ortho-stable-id-history'){
62+
// Download 'stable_id_mapping.stored_data' from S3
63+
sh "aws s3 cp ${env.S3_RELEASE_DIRECTORY_URL}/supplementary_files/stable_id_mapping.stored_data.zip ."
64+
sh "unzip stable_id_mapping.stored_data.zip"
65+
// Ensure that the file is in the same location as the Perl script
66+
sh "cp ./stable_id_mapping.stored_data ${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/stable_id_mapping.stored_data"
67+
withCredentials([usernamePassword(credentialsId: 'mySQLUsernamePassword', passwordVariable: 'pass', usernameVariable: 'user')]){
68+
sh "perl ${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/old_stable_id_mapping.pl -db ${env.RELEASE_CURRENT_DB} -host localhost"
69+
}
70+
sh "rm stable_id_mapping.stored_data*"
71+
}
72+
}
73+
}
74+
}
75+
// Runs the StableIdentifier QA.
76+
stage('Post: Run StableIdentifier QA'){
77+
steps{
78+
script{
79+
dir('ortho-stable-id-history') {
80+
withCredentials([file(credentialsId: 'Config', variable: 'ConfigFile')]) {
81+
sh "java -jar target/OrthoStableIdHistory-*-jar-with-dependencies.jar $ConfigFile"
82+
}
83+
}
84+
}
85+
}
86+
}
87+
// Backs up the 'release_current' and 'stable_identifier' databases after the step has run.
88+
stage('Post: Backup DBs'){
89+
steps{
90+
script{
91+
dir('ortho-stable-id-history'){
92+
// Download 'stable_id_mapping.stored_data' from S3
93+
def stableIdMappingStorFile = "stable_id_mapping.stored_data"
94+
sh "aws s3 --no-progress cp ${env.S3_RELEASE_DIRECTORY_URL}/supplementary_files/${stableIdMappingStorFile}.zip ."
95+
sh "unzip ${stableIdMappingStorFile}.zip"
96+
sh "mv ${stableIdMappingStorFile} ${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/"
97+
withCredentials([usernamePassword(credentialsId: 'mySQLUsernamePassword', passwordVariable: 'pass', usernameVariable: 'user')]){
98+
sh "perl ${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/old_stable_id_mapping.pl -db ${env.RELEASE_CURRENT_DB} -host localhost"
99+
}
100+
sh "rm ${stableIdMappingStorFile}.zip"
101+
sh "rm ${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/${stableIdMappingStorFile}"
102+
}
103+
}
104+
}
105+
}
106+
// This stage archives all logs and database backups produced by OrthoinferenceStableIdentifierHistory.
107+
stage('Post: Archive Outputs'){
108+
steps{
109+
script{
110+
dir('ortho-stable-id-history'){
111+
def dataFiles = []
112+
def logFiles = ["${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/*log", "${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/*err"]
113+
def foldersToDelete = []
114+
utils.cleanUpAndArchiveBuildFiles("ortho_stable_id_history", dataFiles, logFiles, foldersToDelete)
115+
}
116+
}
117+
}
118+
}
119+
}
120+
}

Diff for: ortho-stable-id-history/pom.xml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.reactome.release</groupId>
8+
<artifactId>OrthoStableIdHistory</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<dependencies>
12+
<dependency>
13+
<groupId>org.apache.logging.log4j</groupId>
14+
<artifactId>log4j-core</artifactId>
15+
<version>2.11.0</version>
16+
</dependency>
17+
<dependency>
18+
<groupId>org.reactome.release</groupId>
19+
<artifactId>release-common-lib</artifactId>
20+
<version>1.1.1-SNAPSHOT</version>
21+
</dependency>
22+
</dependencies>
23+
24+
<build>
25+
<plugins>
26+
<plugin>
27+
<groupId>org.apache.maven.plugins</groupId>
28+
<artifactId>maven-compiler-plugin</artifactId>
29+
<configuration>
30+
<source>8</source>
31+
<target>8</target>
32+
</configuration>
33+
</plugin>
34+
<plugin>
35+
<artifactId>maven-assembly-plugin</artifactId>
36+
<configuration>
37+
<archive>
38+
<manifest>
39+
<mainClass>org.reactome.release.orthoStableIdentifierHistory.Main</mainClass>
40+
</manifest>
41+
</archive>
42+
<descriptorRefs>
43+
<descriptorRef>jar-with-dependencies</descriptorRef>
44+
</descriptorRefs>
45+
</configuration>
46+
</plugin>
47+
</plugins>
48+
</build>
49+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.reactome.release.orthoStableIdentifierHistory;
2+
3+
import org.apache.logging.log4j.LogManager;
4+
import org.apache.logging.log4j.Logger;
5+
import org.gk.persistence.MySQLAdaptor;
6+
7+
import java.io.FileInputStream;
8+
import java.nio.file.Paths;
9+
import java.util.Properties;
10+
11+
public class Main {
12+
13+
private static final Logger logger = LogManager.getLogger();
14+
private static final String RESOURCES_DIR = Paths.get("src", "main", "resources").toString();
15+
16+
public static void main(String[] args) throws Exception {
17+
18+
String pathToConfig = args.length > 0 ? args[0] : Paths.get(RESOURCES_DIR ,"config.properties").toString();
19+
20+
Properties props = new Properties();
21+
props.load(new FileInputStream(pathToConfig));
22+
23+
//Set up DB adaptors
24+
String releaseUsername = props.getProperty("release.database.user");
25+
String releasePassword = props.getProperty("release.database.password");
26+
String releaseHost = props.getProperty("release.database.host");
27+
int releasePort = Integer.valueOf(props.getProperty("release.database.port"));
28+
String releaseCurrent = props.getProperty("release_current.name");
29+
30+
String curatorUsername = props.getProperty("curator.database.user");
31+
String curatorPassword = props.getProperty("curator.database.password");
32+
String curatorHost = props.getProperty("curator.database.host");
33+
int curatorPort = Integer.valueOf(props.getProperty("curator.database.port"));
34+
String curatorDatabase = props.getProperty("curator.database.name");
35+
36+
MySQLAdaptor dbAdaptor = new MySQLAdaptor(releaseHost, releaseCurrent, releaseUsername, releasePassword, releasePort);
37+
MySQLAdaptor dbAdaptorCurator = new MySQLAdaptor(curatorHost, curatorDatabase, curatorUsername, curatorPassword, curatorPort);
38+
39+
logger.info("Executing post-step checks");
40+
PostStepChecks.performStableIdentifierHistoryQA(dbAdaptor, dbAdaptorCurator);
41+
logger.info("Finished post-step checks");
42+
}
43+
}

0 commit comments

Comments
 (0)