Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a PR main.tf template and use tfvars to specify test envs #898

Merged
merged 110 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 106 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
005723f
first draft tfvars
maximenoel8 Jun 16, 2023
ede8e0c
Add space
maximenoel8 Jun 16, 2023
3d7b038
Add comments
maximenoel8 Jun 16, 2023
2404c64
Frist version with env settings variable depending on environment.
maximenoel8 Jun 18, 2023
1c5558f
update tf name to solution 2
maximenoel8 Jun 18, 2023
2e3b1ad
Change file name for default terraform.tfvars name
maximenoel8 Jun 18, 2023
0899e77
REmove some default variable
maximenoel8 Jun 19, 2023
8c18211
Add back spaces
maximenoel8 Jun 19, 2023
086fab6
convert json to tfvars
maximenoel8 Jun 19, 2023
068afc9
Add back space
maximenoel8 Jun 19, 2023
0559f69
Update variable specific to uyuni or spacewalk
maximenoel8 Jun 19, 2023
1ea5fe2
Remove obsolete template
maximenoel8 Jun 19, 2023
68976d9
Add NUE env description
maximenoel8 Jun 21, 2023
debc487
update uyuni tfvars
maximenoel8 Jun 21, 2023
bba7d7e
Add provo env variables
maximenoel8 Jun 21, 2023
fc3dd23
move mirror and domain at the file top
maximenoel8 Jun 21, 2023
f5d5e2b
Remove mirror and domain from product tfvars
maximenoel8 Jun 21, 2023
0865e4c
Update manager 4.3 tfvars
maximenoel8 Jun 21, 2023
3bffb28
Add general main.tf for PR testing
maximenoel8 Jun 21, 2023
33b913e
Add variable file for PR testing
maximenoel8 Jun 21, 2023
81c9dbe
Update all files use for PR testing with PR-TEST prefix
maximenoel8 Jun 21, 2023
4d879a1
Delete solution example
maximenoel8 Jun 21, 2023
ca62bfb
Change to correct file name
maximenoel8 Jun 21, 2023
e39cadf
Update git profiles repo, profiles are only available on uyuni and ar…
maximenoel8 Jul 24, 2023
2910d26
fix issues from testing
maximenoel8 Jul 24, 2023
eb5eee0
Add BRIDGE variable. Depending on NUE or PRV env
maximenoel8 Jul 25, 2023
09e6275
Add bridge and change the mac address for the correct one for NUE
maximenoel8 Jul 25, 2023
7531252
Add bridge
maximenoel8 Jul 25, 2023
b25382b
Move to light
maximenoel8 Jul 25, 2023
7fd16ca
Change gitsync
maximenoel8 Jul 25, 2023
e62db42
Change --tfvariable declaration
maximenoel8 Jul 25, 2023
75b3561
Fix variable issue
maximenoel8 Jul 25, 2023
a448877
change tfvars with append action
maximenoel8 Jul 25, 2023
93bcef7
Add default value to mandatory variables
maximenoel8 Jul 25, 2023
13d9c7d
Add default value to mandatory variables
maximenoel8 Jul 25, 2023
2724752
Add default value to mandatory variables
maximenoel8 Jul 25, 2023
6507dac
Add variable for additionnal_repos_only
maximenoel8 Jul 25, 2023
efe5384
Fix with Oscar comments
maximenoel8 Jul 25, 2023
f0f6096
Move tfvars into terraform tfvars
maximenoel8 Jul 25, 2023
66b1358
Fix rm
maximenoel8 Jul 25, 2023
d15163d
fix echo
maximenoel8 Jul 25, 2023
bffa976
Have variable in only one place
maximenoel8 Jul 25, 2023
8a65cfb
Add unique variable descirption
maximenoel8 Jul 25, 2023
5e8db3c
Fix env copy command
maximenoel8 Jul 25, 2023
9b37d03
Add lane
maximenoel8 Jul 25, 2023
2b547e7
Try to fix echo
maximenoel8 Jul 25, 2023
8b8739e
Add additionnal repository variable
maximenoel8 Jul 26, 2023
53bf751
Update kvm host
maximenoel8 Jul 26, 2023
bf33ff1
Add local mode variables to manage additionnal repos configuration
maximenoel8 Jul 26, 2023
179fddd
remove additionnal repo for variables.tf
maximenoel8 Jul 26, 2023
2f2303e
correct cp
maximenoel8 Jul 26, 2023
769f78b
Remove mirror from NUE env
maximenoel8 Jul 31, 2023
c790a23
Remove mirror from NUE env
maximenoel8 Jul 31, 2023
a7a3596
Disable mirror images
maximenoel8 Jul 31, 2023
3dcadbb
remove uselss comment
maximenoel8 Jul 31, 2023
f7c3fc3
Change debian install_salt_bundle = true
maximenoel8 Jul 31, 2023
31e63ce
Add ENV specific extension
maximenoel8 Aug 1, 2023
a1c612c
Rename variable
maximenoel8 Aug 1, 2023
66a5b80
Uyuni: Switch from SLES to openSUSE Leap
nodeg May 16, 2023
b6a9bf4
Use generic names for SUSE minions
nodeg Aug 3, 2023
93d6b07
Merge CI and BV mirrors
Bischoff Aug 18, 2023
1633344
Fixup images in k3s tf file
cbosdo Aug 29, 2023
a2730a1
Revert buildhost to use SLES instead of Leap (#946)
nodeg Sep 6, 2023
7f48612
Revert pxeboot-minion from Leap to SLES15 SP4 (#947)
nodeg Sep 8, 2023
6752b5a
Update PR testing to Leap 15.5
jordimassaguerpla Sep 14, 2023
6ebc82e
use update-AMIs sumaform branch
mcalmer Sep 14, 2023
fcb6db3
Use opensuse 15.5 official image for kvm-host
jordimassaguerpla Sep 14, 2023
ce39c58
Revert "use update-AMIs sumaform branch"
mcalmer Sep 18, 2023
d36f13d
Fix kvm-host for PR testing
jordimassaguerpla Sep 20, 2023
372276e
disable kvm host until it works
jordimassaguerpla Sep 21, 2023
e422512
fix mac address for min-kvm and enable it back-s
jordimassaguerpla Sep 21, 2023
245d74d
Delete Uyuni main tf description
maximenoel8 Jun 21, 2023
1b101ba
Update suse minion names
maximenoel8 Oct 4, 2023
69e3a1c
Update mirror
maximenoel8 Oct 11, 2023
0d28d95
Add back opensuses154o for controller
maximenoel8 Oct 11, 2023
4f08832
Change default repo for testing purpose
maximenoel8 Oct 11, 2023
6c89ed3
Use normalize name for rh and deb like minion
maximenoel8 Oct 12, 2023
b7bb1ed
Rename testing pipeline
maximenoel8 Oct 12, 2023
6e298cb
Rename template main tf file
maximenoel8 Oct 12, 2023
4a21f11
Rename template main tf file
maximenoel8 Oct 12, 2023
8e630c1
Rename template main tf file
maximenoel8 Oct 12, 2023
e3b0737
Remove name configuration duplication
maximenoel8 Oct 12, 2023
8a12cb5
Rename files
maximenoel8 Oct 12, 2023
0d8612d
Move git profiles from product description to environment description
maximenoel8 Oct 12, 2023
2d202e3
Temporary change back rh and deb names
maximenoel8 Oct 12, 2023
9651a81
Update repositories
maximenoel8 Oct 12, 2023
7842e27
Switch back to pr pipeline
maximenoel8 Oct 12, 2023
402dd41
use provo
maximenoel8 Oct 12, 2023
a0ac1e3
Correctly update variables in ENV files
maximenoel8 Oct 13, 2023
ac8ffff
Use correct extension for repositories
maximenoel8 Oct 13, 2023
ed4d18c
Update the repository
maximenoel8 Dec 20, 2023
aeda32e
update uyuni env
maximenoel8 Dec 20, 2023
e205bd3
REmove useless variable
maximenoel8 Dec 20, 2023
f753b51
Change PR call
maximenoel8 Dec 20, 2023
e1c1f45
add pool config
maximenoel8 Dec 20, 2023
37019b1
add pool config
maximenoel8 Dec 20, 2023
b93a09d
remove else step from envs groovy ( to be roll back )
maximenoel8 Dec 20, 2023
a231f54
Remove environment
maximenoel8 Dec 20, 2023
db3c063
copy repo declaration in tfvars
maximenoel8 Dec 21, 2023
b954578
Remove useless environement and correctly manage git profile
maximenoel8 Dec 21, 2023
c3484df
Improve visibility
maximenoel8 Dec 21, 2023
a2c0a56
Make bridge related to environment because of env 9 and 10 from PR
maximenoel8 Dec 21, 2023
c74e361
Remove BRIDGE from variables
maximenoel8 Dec 21, 2023
9430b19
update last changes to main pipeline
maximenoel8 Dec 21, 2023
9f72b6c
Use master for terracumber
maximenoel8 Dec 21, 2023
a1147ef
temporary change sumaform
maximenoel8 Dec 21, 2023
a45e58b
remove none related changes
maximenoel8 Dec 21, 2023
ed571a5
Fix leap image link for kvm
maximenoel8 Dec 21, 2023
3973b11
Remove changes for Jordi
maximenoel8 Jan 3, 2024
adb8d11
Revert changes
maximenoel8 Jan 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
def run(params) {
timestamps {
// Start pipeline with default values
arch= 'x86_64'
built = false
deployed = false
tests_passed = false
sumaform_backend = 'libvirt'
terraform_bin = '/usr/bin/terraform'
terraform_bin_plugins = '/usr/bin'
service_pack_migration = false
// terracumber_gitrepo = 'https://github.com/uyuni-project/terracumber.git'
terracumber_gitrepo = 'https://github.com/maximenoel8/terracumber.git'
terracumber_ref = 'support_tfvars'
terraform_init = true
rake_namespace = 'cucumber'
rake_parallel_namespace = 'parallel'
jenkins_workspace = '/home/jenkins/jenkins-build/workspace/'
pull_request_repo = 'https://github.com/uyuni-project/uyuni.git'
builder_api = 'https://api.opensuse.org'
build_url = 'https://build.opensuse.org'
builder_project = 'systemsmanagement:Uyuni:Master:PR'
source_project = 'systemsmanagement:Uyuni:Master'
sumaform_tools_project = 'systemsmanagement:sumaform:tools'
test_packages_project = 'systemsmanagement:Uyuni:Test-Packages:Pool'
build_repo = 'openSUSE_Leap_15.5'
environment_workspace = null
url_prefix="https://ci.suse.de/view/Manager/view/Uyuni/job/${env.JOB_NAME}"
env.common_params = ''
fqdn_jenkins_node = sh(script: "hostname -f", returnStdout: true).trim()
env_number = 10
tfvariables_file = 'susemanager-ci/terracumber_config/tf_files/variables/PR-testing-variables.tf'
tfvars_product_version = "susemanager-ci/terracumber_config/tf_files/tfvars/PR-testing-${product_version}.tfvars"
tfvars_platform_localisation = "susemanager-ci/terracumber_config/tf_files/tfvars/PR-testing-${platform_localisation}-environments.tfvars"
tf_local_variables = 'susemanager-ci/terracumber_config/tf_files/tfvars/PR-testing-additionnal-repos.tf'
try {
stage('Checkout CI tools') {
ws(environment_workspace){
if(must_test) {
git url: terracumber_gitrepo, branch: terracumber_ref
dir("susemanager-ci") {
checkout scm
}

// Define test environment parameters
env.resultdir = "${WORKSPACE}/results"
env.resultdirbuild = "${resultdir}/${BUILD_NUMBER}"
env.tf_file = "susemanager-ci/terracumber_config/tf_files/PR-testing-template.tf"
env.common_params = "--outputdir ${resultdir} --tf ${tf_file} --gitfolder ${resultdir}/sumaform --tf_variables_description_file=${tfvariables_file}"

if (params.terraform_parallelism) {
env.common_params = "${env.common_params} --parallelism ${params.terraform_parallelism}"
}

// Clean up old results
sh "if [ -d ${resultdir} ];then ./clean-old-results -r ${resultdir};fi"

// Create a directory for to place the directory with the build results (if it does not exist)
sh "mkdir -p ${resultdir}"

// Clone sumaform
sh "set +x; source /home/jenkins/.credentials set -x; ./terracumber-cli ${common_params} --gitrepo ${sumaform_gitrepo} --gitref ${sumaform_ref} --runstep gitsync"
}
}
}
stage('Deploy') {
ws(environment_workspace){
if(must_test) {
// Delete old terraform.tfvars
sh "rm -f ${env.resultdir}/sumaform/terraform.tfvars"
// Merge product en platform variables into terraform.tfvars
sh "cat ${tfvars_product_version} ${tfvars_platform_localisation} >> ${env.resultdir}/sumaform/terraform.tfvars"
// Add environment to use in tfvars
sh "echo 'ENVIRONMENT = \'${env_number}\'' >> ${env.resultdir}/sumaform/terraform.tfvars"
// Copy the variable declaration file
sh "cp ${tf_local_variables} ${env.resultdir}/sumaform/"

// Add all
// Passing the built repository by parameter using a environment variable to terraform file
// TODO: We will need to add a logic to replace the host, when we use IBS for spacewalk
sh "echo -e \\\n############ Repositories variables ############\\\n >> ${env.resultdir}/sumaform/terraform.tfvars"
sh "echo PULL_REQUEST_REPO = \\\"http://download.suse.de/ibs/SUSE/Products/SLE-Module-Development-Tools/15-SP4/x86_64/product/\\\" >> ${env.resultdir}/sumaform/terraform.tfvars"
sh "echo MASTER_REPO = \\\"http://download.suse.de/ibs/SUSE/Products/SLE-Module-Development-Tools/15-SP4/x86_64/product/\\\" >> ${env.resultdir}/sumaform/terraform.tfvars"
sh "echo MASTER_OTHER_REPO = \\\"http://download.suse.de/ibs/SUSE/Products/SLE-Module-Development-Tools/15-SP4/x86_64/product/\\\" >> ${env.resultdir}/sumaform/terraform.tfvars"
sh "echo MASTER_SUMAFORM_TOOLS_REPO = \\\"http://download.suse.de/ibs/SUSE/Products/SLE-Module-Development-Tools/15-SP4/x86_64/product/\\\" >> ${env.resultdir}/sumaform/terraform.tfvars"
sh "echo TEST_PACKAGES_REPO = \\\"http://download.suse.de/ibs/SUSE/Products/SLE-Module-Development-Tools/15-SP4/x86_64/product/\\\" >> ${env.resultdir}/sumaform/terraform.tfvars"
sh "echo UPDATE_REPO = \\\"http://download.suse.de/ibs/SUSE/Products/SLE-Module-Development-Tools/15-SP4/x86_64/product/\\\" >> ${env.resultdir}/sumaform/terraform.tfvars"

if (additional_repo_url == '') {
echo "Adding dummy repo for update repo"
sh "echo ADDITIONAL_REPO_URL = \\\"${additional_repo}\\\" >> ${env.resultdir}/sumaform/terraform.tfvars"
} else {
echo "Adding ${additional_repo_url}"
sh "echo ADDITIONAL_REPO_URL = \\\"${additional_repo_url}\\\" >> ${env.resultdir}/sumaform/terraform.tfvars"
}

sh "echo SLE_CLIENT_REPO = \\\"http://download.suse.de/ibs/SUSE/Products/SLE-Module-Development-Tools/15-SP4/x86_64/product/\\\" >> ${env.resultdir}/sumaform/terraform.tfvars"
sh "echo RHLIKE_CLIENT_REPO = \\\"http://download.suse.de/ibs/SUSE/Products/SLE-Module-Development-Tools/15-SP4/x86_64/product/\\\" >> ${env.resultdir}/sumaform/terraform.tfvars"
sh "echo DEBLIKE_CLIENT_REPO = \\\"http://download.suse.de/ibs/SUSE/Products/SLE-Module-Development-Tools/15-SP4/x86_64/product/\\\" >> ${env.resultdir}/sumaform/terraform.tfvars"
sh "echo OPENSUSE_CLIENT_REPO = \\\"http://download.suse.de/ibs/SUSE/Products/SLE-Module-Development-Tools/15-SP4/x86_64/product/\\\" >> ${env.resultdir}/sumaform/terraform.tfvars"

// Provision the environment
if (terraform_init) {
env.TERRAFORM_INIT = '--init'
} else {
env.TERRAFORM_INIT = ''
}
sh "set +x; source /home/jenkins/.credentials set -x; export TF_VAR_CUCUMBER_GITREPO=${cucumber_gitrepo}; export TF_VAR_CUCUMBER_BRANCH=${cucumber_ref}; export TERRAFORM=${terraform_bin}; export TERRAFORM_PLUGINS=${terraform_bin_plugins}; ./terracumber-cli ${common_params} --logfile ${resultdirbuild}/sumaform.log ${env.TERRAFORM_INIT} --taint '.*(domain|main_disk).*' --runstep provision"
deployed = true

// Collect and tag Flaky tests from the GitHub Board
def statusCode = sh script:"./terracumber-cli ${common_params} --logfile ${resultdirbuild}/testsuite.log --runstep cucumber --cucumber-cmd 'cd /root/spacewalk/testsuite; export BUILD_NUMBER=${BUILD_NUMBER}; rake utils:collect_and_tag_flaky_tests'", returnStatus:true
sh "exit 0"
}
}
}
stage('Sanity Check') {
ws(environment_workspace){
if(must_test) {
sh "./terracumber-cli ${common_params} --logfile ${resultdirbuild}/testsuite.log --runstep cucumber --cucumber-cmd 'cd /root/spacewalk/testsuite; rake cucumber:sanity_check'"
}
}
}
stage('Core - Setup') {
ws(environment_workspace){
if(must_test) {
sh "./terracumber-cli ${common_params} --logfile ${resultdirbuild}/testsuite.log --runstep cucumber --cucumber-cmd 'cd /root/spacewalk/testsuite; rake cucumber:core'"
sh "./terracumber-cli ${common_params} --logfile ${resultdirbuild}/testsuite.log --runstep cucumber --cucumber-cmd 'cd /root/spacewalk/testsuite; rake cucumber:reposync'"
}
}
}
stage('Core - Initialize clients') {
ws(environment_workspace){
if(must_test) {
namespace = rake_namespace
sh "./terracumber-cli ${common_params} --logfile ${resultdirbuild}/testsuite.log --runstep cucumber --cucumber-cmd 'cd /root/spacewalk/testsuite; rake ${namespace}:init_clients'"
}
}
}
stage('Secondary features') {
ws(environment_workspace){
if(must_test && ( params.functional_scopes || run_all_scopes) ) {
def statusCode1 = sh script:"./terracumber-cli ${common_params} --logfile ${resultdirbuild}/testsuite.log --runstep cucumber --cucumber-cmd '${secondary_exports} cd /root/spacewalk/testsuite; rake cucumber:secondary'", returnStatus:true
def statusCode2 = sh script:"./terracumber-cli ${common_params} --logfile ${resultdirbuild}/testsuite.log --runstep cucumber --cucumber-cmd '${secondary_exports} cd /root/spacewalk/testsuite; rake ${rake_namespace}:secondary_parallelizable'", returnStatus:true
sh "exit \$(( ${statusCode1}|${statusCode2} ))"
}
}
tests_passed = true
}
}
finally {
stage('Clean up lockfiles') {
if(running_same_pr == "no"){
sh(script: "rm -f ${env.suma_pr_lockfile}")
}
if(environment_workspace){
ws(environment_workspace){
if (env.env_file) {
if (tests_passed || !deployed){
println("Unlock environment")
sh "rm -f ${env_file}*"
} else {
println("Keep the environment locked for 24 hours so you can debug")
sh "echo \"rm -f ${env_file}*\" | at now +24 hour"
sh "echo keep:24h >> ${env_file}.info"
sh "python3 ${WORKSPACE}/product/susemanager-utils/testing/automation/run-command-in-server.py --command=\"chmod 755 /tmp/set_custom_header.sh;/tmp/set_custom_header.sh -e ${env_number} -m ${email_to} -t 24\" --username=\"root\" --password=\"linux\" -v -i suma-pr${env_number}-srv.mgr.prv.suse.net"
}
}
}
}
}
stage('Get test results') {
if(environment_workspace && common_params != ''){
ws(environment_workspace){
def error = 0
if(must_test) {
if (deployed) {
try {
sh "./terracumber-cli ${common_params} --logfile ${resultdirbuild}/testsuite.log --runstep cucumber --cucumber-cmd 'cd /root/spacewalk/testsuite; rake cucumber:finishing_pr'"
} catch(Exception ex) {
println("ERROR: rake cucumber:finishing_pr failed")
error = 1
}
try {
sh "./terracumber-cli ${common_params} --logfile ${resultdirbuild}/testsuite.log --runstep cucumber --cucumber-cmd 'cd /root/spacewalk/testsuite; rake utils:generate_test_report'"
} catch(Exception ex) {
println("ERROR: rake utils:generate_test_repor failed")
error = 1
}
sh "./terracumber-cli ${common_params} --logfile ${resultdirbuild}/testsuite.log --runstep getresults"
publishHTML( target: [
allowMissing: true,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: "${resultdirbuild}/cucumber_report/",
reportFiles: 'cucumber_report.html',
reportName: "TestSuite Report for Pull Request ${builder_project}:${pull_request_number}"]
)
junit allowEmptyResults: true, testResults: "results/${BUILD_NUMBER}/results_junit/*.xml"
}
if (fileExists("results/${BUILD_NUMBER}")) {
archiveArtifacts artifacts: "results/${BUILD_NUMBER}/**/*"
}
if (email_to != '') {
sh " export TF_VAR_MAIL_TO=${email_to};export TF_VAR_URL_PREFIX=${url_prefix}; ./terracumber-cli ${common_params} --logfile ${resultdirbuild}/mail.log --runstep mail"
}
// Clean up old results
sh "./clean-old-results -r ${resultdir} -s 10"
sh "exit ${error}"
}
}
}
}
stage('Remove build project') {
if(environment_workspace){
ws(environment_workspace){
sh "rm -rf ${environment_workspace}/repos/${builder_project}:${pull_request_number}/${build_repo}/${arch}"
sh "rm -rf ${builder_project}:${pull_request_number}"
}
}
}
}
}
}

return this
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ if (env.JOB_NAME == "uyuni-prs-ci-tests-jordi") {
first_env = 10;
last_env = 10;
// if you change the sumaform repo or reference, you need to remove the sumaform directory from the results folder
sumaform_gitrepo = "https://github.com/witekest/sumaform.git";
sumaform_ref = "server_monitoring";
// /!\ Temporary change /!\
//sumaform_gitrepo = "https://github.com/witekest/sumaform.git";
//sumaform_ref = "server_monitoring";
sumaform_gitrepo = "https://github.com/uyuni-project/sumaform.git";
sumaform_ref = "master";
} else if (env.JOB_NAME == "uyuni-prs-ci-tests-ion") {
first_env = 7;
last_env = 7;
Expand Down
Loading
Loading