Move ethernet product script to common scripts area so it can be easily reused
This commit is contained in:
parent
fa63436076
commit
222a2374d0
1 changed files with 196 additions and 0 deletions
196
test/testethernetproduct.groovy
Normal file
196
test/testethernetproduct.groovy
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
import jenkins.model.Jenkins
|
||||
|
||||
pipeline {
|
||||
agent { label AGENT_LABEL }
|
||||
stages {
|
||||
stage ("Initial Setup") {
|
||||
steps{
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ("Checkout test environment") {
|
||||
steps {
|
||||
script {
|
||||
toolsimporter = load("${autobuilder.commonscripts()}/configuration/tools.groovy")
|
||||
|
||||
def TEST_ENVIRONMENT_URL = 'git@hydra:gistest/jenkins-ethernet-test-environment.git'
|
||||
def TEST_ENVIRONMENT_DIR = 'TestEnvironmentDir'
|
||||
def TEST_ENVIRONMENT_REVISION = 'origin/master'
|
||||
|
||||
def environmentoptions = toolsimporter.getNewToolOptions()
|
||||
environmentoptions.toolName('Ethernet product test environment')
|
||||
environmentoptions.toolRepo(TEST_ENVIRONMENT_URL, TEST_SOURCE_REVISION)
|
||||
toolsimporter.getTool(meta, environmentoptions, TEST_ENVIRONMENT_DIR)
|
||||
|
||||
TEST_ENVIRONMENT_FILE = "${TEST_ENVIRONMENT_DIR}/environment.json"
|
||||
def alltestenvironment = readJSON(file: "${TEST_ENVIRONMENT_FILE}")
|
||||
TEST_ENVIRONMENT = alltestenvironment[ETHERNET_PRODUCT_TO_RUN_TEST]
|
||||
echo "Selected environment:\n${TEST_ENVIRONMENT}"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ('Setup') {
|
||||
agent { label TEST_ENVIRONMENT['FTDI_AGENT'] }
|
||||
stages {
|
||||
stage ("Checkout dependencies") {
|
||||
steps {
|
||||
script {
|
||||
def PYTHON_URL = 'git@hydra:tools/python.git'
|
||||
if (isUnix()) {
|
||||
PYTHON_REVISION = 'origin/3.6.3_linux'
|
||||
}
|
||||
else {
|
||||
PYTHON_REVISION = 'origin/3.8.10_windows_for_test'
|
||||
}
|
||||
PYTHONDIR = "${WORKSPACE}/python"
|
||||
|
||||
def pythonimportoptions = toolsimporter.getNewToolOptions()
|
||||
pythonimportoptions.toolName('Python')
|
||||
pythonimportoptions.toolRepo(PYTHON_URL, PYTHON_REVISION)
|
||||
toolsimporter.getTool(meta, pythonimportoptions, PYTHONDIR)
|
||||
if (isUnix()) {
|
||||
env.PYTHON = "${PYTHONDIR}/usr/local/bin/python3"
|
||||
}
|
||||
else {
|
||||
env.PYTHON = "${PYTHONDIR}/ver/python.exe"
|
||||
}
|
||||
|
||||
def TEST_SOURCE_URL = 'git@hydra:hmb_regression/hmb_fd_hv_tests.git'
|
||||
TEST_SUITE_DIR = 'TestSuiteDir'
|
||||
env.GIS_TEST_SUITE_HOME = "${WORKSPACE}/${TEST_SUITE_DIR}"
|
||||
|
||||
def regressiontestimportoptions = toolsimporter.getNewToolOptions()
|
||||
regressiontestimportoptions.toolName('Tests')
|
||||
regressiontestimportoptions.toolRepo(TEST_SOURCE_URL, TEST_SOURCE_REVISION)
|
||||
toolsimporter.getTool(meta, regressiontestimportoptions, GIS_TEST_SUITE_HOME)
|
||||
|
||||
env.HISTORY_FOLDER = "${WORKSPACE}/testhistory"
|
||||
|
||||
def resultimportoptions = toolsimporter.getNewToolOptions()
|
||||
resultimportoptions.toolName('Test history')
|
||||
resultimportoptions.toolRepo(HISTORY_REPO, HISTORY_REVISION)
|
||||
toolsimporter.getTool(meta, resultimportoptions, HISTORY_FOLDER)
|
||||
|
||||
def CORE_SOURCE_URL = 'git@hydra:gistest/giscorelite.git'
|
||||
env.GIS_TEST_SUITE_CORE = "${WORKSPACE}/GisCore"
|
||||
|
||||
def coreimportoptions = toolsimporter.getNewToolOptions()
|
||||
coreimportoptions.toolName('Test core')
|
||||
coreimportoptions.toolRepo(CORE_SOURCE_URL, CORE_SOURCE_REVISION)
|
||||
toolsimporter.getTool(meta, coreimportoptions, GIS_TEST_SUITE_CORE)
|
||||
|
||||
def FTDI_SOURCE_URL = 'git@hydra:python_scripts/ftdi_relay.git'
|
||||
def FTDI_SOURCE_REVISION = 'origin/Core-98'
|
||||
FTDI_SOURCE_DIR = "${WORKSPACE}/PowerController"
|
||||
|
||||
def ftdiimportoptions = toolsimporter.getNewToolOptions()
|
||||
ftdiimportoptions.toolName('FTDI relay driver')
|
||||
ftdiimportoptions.toolRepo(FTDI_SOURCE_URL, FTDI_SOURCE_REVISION)
|
||||
toolsimporter.getTool(meta, ftdiimportoptions, FTDI_SOURCE_DIR)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ("Import application to test") {
|
||||
steps {
|
||||
script {
|
||||
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
|
||||
APPLICATION_UNDER_TEST = 'application_under_test'
|
||||
env.APPLICATION_ARTIFACT_FOLDER = "${WORKSPACE}/${APPLICATION_UNDER_TEST}"
|
||||
|
||||
def applicationimportoptions = importer.getNewImportOptions()
|
||||
applicationimportoptions.jenkinsjob(APPLICATION_ARTIFACT_PROJECT, APPLICATION_ARTIFACT_SELECTOR)
|
||||
applicationimportoptions.setfilter('app_package/**,control_package/**')
|
||||
applicationmeta = importer.artifactimport(meta, applicationimportoptions, APPLICATION_ARTIFACT_FOLDER)
|
||||
|
||||
meta.productinfo.set(applicationmeta.productinfo)
|
||||
meta.productinfo.subcomponentname = "${applicationmeta.productinfo.subcomponentname}_TEST"
|
||||
meta.gitinfo.set(applicationmeta.gitinfo)
|
||||
meta.buildstampinfo.set(applicationmeta.buildstampinfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Clean") {
|
||||
steps {
|
||||
script {
|
||||
LOGGING_ROOT = 'Logging'
|
||||
env.GIS_TEST_OUTPUT_LOGGING_ROOT = "${WORKSPACE}/${LOGGING_ROOT}"
|
||||
cleanfolders = [
|
||||
GIS_TEST_OUTPUT_LOGGING_ROOT,
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ('Test') {
|
||||
steps {
|
||||
script {
|
||||
lock(TEST_ENVIRONMENT['RESOURCE_LOCK']) {
|
||||
if (POWER_CYCLE_HARDWARE == 'true') {
|
||||
dir(FTDI_SOURCE_DIR) {
|
||||
bat """
|
||||
"${PYTHON}" "${FTDI_SOURCE_DIR}/RegressionPower.py" -d ${TEST_ENVIRONMENT['FTDI_RELAY_DEVICE']} -o True
|
||||
"""
|
||||
}
|
||||
}
|
||||
if (UPDATE_HARDWARE == 'true') {
|
||||
dir(GIS_TEST_SUITE_CORE) {
|
||||
bat """
|
||||
"${PYTHON}" "${GIS_TEST_SUITE_CORE}/HMBCommon/hmbPackageDeployer.py" -p "${APPLICATION_ARTIFACT_FOLDER}" -t "${TEST_ENVIRONMENT['IP_ADDRESS']}"
|
||||
"""
|
||||
rc = bat (script:"""
|
||||
"${PYTHON}" "${GIS_TEST_SUITE_CORE}/HMBCommon/hmbinspectstate.py"
|
||||
""",
|
||||
returnStatus: true)
|
||||
if (rc == 1) {
|
||||
unstable('FAILED while inspecting state of hardware')
|
||||
}
|
||||
}
|
||||
}
|
||||
if (DO_TEST == 'true') {
|
||||
rc = bat(script:"""
|
||||
${PYTHON} "${GIS_TEST_SUITE_CORE}/GISTestMaster.py" -w ${PRODUCT_LOCATION_UNDER_TEST} -fl --include ${TEST_INCLUDE_FILTER}
|
||||
""",
|
||||
returnStatus: true
|
||||
)
|
||||
if (rc == 1) {
|
||||
unstable('FAILED while running tests')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Archive Test History") {
|
||||
steps{
|
||||
script {
|
||||
dir(HISTORY_FOLDER) {
|
||||
rc = bat (script:"""
|
||||
"${PYTHON}" "GitCyclicPush.py"
|
||||
""",
|
||||
returnStatus: true
|
||||
)
|
||||
if (rc == 1) {
|
||||
unstable('FAILED to process history')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Archive test artifacts"){
|
||||
steps{
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts([ "${LOGGING_ROOT}/**"])
|
||||
archiveArtifacts artifactlist
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue