mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
6e26d78047
The following features were added: Lock resources for deployment New parameters: environment, vmArguments Assert password does not start with @ Link to cloud cockpit Only execute rolling update if app is running Show logs if deployment failed Restart app after normal deployment Use neo namespace for parameters Align parameter names with neo sdk: size, application, source Remove vmSize check as done by the tool itself
132 lines
5.5 KiB
Groovy
132 lines
5.5 KiB
Groovy
package com.sap.piper.tools.neo
|
|
|
|
import org.junit.Assert
|
|
import org.junit.Rule
|
|
import org.junit.Test
|
|
import org.junit.rules.RuleChain
|
|
import util.BasePiperTest
|
|
import util.JenkinsFileExistsRule
|
|
import util.Rules
|
|
|
|
class NeoCommandHelperTest extends BasePiperTest {
|
|
|
|
|
|
private JenkinsFileExistsRule fileExistsRule = new JenkinsFileExistsRule(this, ['file.mta', 'file.war', 'file.properties'])
|
|
@Rule
|
|
public RuleChain rules = Rules
|
|
.getCommonRules(this)
|
|
.around(fileExistsRule)
|
|
|
|
NeoCommandHelper getTestFixture(DeployMode deployMode) {
|
|
|
|
Map deploymentConfiguration = [
|
|
host : 'host_value',
|
|
account : 'account_value',
|
|
application : 'application_value',
|
|
environment : [ENV1: 'value1', ENV2: 'value2'],
|
|
vmArguments : '-Dargument1=value1 -Dargument2=value2',
|
|
runtime : 'neо-javaee6-wp',
|
|
runtimeVersion: '2',
|
|
size : 'lite',
|
|
propertiesFile: 'file.properties'
|
|
]
|
|
|
|
String source = (deployMode == DeployMode.MTA) ? 'file.mta' : 'file.war'
|
|
String username = 'username'
|
|
String password = 'password'
|
|
String neoExecutable = '/path/tools/neo.sh';
|
|
|
|
nullScript.STEP_NAME="neoDeploy"
|
|
|
|
return new NeoCommandHelper(
|
|
nullScript,
|
|
deployMode,
|
|
deploymentConfiguration,
|
|
neoExecutable,
|
|
username,
|
|
password,
|
|
source
|
|
)
|
|
}
|
|
|
|
@Test
|
|
void testStatusCommand() {
|
|
String actual = getTestFixture(DeployMode.WAR_PARAMS).statusCommand()
|
|
String expected = "\"/path/tools/neo.sh\" status --host 'host_value' --account 'account_value' " +
|
|
"--application 'application_value' --user 'username' --password 'password'"
|
|
Assert.assertEquals(expected, actual)
|
|
}
|
|
|
|
@Test
|
|
void testStatusCommandForProperties() {
|
|
String actual = getTestFixture(DeployMode.WAR_PROPERTIES_FILE).statusCommand()
|
|
String expected = "\"/path/tools/neo.sh\" status file.properties --user 'username' --password 'password'"
|
|
Assert.assertEquals(expected, actual)
|
|
}
|
|
|
|
@Test
|
|
void testRollingUpdateCommand() {
|
|
String actual = getTestFixture(DeployMode.WAR_PARAMS).rollingUpdateCommand()
|
|
String basicCommand = "\"/path/tools/neo.sh\" rolling-update --host 'host_value' --account 'account_value' " +
|
|
"--application 'application_value' --user 'username' --password 'password' --source 'file.war'"
|
|
|
|
Assert.assertTrue(actual.contains(basicCommand))
|
|
Assert.assertTrue(actual.contains(' --ev \'ENV1\'=\'value1\' --ev \'ENV2\'=\'value2\''))
|
|
Assert.assertTrue(actual.contains(' --vm-arguments \'-Dargument1=value1 -Dargument2=value2\''))
|
|
Assert.assertTrue(actual.contains('--runtime \'neо-javaee6-wp\''))
|
|
Assert.assertTrue(actual.contains(' --runtime-version \'2\''))
|
|
Assert.assertTrue(actual.contains(' --size \'lite\''))
|
|
}
|
|
|
|
@Test
|
|
void testRollingUpdateCommandForProperties() {
|
|
String actual = getTestFixture(DeployMode.WAR_PROPERTIES_FILE).rollingUpdateCommand()
|
|
String expected = "\"/path/tools/neo.sh\" rolling-update file.properties --user 'username' --password 'password' --source 'file.war' "
|
|
Assert.assertEquals(expected, actual)
|
|
}
|
|
|
|
@Test
|
|
void testDeployCommand() {
|
|
String actual = getTestFixture(DeployMode.WAR_PARAMS).deployCommand()
|
|
String basicCommand = "\"/path/tools/neo.sh\" deploy --host 'host_value' --account 'account_value' " +
|
|
"--application 'application_value' --user 'username' --password 'password' --source 'file.war'"
|
|
|
|
Assert.assertTrue(actual.contains(basicCommand))
|
|
Assert.assertTrue(actual.contains(' --ev \'ENV1\'=\'value1\' --ev \'ENV2\'=\'value2\''))
|
|
Assert.assertTrue(actual.contains(' --vm-arguments \'-Dargument1=value1 -Dargument2=value2\''))
|
|
Assert.assertTrue(actual.contains(' --runtime \'neо-javaee6-wp\''))
|
|
Assert.assertTrue(actual.contains(' --runtime-version \'2\''))
|
|
Assert.assertTrue(actual.contains(' --size \'lite\''))
|
|
}
|
|
|
|
@Test
|
|
void testDeployCommandForProperties() {
|
|
String actual = getTestFixture(DeployMode.WAR_PROPERTIES_FILE).deployCommand()
|
|
String expected = "\"/path/tools/neo.sh\" deploy file.properties --user 'username' --password 'password' --source 'file.war' "
|
|
Assert.assertEquals(expected, actual)
|
|
}
|
|
|
|
@Test
|
|
void testRestartCommand() {
|
|
String actual = getTestFixture(DeployMode.WAR_PARAMS).restartCommand()
|
|
String expected = "\"/path/tools/neo.sh\" restart --synchronous --host 'host_value' --account 'account_value' " +
|
|
"--application 'application_value' --user 'username' --password 'password'"
|
|
Assert.assertEquals(expected, actual)
|
|
}
|
|
|
|
@Test
|
|
void testRestartCommandForProperties() {
|
|
String actual = getTestFixture(DeployMode.WAR_PROPERTIES_FILE).restartCommand()
|
|
String expected = "\"/path/tools/neo.sh\" restart --synchronous file.properties --user 'username' --password 'password'"
|
|
Assert.assertEquals(expected, actual)
|
|
}
|
|
|
|
@Test
|
|
void deployMta() {
|
|
String actual = getTestFixture(DeployMode.MTA).deployMta()
|
|
String expected = "\"/path/tools/neo.sh\" deploy-mta --synchronous --host 'host_value' --account 'account_value' " +
|
|
"--user 'username' --password 'password' --source 'file.mta'"
|
|
Assert.assertEquals(expected, actual)
|
|
}
|
|
}
|