Skip to content

Commit

Permalink
run AAP installation on PR (#1948)
Browse files Browse the repository at this point in the history
* run AAP installation on PR
No-Issue
  • Loading branch information
chr-stian authored Oct 23, 2023
1 parent 9823b29 commit 3360156
Showing 1 changed file with 255 additions and 0 deletions.
255 changes: 255 additions & 0 deletions .ci/aap_install.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
@Library(['aap-jenkins-shared-library']) _
import steps.StepsFactory
import validation.AapqaProvisionerParameters

StepsFactory stepsFactory = new StepsFactory(this, [:], 'galaxy_ng_aap_install')
Map provisionInfo = [:]
Map installInfo = [:]
Map validateInfo = [:]
List installerFlags = []
Map installerVars = [:]
String pulpcore_version = ''
String automationhub_pulp_ansible_version = ''
String automationhub_pulp_container_version = ''

pipeline {
agent {
kubernetes {
yaml libraryResource('pod_templates/unpriv-ansible-pod.yaml')
}
}
options {
ansiColor('xterm')
timestamps()
timeout(time: 18, unit: 'HOURS')
buildDiscarder(logRotator(daysToKeepStr: '10', numToKeepStr: '50', artifactNumToKeepStr: '40'))
}

stages {
stage('Set variables') {
steps {
script {

echo "GitHub Fork: ${env.CHANGE_FORK}"
fork = env.CHANGE_FORK ?: 'ansible'
echo "${fork}"
echo "Branch Name: ${env.CHANGE_BRANCH}"

List provisionFlags = []

installerFlags.add('input/install/flags/automationhub_content_signing.yml')
installerFlags.add('input/install/flags/automationhub_routable_hostname.yml')
installerFlags.add('input/install/flags/automationhub_from_git.yml')

provisionFlags.add('input/provisioner/flags/domain.yml')
provisionFlags.add("input/provisioner/architecture/x86_64.yml")
provisionFlags.add('input/provisioner/flags/domain.yml')

validateInfo.put("provisionFlags", provisionFlags)
validateInfo.put("installerFlags", installerFlags)
}
}
}

stage('Get pulpcore, pulp_ansible, pulp-container versions from setup.py') {
steps {
container('aapqa-ansible') {
script {
def setupPyContent = readFile('setup.py').trim()
def lines = setupPyContent.split('\n')
def dependenciesToExtract = ["pulpcore", "pulp_ansible", "pulp-container"]
def minimumVersions = [:]
lines.each { line ->
dependenciesToExtract.each { dependency ->
if (line.contains("$dependency>=")) {
def versionMatch = line =~ /$dependency>=([\d.]+)/
if (versionMatch) {
minimumVersions[dependency] = versionMatch[0][1]
}
}
}
}

dependenciesToExtract.each { dependency ->
if (minimumVersions.containsKey(dependency)) {
println("Using $dependency version: ${minimumVersions[dependency]}")
} else {
println("$dependency not found in setup.py. Using version defined in the installer")
}
}
if (minimumVersions.containsKey("pulpcore")){
pulpcore_version = minimumVersions["pulpcore"]
}
if (minimumVersions.containsKey("pulp_ansible")){
automationhub_pulp_ansible_version = minimumVersions["pulp_ansible"]
}
if (minimumVersions.containsKey("pulp-container")){
automationhub_pulp_container_version = minimumVersions["pulp-container"]
}
}
}
}

}

stage('Setup aapqa-provisioner') {
steps {
container('aapqa-ansible') {
script {
stepsFactory.aapqaSetupSteps.setup()
}
}
}
}

stage('Provision') {
steps {
container('aapqa-ansible') {
script {
provisionInfo = [
provisionerPrefix: validateInfo.provisionPrefix,
cloudVarFile : "input/provisioner/cloud/aws.yml",
scenarioVarFile : "input/aap_scenarios/1inst_1hybr_1ahub.yml",
]
provisionInfo = stepsFactory.aapqaOnPremProvisionerSteps.provision(provisionInfo + [
provisionerVarFiles: validateInfo.get("provisionFlags") + [
"input/platform/rhel88.yml",
],
isPermanentDeploy : false,
registerWithRhsm : true,
runMeshScalingTests: false,
runInstallerTests : false
])
}
}
}
post {
always {
script {
stepsFactory.aapqaOnPremProvisionerSteps.archiveArtifacts()
}
}
}
}

stage('Install') {
steps {
container('aapqa-ansible') {
script {
installerFlags = validateInfo.get("installerFlags")

installerVars = [:]

Map ahubPipParams = [
automationhub_git_url: "https://github.com/${fork}/galaxy_ng",
automationhub_git_version: "${env.CHANGE_BRANCH}",
automationhub_ui_download_url: "https://github.com/ansible/ansible-hub-ui/releases/download/dev/automation-hub-ui-dist.tar.gz",
]
if (pulpcore_version != '') {
ahubPipParams['pulpcore_version'] = "${pulpcore_version}"
println("Using pulpcore version: ${pulpcore_version}")
}else{
println("pulpcore_version version not provided, using version defined in the installer")
}
if (automationhub_pulp_ansible_version != '') {
ahubPipParams['automationhub_pulp_ansible_version'] = "${automationhub_pulp_ansible_version}"
println("Using pulp_ansible version: ${automationhub_pulp_ansible_version}")
}else{
println("pulp_ansible version not provided, using version defined in the installer")
}
if (automationhub_pulp_container_version != '') {
ahubPipParams['automationhub_pulp_container_version'] = "${automationhub_pulp_container_version}"
println("Using pulp-container version: ${automationhub_pulp_container_version}")
}else{
println("pulp-container version not provided, using version defined in the installer")
}

writeYaml(
file: 'input/install/ahub_pip.yml',
data: ahubPipParams
)
installerFlags.add('input/install/ahub_pip.yml')
archiveArtifacts(artifacts: 'input/install/ahub_pip.yml')

installInfo = stepsFactory.aapqaAapInstallerSteps.install(provisionInfo + [
aapVersionVarFile: "input/install/devel.yml",
installerVarFiles: installerFlags + [
"input/aap_scenarios/1inst_1hybr_1ahub.yml",
"input/platform/rhel88.yml"
],
installerVars: installerVars
])
}
}
}

post {
always {
script {
container('aapqa-ansible') {
stepsFactory.aapqaAapInstallerSteps.collectAapInstallerArtifacts(provisionInfo + [
archiveArtifactsSubdir: 'install'
])

if (fileExists('artifacts/install/setup.log')) {
sh """
echo "Install setup log:"
echo "-------------------------------------------------"
cat artifacts/install/setup.log
echo "-------------------------------------------------"
"""
}
}
}
}
}
}

stage('Run AutomationHub Tests') {
steps {
container('aapqa-ansible') {
script {

stepsFactory.aapqaAutomationHubSteps.setup(installInfo + [galaxyNgFork: "chr-stian", galaxyNgBranch: "installer_smoke_test"])
stepsFactory.aapqaAutomationHubSteps.runAutomationHubSuite(installInfo + [ahubTestExpression: "installer_smoke_test"])
stepsFactory.commonSteps.saveXUnitResultsToJenkins(xunitFile: 'ah-results.xml')
stepsFactory.aapqaAutomationHubSteps.reportTestResults(provisionInfo + installInfo +
[
component: 'ahub',
testType: 'api',
], "ah-results.xml")
}
}
}
post {
always {
container('aapqa-ansible') {
script {
stepsFactory.aapqaAutomationHubSteps.cleanup(installInfo)
}
}
}
}
}

}

post {
always {
container('aapqa-ansible') {
script {
stepsFactory.aapqaAapInstallerSteps.generateAndCollectSosReports(provisionInfo)
}
}
}
cleanup {
container('aapqa-ansible') {
script {
if (provisionInfo != [:]) {
stepsFactory.aapqaOnPremProvisionerSteps.cleanup(provisionInfo)
}
}
}
}
}
}

0 comments on commit 3360156

Please sign in to comment.