mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-03-05 15:15:44 +02:00
Merge pull request #595 from alejandraferreirovidal/formatNeoDeploy
Format neo deploy test
This commit is contained in:
commit
a3b050b184
@ -9,13 +9,10 @@ import org.hamcrest.Matchers
|
|||||||
import org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException
|
import org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.BeforeClass
|
|
||||||
import org.junit.ClassRule
|
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.rules.ExpectedException
|
import org.junit.rules.ExpectedException
|
||||||
import org.junit.rules.RuleChain
|
import org.junit.rules.RuleChain
|
||||||
import org.junit.rules.TemporaryFolder
|
|
||||||
import util.BasePiperTest
|
import util.BasePiperTest
|
||||||
import util.CommandLineMatcher
|
import util.CommandLineMatcher
|
||||||
import util.JenkinsCredentialsRule
|
import util.JenkinsCredentialsRule
|
||||||
@ -27,27 +24,26 @@ import util.JenkinsShellCallRule
|
|||||||
import util.JenkinsShellCallRule.Type
|
import util.JenkinsShellCallRule.Type
|
||||||
import util.JenkinsStepRule
|
import util.JenkinsStepRule
|
||||||
import util.JenkinsWithEnvRule
|
import util.JenkinsWithEnvRule
|
||||||
|
import util.JenkinsFileExistsRule
|
||||||
import util.Rules
|
import util.Rules
|
||||||
|
|
||||||
class NeoDeployTest extends BasePiperTest {
|
class NeoDeployTest extends BasePiperTest {
|
||||||
|
|
||||||
def toolJavaValidateCalled = false
|
def toolJavaValidateCalled = false
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static TemporaryFolder tmp = new TemporaryFolder()
|
|
||||||
|
|
||||||
private ExpectedException thrown = new ExpectedException().none()
|
private ExpectedException thrown = new ExpectedException().none()
|
||||||
private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
|
private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
|
||||||
private JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
|
private JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
|
||||||
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
||||||
private JenkinsLockRule lockRule = new JenkinsLockRule(this)
|
private JenkinsLockRule lockRule = new JenkinsLockRule(this)
|
||||||
|
private JenkinsFileExistsRule fileExistsRule = new JenkinsFileExistsRule(this, ['warArchive.war', 'archive.mtar', 'war.properties'])
|
||||||
|
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public RuleChain ruleChain = Rules
|
public RuleChain ruleChain = Rules
|
||||||
.getCommonRules(this)
|
.getCommonRules(this)
|
||||||
.around(new JenkinsReadYamlRule(this))
|
.around(new JenkinsReadYamlRule(this))
|
||||||
.around(new JenkinsPropertiesRule(this, propertiesFileName, configProperties))
|
.around(new JenkinsPropertiesRule(this, warPropertiesFileName, warProperties))
|
||||||
.around(thrown)
|
.around(thrown)
|
||||||
.around(loggingRule)
|
.around(loggingRule)
|
||||||
.around(shellRule)
|
.around(shellRule)
|
||||||
@ -57,39 +53,25 @@ class NeoDeployTest extends BasePiperTest {
|
|||||||
.around(stepRule)
|
.around(stepRule)
|
||||||
.around(lockRule)
|
.around(lockRule)
|
||||||
.around(new JenkinsWithEnvRule(this))
|
.around(new JenkinsWithEnvRule(this))
|
||||||
|
.around(fileExistsRule)
|
||||||
|
|
||||||
|
|
||||||
private static workspacePath
|
private static warArchiveName = 'warArchive.war'
|
||||||
private static warArchiveName
|
private static warPropertiesFileName = 'war.properties'
|
||||||
private static propertiesFileName
|
private static archiveName = 'archive.mtar'
|
||||||
private static archiveName
|
private static warProperties
|
||||||
private static configProperties
|
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
static void createTestFiles() {
|
|
||||||
|
|
||||||
workspacePath = "${tmp.getRoot()}"
|
|
||||||
warArchiveName = 'warArchive.war'
|
|
||||||
propertiesFileName = 'config.properties'
|
|
||||||
archiveName = 'archive.mtar'
|
|
||||||
|
|
||||||
configProperties = new Properties()
|
|
||||||
configProperties.put('account', 'trialuser123')
|
|
||||||
configProperties.put('host', 'test.deploy.host.com')
|
|
||||||
configProperties.put('application', 'testApp')
|
|
||||||
|
|
||||||
tmp.newFile(warArchiveName) << 'dummy war archive'
|
|
||||||
tmp.newFile(propertiesFileName) << 'dummy properties file'
|
|
||||||
tmp.newFile(archiveName) << 'dummy archive'
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
void init() {
|
void init() {
|
||||||
|
|
||||||
|
warProperties = new Properties()
|
||||||
|
warProperties.put('account', 'trialuser123')
|
||||||
|
warProperties.put('host', 'test.deploy.host.com')
|
||||||
|
warProperties.put('application', 'testApp')
|
||||||
|
|
||||||
helper.registerAllowedMethod('dockerExecute', [Map, Closure], null)
|
helper.registerAllowedMethod('dockerExecute', [Map, Closure], null)
|
||||||
helper.registerAllowedMethod('fileExists', [String], { s -> return new File(workspacePath, s).exists() })
|
helper.registerAllowedMethod('pwd', [], { return './' })
|
||||||
helper.registerAllowedMethod('pwd', [], { return workspacePath })
|
|
||||||
|
|
||||||
nullScript.commonPipelineEnvironment.configuration = [steps: [neoDeploy: [neo: [host: 'test.deploy.host.com', account: 'trialuser123']]]]
|
nullScript.commonPipelineEnvironment.configuration = [steps: [neoDeploy: [neo: [host: 'test.deploy.host.com', account: 'trialuser123']]]]
|
||||||
}
|
}
|
||||||
@ -97,14 +79,6 @@ class NeoDeployTest extends BasePiperTest {
|
|||||||
@Test
|
@Test
|
||||||
void straightForwardTestConfigViaParameters() {
|
void straightForwardTestConfigViaParameters() {
|
||||||
|
|
||||||
boolean notifyOldConfigFrameworkUsed = true
|
|
||||||
|
|
||||||
def utils = new Utils() {
|
|
||||||
void pushToSWA(Map parameters, Map config) {
|
|
||||||
notifyOldConfigFrameworkUsed = parameters.stepParam4
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stepRule.step.neoDeploy(script: nullScript,
|
stepRule.step.neoDeploy(script: nullScript,
|
||||||
source: archiveName,
|
source: archiveName,
|
||||||
neo:[credentialsId: 'myCredentialsId'],
|
neo:[credentialsId: 'myCredentialsId'],
|
||||||
@ -119,8 +93,6 @@ class NeoDeployTest extends BasePiperTest {
|
|||||||
.hasSingleQuotedOption('user', 'anonymous')
|
.hasSingleQuotedOption('user', 'anonymous')
|
||||||
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
||||||
.hasSingleQuotedOption('source', '.*'))
|
.hasSingleQuotedOption('source', '.*'))
|
||||||
|
|
||||||
assert !notifyOldConfigFrameworkUsed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -152,7 +124,9 @@ class NeoDeployTest extends BasePiperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void archivePathFromCPETest() {
|
void archivePathFromCPETest() {
|
||||||
|
|
||||||
nullScript.commonPipelineEnvironment.setMtarFilePath('archive.mtar')
|
nullScript.commonPipelineEnvironment.setMtarFilePath('archive.mtar')
|
||||||
|
|
||||||
stepRule.step.neoDeploy(script: nullScript)
|
stepRule.step.neoDeploy(script: nullScript)
|
||||||
|
|
||||||
Assert.assertThat(shellRule.shell,
|
Assert.assertThat(shellRule.shell,
|
||||||
@ -162,7 +136,9 @@ class NeoDeployTest extends BasePiperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void archivePathFromParamsHasHigherPrecedenceThanCPETest() {
|
void archivePathFromParamsHasHigherPrecedenceThanCPETest() {
|
||||||
|
|
||||||
nullScript.commonPipelineEnvironment.setMtarFilePath('archive2.mtar')
|
nullScript.commonPipelineEnvironment.setMtarFilePath('archive2.mtar')
|
||||||
|
|
||||||
stepRule.step.neoDeploy(script: nullScript,
|
stepRule.step.neoDeploy(script: nullScript,
|
||||||
source: "archive.mtar")
|
source: "archive.mtar")
|
||||||
|
|
||||||
@ -410,7 +386,7 @@ class NeoDeployTest extends BasePiperTest {
|
|||||||
deployMode: 'warPropertiesFile',
|
deployMode: 'warPropertiesFile',
|
||||||
warAction: 'deploy',
|
warAction: 'deploy',
|
||||||
neo: [
|
neo: [
|
||||||
propertiesFile: propertiesFileName,
|
propertiesFile: warPropertiesFileName,
|
||||||
application: 'testApp',
|
application: 'testApp',
|
||||||
runtime: 'neo-javaee6-wp',
|
runtime: 'neo-javaee6-wp',
|
||||||
runtimeVersion: '2.125',
|
runtimeVersion: '2.125',
|
||||||
@ -420,7 +396,7 @@ class NeoDeployTest extends BasePiperTest {
|
|||||||
|
|
||||||
Assert.assertThat(shellRule.shell,
|
Assert.assertThat(shellRule.shell,
|
||||||
new CommandLineMatcher().hasProlog("neo.sh deploy")
|
new CommandLineMatcher().hasProlog("neo.sh deploy")
|
||||||
.hasArgument("config.properties")
|
.hasArgument('war.properties')
|
||||||
.hasSingleQuotedOption('user', 'defaultUser')
|
.hasSingleQuotedOption('user', 'defaultUser')
|
||||||
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
||||||
.hasSingleQuotedOption('source', '.*\\.war'))
|
.hasSingleQuotedOption('source', '.*\\.war'))
|
||||||
@ -436,7 +412,7 @@ class NeoDeployTest extends BasePiperTest {
|
|||||||
deployMode: 'warPropertiesFile',
|
deployMode: 'warPropertiesFile',
|
||||||
warAction: 'rolling-update',
|
warAction: 'rolling-update',
|
||||||
neo: [
|
neo: [
|
||||||
propertiesFile: propertiesFileName,
|
propertiesFile: warPropertiesFileName,
|
||||||
application: 'testApp',
|
application: 'testApp',
|
||||||
runtime: 'neo-javaee6-wp',
|
runtime: 'neo-javaee6-wp',
|
||||||
runtimeVersion: '2.125',
|
runtimeVersion: '2.125',
|
||||||
@ -445,7 +421,7 @@ class NeoDeployTest extends BasePiperTest {
|
|||||||
|
|
||||||
Assert.assertThat(shellRule.shell,
|
Assert.assertThat(shellRule.shell,
|
||||||
new CommandLineMatcher().hasProlog("neo.sh rolling-update")
|
new CommandLineMatcher().hasProlog("neo.sh rolling-update")
|
||||||
.hasArgument('config.properties')
|
.hasArgument('war.properties')
|
||||||
.hasSingleQuotedOption('user', 'defaultUser')
|
.hasSingleQuotedOption('user', 'defaultUser')
|
||||||
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
.hasSingleQuotedOption('password', '\\*\\*\\*\\*\\*\\*\\*\\*')
|
||||||
.hasSingleQuotedOption('source', '.*\\.war'))
|
.hasSingleQuotedOption('source', '.*\\.war'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user