2017-07-11 15:12:03 +02:00
import hudson.AbortException
2017-12-11 12:15:51 +02:00
2017-07-11 15:12:03 +02:00
import org.junit.rules.TemporaryFolder
2018-01-16 18:06:25 +02:00
import com.lesfurets.jenkins.unit.BasePipelineTest
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-01-26 14:35:49 +02:00
2018-01-16 10:33:13 +02:00
import util.JenkinsLoggingRule
2018-01-16 16:03:00 +02:00
import util.JenkinsShellCallRule
2018-01-26 15:55:15 +02:00
import util.Rules
2017-07-11 15:12:03 +02:00
2018-01-16 18:06:25 +02:00
class NeoDeploymentTest extends BasePipelineTest {
2017-07-11 15:12:03 +02:00
2018-01-16 10:33:13 +02:00
private ExpectedException thrown = new ExpectedException ( ) . none ( )
private TemporaryFolder tmp = new TemporaryFolder ( )
private JenkinsLoggingRule jlr = new JenkinsLoggingRule ( this )
2018-01-16 16:03:00 +02:00
private JenkinsShellCallRule jscr = new JenkinsShellCallRule ( this )
2017-07-11 15:12:03 +02:00
@Rule
2018-01-26 15:55:15 +02:00
public RuleChain ruleChain = Rules . getCommonRules ( this )
. around ( thrown )
. around ( tmp )
. around ( jlr )
. around ( jscr )
2018-01-18 11:40:18 +02:00
def workspacePath
def warArchiveName
def propertiesFileName
def archiveName
2017-07-11 15:12:03 +02:00
2018-01-16 18:06:25 +02:00
def neoDeployScript
def cpe
2017-07-11 15:12:03 +02:00
@Before
2018-01-16 10:33:13 +02:00
void init ( ) {
2017-07-11 15:12:03 +02:00
2018-01-18 11:40:18 +02:00
workspacePath = "${tmp.newFolder(" workspace ").toURI().getPath()}"
warArchiveName = 'warArchive.war'
propertiesFileName = 'config.properties'
archiveName = "archive.mtar"
2017-07-11 15:12:03 +02:00
2017-12-13 11:05:19 +02:00
helper . registerAllowedMethod ( 'dockerExecute' , [ Map , Closure ] , null )
2017-07-11 15:12:03 +02:00
helper . registerAllowedMethod ( 'error' , [ String ] , { s - > throw new AbortException ( s ) } )
2018-01-18 11:40:18 +02:00
helper . registerAllowedMethod ( 'fileExists' , [ String ] , { s - > return new File ( workspacePath , s ) . exists ( ) } )
2017-07-11 15:12:03 +02:00
helper . registerAllowedMethod ( 'usernamePassword' , [ Map ] , { m - > return m } )
helper . registerAllowedMethod ( 'withCredentials' , [ List , Closure ] , { l , c - >
if ( l [ 0 ] . credentialsId = = 'myCredentialsId' ) {
binding . setProperty ( 'username' , 'anonymous' )
binding . setProperty ( 'password' , '********' )
} else if ( l [ 0 ] . credentialsId = = 'CI_CREDENTIALS_ID' ) {
binding . setProperty ( 'username' , 'defaultUser' )
binding . setProperty ( 'password' , '********' )
}
try {
c ( )
} finally {
binding . setProperty ( 'username' , null )
binding . setProperty ( 'password' , null )
}
} )
binding . setVariable ( 'env' , [ : ] )
2018-01-16 18:06:25 +02:00
neoDeployScript = loadScript ( "neoDeploy.groovy" ) . neoDeploy
cpe = loadScript ( 'commonPipelineEnvironment.groovy' ) . commonPipelineEnvironment
2017-07-11 15:12:03 +02:00
}
@Test
2017-12-11 12:15:51 +02:00
void straightForwardTestConfigViaConfigProperties ( ) {
2017-07-11 15:12:03 +02:00
binding . getVariable ( 'env' ) [ 'NEO_HOME' ] = '/opt/neo'
2018-01-18 11:40:18 +02:00
new File ( workspacePath , archiveName ) < < "dummy archive"
2017-07-11 15:12:03 +02:00
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: archiveName ,
2018-01-16 18:06:25 +02:00
neoCredentialsId: 'myCredentialsId'
)
2017-07-11 15:12:03 +02:00
2017-12-13 11:05:19 +02:00
assert jscr . shell [ 0 ] = ~ /#!\/ bin \ /bash "\/ opt \ /neo\/ tools \ /neo\.sh" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*"/
2017-07-11 15:12:03 +02:00
2018-01-16 10:33:13 +02:00
assert jlr . log . contains ( "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment." )
2017-07-11 15:12:03 +02:00
}
2017-12-11 12:15:51 +02:00
@Test
void straightForwardTestConfigViaConfiguration ( ) {
binding . getVariable ( 'env' ) [ 'NEO_HOME' ] = '/opt/neo'
new File ( workspacePath , archiveName ) < < "dummy archive"
cpe . configuration . put ( 'steps' , [ neoDeploy: [ host: 'test.deploy.host.com' ,
account: 'trialuser123' ] ] )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
archivePath: archiveName ,
neoCredentialsId: 'myCredentialsId'
)
2017-12-13 11:05:19 +02:00
assert jscr . shell [ 0 ] = ~ /#!\/ bin \ /bash "\/ opt \ /neo\/ tools \ /neo\.sh" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*"/
2017-12-11 12:15:51 +02:00
assert jlr . log . contains ( "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment." )
}
@Test
void straightForwardTestConfigViaConfigurationAndViaConfigProperties ( ) {
//configuration via configurationFramekwork superseds.
binding . getVariable ( 'env' ) [ 'NEO_HOME' ] = '/opt/neo'
new File ( workspacePath , archiveName ) < < "dummy archive"
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'configProperties.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'configPropsUser123' )
cpe . configuration . put ( 'steps' , [ neoDeploy: [ host: 'configuration-frwk.deploy.host.com' ,
account: 'configurationFrwkUser123' ] ] )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
archivePath: archiveName ,
neoCredentialsId: 'myCredentialsId'
)
2017-12-13 11:05:19 +02:00
assert jscr . shell [ 0 ] = ~ /#!\/ bin \ /bash "\/ opt \ /neo\/ tools \ /neo\.sh" deploy-mta --host 'configuration-frwk\.deploy\.host\.com' --account 'configurationFrwkUser123' --synchronous --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*"/
2017-12-11 12:15:51 +02:00
assert jlr . log . contains ( "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment." )
}
2017-07-11 15:12:03 +02:00
@Test
void badCredentialsIdTest ( ) {
binding . getVariable ( 'env' ) [ 'NEO_HOME' ] = '/opt/neo'
2018-01-18 11:40:18 +02:00
new File ( workspacePath , archiveName ) < < "dummy archive"
2017-07-11 15:12:03 +02:00
thrown . expect ( MissingPropertyException )
2017-12-11 12:15:51 +02:00
thrown . expectMessage ( 'No such property: username' )
2017-07-11 15:12:03 +02:00
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
2017-07-11 15:12:03 +02:00
2018-01-16 18:06:25 +02:00
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: archiveName ,
2018-01-16 18:06:25 +02:00
neoCredentialsId: 'badCredentialsId'
)
2017-07-11 15:12:03 +02:00
}
@Test
void credentialsIdNotProvidedTest ( ) {
binding . getVariable ( 'env' ) [ 'NEO_HOME' ] = '/opt/neo'
2018-01-18 11:40:18 +02:00
new File ( workspacePath , archiveName ) < < "dummy archive"
2017-07-11 15:12:03 +02:00
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: archiveName
2018-01-16 18:06:25 +02:00
)
2017-07-11 15:12:03 +02:00
2017-12-13 11:05:19 +02:00
assert jscr . shell [ 0 ] = ~ /#!\/ bin \ /bash "\/ opt \ /neo\/ tools \ /neo\.sh" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*"/
2017-07-11 15:12:03 +02:00
2018-01-16 10:33:13 +02:00
assert jlr . log . contains ( "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment." )
2017-07-11 15:12:03 +02:00
}
@Test
void neoHomeNotSetTest ( ) {
2018-01-18 11:40:18 +02:00
new File ( workspacePath , archiveName ) < < "dummy archive"
2017-07-11 15:12:03 +02:00
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: archiveName
2018-01-16 18:06:25 +02:00
)
2017-07-11 15:12:03 +02:00
2017-12-15 16:34:25 +02:00
assert jscr . shell [ 0 ] = ~ /#!\/ bin \ /bash "neo.sh" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*"/
2017-07-11 15:12:03 +02:00
2018-01-16 10:33:13 +02:00
assert jlr . log . contains ( "Using Neo executable from PATH." )
2017-07-11 15:12:03 +02:00
}
@Test
void neoHomeAsParameterTest ( ) {
2018-01-18 11:40:18 +02:00
new File ( workspacePath , archiveName ) < < "dummy archive"
2017-07-11 15:12:03 +02:00
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: archiveName ,
2018-01-16 18:06:25 +02:00
neoCredentialsId: 'myCredentialsId' ,
neoHome: '/etc/neo'
)
2017-07-11 15:12:03 +02:00
2017-12-13 11:05:19 +02:00
assert jscr . shell [ 0 ] = ~ /#!\/ bin \ /bash "\/ etc \ /neo\/ tools \ /neo\.sh" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'anonymous' --password '\*\*\*\*\*\*\*\*' --source ".*"/
2017-07-11 15:12:03 +02:00
}
@Test
void archiveNotProvidedTest ( ) {
thrown . expect ( Exception )
2017-12-11 12:15:51 +02:00
thrown . expectMessage ( 'Archive path not configured (parameter "archivePath").' )
2017-07-11 15:12:03 +02:00
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
2017-07-11 15:12:03 +02:00
2018-01-16 18:06:25 +02:00
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] )
2017-07-11 15:12:03 +02:00
}
@Test
void wrongArchivePathProvidedTest ( ) {
thrown . expect ( AbortException )
2017-12-11 12:15:51 +02:00
thrown . expectMessage ( "Archive cannot be found" )
2017-07-11 15:12:03 +02:00
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
2017-07-11 15:12:03 +02:00
2018-01-16 18:06:25 +02:00
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: archiveName )
2017-07-11 15:12:03 +02:00
}
@Test
void scriptNotProvidedTest ( ) {
2018-01-18 11:40:18 +02:00
new File ( workspacePath , archiveName ) < < "dummy archive"
2017-07-11 15:12:03 +02:00
thrown . expect ( Exception )
2017-12-11 12:15:51 +02:00
thrown . expectMessage ( 'ERROR - NO VALUE AVAILABLE FOR host' )
2017-07-11 15:12:03 +02:00
2018-01-18 11:40:18 +02:00
neoDeployScript . call ( archivePath: archiveName )
2017-07-11 15:12:03 +02:00
}
2018-01-11 16:25:58 +02:00
@Test
void mtaDeployModeTest ( ) {
binding . getVariable ( 'env' ) [ 'NEO_HOME' ] = '/opt/neo'
2018-01-18 11:40:18 +02:00
new File ( workspacePath , archiveName ) < < "dummy archive"
2018-01-11 16:25:58 +02:00
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
2018-01-18 11:40:18 +02:00
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] , archivePath: archiveName , deployMode: 'mta' )
2018-01-16 18:06:25 +02:00
2018-01-11 16:25:58 +02:00
2017-12-13 11:05:19 +02:00
assert jscr . shell [ 0 ] = ~ /#!\/ bin \ /bash "\/ opt \ /neo\/ tools \ /neo\.sh" deploy-mta --host 'test\.deploy\.host\.com' --account 'trialuser123' --synchronous --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*"/
2018-01-16 16:03:00 +02:00
assert jlr . log . contains ( "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment." )
2018-01-11 16:25:58 +02:00
}
@Test
void warFileParamsDeployModeTest ( ) {
binding . getVariable ( 'env' ) [ 'NEO_HOME' ] = '/opt/neo'
2018-01-18 11:40:18 +02:00
new File ( workspacePath , warArchiveName ) < < "dummy war archive"
2018-01-11 16:25:58 +02:00
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
applicationName: 'testApp' ,
runtime: 'neo-javaee6-wp' ,
runtimeVersion: '2.125' ,
deployMode: 'warParams' ,
vmSize: 'lite' ,
warAction: 'deploy' ,
2018-01-18 11:40:18 +02:00
archivePath: warArchiveName )
2018-01-11 16:25:58 +02:00
2017-12-13 11:05:19 +02:00
assert jscr . shell [ 0 ] = ~ /#!\/ bin \ /bash "\/ opt \ /neo\/ tools \ /neo\.sh" deploy --host 'test\.deploy\.host\.com' --account 'trialuser123' --application 'testApp' --runtime 'neo-javaee6-wp' --runtime-version '2\.125' --size 'lite' --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war"/
2018-01-16 16:03:00 +02:00
assert jlr . log . contains ( "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment." )
2018-01-11 16:25:58 +02:00
}
2018-01-17 15:01:15 +02:00
@Test
void warFileParamsDeployModeRollingUpdateTest ( ) {
binding . getVariable ( 'env' ) [ 'NEO_HOME' ] = '/opt/neo'
2018-01-18 11:40:18 +02:00
new File ( workspacePath , warArchiveName ) < < "dummy war archive"
2018-01-17 15:01:15 +02:00
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: warArchiveName ,
2018-01-16 18:06:25 +02:00
deployMode: 'warParams' ,
applicationName: 'testApp' ,
runtime: 'neo-javaee6-wp' ,
runtimeVersion: '2.125' ,
warAction: 'rolling-update' ,
vmSize: 'lite' )
2018-01-17 15:01:15 +02:00
2017-12-13 11:05:19 +02:00
assert jscr . shell [ 0 ] = ~ /#!\/ bin \ /bash "\/ opt \ /neo\/ tools \ /neo\.sh" rolling-update --host 'test\.deploy\.host\.com' --account 'trialuser123' --application 'testApp' --runtime 'neo-javaee6-wp' --runtime-version '2\.125' --size 'lite' --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war"/
2018-01-16 16:03:00 +02:00
assert jlr . log . contains ( "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment." )
2018-01-17 15:01:15 +02:00
}
2018-01-11 16:25:58 +02:00
@Test
void warPropertiesFileDeployModeTest ( ) {
binding . getVariable ( 'env' ) [ 'NEO_HOME' ] = '/opt/neo'
2018-01-18 11:40:18 +02:00
new File ( workspacePath , warArchiveName ) < < "dummy war archive"
new File ( workspacePath , propertiesFileName ) < < "dummy properties file"
2018-01-11 16:25:58 +02:00
2018-01-16 18:06:25 +02:00
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: warArchiveName ,
2018-01-16 18:06:25 +02:00
deployMode: 'warPropertiesFile' ,
2018-01-18 11:40:18 +02:00
propertiesFile: propertiesFileName ,
2018-01-16 18:06:25 +02:00
applicationName: 'testApp' ,
runtime: 'neo-javaee6-wp' ,
runtimeVersion: '2.125' ,
warAction: 'deploy' ,
vmSize: 'lite' )
2018-01-11 16:25:58 +02:00
2017-12-13 11:05:19 +02:00
assert jscr . shell [ 0 ] = ~ /#!\/ bin \ /bash "\/ opt \ /neo\/ tools \ /neo\.sh" deploy .*\.properties --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war"/
2018-01-16 16:03:00 +02:00
assert jlr . log . contains ( "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment." )
2018-01-11 16:25:58 +02:00
}
2018-01-17 15:01:15 +02:00
@Test
void warPropertiesFileDeployModeRollingUpdateTest ( ) {
binding . getVariable ( 'env' ) [ 'NEO_HOME' ] = '/opt/neo'
2018-01-18 11:40:18 +02:00
new File ( workspacePath , warArchiveName ) < < "dummy war archive"
new File ( workspacePath , propertiesFileName ) < < "dummy properties file"
2018-01-17 15:01:15 +02:00
2018-01-16 18:06:25 +02:00
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: warArchiveName ,
2018-01-16 18:06:25 +02:00
deployMode: 'warPropertiesFile' ,
2018-01-18 11:40:18 +02:00
propertiesFile: propertiesFileName ,
2018-01-16 18:06:25 +02:00
applicationName: 'testApp' ,
runtime: 'neo-javaee6-wp' ,
runtimeVersion: '2.125' ,
warAction: 'rolling-update' ,
vmSize: 'lite' )
2018-01-17 15:01:15 +02:00
2017-12-13 11:05:19 +02:00
assert jscr . shell [ 0 ] = ~ /#!\/ bin \ /bash "\/ opt \ /neo\/ tools \ /neo\.sh" rolling-update .*\.properties --user 'defaultUser' --password '\*\*\*\*\*\*\*\*' --source ".*\.war"/
2018-01-16 16:03:00 +02:00
assert jlr . log . contains ( "[neoDeploy] Neo executable \"/opt/neo/tools/neo.sh\" retrieved from environment." )
2018-01-17 15:01:15 +02:00
}
2018-01-11 16:25:58 +02:00
@Test
void applicationNameNotProvidedTest ( ) {
2018-01-18 11:40:18 +02:00
new File ( workspacePath , warArchiveName ) < < "dummy war archive"
2018-01-11 16:25:58 +02:00
thrown . expect ( Exception )
thrown . expectMessage ( 'ERROR - NO VALUE AVAILABLE FOR applicationName' )
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: warArchiveName ,
2018-01-16 18:06:25 +02:00
deployMode: 'warParams' ,
runtime: 'neo-javaee6-wp' ,
runtimeVersion: '2.125'
)
2018-01-11 16:25:58 +02:00
}
@Test
void runtimeNotProvidedTest ( ) {
2018-01-18 11:40:18 +02:00
new File ( workspacePath , warArchiveName ) < < "dummy war archive"
2018-01-11 16:25:58 +02:00
thrown . expect ( Exception )
thrown . expectMessage ( 'ERROR - NO VALUE AVAILABLE FOR runtime' )
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: warArchiveName ,
2018-01-16 18:06:25 +02:00
applicationName: 'testApp' ,
deployMode: 'warParams' ,
runtimeVersion: '2.125' )
2018-01-11 16:25:58 +02:00
}
@Test
void runtimeVersionNotProvidedTest ( ) {
2018-01-18 11:40:18 +02:00
new File ( workspacePath , warArchiveName ) < < "dummy war archive"
2018-01-11 16:25:58 +02:00
thrown . expect ( Exception )
thrown . expectMessage ( 'ERROR - NO VALUE AVAILABLE FOR runtimeVersion' )
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: warArchiveName ,
2018-01-16 18:06:25 +02:00
applicationName: 'testApp' ,
deployMode: 'warParams' ,
runtime: 'neo-javaee6-wp' )
2018-01-16 11:54:17 +02:00
}
@Test
void illegalDeployModeTest ( ) {
2018-01-18 11:40:18 +02:00
new File ( workspacePath , warArchiveName ) < < "dummy war archive"
2018-01-16 11:54:17 +02:00
2018-01-17 12:19:02 +02:00
thrown . expect ( Exception )
2018-01-17 12:17:24 +02:00
thrown . expectMessage ( "[neoDeploy] Invalid deployMode = 'illegalMode'. Valid 'deployMode' values are: 'mta', 'warParams' and 'warPropertiesFile'" )
2018-01-16 11:54:17 +02:00
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: warArchiveName ,
2018-01-16 18:06:25 +02:00
deployMode: 'illegalMode' ,
applicationName: 'testApp' ,
runtime: 'neo-javaee6-wp' ,
runtimeVersion: '2.125' ,
warAction: 'deploy' ,
vmSize: 'lite' )
2018-01-16 11:54:17 +02:00
}
@Test
void illegalVMSizeTest ( ) {
2018-01-18 11:40:18 +02:00
new File ( workspacePath , warArchiveName ) < < "dummy war archive"
2018-01-16 11:54:17 +02:00
2018-01-17 12:19:02 +02:00
thrown . expect ( Exception )
2018-01-16 11:54:17 +02:00
thrown . expectMessage ( "[neoDeploy] Invalid vmSize = 'illegalVM'. Valid 'vmSize' values are: 'lite', 'pro', 'prem' and 'prem-plus'." )
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: warArchiveName ,
2018-01-16 18:06:25 +02:00
deployMode: 'warParams' ,
applicationName: 'testApp' ,
runtime: 'neo-javaee6-wp' ,
runtimeVersion: '2.125' ,
warAction: 'deploy' ,
vmSize: 'illegalVM' )
2018-01-16 11:54:17 +02:00
}
@Test
void illegalWARActionTest ( ) {
2018-01-18 11:40:18 +02:00
new File ( workspacePath , warArchiveName ) < < "dummy war archive"
2018-01-16 11:54:17 +02:00
2018-01-17 12:19:02 +02:00
thrown . expect ( Exception )
2018-01-16 11:54:17 +02:00
thrown . expectMessage ( "[neoDeploy] Invalid warAction = 'illegalWARAction'. Valid 'warAction' values are: 'deploy' and 'rolling-update'." )
2018-01-16 18:06:25 +02:00
cpe . setConfigProperty ( 'DEPLOY_HOST' , 'test.deploy.host.com' )
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'trialuser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
2018-01-18 11:40:18 +02:00
archivePath: warArchiveName ,
2018-01-16 18:06:25 +02:00
deployMode: 'warParams' ,
applicationName: 'testApp' ,
runtime: 'neo-javaee6-wp' ,
runtimeVersion: '2.125' ,
warAction: 'illegalWARAction' ,
vmSize: 'lite' )
2017-07-11 15:12:03 +02:00
}
2018-01-29 13:50:59 +02:00
@Test
void deployHostProvidedAsDeprecatedParameterTest ( ) {
new File ( workspacePath , archiveName ) < < "dummy archive"
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'configPropsUser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
archivePath: archiveName ,
deployHost: "my.deploy.host.com"
)
assert jlr . log . contains ( "[WARNING][neoDeploy] Deprecated parameter 'deployHost' is used. This will not work anymore in future versions. Use parameter 'host' instead." )
}
@Test
void deployAccountProvidedAsDeprecatedParameterTest ( ) {
new File ( workspacePath , archiveName ) < < "dummy archive"
cpe . setConfigProperty ( 'CI_DEPLOY_ACCOUNT' , 'configPropsUser123' )
neoDeployScript . call ( script: [ commonPipelineEnvironment: cpe ] ,
archivePath: archiveName ,
host: "my.deploy.host.com" ,
deployAccount: "myAccount"
)
assert jlr . log . contains ( "Deprecated parameter 'deployAccount' is used. This will not work anymore in future versions. Use parameter 'account' instead." )
}
2017-07-11 15:12:03 +02:00
}