2018-11-08 09:44:11 +01:00
|
|
|
import com.sap.piper.Utils
|
2017-07-11 15:12:03 +02:00
|
|
|
import hudson.AbortException
|
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
|
2019-01-28 11:32:24 +01:00
|
|
|
import org.junit.BeforeClass
|
|
|
|
import org.junit.ClassRule
|
2017-07-11 15:12:03 +02:00
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.rules.ExpectedException
|
2018-01-16 09:33:13 +01:00
|
|
|
import org.junit.rules.RuleChain
|
2019-01-28 11:32:24 +01:00
|
|
|
import org.junit.rules.TemporaryFolder
|
2018-06-06 11:19:19 +02:00
|
|
|
import util.BasePiperTest
|
2019-01-28 11:32:24 +01:00
|
|
|
import util.CommandLineMatcher
|
2018-09-03 11:09:09 +02:00
|
|
|
import util.JenkinsCredentialsRule
|
2019-01-28 11:32:24 +01:00
|
|
|
import util.JenkinsLockRule
|
2018-01-16 09:33:13 +01:00
|
|
|
import util.JenkinsLoggingRule
|
2019-01-28 11:32:24 +01:00
|
|
|
import util.JenkinsPropertiesRule
|
2018-08-31 10:22:43 +02:00
|
|
|
import util.JenkinsReadYamlRule
|
2018-01-16 15:03:00 +01:00
|
|
|
import util.JenkinsShellCallRule
|
2019-01-28 11:32:24 +01:00
|
|
|
import util.JenkinsShellCallRule.Type
|
2018-02-28 13:11:09 +01:00
|
|
|
import util.JenkinsStepRule
|
2019-01-28 11:32:24 +01:00
|
|
|
import util.JenkinsWithEnvRule
|
2018-01-26 14:55:15 +01: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 13:10:14 +01:00
|
|
|
|
|
|
|
def toolJavaValidateCalled = false
|
|
|
|
|
2018-02-12 11:03:07 +01:00
|
|
|
@ClassRule
|
|
|
|
public static TemporaryFolder tmp = new TemporaryFolder()
|
|
|
|
|
2018-01-16 09:33:13 +01:00
|
|
|
private ExpectedException thrown = new ExpectedException().none()
|
2019-01-22 09:22:15 +01:00
|
|
|
private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
|
2019-01-22 09:19:28 +01:00
|
|
|
private JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
|
2019-01-22 09:25:42 +01:00
|
|
|
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
2019-01-28 11:32:24 +01:00
|
|
|
private JenkinsLockRule lockRule = new JenkinsLockRule(this)
|
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
@Rule
|
2018-02-28 13:11:09 +01:00
|
|
|
public RuleChain ruleChain = Rules
|
|
|
|
.getCommonRules(this)
|
2018-08-31 10:22:43 +02:00
|
|
|
.around(new JenkinsReadYamlRule(this))
|
2019-01-28 11:32:24 +01:00
|
|
|
.around(new JenkinsPropertiesRule(this, propertiesFileName, configProperties))
|
2018-02-28 13:11:09 +01:00
|
|
|
.around(thrown)
|
2019-01-22 09:22:15 +01:00
|
|
|
.around(loggingRule)
|
2019-01-22 09:19:28 +01:00
|
|
|
.around(shellRule)
|
2018-09-03 11:09:09 +02:00
|
|
|
.around(new JenkinsCredentialsRule(this)
|
2019-01-28 11:32:24 +01:00
|
|
|
.withCredentials('myCredentialsId', 'anonymous', '********')
|
|
|
|
.withCredentials('CI_CREDENTIALS_ID', 'defaultUser', '********'))
|
2019-01-22 09:25:42 +01:00
|
|
|
.around(stepRule)
|
2019-01-28 11:32:24 +01:00
|
|
|
.around(lockRule)
|
|
|
|
.around(new JenkinsWithEnvRule(this))
|
|
|
|
|
2018-01-18 10:40:18 +01:00
|
|
|
|
2018-02-12 11:03:07 +01:00
|
|
|
private static workspacePath
|
|
|
|
private static warArchiveName
|
|
|
|
private static propertiesFileName
|
|
|
|
private static archiveName
|
2019-01-28 11:32:24 +01:00
|
|
|
private static configProperties
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2018-03-12 16:50:32 +01:00
|
|
|
|
2018-02-12 11:03:07 +01:00
|
|
|
@BeforeClass
|
|
|
|
static void createTestFiles() {
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2018-02-12 10:52:13 +01:00
|
|
|
workspacePath = "${tmp.getRoot()}"
|
2018-01-18 10:40:18 +01:00
|
|
|
warArchiveName = 'warArchive.war'
|
|
|
|
propertiesFileName = 'config.properties'
|
2018-02-12 11:03:07 +01:00
|
|
|
archiveName = 'archive.mtar'
|
|
|
|
|
2019-01-28 11:32:24 +01:00
|
|
|
configProperties = new Properties()
|
|
|
|
configProperties.put('account', 'trialuser123')
|
|
|
|
configProperties.put('host', 'test.deploy.host.com')
|
|
|
|
configProperties.put('application', 'testApp')
|
|
|
|
|
2018-02-13 15:06:09 +01:00
|
|
|
tmp.newFile(warArchiveName) << 'dummy war archive'
|
|
|
|
tmp.newFile(propertiesFileName) << 'dummy properties file'
|
|
|
|
tmp.newFile(archiveName) << 'dummy archive'
|
2018-02-12 11:03:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Before
|
|
|
|
void init() {
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2017-12-13 10:05:19 +01:00
|
|
|
helper.registerAllowedMethod('dockerExecute', [Map, Closure], null)
|
2018-01-18 10:40:18 +01:00
|
|
|
helper.registerAllowedMethod('fileExists', [String], { s -> return new File(workspacePath, s).exists() })
|
2019-01-28 11:32:24 +01:00
|
|
|
helper.registerAllowedMethod('pwd', [], { return workspacePath })
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2019-01-28 11:32:24 +01: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 11:15:51 +01:00
|
|
|
@Test
|
2019-03-18 14:55:51 +01:00
|
|
|
void straightForwardTestConfigViaParameters() {
|
2017-12-11 11:15:51 +01:00
|
|
|
|
2018-11-08 09:44:11 +01:00
|
|
|
boolean notifyOldConfigFrameworkUsed = true
|
|
|
|
|
|
|
|
def utils = new Utils() {
|
|
|
|
void pushToSWA(Map parameters, Map config) {
|
|
|
|
notifyOldConfigFrameworkUsed = parameters.stepParam4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: archiveName,
|
|
|
|
neo:[credentialsId: 'myCredentialsId'],
|
2018-11-08 09:44:11 +01:00
|
|
|
utils: utils,
|
2018-02-28 13:11:09 +01:00
|
|
|
)
|
2017-12-11 11:15:51 +01:00
|
|
|
|
2019-01-22 09:19:28 +01:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 12:53:25 +01:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy-mta")
|
2019-01-28 11:32:24 +01:00
|
|
|
.hasSingleQuotedOption('host', 'test\\.deploy\\.host\\.com')
|
|
|
|
.hasSingleQuotedOption('account', 'trialuser123')
|
|
|
|
.hasOption('synchronous', '')
|
|
|
|
.hasSingleQuotedOption('user', 'anonymous')
|
|
|
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
|
|
|
.hasSingleQuotedOption('source', '.*'))
|
2018-11-08 09:44:11 +01:00
|
|
|
|
|
|
|
assert !notifyOldConfigFrameworkUsed
|
2017-12-11 11:15:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-03-18 14:55:51 +01:00
|
|
|
void straightForwardTestConfigViaConfiguration() {
|
2017-12-11 11:15:51 +01:00
|
|
|
|
2019-03-18 14:55:51 +01:00
|
|
|
nullScript.commonPipelineEnvironment.configuration = [steps: [
|
|
|
|
neoDeploy: [
|
|
|
|
neo: [
|
|
|
|
host: 'configuration-frwk.deploy.host.com',
|
|
|
|
account: 'configurationFrwkUser123'
|
|
|
|
],
|
|
|
|
source: archiveName
|
|
|
|
]
|
|
|
|
]]
|
2017-12-11 11:15:51 +01:00
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
neo:[credentialsId: 'myCredentialsId']
|
2017-12-11 11:15:51 +01:00
|
|
|
)
|
|
|
|
|
2019-01-22 09:19:28 +01:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 12:53:25 +01:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy-mta")
|
2019-01-28 11:32:24 +01:00
|
|
|
.hasSingleQuotedOption('host', 'configuration-frwk\\.deploy\\.host\\.com')
|
|
|
|
.hasSingleQuotedOption('account', 'configurationFrwkUser123')
|
|
|
|
.hasOption('synchronous', '')
|
|
|
|
.hasSingleQuotedOption('user', 'anonymous')
|
|
|
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
2019-03-18 14:55:51 +01:00
|
|
|
.hasSingleQuotedOption('source', archiveName))
|
2017-12-11 11:15:51 +01:00
|
|
|
}
|
|
|
|
|
2018-08-17 12:52:01 +02:00
|
|
|
@Test
|
|
|
|
void archivePathFromCPETest() {
|
|
|
|
nullScript.commonPipelineEnvironment.setMtarFilePath('archive.mtar')
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript)
|
2018-08-17 12:52:01 +02:00
|
|
|
|
2019-01-22 09:19:28 +01:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 12:53:25 +01:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy-mta")
|
2019-01-28 11:32:24 +01:00
|
|
|
.hasSingleQuotedOption('source', 'archive.mtar'))
|
2018-08-17 12:52:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void archivePathFromParamsHasHigherPrecedenceThanCPETest() {
|
|
|
|
nullScript.commonPipelineEnvironment.setMtarFilePath('archive2.mtar')
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: "archive.mtar")
|
2018-08-17 12:52:01 +02:00
|
|
|
|
2019-01-22 09:19:28 +01:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 12:53:25 +01:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy-mta")
|
2019-01-28 11:32:24 +01: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 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: archiveName,
|
|
|
|
neo:[credentialsId: 'badCredentialsId']
|
2018-01-16 17:06:25 +01:00
|
|
|
)
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void credentialsIdNotProvidedTest() {
|
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: archiveName
|
2018-01-16 17:06:25 +01:00
|
|
|
)
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2019-01-22 09:19:28 +01:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 12:53:25 +01:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy-mta")
|
2019-01-28 11:32:24 +01: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 archiveNotProvidedTest() {
|
|
|
|
|
|
|
|
thrown.expect(Exception)
|
2019-01-28 11:32:24 +01:00
|
|
|
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR source')
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript)
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void wrongArchivePathProvidedTest() {
|
|
|
|
|
|
|
|
thrown.expect(AbortException)
|
2019-01-28 11:32:24 +01:00
|
|
|
thrown.expectMessage('File wrongArchiveName cannot be found')
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: 'wrongArchiveName')
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void scriptNotProvidedTest() {
|
|
|
|
|
|
|
|
thrown.expect(Exception)
|
2019-03-13 15:32:31 +01:00
|
|
|
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR neo/host')
|
2017-07-11 15:12:03 +02:00
|
|
|
|
2018-06-06 11:19:19 +02:00
|
|
|
nullScript.commonPipelineEnvironment.configuration = [:]
|
2018-02-12 11:21:29 +01:00
|
|
|
|
2019-01-28 11:32:24 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript, source: archiveName)
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
|
2018-01-11 15:25:58 +01:00
|
|
|
@Test
|
|
|
|
void mtaDeployModeTest() {
|
|
|
|
|
2019-01-28 11:32:24 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript, source: archiveName, deployMode: 'mta')
|
2018-01-16 17:06:25 +01:00
|
|
|
|
2019-01-22 09:19:28 +01:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 12:53:25 +01:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy-mta")
|
2019-01-28 11:32:24 +01: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 15:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void warFileParamsDeployModeTest() {
|
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125',
|
|
|
|
size: 'lite',
|
|
|
|
],
|
|
|
|
deployMode: 'warParams',
|
|
|
|
warAction: 'deploy',
|
|
|
|
source: warArchiveName)
|
2018-01-11 15:25:58 +01:00
|
|
|
|
2019-01-22 09:19:28 +01:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 12:53:25 +01:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy")
|
2019-01-28 11:32:24 +01: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 15:25:58 +01:00
|
|
|
}
|
|
|
|
|
2018-01-17 14:01:15 +01:00
|
|
|
@Test
|
|
|
|
void warFileParamsDeployModeRollingUpdateTest() {
|
|
|
|
|
2019-01-28 11:32:24 +01: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 12:53:25 +01:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh rolling-update")
|
2019-01-28 11:32:24 +01: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 12:53:25 +01:00
|
|
|
.hasProlog("neo.sh deploy")
|
2019-01-28 11:32:24 +01:00
|
|
|
.hasSingleQuotedOption('application', 'testApp'))
|
|
|
|
}
|
|
|
|
|
|
|
|
void warNotStartedRollingUpdateTest() {
|
|
|
|
|
|
|
|
shellRule.setReturnValue(JenkinsShellCallRule.Type.REGEX, '.* status .*', 'Status: STOPPED')
|
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: warArchiveName,
|
|
|
|
deployMode: 'warParams',
|
|
|
|
warAction: 'rolling-update',
|
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125'
|
|
|
|
]
|
|
|
|
)
|
2018-01-17 14:01:15 +01:00
|
|
|
|
2019-01-22 09:19:28 +01:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-01-28 11:32:24 +01: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 14:01:15 +01:00
|
|
|
}
|
|
|
|
|
2018-01-11 15:25:58 +01:00
|
|
|
@Test
|
|
|
|
void warPropertiesFileDeployModeTest() {
|
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: warArchiveName,
|
|
|
|
deployMode: 'warPropertiesFile',
|
|
|
|
warAction: 'deploy',
|
|
|
|
neo: [
|
|
|
|
propertiesFile: propertiesFileName,
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125',
|
|
|
|
size: 'lite'
|
|
|
|
]
|
|
|
|
)
|
2018-01-11 15:25:58 +01:00
|
|
|
|
2019-01-22 09:19:28 +01:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 12:53:25 +01:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh deploy")
|
2019-01-28 11:32:24 +01:00
|
|
|
.hasArgument("config.properties")
|
|
|
|
.hasSingleQuotedOption('user', 'defaultUser')
|
|
|
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
|
|
|
.hasSingleQuotedOption('source', '.*\\.war'))
|
2018-01-11 15:25:58 +01:00
|
|
|
}
|
|
|
|
|
2018-01-17 14:01:15 +01:00
|
|
|
@Test
|
|
|
|
void warPropertiesFileDeployModeRollingUpdateTest() {
|
|
|
|
|
2019-01-28 11:32:24 +01:00
|
|
|
shellRule.setReturnValue(JenkinsShellCallRule.Type.REGEX, '.* status .*', 'Status: STARTED')
|
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: warArchiveName,
|
|
|
|
deployMode: 'warPropertiesFile',
|
|
|
|
warAction: 'rolling-update',
|
|
|
|
neo: [
|
|
|
|
propertiesFile: propertiesFileName,
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125',
|
|
|
|
size: 'lite'
|
|
|
|
])
|
2018-01-17 14:01:15 +01:00
|
|
|
|
2019-01-22 09:19:28 +01:00
|
|
|
Assert.assertThat(shellRule.shell,
|
2019-03-07 12:53:25 +01:00
|
|
|
new CommandLineMatcher().hasProlog("neo.sh rolling-update")
|
2019-01-28 11:32:24 +01:00
|
|
|
.hasArgument('config.properties')
|
|
|
|
.hasSingleQuotedOption('user', 'defaultUser')
|
|
|
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
|
|
|
.hasSingleQuotedOption('source', '.*\\.war'))
|
2018-01-17 14:01:15 +01:00
|
|
|
}
|
|
|
|
|
2018-01-11 15:25:58 +01:00
|
|
|
@Test
|
|
|
|
void applicationNameNotProvidedTest() {
|
|
|
|
|
|
|
|
thrown.expect(Exception)
|
2019-03-13 15:32:31 +01:00
|
|
|
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR neo/application')
|
2018-01-11 15:25:58 +01:00
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: warArchiveName,
|
|
|
|
deployMode: 'warParams',
|
|
|
|
neo: [
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125'
|
|
|
|
]
|
|
|
|
)
|
2018-01-11 15:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void runtimeNotProvidedTest() {
|
|
|
|
|
|
|
|
thrown.expect(Exception)
|
2019-03-13 15:32:31 +01:00
|
|
|
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR neo/runtime')
|
2018-01-11 15:25:58 +01:00
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: warArchiveName,
|
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtimeVersion: '2.125'
|
|
|
|
],
|
|
|
|
deployMode: 'warParams')
|
2018-01-11 15:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void runtimeVersionNotProvidedTest() {
|
|
|
|
|
|
|
|
thrown.expect(Exception)
|
2019-03-13 15:32:31 +01:00
|
|
|
thrown.expectMessage('ERROR - NO VALUE AVAILABLE FOR neo/runtimeVersion')
|
2018-01-11 15:25:58 +01:00
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: warArchiveName,
|
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp'
|
|
|
|
],
|
|
|
|
deployMode: 'warParams')
|
2018-01-16 10:54:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void illegalDeployModeTest() {
|
|
|
|
|
2018-01-17 11:19:02 +01:00
|
|
|
thrown.expect(Exception)
|
2019-01-28 11:32:24 +01:00
|
|
|
thrown.expectMessage("Invalid deployMode = 'illegalMode'. Valid 'deployMode' values are: [mta, warParams, warPropertiesFile].")
|
2018-01-16 10:54:17 +01:00
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: warArchiveName,
|
2018-01-16 17:06:25 +01:00
|
|
|
deployMode: 'illegalMode',
|
|
|
|
warAction: 'deploy',
|
2019-01-28 11:32:24 +01:00
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125',
|
|
|
|
size: 'lite'
|
|
|
|
])
|
2018-01-16 10:54:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void illegalWARActionTest() {
|
|
|
|
|
2018-01-17 11:19:02 +01:00
|
|
|
thrown.expect(Exception)
|
2019-01-28 11:32:24 +01:00
|
|
|
thrown.expectMessage("Invalid warAction = 'illegalWARAction'. Valid 'warAction' values are: [deploy, rolling-update].")
|
2018-01-16 10:54:17 +01:00
|
|
|
|
2019-01-22 09:25:42 +01:00
|
|
|
stepRule.step.neoDeploy(script: nullScript,
|
2019-01-28 11:32:24 +01:00
|
|
|
source: warArchiveName,
|
2018-01-16 17:06:25 +01:00
|
|
|
deployMode: 'warParams',
|
|
|
|
warAction: 'illegalWARAction',
|
2019-01-28 11:32:24 +01:00
|
|
|
neo: [
|
|
|
|
application: 'testApp',
|
|
|
|
runtime: 'neo-javaee6-wp',
|
|
|
|
runtimeVersion: '2.125',
|
|
|
|
size: 'lite'
|
|
|
|
])
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|
|
|
|
}
|