-
Notifications
You must be signed in to change notification settings - Fork 38
SQL-2544: Merge on-prem-eap
branch into master
#337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
2aee0bd
7710e36
27438f9
022740a
811885f
dd9e7cd
d21d5fa
af6dea4
8bb2bbd
7505253
a769fcf
5dfda69
a24ba4d
95cfb35
56a22f4
bd95a92
51e7c97
87a7e6b
548ad8d
9ca05bd
3ae02e9
59c757f
6ef7638
46a34c2
75610de
7efcc7f
4f5fa6c
013161d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import com.github.jk1.license.render.TextReportRenderer | |
|
||
if (project.hasProperty('isTagTriggered')) { | ||
version = getAbbreviatedGitVersion() | ||
} else if (project.hasProperty('isEapBuild')){ | ||
version = getLatestEapTag() | ||
} else { | ||
version = getGitVersion() | ||
} | ||
|
@@ -20,6 +22,7 @@ ext { | |
println("Driver version = " + version) | ||
releaseVersion = getReleaseVersion() | ||
println("Artifacts version = " + releaseVersion) | ||
|
||
javaDataLoader = "com.mongodb.jdbc.integration.testharness.DataLoader" | ||
javaTestGenerator = "com.mongodb.jdbc.integration.testharness.TestGenerator" | ||
aspectjVersion = '1.9.7' | ||
|
@@ -168,8 +171,9 @@ task integrationTest(type: Test) { | |
description = 'Runs integration tests.' | ||
group = 'verification' | ||
|
||
dependsOn tasks.named('jar') | ||
testClassesDirs = sourceSets.integrationTest.output.classesDirs | ||
classpath = sourceSets.integrationTest.runtimeClasspath | ||
classpath = sourceSets.integrationTest.runtimeClasspath + files(tasks.jar.archiveFile.get()) - sourceSets.main.output | ||
shouldRunAfter test | ||
} | ||
|
||
|
@@ -270,6 +274,16 @@ def getGitVersion() { | |
out.toString().substring(1).trim() | ||
} | ||
|
||
def getLatestEapTag() { | ||
def stdout = new ByteArrayOutputStream() | ||
exec { | ||
commandLine 'git', 'tag', '--list', '*libv*', '--sort=-creatordate' | ||
standardOutput = stdout | ||
} | ||
def tags = stdout.toString().trim().readLines() | ||
return tags ? tags[0].toString().substring(1).trim() : null | ||
} | ||
|
||
def getAbbreviatedGitVersion() { | ||
def out = new ByteArrayOutputStream() | ||
exec { | ||
|
@@ -279,6 +293,110 @@ def getAbbreviatedGitVersion() { | |
out.toString().substring(1).trim() | ||
} | ||
|
||
// Determines the version of libmongosqltranslate to use based on the following priority: | ||
// Command line property 'libVersion' ie -PlibmongosqltranslateVersion=1.2.3 for manual testing | ||
// If build is triggered by a tag, check that LIBMONGOSQLTRANSLATE_VER environment variable is set and use that value | ||
// Otherwise default to "snapshot" version | ||
def getLibMongosqlTranslateVersion() { | ||
if (project.hasProperty('libmongosqltranslateVersion')) { | ||
logger.lifecycle("Using manually specified libVersion: ${project.property('libmongosqltranslateVersion')}") | ||
return project.property('libmongosqltranslateVersion') | ||
} | ||
if (project.hasProperty('isTagTriggered')) { | ||
if (System.getenv('LIBMONGOSQLTRANSLATE_VER')) { | ||
logger.lifecycle("Using version from environment: ${System.getenv('LIBMONGOSQLTRANSLATE_VER')}") | ||
return System.getenv('LIBMONGOSQLTRANSLATE_VER') | ||
} else { | ||
throw new GradleException("Build is tag-triggered but LIBMONGOSQLTRANSLATE_VER " + | ||
"environment variable is not set. This is required for tag-triggered builds.") | ||
} | ||
} | ||
logger.lifecycle("Using snapshot version") | ||
return "snapshot" | ||
} | ||
|
||
def libraryCache = new File("${project.rootDir}/.library_cache") | ||
|
||
task downloadLibMongosqlTranslate { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Note] We will probably need to do things differently.
or we can customize the jar task. |
||
def libraryPlatforms = [ | ||
[platform: 'linux', arch: 'arm', libPrefix: 'lib', ext: 'so'], | ||
[platform: 'linux', arch: 'x86_64', libPrefix: 'lib', ext: 'so'], | ||
[platform: 'macos', arch: 'arm', libPrefix: 'lib', ext: 'dylib'], | ||
[platform: 'macos', arch: 'x86_64', libPrefix: 'lib', ext: 'dylib'], | ||
[platform: 'win', arch: 'x86_64', libPrefix: '', ext: 'dll'] | ||
] | ||
description = 'Downloads mongosqltranslate libraries for all platforms' | ||
group = 'Build Setup' | ||
|
||
// Read the force-update flag from the command line `-PupdateLibs=true` | ||
def updateLibs = project.hasProperty('updateLibs') ? project.property('updateLibs').toBoolean() : false | ||
doLast { | ||
def libVersion = getLibMongosqlTranslateVersion() | ||
logger.lifecycle("Using libmongosqltranslate version: ${libVersion}") | ||
|
||
libraryCache.mkdirs() | ||
|
||
libraryPlatforms.each { platform -> | ||
def libraryFileName = "${platform.libPrefix}mongosqltranslate.${platform.ext}" | ||
def s3FileName = | ||
"${platform.libPrefix}mongosqltranslate-v${libVersion}-${platform.platform}-${platform.arch}.${platform.ext}" | ||
def s3Url = "https://translators-connectors-releases.s3.amazonaws.com/mongosqltranslate/${s3FileName}" | ||
|
||
def cacheFile = new File(libraryCache, s3FileName) | ||
def resourceDir = new File("${project.rootDir}/src/main/resources/${platform.arch}/${platform.platform}") | ||
resourceDir.mkdirs() | ||
|
||
def destinationFile = new File(resourceDir, libraryFileName) | ||
|
||
// Skip the download if the force-update flag is not set and the library already exists in library cache | ||
if (!updateLibs && cacheFile.exists() && cacheFile.length() > 0) { | ||
logger.lifecycle("Using cached version of ${s3FileName} for ${platform.platform}-${platform.arch}") | ||
destinationFile.bytes = cacheFile.bytes | ||
return | ||
} | ||
|
||
try { | ||
logger.lifecycle("Downloading ${s3Url}...") | ||
|
||
def connection = new URL(s3Url).openConnection() | ||
connection.connectTimeout = 30000 | ||
connection.readTimeout = 30000 | ||
|
||
cacheFile.withOutputStream { outputStream -> | ||
connection.getInputStream().withCloseable { inputStream -> | ||
outputStream << inputStream | ||
} | ||
} | ||
|
||
// Verify we downloaded actual content | ||
if (cacheFile.length() == 0) { | ||
throw new IOException("Downloaded file is empty") | ||
} | ||
|
||
destinationFile.bytes = cacheFile.bytes | ||
logger.lifecycle("Successfully downloaded ${s3FileName} for ${platform.platform}-${platform.arch}") | ||
|
||
} catch (Exception e) { | ||
logger.warn("Could not download ${s3FileName}: ${e.message}") | ||
|
||
if (cacheFile.exists() && cacheFile.length() > 0) { | ||
logger.lifecycle("Using cached version from ${cacheFile.path}") | ||
destinationFile.bytes = cacheFile.bytes | ||
} else { | ||
logger.error("ERROR: Could not download ${s3FileName} and no valid cached version available.") | ||
logger.error("S3 URL attempted: ${s3Url}") | ||
throw new GradleException("Failed to download " + s3FileName + | ||
" and no valid cached version exists. Build cannot continue.") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
tasks.named('compileJava').configure { | ||
dependsOn tasks.named('downloadLibMongosqlTranslate') | ||
} | ||
|
||
tasks.register('runMongoSQLTranslateLibTest', Test) { | ||
description = 'Runs MongoSQLTranslateLibTest' | ||
group = 'verification' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this property for integration tests to set the version to the
eap
format.