1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

Better readable rule names: dockerExecuteRule

This commit is contained in:
Marcus Holl 2019-01-22 09:34:18 +01:00
parent f81b83169a
commit 9e56ebc724
3 changed files with 37 additions and 37 deletions

View File

@ -31,7 +31,7 @@ class CloudFoundryDeployTest extends BasePiperTest {
private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
private JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
private JenkinsWriteFileRule writeFileRule = new JenkinsWriteFileRule(this)
private JenkinsDockerExecuteRule jedr = new JenkinsDockerExecuteRule(this)
private JenkinsDockerExecuteRule dockerExecuteRule = new JenkinsDockerExecuteRule(this)
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
private JenkinsEnvironmentRule environmentRule = new JenkinsEnvironmentRule(this)
private JenkinsReadYamlRule readYamlRule = new JenkinsReadYamlRule(this)
@ -52,10 +52,10 @@ class CloudFoundryDeployTest extends BasePiperTest {
.around(loggingRule)
.around(shellRule)
.around(writeFileRule)
.around(jedr)
.around(dockerExecuteRule)
.around(environmentRule)
.around(new JenkinsCredentialsRule(this).withCredentials('test_cfCredentialsId', 'test_cf', '********'))
.around(stepRule) // needs to be activated after jedr, otherwise executeDocker is not mocked
.around(stepRule) // needs to be activated after dockerExecuteRule, otherwise executeDocker is not mocked
@Before
void init() {
@ -142,9 +142,9 @@ class CloudFoundryDeployTest extends BasePiperTest {
cfManifest: 'test.yml'
])
// asserts
assertThat(jedr.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
assertThat(jedr.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(jedr.dockerParams.dockerEnvVars, hasEntry('STATUS_CODE', "${200}"))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(dockerExecuteRule.dockerParams.dockerEnvVars, hasEntry('STATUS_CODE', "${200}"))
assertThat(shellRule.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
assertThat(shellRule.shell, hasItem(containsString("cf push testAppName -f 'test.yml'")))
assertThat(shellRule.shell, hasItem(containsString("cf logout")))
@ -194,9 +194,9 @@ class CloudFoundryDeployTest extends BasePiperTest {
]
])
// asserts
assertThat(jedr.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
assertThat(jedr.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(jedr.dockerParams.dockerEnvVars, hasEntry('STATUS_CODE', "${200}"))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(dockerExecuteRule.dockerParams.dockerEnvVars, hasEntry('STATUS_CODE', "${200}"))
assertThat(shellRule.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
assertThat(shellRule.shell, hasItem(containsString("cf push testAppName -f 'test.yml'")))
assertThat(shellRule.shell, hasItem(containsString("cf logout")))
@ -268,8 +268,8 @@ class CloudFoundryDeployTest extends BasePiperTest {
cfManifest: 'test.yml'
])
assertThat(jedr.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
assertThat(jedr.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(shellRule.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
assertThat(shellRule.shell, hasItem(containsString("cf blue-green-deploy testAppName --delete-old-apps -f 'test.yml'")))
@ -296,8 +296,8 @@ class CloudFoundryDeployTest extends BasePiperTest {
cfManifest: 'test.yml'
])
assertThat(jedr.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
assertThat(jedr.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(shellRule.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
assertThat(shellRule.shell, hasItem(containsString("cf blue-green-deploy testAppName --delete-old-apps -f 'test.yml'")))
@ -325,8 +325,8 @@ class CloudFoundryDeployTest extends BasePiperTest {
cfManifest: 'test.yml'
])
assertThat(jedr.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
assertThat(jedr.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(shellRule.shell, hasItem(containsString('cf login -u "test_cf" -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
assertThat(shellRule.shell, hasItem(containsString("cf blue-green-deploy testAppName -f 'test.yml'")))
@ -392,8 +392,8 @@ class CloudFoundryDeployTest extends BasePiperTest {
mtaPath: 'target/test.mtar'
])
// asserts
assertThat(jedr.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
assertThat(jedr.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerImage', 's4sdk/docker-cf-cli'))
assertThat(dockerExecuteRule.dockerParams, hasEntry('dockerWorkspace', '/home/piper'))
assertThat(shellRule.shell, hasItem(containsString('cf login -u test_cf -p \'********\' -a https://api.cf.eu10.hana.ondemand.com -o "testOrg" -s "testSpace"')))
assertThat(shellRule.shell, hasItem(containsString('cf deploy target/test.mtar -f')))
assertThat(shellRule.shell, hasItem(containsString('cf logout')))

View File

@ -25,17 +25,17 @@ class NewmanExecuteTest extends BasePiperTest {
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
private JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
private JenkinsDockerExecuteRule jedr = new JenkinsDockerExecuteRule(this)
private JenkinsDockerExecuteRule dockerExecuteRule = new JenkinsDockerExecuteRule(this)
@Rule
public RuleChain rules = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jedr)
.around(dockerExecuteRule)
.around(shellRule)
.around(loggingRule)
.around(stepRule) // needs to be activated after jedr, otherwise executeDocker is not mocked
.around(stepRule) // needs to be activated after dockerExecuteRule, otherwise executeDocker is not mocked
def gitMap
@ -72,7 +72,7 @@ class NewmanExecuteTest extends BasePiperTest {
// asserts
assertThat(shellRule.shell, hasItem(endsWith('npm install newman newman-reporter-html --global --quiet')))
assertThat(shellRule.shell, hasItem(endsWith('newman run \'testCollection\' --environment \'testEnvironment\' --globals \'testGlobals\' --reporters junit,html --reporter-junit-export \'target/newman/TEST-testCollection.xml\' --reporter-html-export \'target/newman/TEST-testCollection.html\'')))
assertThat(jedr.dockerParams.dockerImage, is('node:8-stretch'))
assertThat(dockerExecuteRule.dockerParams.dockerImage, is('node:8-stretch'))
assertThat(loggingRule.log, containsString('[newmanExecute] Found files [testCollection]'))
assertJobStatusSuccess()
}
@ -118,7 +118,7 @@ class NewmanExecuteTest extends BasePiperTest {
failOnError: false
)
// asserts
assertThat(jedr.dockerParams.dockerImage, is('testImage'))
assertThat(dockerExecuteRule.dockerParams.dockerImage, is('testImage'))
assertThat(gitMap.url, is('testRepo'))
assertThat(shellRule.shell, hasItem(endsWith('newman run \'testCollection\' --environment \'testEnvironment\' --globals \'testGlobals\' --reporters junit,html --reporter-junit-export \'target/newman/TEST-testCollection.xml\' --reporter-html-export \'target/newman/TEST-testCollection.html\' --suppress-exit-code')))
assertJobStatusSuccess()

View File

@ -14,15 +14,15 @@ class SeleniumExecuteTestsTest extends BasePiperTest {
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
private JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
private JenkinsDockerExecuteRule jedr = new JenkinsDockerExecuteRule(this)
private JenkinsDockerExecuteRule dockerExecuteRule = new JenkinsDockerExecuteRule(this)
@Rule
public RuleChain rules = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(thrown)
.around(jedr)
.around(stepRule) // needs to be activated after jedr, otherwise executeDocker is not mocked
.around(dockerExecuteRule)
.around(stepRule) // needs to be activated after dockerExecuteRule, otherwise executeDocker is not mocked
boolean bodyExecuted = false
@ -46,15 +46,15 @@ class SeleniumExecuteTestsTest extends BasePiperTest {
bodyExecuted = true
}
assertThat(bodyExecuted, is(true))
assertThat(jedr.dockerParams.containerPortMappings, is(['selenium/standalone-chrome': [[containerPort: 4444, hostPort: 4444]]]))
assertThat(jedr.dockerParams.dockerEnvVars, is(null))
assertThat(jedr.dockerParams.dockerImage, is('node:8-stretch'))
assertThat(jedr.dockerParams.dockerName, is('npm'))
assertThat(jedr.dockerParams.dockerWorkspace, is('/home/node'))
assertThat(jedr.dockerParams.sidecarEnvVars, is(null))
assertThat(jedr.dockerParams.sidecarImage, is('selenium/standalone-chrome'))
assertThat(jedr.dockerParams.sidecarName, is('selenium'))
assertThat(jedr.dockerParams.sidecarVolumeBind, is(['/dev/shm': '/dev/shm']))
assertThat(dockerExecuteRule.dockerParams.containerPortMappings, is(['selenium/standalone-chrome': [[containerPort: 4444, hostPort: 4444]]]))
assertThat(dockerExecuteRule.dockerParams.dockerEnvVars, is(null))
assertThat(dockerExecuteRule.dockerParams.dockerImage, is('node:8-stretch'))
assertThat(dockerExecuteRule.dockerParams.dockerName, is('npm'))
assertThat(dockerExecuteRule.dockerParams.dockerWorkspace, is('/home/node'))
assertThat(dockerExecuteRule.dockerParams.sidecarEnvVars, is(null))
assertThat(dockerExecuteRule.dockerParams.sidecarImage, is('selenium/standalone-chrome'))
assertThat(dockerExecuteRule.dockerParams.sidecarName, is('selenium'))
assertThat(dockerExecuteRule.dockerParams.sidecarVolumeBind, is(['/dev/shm': '/dev/shm']))
}
@Test
@ -67,9 +67,9 @@ class SeleniumExecuteTestsTest extends BasePiperTest {
bodyExecuted = true
}
assertThat(bodyExecuted, is(true))
assertThat(jedr.dockerParams.dockerImage, is('maven:3.5-jdk-8'))
assertThat(jedr.dockerParams.dockerName, is('maven'))
assertThat(jedr.dockerParams.dockerWorkspace, is(''))
assertThat(dockerExecuteRule.dockerParams.dockerImage, is('maven:3.5-jdk-8'))
assertThat(dockerExecuteRule.dockerParams.dockerName, is('maven'))
assertThat(dockerExecuteRule.dockerParams.dockerWorkspace, is(''))
}
@Test
void testExecuteSeleniumError() {