2018-11-08 10:44:11 +02:00
|
|
|
import com.sap.piper.Utils
|
2017-07-11 15:12:03 +02:00
|
|
|
import hudson.AbortException
|
2019-03-20 13:14:57 +02:00
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.allOf
|
|
|
|
import static org.hamcrest.Matchers.containsString
|
|
|
|
import static org.hamcrest.Matchers.not
|
|
|
|
|
|
|
|
import org.hamcrest.Matchers
|
2019-03-29 16:02:09 +02:00
|
|
|
import org.hamcrest.BaseMatcher
|
|
|
|
import org.hamcrest.Description
|
2018-09-03 11:09:09 +02:00
|
|
|
import org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException
|
2018-05-28 11:56:06 +02:00
|
|
|
import org.junit.Assert
|
2017-07-11 15:12:03 +02:00
|
|
|
import org.junit.Before
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.rules.ExpectedException
|
2018-01-16 10:33:13 +02:00
|
|
|
import org.junit.rules.RuleChain
|
2018-06-06 11:19:19 +02:00
|
|
|
import util.BasePiperTest
|
2019-01-28 12:32:24 +02:00
|
|
|
import util.CommandLineMatcher
|
2018-09-03 11:09:09 +02:00
|
|
|
import util.JenkinsCredentialsRule
|
2019-01-28 12:32:24 +02:00
|
|
|
import util.JenkinsLockRule
|
2018-01-16 10:33:13 +02:00
|
|
|
import util.JenkinsLoggingRule
|
2019-01-28 12:32:24 +02:00
|
|
|
import util.JenkinsPropertiesRule
|
2018-08-31 10:22:43 +02:00
|
|
|
import util.JenkinsReadYamlRule
|
2018-01-16 16:03:00 +02:00
|
|
|
import util.JenkinsShellCallRule
|
2019-01-28 12:32:24 +02:00
|
|
|
import util.JenkinsShellCallRule.Type
|
2018-02-28 14:11:09 +02:00
|
|
|
import util.JenkinsStepRule
|
2019-01-28 12:32:24 +02:00
|
|
|
import util.JenkinsWithEnvRule
|
2019-03-25 17:42:23 +02:00
|
|
|
import util.JenkinsFileExistsRule
|
2018-01-26 15:55:15 +02:00
|
|
|
import util.Rules
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2018-06-06 11:19:19 +02:00
|
|
|
class NeoDeployTest extends BasePiperTest {
|
2018-02-20 14:10:14 +02:00
|
|
|
|
2018-01-16 10:33:13 +02:00
|
|
|
private ExpectedException thrown = new ExpectedException().none()
|
2019-01-22 10:22:15 +02:00
|
|
|
private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
|
2019-01-22 10:19:28 +02:00
|
|
|
private JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
|
2019-01-22 10:25:42 +02:00
|
|
|
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
2019-01-28 12:32:24 +02:00
|
|
|
private JenkinsLockRule lockRule = new JenkinsLockRule(this)
|
2019-03-25 17:42:23 +02:00
|
|
|
private JenkinsFileExistsRule fileExistsRule = new JenkinsFileExistsRule(this, ['warArchive.war', 'archive.mtar', 'war.properties'])
|
2019-01-28 12:32:24 +02:00
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
@Rule
|
2018-02-28 14:11:09 +02:00
|
|
|
public RuleChain ruleChain = Rules
|
|
|
|
.getCommonRules(this)
|
2018-08-31 10:22:43 +02:00
|
|
|
.around(new JenkinsReadYamlRule(this))
|
2019-03-26 15:16:01 +02:00
|
|
|
.around(new JenkinsPropertiesRule(this, warPropertiesFileName, warProperties))
|
2018-02-28 14:11:09 +02:00
|
|
|
.around(thrown)
|
2019-01-22 10:22:15 +02:00
|
|
|
.around(loggingRule)
|
2019-01-22 10:19:28 +02:00
|
|
|
.around(shellRule)
|
2018-09-03 11:09:09 +02:00
|
|
|
.around(new JenkinsCredentialsRule(this)
|
2019-01-28 12:32:24 +02:00
|
|
|
.withCredentials('myCredentialsId', 'anonymous', '********')
|
|
|
|
.withCredentials('CI_CREDENTIALS_ID', 'defaultUser', '********'))
|
2019-01-22 10:25:42 +02:00
|
|
|
.around(stepRule)
|
2019-01-28 12:32:24 +02:00
|
|
|
.around(lockRule)
|
|
|
|
.around(new JenkinsWithEnvRule(this))
|
2019-03-25 17:42:23 +02:00
|
|
|
.around(fileExistsRule)
|
2019-01-28 12:32:24 +02:00
|
|
|
|
2018-01-18 11:40:18 +02:00
|
|
|
|
2019-03-25 17:42:23 +02:00
|
|
|
private static warArchiveName = 'warArchive.war'
|
|
|
|
private static warPropertiesFileName = 'war.properties'
|
|
|
|
private static archiveName = 'archive.mtar'
|
2019-03-26 15:16:01 +02:00
|
|
|
private static warProperties
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2018-03-12 17:50:32 +02:00
|
|
|
|
2019-03-25 17:42:23 +02:00
|
|
|
@Before
|
|
|
|
void init() {
|
2018-02-12 12:03:07 +02:00
|
|
|
|
2019-03-26 15:16:01 +02:00
|
|
|
warProperties = new Properties()
|
|
|
|
warProperties.put('account', 'trialuser123')
|
|
|
|
warProperties.put('host', 'test.deploy.host.com')
|
|
|
|
warProperties.put('application', 'testApp')
|
2019-01-28 12:32:24 +02:00
|
|
|
|
2017-12-13 11:05:19 +02:00
|
|
|
helper.registerAllowedMethod('dockerExecute', [Map, Closure], null)
|
2019-03-25 17:42:23 +02:00
|
|
|
helper.registerAllowedMethod('pwd', [], { return './' })
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2019-01-28 12:32:24 +02:00
|
|
|
nullScript.commonPipelineEnvironment.configuration = [steps: [neoDeploy: [neo: [host: 'test.deploy.host.com', account: 'trialuser123']]]]
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
|
2017-12-11 12:15:51 +02:00
|
|
|
@Test
|
2019-03-18 15:55:51 +02:00
|
|
|
void straightForwardTestConfigViaParameters() {
|
2017-12-11 12:15:51 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 12:32:24 +02:00
|
|
|
source: archiveName,
|
|
|
|
neo:[credentialsId: 'myCredentialsId'],
|
2018-11-08 10:44:11 +02:00
|
|
|
utils: utils,
|
2018-02-28 14:11:09 +02:00
|
|
|
)
|
2017-12-11 12:15:51 +02:00
|
|
|
|
2019-01-22 10:19:28 +02:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 13:53:25 +02:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy-mta")
|
2019-01-28 12:32:24 +02:00
|
|
|
.hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com')
|
|
|
|
.hasSingleQuotedOption('account', 'trialuser123')
|
|
|
|
.hasOption('synchronous', '')
|
|
|
|
.hasSingleQuotedOption('user', 'anonymous')
|
|
|
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
|
|
|
.hasSingleQuotedOption('source', '.*'))
|
2017-12-11 12:15:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-03-18 15:55:51 +02:00
|
|
|
void straightForwardTestConfigViaConfiguration() {
|
2017-12-11 12:15:51 +02:00
|
|
|
|
2019-03-18 15:55:51 +02:00
|
|
|
nullScript.commonPipelineEnvironment.configuration = [steps: [
|
|
|
|
neoDeploy: [
|
|
|
|
neo: [
|
|
|
|
host: 'configuration-frwk.deploy.host.com',
|
|
|
|
account: 'configurationFrwkUser123'
|
|
|
|
],
|
|
|
|
source: archiveName
|
|
|
|
]
|
|
|
|
]]
|
2017-12-11 12:15:51 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 12:32:24 +02:00
|
|
|
neo:[credentialsId: 'myCredentialsId']
|
2017-12-11 12:15:51 +02:00
|
|
|
)
|
|
|
|
|
2019-01-22 10:19:28 +02:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 13:53:25 +02:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy-mta")
|
2019-01-28 12:32:24 +02:00
|
|
|
.hasSingleQuotedOption('host', 'configuration-frwk\\.deploy\\.host\\.com')
|
|
|
|
.hasSingleQuotedOption('account', 'configurationFrwkUser123')
|
|
|
|
.hasOption('synchronous', '')
|
|
|
|
.hasSingleQuotedOption('user', 'anonymous')
|
|
|
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
2019-03-18 15:55:51 +02:00
|
|
|
.hasSingleQuotedOption('source', archiveName))
|
2017-12-11 12:15:51 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 12:52:01 +02:00
|
|
|
@Test
|
|
|
|
void archivePathFromCPETest() {
|
2019-03-26 16:04:30 +02:00
|
|
|
|
2018-08-17 12:52:01 +02:00
|
|
|
nullScript.commonPipelineEnvironment.setMtarFilePath('archive.mtar')
|
2019-03-26 16:04:30 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript)
|
2018-08-17 12:52:01 +02:00
|
|
|
|
2019-01-22 10:19:28 +02:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 13:53:25 +02:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy-mta")
|
2019-01-28 12:32:24 +02:00
|
|
|
.hasSingleQuotedOption('source', 'archive.mtar'))
|
2018-08-17 12:52:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void archivePathFromParamsHasHigherPrecedenceThanCPETest() {
|
2019-03-26 16:04:30 +02:00
|
|
|
|
2018-08-17 12:52:01 +02:00
|
|
|
nullScript.commonPipelineEnvironment.setMtarFilePath('archive2.mtar')
|
2019-03-26 16:04:30 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 12:32:24 +02:00
|
|
|
source: "archive.mtar")
|
2018-08-17 12:52:01 +02:00
|
|
|
|
2019-01-22 10:19:28 +02:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 13:53:25 +02:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy-mta")
|
2019-01-28 12:32:24 +02:00
|
|
|
.hasSingleQuotedOption('source', 'archive.mtar'))
|
2018-08-17 12:52:01 +02:00
|
|
|
}
|
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void badCredentialsIdTest() {
|
|
|
|
|
2018-09-03 11:09:09 +02:00
|
|
|
thrown.expect(CredentialNotFoundException)
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 12:32:24 +02:00
|
|
|
source: archiveName,
|
|
|
|
neo:[credentialsId: 'badCredentialsId']
|
2018-01-16 18:06:25 +02:00
|
|
|
)
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void credentialsIdNotProvidedTest() {
|
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 12:32:24 +02:00
|
|
|
source: archiveName
|
2018-01-16 18:06:25 +02:00
|
|
|
)
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2019-01-22 10:19:28 +02:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 13:53:25 +02:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy-mta")
|
2019-01-28 12:32:24 +02:00
|
|
|
.hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com')
|
|
|
|
.hasSingleQuotedOption('account', 'trialuser123')
|
|
|
|
.hasOption('synchronous', '')
|
|
|
|
.hasSingleQuotedOption('user', 'defaultUser')
|
|
|
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
|
|
|
.hasSingleQuotedOption('source', '.*')
|
|
|
|
)
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void wrongArchivePathProvidedTest() {
|
|
|
|
|
|
|
|
thrown.expect(AbortException)
|
2019-01-28 12:32:24 +02:00
|
|
|
thrown.expectMessage('File wrongArchiveName cannot be found')
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 12:32:24 +02:00
|
|
|
source: 'wrongArchiveName')
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
2019-03-20 13:14:57 +02:00
|
|
|
void sanityChecksDeployModeMTATest() {
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
thrown.expect(Exception)
|
2019-03-20 13:14:57 +02:00
|
|
|
thrown.expectMessage(
|
|
|
|
allOf(
|
|
|
|
containsString('ERROR - NO VALUE AVAILABLE FOR:'),
|
|
|
|
containsString('neo/host'),
|
|
|
|
containsString('neo/account'),
|
|
|
|
containsString('source')))
|
|
|
|
|
|
|
|
nullScript.commonPipelineEnvironment.configuration = [:]
|
|
|
|
|
|
|
|
// deployMode mta is the default, but for the sake of transparency it is better to repeat it.
|
|
|
|
stepRule.step.neoDeploy(script: nullScript, deployMode: 'mta')
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void sanityChecksDeployModeWarPropertiesFileTest() {
|
|
|
|
|
|
|
|
thrown.expect(IllegalArgumentException)
|
|
|
|
// using this deploy mode 'account' and 'host' are provided by the properties file
|
|
|
|
thrown.expectMessage(
|
|
|
|
allOf(
|
|
|
|
containsString('ERROR - NO VALUE AVAILABLE FOR source'),
|
|
|
|
not(containsString('neo/host')),
|
|
|
|
not(containsString('neo/account'))))
|
|
|
|
|
|
|
|
nullScript.commonPipelineEnvironment.configuration = [:]
|
|
|
|
|
|
|
|
stepRule.step.neoDeploy(script: nullScript, deployMode: 'warPropertiesFile')
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void sanityChecksDeployModeWarParamsTest() {
|
|
|
|
|
|
|
|
thrown.expect(IllegalArgumentException)
|
|
|
|
thrown.expectMessage(
|
|
|
|
allOf(
|
|
|
|
containsString('ERROR - NO VALUE AVAILABLE FOR:'),
|
|
|
|
containsString('source'),
|
|
|
|
containsString('neo/application'),
|
|
|
|
containsString('neo/runtime'),
|
|
|
|
containsString('neo/runtimeVersion'),
|
|
|
|
containsString('neo/host'),
|
|
|
|
containsString('neo/account')))
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2018-06-06 11:19:19 +02:00
|
|
|
nullScript.commonPipelineEnvironment.configuration = [:]
|
2018-02-12 12:21:29 +02:00
|
|
|
|
2019-03-20 13:14:57 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript, deployMode: 'warParams')
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
|
2018-01-11 16:25:58 +02:00
|
|
|
@Test
|
|
|
|
void mtaDeployModeTest() {
|
|
|
|
|
2019-01-28 12:32:24 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript, source: archiveName, deployMode: 'mta')
|
2018-01-16 18:06:25 +02:00
|
|
|
|
2019-01-22 10:19:28 +02:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 13:53:25 +02:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy-mta")
|
2019-01-28 12:32:24 +02:00
|
|
|
.hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com')
|
|
|
|
.hasSingleQuotedOption('account', 'trialuser123')
|
|
|
|
.hasOption('synchronous', '')
|
|
|
|
.hasSingleQuotedOption('user', 'defaultUser')
|
|
|
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
|
|
|
.hasSingleQuotedOption('source', '.*'))
|
2018-05-28 11:56:06 +02:00
|
|
|
|
2018-01-11 16:25:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void warFileParamsDeployModeTest() {
|
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 12:32:24 +02:00
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125',
|
|
|
|
size: 'lite',
|
|
|
|
],
|
|
|
|
deployMode: 'warParams',
|
|
|
|
warAction: 'deploy',
|
|
|
|
source: warArchiveName)
|
2018-01-11 16:25:58 +02:00
|
|
|
|
2019-01-22 10:19:28 +02:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 13:53:25 +02:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy")
|
2019-01-28 12:32:24 +02:00
|
|
|
.hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com')
|
|
|
|
.hasSingleQuotedOption('account', 'trialuser123')
|
|
|
|
.hasSingleQuotedOption('application', 'testApp')
|
|
|
|
.hasSingleQuotedOption('runtime', 'neo-javaee6-wp')
|
|
|
|
.hasSingleQuotedOption('runtime-version', '2\\.125')
|
|
|
|
.hasSingleQuotedOption('size', 'lite')
|
|
|
|
.hasSingleQuotedOption('user', 'defaultUser')
|
|
|
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
|
|
|
.hasSingleQuotedOption('source', '.*\\.war'))
|
2018-05-28 11:56:06 +02:00
|
|
|
|
2018-01-11 16:25:58 +02:00
|
|
|
}
|
|
|
|
|
2018-01-17 15:01:15 +02:00
|
|
|
@Test
|
|
|
|
void warFileParamsDeployModeRollingUpdateTest() {
|
|
|
|
|
2019-01-28 12:32:24 +02:00
|
|
|
shellRule.setReturnValue(JenkinsShellCallRule.Type.REGEX, '.* status .*', 'Status: STARTED')
|
|
|
|
|
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
|
|
|
source: warArchiveName,
|
|
|
|
deployMode: 'warParams',
|
|
|
|
warAction: 'rolling-update',
|
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125',
|
|
|
|
size: 'lite'
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 13:53:25 +02:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh rolling-update")
|
2019-01-28 12:32:24 +02:00
|
|
|
.hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com')
|
|
|
|
.hasSingleQuotedOption('account', 'trialuser123')
|
|
|
|
.hasSingleQuotedOption('application', 'testApp')
|
|
|
|
.hasSingleQuotedOption('runtime', 'neo-javaee6-wp')
|
|
|
|
.hasSingleQuotedOption('runtime-version', '2\\.125')
|
|
|
|
.hasSingleQuotedOption('size', 'lite')
|
|
|
|
.hasSingleQuotedOption('user', 'defaultUser')
|
|
|
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
|
|
|
.hasSingleQuotedOption('source', '.*\\.war'))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void warFirstTimeRollingUpdateTest() {
|
|
|
|
|
|
|
|
shellRule.setReturnValue(JenkinsShellCallRule.Type.REGEX, '.* status .*', 'ERROR: Application [testApp] not found')
|
|
|
|
|
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
|
|
|
source: warArchiveName,
|
|
|
|
deployMode: 'warParams',
|
|
|
|
warAction: 'rolling-update',
|
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125'
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
Assert.assertThat(shellRule.shell,
|
|
|
|
new CommandLineMatcher()
|
2019-03-07 13:53:25 +02:00
|
|
|
.hasProlog("neo.sh deploy")
|
2019-01-28 12:32:24 +02:00
|
|
|
.hasSingleQuotedOption('application', 'testApp'))
|
|
|
|
}
|
|
|
|
|
|
|
|
void warNotStartedRollingUpdateTest() {
|
|
|
|
|
|
|
|
shellRule.setReturnValue(JenkinsShellCallRule.Type.REGEX, '.* status .*', 'Status: STOPPED')
|
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 12:32:24 +02:00
|
|
|
source: warArchiveName,
|
|
|
|
deployMode: 'warParams',
|
|
|
|
warAction: 'rolling-update',
|
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125'
|
|
|
|
]
|
|
|
|
)
|
2018-01-17 15:01:15 +02:00
|
|
|
|
2019-01-22 10:19:28 +02:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-01-28 12:32:24 +02:00
|
|
|
new CommandLineMatcher()
|
|
|
|
.hasProlog("\"/opt/neo/tools/neo.sh\" deploy")
|
|
|
|
.hasSingleQuotedOption('application', 'testApp'))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void showLogsOnFailingDeployment() {
|
|
|
|
|
|
|
|
thrown.expect(Exception)
|
|
|
|
shellRule.failExecution(Type.REGEX, '.* deploy .*')
|
|
|
|
|
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
|
|
|
source: warArchiveName,
|
|
|
|
deployMode: 'warParams',
|
|
|
|
warAction: 'deploy',
|
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125'
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
Assert.assertThat(shellRule.shell,
|
|
|
|
new CommandLineMatcher().hasProlog("cat /var/log/neo/*"))
|
2018-01-17 15:01:15 +02:00
|
|
|
}
|
|
|
|
|
2018-01-11 16:25:58 +02:00
|
|
|
@Test
|
|
|
|
void warPropertiesFileDeployModeTest() {
|
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 12:32:24 +02:00
|
|
|
source: warArchiveName,
|
|
|
|
deployMode: 'warPropertiesFile',
|
|
|
|
warAction: 'deploy',
|
|
|
|
neo: [
|
2019-03-26 15:16:01 +02:00
|
|
|
propertiesFile: warPropertiesFileName,
|
2019-01-28 12:32:24 +02:00
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125',
|
|
|
|
size: 'lite'
|
|
|
|
]
|
|
|
|
)
|
2018-01-11 16:25:58 +02:00
|
|
|
|
2019-01-22 10:19:28 +02:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 13:53:25 +02:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy")
|
2019-03-26 15:16:01 +02:00
|
|
|
.hasArgument('war.properties')
|
2019-01-28 12:32:24 +02:00
|
|
|
.hasSingleQuotedOption('user', 'defaultUser')
|
|
|
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
|
|
|
.hasSingleQuotedOption('source', '.*\\.war'))
|
2018-01-11 16:25:58 +02:00
|
|
|
}
|
|
|
|
|
2018-01-17 15:01:15 +02:00
|
|
|
@Test
|
|
|
|
void warPropertiesFileDeployModeRollingUpdateTest() {
|
|
|
|
|
2019-01-28 12:32:24 +02:00
|
|
|
shellRule.setReturnValue(JenkinsShellCallRule.Type.REGEX, '.* status .*', 'Status: STARTED')
|
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 12:32:24 +02:00
|
|
|
source: warArchiveName,
|
|
|
|
deployMode: 'warPropertiesFile',
|
|
|
|
warAction: 'rolling-update',
|
|
|
|
neo: [
|
2019-03-26 15:16:01 +02:00
|
|
|
propertiesFile: warPropertiesFileName,
|
2019-01-28 12:32:24 +02:00
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125',
|
|
|
|
size: 'lite'
|
|
|
|
])
|
2018-01-17 15:01:15 +02:00
|
|
|
|
2019-01-22 10:19:28 +02:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 13:53:25 +02:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh rolling-update")
|
2019-03-26 15:16:01 +02:00
|
|
|
.hasArgument('war.properties')
|
2019-01-28 12:32:24 +02:00
|
|
|
.hasSingleQuotedOption('user', 'defaultUser')
|
|
|
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
|
|
|
.hasSingleQuotedOption('source', '.*\\.war'))
|
2018-01-17 15:01:15 +02:00
|
|
|
}
|
|
|
|
|
2018-01-16 11:54:17 +02:00
|
|
|
@Test
|
|
|
|
void illegalDeployModeTest() {
|
|
|
|
|
2018-01-17 12:19:02 +02:00
|
|
|
thrown.expect(Exception)
|
2019-01-28 12:32:24 +02:00
|
|
|
thrown.expectMessage("Invalid deployMode = 'illegalMode'. Valid 'deployMode' values are: [mta, warParams, warPropertiesFile].")
|
2018-01-16 11:54:17 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 12:32:24 +02:00
|
|
|
source: warArchiveName,
|
2018-01-16 18:06:25 +02:00
|
|
|
deployMode: 'illegalMode',
|
|
|
|
warAction: 'deploy',
|
2019-01-28 12:32:24 +02:00
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125',
|
|
|
|
size: 'lite'
|
|
|
|
])
|
2018-01-16 11:54:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void illegalWARActionTest() {
|
|
|
|
|
2018-01-17 12:19:02 +02:00
|
|
|
thrown.expect(Exception)
|
2019-01-28 12:32:24 +02:00
|
|
|
thrown.expectMessage("Invalid warAction = 'illegalWARAction'. Valid 'warAction' values are: [deploy, rolling-update].")
|
2018-01-16 11:54:17 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 12:32:24 +02:00
|
|
|
source: warArchiveName,
|
2018-01-16 18:06:25 +02:00
|
|
|
deployMode: 'warParams',
|
|
|
|
warAction: 'illegalWARAction',
|
2019-01-28 12:32:24 +02:00
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125',
|
|
|
|
size: 'lite'
|
|
|
|
])
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
2019-03-29 16:02:09 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void dontSwallowExceptionWhenUnableToProvideLogsTest() {
|
|
|
|
|
|
|
|
thrown.expect(AbortException)
|
2019-04-12 13:10:15 +02:00
|
|
|
thrown.expectMessage('Something went wrong during neo deployment')
|
2019-03-29 16:02:09 +02:00
|
|
|
thrown.expect(new BaseMatcher() {
|
|
|
|
|
|
|
|
def expectedException = AbortException
|
|
|
|
def expectedText = 'Cannot provide logs.'
|
|
|
|
|
|
|
|
boolean matches(def ex) {
|
|
|
|
def suppressed = ex.getSuppressed()
|
|
|
|
return (suppressed.size() == 1 &&
|
|
|
|
suppressed[0] in expectedException &&
|
|
|
|
suppressed[0].message == expectedText)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void describeTo(Description d) {
|
|
|
|
d.appendText(" a suppressed ${expectedException} with message ${expectedText}.")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
loggingRule.expect('Unable to provide the logs.')
|
|
|
|
|
2019-04-12 13:10:15 +02:00
|
|
|
helper.registerAllowedMethod('fileExists', [String],
|
|
|
|
{ f ->
|
|
|
|
f == 'archive.mtar'
|
|
|
|
}
|
|
|
|
)
|
|
|
|
helper.registerAllowedMethod('sh', [Map],
|
|
|
|
{ m ->
|
|
|
|
if(m.script.toString().contains('neo.sh deploy-mta'))
|
|
|
|
throw new AbortException('Something went wrong during neo deployment.')
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2019-03-29 16:02:09 +02:00
|
|
|
helper.registerAllowedMethod("sh", [String],
|
|
|
|
{ cmd ->
|
|
|
|
if (cmd == 'cat logs/neo/*')
|
|
|
|
throw new AbortException('Cannot provide logs.')
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
|
|
|
|
|
|
|
source: archiveName,
|
|
|
|
neo:[credentialsId: 'myCredentialsId'],
|
|
|
|
deployMode: 'mta',
|
|
|
|
utils: utils,
|
|
|
|
)
|
|
|
|
}
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|