Skip to content

Commit

Permalink
add review notes (#143)
Browse files Browse the repository at this point in the history
- add et icon
- add timeout default to jelly
- adjust hints for timeout
- add timeout tests
  • Loading branch information
MxEh-TT committed Jul 29, 2024
1 parent afda74e commit e08ec92
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import de.tracetronic.jenkins.plugins.ecutestexecution.clients.model.TGUploadOrd
import de.tracetronic.jenkins.plugins.ecutestexecution.model.CheckPackageResult
import de.tracetronic.jenkins.plugins.ecutestexecution.model.GenerationResult
import de.tracetronic.jenkins.plugins.ecutestexecution.model.UploadResult
import hudson.AbortException

import java.util.concurrent.TimeoutException

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import org.kohsuke.stapler.DataBoundSetter
import java.text.SimpleDateFormat

class ProvideLogsStep extends Step {
public static final int DEFAULT_TIMEOUT = 3600
public static final int DEFAULT_TIMEOUT = 0
private int timeout

ProvideLogsStep() {
Expand Down Expand Up @@ -209,14 +209,18 @@ class ProvideLogsStep extends Step {
@Extension
static final class DescriptorImpl extends StepDescriptor {

static int getDefaultTimeout() {
DEFAULT_TIMEOUT
}

@Override
String getFunctionName() {
'ttProvideLogs'
}

@Override
String getDisplayName() {
'[TT] Provide ecu.test logs as artifacts.'
'[TT] Provide ecu.test logs as job artifacts.'
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ProvideLogsActionView implements Action {

@Override
String getIconFileName() {
return "orange-square.png"
return "plugin/ecu-test-execution/images/ecu.test.svg"
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
configSection.title=Execution Configuration
timeout.description=Defines the maximum execution time in seconds running this test case, 0 to disable it.
timeout.description=Defines the maximum execution time in seconds running this test case. Set to 0 to disable timeout.
timeout.title=Execution Timeout
stopOnError.description=If test execution fails, stop running ecu.test/trace.check instances. Additionally, if <i>ttCheckPackage</i> is also selected the execution will be skipped on package check errors.
stopOnError.title=Stop Tools on Error
stopUndefinedTools.description=<b>It only has an impact if <i>Stop Tools on Error</i> is also selected.</b> Additionally, all tracetronic tools that are not defined by the Jenkins ETInstallations are stopped.
stopUndefinedTools.title=Stop undefined tracetronic tools
executePackageCheck.description= Perform the ttCheckPackage step before execution of package or project
executePackageCheck.title= ttCheckPackage
executePackageCheck.description=Perform the ttCheckPackage step before execution of package or project
executePackageCheck.title=ttCheckPackage
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<f:section title="Settings">
<f:advanced>
<f:entry title="${%timeout.title}" description="${%timeout.description}" field="timeout">
<f:number clazz="non-negative-number-required" min="0"/>
<f:number clazz="non-negative-number-required" min="0" default="${descriptor.defaultTimeout}"/>
</f:entry>
</f:advanced>
</f:section>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
step.description=This step provides all ecu.test logs as artifacts.
step.description=This step provides all ecu.test logs as job artifacts.
step.compatNote=This feature is only available for ecu.test 2024.2 or higher!
timeout.description=Defines the maximum execution time for providing all ecu test logs.
timeout.description=Defines the maximum execution time for providing all ecu test logs. Set to 0 to disable timeout.
timeout.title=Timeout
51 changes: 51 additions & 0 deletions src/main/webapp/images/ecu.test.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,11 @@ class ETV2ContainerTest extends ETContainerTest {
.waitingFor(Wait.forHttp("/api/v2/live"))
}

def "Perform provide logs step with no reports"() {
given: "a test execution pipeline"
String script = """
node {
withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) {
ttProvideLogs()
}
}
""".stripIndent()
WorkflowJob job = jenkins.createProject(WorkflowJob.class, "pipeline")
job.setDefinition(new CpsFlowDefinition(script, true))
when: "scheduling a new build"
WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job)

then: "expect successful test completion"
jenkins.assertLogContains("Providing ecu.test logs to jenkins.", run)
jenkins.assertLogContains("[WARNING] No ecu.test log files found!", run)
}

def "Perform provide logs step with reports"() {
def "Perform provide logs step with no reports"() {
given: "a test execution pipeline"
String script = """
node {
withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) {
ttRunPackage testCasePath: 'test.pkg'
ttProvideLogs()
}
}
Expand All @@ -75,6 +55,47 @@ class ETV2ContainerTest extends ETContainerTest {

then: "expect successful test completion"
jenkins.assertLogContains("Providing ecu.test logs to jenkins.", run)
jenkins.assertLogContains("Successfully added ecu.test logs to jenkins.", run)
jenkins.assertLogContains("[WARNING] No ecu.test log files found!", run)
}

def "Perform provide logs step with reports"() {
given: "a test execution pipeline"
String script = """
node {
withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) {
ttRunPackage testCasePath: 'test.pkg'
ttProvideLogs()
}
}
""".stripIndent()
WorkflowJob job = jenkins.createProject(WorkflowJob.class, "pipeline")
job.setDefinition(new CpsFlowDefinition(script, true))
when: "scheduling a new build"
WorkflowRun run = jenkins.buildAndAssertStatus(Result.SUCCESS, job)

then: "expect successful test completion"
jenkins.assertLogContains("Providing ecu.test logs to jenkins.", run)
jenkins.assertLogContains("Successfully added ecu.test logs to jenkins.", run)
}
def "Perform provide logs step with timeout"() {
int timeout = 1
given: "a test execution pipeline"
String script = """
node {
withEnv(['ET_API_HOSTNAME=${etContainer.host}', 'ET_API_PORT=${etContainer.getMappedPort(ET_PORT)}']) {
ttRunPackage testCasePath: 'test.pkg'
ttProvideLogs timeout:${timeout}
}
}
""".stripIndent()
WorkflowJob job = jenkins.createProject(WorkflowJob.class, "pipeline")
job.setDefinition(new CpsFlowDefinition(script, true))
when: "scheduling a new build"
WorkflowRun run = jenkins.buildAndAssertStatus(Result.FAILURE, job)

then: "expect successful test completion"
jenkins.assertLogContains("Providing ecu.test logs to jenkins.", run)
jenkins.assertLogContains("Execution has exceeded the configured timeout of ${timeout} seconds", run)
jenkins.assertLogContains("Providing ecu.test logs failed!", run)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,16 @@ class ProvideLogStepIT extends IntegrationTestBase {
jenkins.assertLogContains("Providing ecu.test logs to jenkins.", run)
jenkins.assertLogContains("[WARNING] No ecu.test log files found", run)
}

def 'Run pipeline timeout'() {
int timeout = 1
given:
WorkflowJob job = jenkins.createProject(WorkflowJob.class, 'pipeline')
job.setDefinition(new CpsFlowDefinition("node {ttProvideLogs timeout:${timeout}}", true))
expect:
WorkflowRun run = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get())
jenkins.assertLogContains("Providing ecu.test logs to jenkins.", run)
jenkins.assertLogContains("Execution has exceeded the configured timeout of ${timeout} seconds", run)
jenkins.assertLogContains("Providing ecu.test logs failed!", run)
}
}

0 comments on commit e08ec92

Please sign in to comment.