Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
JNLP mode patch & test (#22)
Browse files Browse the repository at this point in the history
* Attempting to fix cinch mode issue by ensuring env object gets passed as is

* Export and read back env vars as map

* Simplifiy env down to build a Map for the properties we know we care about. Otherwise we have to print to file and readback

* Testing for variable propagation into the libraries, since JNLP issue was an env bug
  • Loading branch information
jaypoulz authored Oct 2, 2018
1 parent 678c040 commit 9cb2a7b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
5 changes: 4 additions & 1 deletion test/PipelineTestScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import groovy.json.JsonSlurper
class PipelineTestScript extends Script {

private static final Logger LOG = Logger.getLogger(PipelineTestScript.name)
public static final String JENKINS_MASTER_URL_DEFAULT = 'https://test-jenkins.com'
public static final String JSWARM_EXTRA_ARGS_DEFAULT = '-tunnel test-jenkins.com:8080'

@Override
Object run() {
Expand Down Expand Up @@ -136,7 +138,8 @@ class PipelineTestScript extends Script {
result:'SUCCESS',
]
env = [
environment:[:],
JENKINS_MASTER_URL:JENKINS_MASTER_URL_DEFAULT,
JSWARM_EXTRA_ARGS:JSWARM_EXTRA_ARGS_DEFAULT,
]
params = [:]
scm = [:]
Expand Down
11 changes: 3 additions & 8 deletions test/com/redhat/ci/provisioner/ProvisioningConfigTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class ProvisioningConfigTest {
private static final String SSH_PRIV_KEY_CREDENTIAL_ID_DEFAULT = 'test-sshprivkey'
private static final String SSH_PUB_KEY_CREDENTIAL_ID_DEFAULT = 'test-sshpubkey'
private static final String JENKINS_SLAVE_CREDENTIAL_ID_DEFAULT = 'test-jenkins-slave-credentials'
private static final String JENKINS_MASTER_URL_DEFAULT = 'https://test-jenkins.com'
private static final String JSWARM_EXTRA_ARGS_DEFAULT = '-tunnel test-jenkins.com:8080'

@Test
void should_support_legacy_api() {
Expand Down Expand Up @@ -47,24 +45,21 @@ class ProvisioningConfigTest {

@Test
void should_load_customized_configuration() {
Map script = [:]
Script script = new PipelineTestScript()
script.params = [:]
script.env = [:]
script.params.KRBPRINCIPALCREDENTIALID = KRB_PRINCIPAL_CREDENTIAL_ID_DEFAULT
script.params.KEYTABCREDENTIALID = KEYTAB_CREDENTIAL_ID_DEFAULT
script.params.SSHPRIVKEYCREDENTIALID = SSH_PRIV_KEY_CREDENTIAL_ID_DEFAULT
script.params.SSHPUBKEYCREDENTIALID = SSH_PUB_KEY_CREDENTIAL_ID_DEFAULT
script.params.JENKINSSLAVECREDENTIALID = JENKINS_SLAVE_CREDENTIAL_ID_DEFAULT
script.env.JENKINS_MASTER_URL = JENKINS_MASTER_URL_DEFAULT
script.env.JSWARM_EXTRA_ARGS = JSWARM_EXTRA_ARGS_DEFAULT

ProvisioningConfig config = new ProvisioningConfig(script.params, script.env)
assert(config.krbPrincipalCredentialId == KRB_PRINCIPAL_CREDENTIAL_ID_DEFAULT)
assert(config.keytabCredentialId == KEYTAB_CREDENTIAL_ID_DEFAULT)
assert(config.sshPrivKeyCredentialId == SSH_PRIV_KEY_CREDENTIAL_ID_DEFAULT)
assert(config.sshPubKeyCredentialId == SSH_PUB_KEY_CREDENTIAL_ID_DEFAULT)
assert(config.jenkinsSlaveCredentialId == JENKINS_SLAVE_CREDENTIAL_ID_DEFAULT)
assert(config.jenkinsMasterUrl == JENKINS_MASTER_URL_DEFAULT)
assert(config.jswarmExtraArgs == JSWARM_EXTRA_ARGS_DEFAULT)
assert(config.jenkinsMasterUrl == PipelineTestScript.JENKINS_MASTER_URL_DEFAULT)
assert(config.jswarmExtraArgs == PipelineTestScript.JSWARM_EXTRA_ARGS_DEFAULT)
}
}
7 changes: 6 additions & 1 deletion vars/TestUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ class TestUtils {
* @return ProvisioningConfig Configuration file for provisioning.
*/
static ProvisioningConfig getProvisioningConfig(Script script) {
new ProvisioningConfig(script.params, script.env.environment)
Map env = [
JENKINS_MASTER_URL:script.env.JENKINS_MASTER_URL,
JSWARM_EXTRA_ARGS:script.env.JSWARM_EXTRA_ARGS,
]

new ProvisioningConfig(script.params, env)
}

/**
Expand Down

0 comments on commit 9cb2a7b

Please sign in to comment.