Skip to content
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

Allow tests targets selection #1300

Merged
merged 1 commit into from
Mar 2, 2018
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
29 changes: 29 additions & 0 deletions buildenv/jenkins/common/pipeline-functions
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,33 @@ def build_with_one_upstream(JOB_NAME, UPSTREAM_JOB_NAME, UPSTREAM_JOB_NUMBER, VA
return JOB
}
}

def workflow() {
def jobs = [:]

// compile the source and build the SDK
BUILD_JOB_NAME = "Build-JDK${SDK_VERSION}-${SPEC}"
jobs["build"] = build(BUILD_JOB_NAME, OPENJDK_REPO, OPENJDK_BRANCH, SHAS['OPENJDK'], OPENJ9_REPO, OPENJ9_BRANCH, SHAS['OPENJ9'], OMR_REPO, OMR_BRANCH, SHAS['OMR'], params.VARIABLE_FILE)

levels = TESTS_TARGETS.split(",")
levels.each { level ->
switch (level.trim().toLowerCase()) {
case "_sanity":
TEST_JOB_NAME = "Test-Sanity-JDK${SDK_VERSION}-${SPEC}"
break
case "_extended":
TEST_JOB_NAME = "Test-Extended-JDK${SDK_VERSION}-${SPEC}"
break
default:
echo "error: Unknown test target: ${level}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, it will not work to pass other targets to internal builds because of this default: handling.

Copy link
Contributor Author

@vsebe vsebe Feb 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct (throws an error).
In order to work with other targets we need Jenkins job[s] and pipeline/groovy scripts that are not available at this moment. As agreed today, we will discuss and address this at a later time (and another PR).

error()
}

// run tests against the SDK build in the upstream job: Build-JDK${SDK_VERSION}-${SPEC}
jobs["${level}"] = build_with_one_upstream(TEST_JOB_NAME, BUILD_JOB_NAME, BUILD_JOB.getNumber(), params.VARIABLE_FILE)
}

// return jobs for further reference
return jobs
}
return this
33 changes: 27 additions & 6 deletions buildenv/jenkins/common/variables-functions
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ def set_repos_variables() {
* if the map contains no mapping for the key.
*/
def get_value(MAP, KEY) {
for (item in MAP) {
if ("${item.key}" == "${KEY}") {
return "${item.value}"
if (MAP != null) {
for (item in MAP) {
if ("${item.key}" == "${KEY}") {
return "${item.value}"
}
}
}

Expand All @@ -141,9 +143,16 @@ def get_value(MAP, KEY) {
* Returns empty string if no values is provided in the variables file (not
* required for public repositories).
*/
def get_git_user_credentials_id () {
if (VARIABLES.user != null) {
return VARIABLES.user.credentials_id
def get_git_user_credentials_id() {
return get_user_credentials_id("git")
}

/*
* Returns Jenkins credentials ID from the variable file for given key.
*/
def get_user_credentials_id(KEY) {
if ((VARIABLES.credentials != null) && (VARIABLES.credentials."${KEY}" != null)) {
return VARIABLES.credentials."${KEY}"
}

return ''
Expand Down Expand Up @@ -207,6 +216,17 @@ def set_test_variables() {
TEST_DEPENDENCIES_JOB_NAME = VARIABLES.test_dependencies_job_name
}

/*
* Set TESTS_TARGETS, indicating the level of testing.
*/
def set_test_targets() {
TESTS_TARGETS = params.TESTS_TARGETS
if (!TESTS_TARGETS) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEST_TARGETS will either be null (no param defined), blank (param defined but no value), or will have a value. I would like to see a test case for each to prove this if condition works as expected.
It is different than how we do it in variables-functions.

Especially since I got burned by my change in #1320

Copy link
Contributor Author

@vsebe vsebe Mar 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In groovy, both null and the empty string evaluate to false thus the contraption:
if ((TESTS_TARGETS == null) || ((TESTS_TARGETS == '')) {...}
or
if (!TESTS_TARGETS){...}

and the opposite:

if ((TESTS_TARGETS != null) && ((TESTS_TARGETS != '')) {...}
or
if (TESTS_TARGETS){...}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I made the mistake of wrapping quotes around null in my change. I think this is correct.

// set default TESTS_TARGETS for pipeline job (run all tests)
TESTS_TARGETS = "_sanity,_extended"
}
}

/*
* Initializes all of the required variables for a Jenkins job by given job type.
*/
Expand Down Expand Up @@ -240,6 +260,7 @@ def set_job_variables(job_type) {
case "pipeline":
// set variables for a pipeline job
set_repos_variables()
set_test_targets()
break
default:
error("Unknown Jenkins job type!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

def BUILD_JOB_NAME = 'Build-JDK8-linux_390-64_cmprssptrs'
def SANITY_JOB_NAME = 'Test-Sanity-JDK8-linux_390-64_cmprssptrs'
def EXTENDED_JOB_NAME = 'Test-Extended-JDK8-linux_390-64_cmprssptrs'
SDK_VERSION = '8'
SPEC = 'linux_390-64_cmprssptrs'

node('master') {
SDK_VERSION = '8'
SPEC = 'linux_390-64_cmprssptrs'

checkout scm
def commonFile = load 'buildenv/jenkins/common/variables-functions'
Expand All @@ -36,6 +33,4 @@ node('master') {
SHAS = buildfile.get_shas(OPENJDK_REPO, OPENJDK_BRANCH, OPENJ9_REPO, OPENJ9_BRANCH, OMR_REPO, OMR_BRANCH)
}

BUILD_JOB = buildfile.build(BUILD_JOB_NAME, OPENJDK_REPO, OPENJDK_BRANCH, SHAS['OPENJDK'], OPENJ9_REPO, OPENJ9_BRANCH, SHAS['OPENJ9'], OMR_REPO, OMR_BRANCH, SHAS['OMR'], params.VARIABLE_FILE)
SANITY_JOB = buildfile.build_with_one_upstream(SANITY_JOB_NAME, BUILD_JOB_NAME, BUILD_JOB.getNumber(), params.VARIABLE_FILE)
EXTENDED_JOB = buildfile.build_with_one_upstream(EXTENDED_JOB_NAME, BUILD_JOB_NAME, BUILD_JOB.getNumber(), params.VARIABLE_FILE)
jobs = buildfile.workflow()
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

def BUILD_JOB_NAME = 'Build-JDK8-linux_ppc-64_cmprssptrs_le'
def SANITY_JOB_NAME = 'Test-Sanity-JDK8-linux_ppc-64_cmprssptrs_le'
def EXTENDED_JOB_NAME = 'Test-Extended-JDK8-linux_ppc-64_cmprssptrs_le'
SDK_VERSION = '8'
SPEC = 'linux_ppc-64_cmprssptrs_le'

node('master') {
SDK_VERSION = '8'
SPEC = 'linux_ppc-64_cmprssptrs_le'

checkout scm
def commonFile = load 'buildenv/jenkins/common/variables-functions'
Expand All @@ -36,6 +33,4 @@ node('master') {
SHAS = buildfile.get_shas(OPENJDK_REPO, OPENJDK_BRANCH, OPENJ9_REPO, OPENJ9_BRANCH, OMR_REPO, OMR_BRANCH)
}

BUILD_JOB = buildfile.build(BUILD_JOB_NAME, OPENJDK_REPO, OPENJDK_BRANCH, SHAS['OPENJDK'], OPENJ9_REPO, OPENJ9_BRANCH, SHAS['OPENJ9'], OMR_REPO, OMR_BRANCH, SHAS['OMR'], params.VARIABLE_FILE)
SANITY_JOB = buildfile.build_with_one_upstream(SANITY_JOB_NAME, BUILD_JOB_NAME, BUILD_JOB.getNumber(), params.VARIABLE_FILE)
EXTENDED_JOB = buildfile.build_with_one_upstream(EXTENDED_JOB_NAME, BUILD_JOB_NAME, BUILD_JOB.getNumber(), params.VARIABLE_FILE)
jobs = buildfile.workflow()
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

def BUILD_JOB_NAME = 'Build-JDK9-linux_390-64_cmprssptrs'
def SANITY_JOB_NAME = 'Test-Sanity-JDK9-linux_390-64_cmprssptrs'
def EXTENDED_JOB_NAME = 'Test-Extended-JDK9-linux_390-64_cmprssptrs'
SDK_VERSION = '9'
SPEC = 'linux_390-64_cmprssptrs'

node('master') {
SDK_VERSION = '9'
SPEC = 'linux_390-64_cmprssptrs'

checkout scm
def commonFile = load 'buildenv/jenkins/common/variables-functions'
Expand All @@ -36,6 +33,4 @@ node('master') {
SHAS = buildfile.get_shas(OPENJDK_REPO, OPENJDK_BRANCH, OPENJ9_REPO, OPENJ9_BRANCH, OMR_REPO, OMR_BRANCH)
}

BUILD_JOB = buildfile.build(BUILD_JOB_NAME, OPENJDK_REPO, OPENJDK_BRANCH, SHAS['OPENJDK'], OPENJ9_REPO, OPENJ9_BRANCH, SHAS['OPENJ9'], OMR_REPO, OMR_BRANCH, SHAS['OMR'], params.VARIABLE_FILE)
SANITY_JOB = buildfile.build_with_one_upstream(SANITY_JOB_NAME, BUILD_JOB_NAME, BUILD_JOB.getNumber(), params.VARIABLE_FILE)
EXTENDED_JOB = buildfile.build_with_one_upstream(EXTENDED_JOB_NAME, BUILD_JOB_NAME, BUILD_JOB.getNumber(), params.VARIABLE_FILE)
jobs = buildfile.workflow()
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

def BUILD_JOB_NAME = 'Build-JDK9-linux_ppc-64_cmprssptrs_le'
def SANITY_JOB_NAME = 'Test-Sanity-JDK9-linux_ppc-64_cmprssptrs_le'
def EXTENDED_JOB_NAME = 'Test-Extended-JDK9-linux_ppc-64_cmprssptrs_le'
SDK_VERSION = '9'
SPEC = 'linux_ppc-64_cmprssptrs_le'

node('master') {
SDK_VERSION = '9'
SPEC = 'linux_ppc-64_cmprssptrs_le'

checkout scm
def commonFile = load 'buildenv/jenkins/common/variables-functions'
Expand All @@ -36,6 +33,4 @@ node('master') {
SHAS = buildfile.get_shas(OPENJDK_REPO, OPENJDK_BRANCH, OPENJ9_REPO, OPENJ9_BRANCH, OMR_REPO, OMR_BRANCH)
}

BUILD_JOB = buildfile.build(BUILD_JOB_NAME, OPENJDK_REPO, OPENJDK_BRANCH, SHAS['OPENJDK'], OPENJ9_REPO, OPENJ9_BRANCH, SHAS['OPENJ9'], OMR_REPO, OMR_BRANCH, SHAS['OMR'], params.VARIABLE_FILE)
SANITY_JOB = buildfile.build_with_one_upstream(SANITY_JOB_NAME, BUILD_JOB_NAME, BUILD_JOB.getNumber(), params.VARIABLE_FILE)
EXTENDED_JOB = buildfile.build_with_one_upstream(EXTENDED_JOB_NAME, BUILD_JOB_NAME, BUILD_JOB.getNumber(), params.VARIABLE_FILE)
jobs = buildfile.workflow()