2025-10-30 11:13:38 +01:00

305 lines
10 KiB
YAML

parameters:
- name: PYTHON_VER
displayName: 'Python Version'
type: string
default: "3.13"
values:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- name: ANSIBLE_VER
displayName: 'Ansible Version'
type: string
default: "2.18"
values:
- "2.16" # End Of Life May 2025 https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix
- "2.17"
- "2.18"
- "devel"
- name: MODULE_NAME
displayName: 'Test Module'
type: string
default: 'all'
values:
- 'all'
- "setup_azure"
- 'sanity'
- "inventory_azure" # Group 1
- 'azure_rm_adapplication'
- "azure_rm_acs"
- "azure_rm_adgroup"
- "azure_rm_aduser"
- "azure_rm_afdendpoint"
- "azure_rm_aks"
- "azure_rm_aksagentpool"
- "azure_rm_apimanagement"
- "azure_rm_appgateway"
- "azure_rm_appserviceplan"
- "azure_rm_automationaccount"
- "azure_rm_automationrunbook"
- "azure_rm_autoscale"
- "azure_rm_availabilityset"
- "azure_rm_azurefirewall"
- "azure_rm_apimanagementservice"
- "azure_rm_batchaccount"
- "azure_rm_backuppolicy"
- "azure_rm_capacityreservationgroup"
- "azure_rm_cdnprofile"
- "azure_rm_containerinstance"
- "azure_rm_containerregistry"
- "azure_rm_containerregistryscopemap"
- "azure_rm_containerregistrytoken"
- "azure_rm_containerregistrytag"
- "azure_rm_cosmosdbaccount"
- "azure_rm_ddosprotectionplan"
- "azure_rm_deployment"
- "azure_rm_diskencryptionset"
- "azure_rm_dnsrecordset"
- "azure_rm_dnszone"
- "azure_rm_eventhub"
- "azure_rm_expressroute"
- "azure_rm_firewallpolicy"
- "azure_rm_functionapp"
- "azure_rm_gallery"
- "azure_rm_hdinsightcluster"
- "azure_rm_hostgroup"
- "azure_rm_image"
- "azure_rm_iothub"
- "azure_rm_ipgroup"
- "azure_rm_keyvault"
- "azure_rm_keyvaultkey"
- "azure_rm_keyvaultsecret"
- "azure_rm_keyvaultcertificate"
- "azure_rm_loadbalancer"
- "azure_rm_loganalyticsworkspace"
- "azure_rm_localnetworkgateway"
- "azure_rm_manageddisk"
- "azure_rm_managementgroup"
- "azure_rm_mariadbserver"
- "azure_rm_monitoractiongroups"
- "azure_rm_monitoractivitylogalerts"
- "azure_rm_monitordatacollectionrules"
- "azure_rm_monitordatacollectionendpoint"
- "azure_rm_monitordatacollectionruleassociation"
- "azure_rm_monitordiagnosticsetting"
- "azure_rm_monitorlogprofile"
- "azure_rm_monitormetricalerts"
- "azure_rm_multiplemanageddisks"
- "azure_rm_mysqlserver"
- "azure_rm_mysqlflexibleserver"
- "azure_rm_natgateway"
- "azure_rm_networkinterface"
- "azure_rm_notificationhub"
- "azure_rm_openshiftmanagedcluster"
- "azure_rm_postgresqlserver"
- "azure_rm_postgresqlflexibleserver"
- "azure_rm_postgresqlflexiblevirtualendpoint"
- "azure_rm_postgresqlflexiblebackup"
- "azure_rm_privatednsrecordset"
- "azure_rm_privatednszone"
- "azure_rm_privateendpoint"
- "azure_rm_privateendpointdnszonegroup"
- "azure_rm_privatelinkservice"
- "azure_rm_privatednszonelink"
- "azure_rm_publicipaddress"
- "azure_rm_publicipprefix"
- "azure_rm_proximityplacementgroup"
- "azure_rm_rediscache"
- "azure_rm_resource"
- "azure_rm_resourcegroup"
- "azure_rm_routetable"
- "azure_rm_roleassignment"
- "azure_rm_roledefinition"
- "azure_rm_registrationassignment"
- "azure_rm_registrationdefinition"
- "azure_rm_cognitivesearch"
- "azure_rm_securitygroup"
- "azure_rm_servicebus"
- "azure_rm_sqlserver"
- "azure_rm_storageaccount"
- "azure_rm_storageaccountmanagementpolicy"
- "azure_rm_storageblob"
- "azure_rm_storageshare"
- "azure_rm_subnet"
- "azure_rm_azure_rm_serviceendpointpolicy"
- "azure_rm_azure_rm_serviceendpointpolicydefinition"
- "azure_rm_subscription"
- "azure_rm_trafficmanagerprofile"
- "azure_rm_virtualmachine"
- "azure_rm_virtualmachineextension"
- "azure_rm_virtualmachineimage_info"
- "azure_rm_virtualmachinescaleset"
- "azure_rm_virtualmachinesize_info"
- "azure_rm_virtualnetwork"
- "azure_rm_virtualnetworkgateway"
- "azure_rm_virtualnetworkpeering"
- "azure_rm_virtualnetworkgatewaynatrule"
- "azure_rm_virtualwan"
- "azure_rm_vpnsite"
- "azure_rm_virtualhub"
- "azure_rm_virtualhubconnection"
- "azure_rm_virtualnetworkgatewayconnection"
- "azure_rm_backupazurevm"
- "azure_rm_recoveryservicesvault"
- "azure_rm_vmbackuppolicy"
- "azure_rm_webapp"
- "azure_rm_webappvnetconnection"
- "azure_rm_webappaccessrestriction"
- "azure_rm_workspace"
- "azure_rm_datafactory"
- "azure_rm_bastionhost"
- "azure_rm_devtestlab"
- "azure_rm_sqlmanagedinstance"
- "azure_rm_sqlmidatabase"
- "azure_rm_sqlmidblongtermretentionpolicy"
- "azure_rm_sqlmidbshorttermretentionpolicy"
- "azure_rm_vmssnetworkinterface_info"
- "azure_rm_sshpublickey"
- "azure_rm_snapshot"
- "azure_rm_networkwatcher"
- "azure_rm_batchaccountapplication"
- "azure_rm_batchaccountapplicationpackage"
- "azure_rm_batchaccountpool"
- "azure_rm_applicationfirewallpolicy"
- "azure_rm_applicationfirewallpolicy_info"
- "azure_rm_diskaccess"
- "azure_rm_diskaccess_info"
- "azure_rm_resourcehealthstates"
- "azure_rm_afdroute"
- "azure_rm_afdorigingroup"
- "azure_rm_afdorigin"
- "azure_rm_afdruleset"
- "azure_rm_afdrules"
- "azure_rm_tags"
- "azure_rm_dedicatedhost"
- "inventory_azure"
- "setup_azure"
trigger: none
pr:
- dev
pool:
name: pool-ubuntu-2404
jobs:
- job: InitializationTest
steps:
- bash: |
echo "##vso[task.setvariable variable=resource_group;isOutput=true]ansibletest-$(uuidgen)"
echo "##vso[task.setvariable variable=resource_group_secondary;isOutput=true]ansibletest2-$(uuidgen)"
name: setvar
- bash: |
echo "Generate test resource group variable $(setvar.resource_group), $(setvar.resource_group_secondary)"
- task: AzureCLI@2
inputs:
azureSubscription: '$(SUBSCRIPTION_FULL_NAME)'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az group create -l eastus -n $(setvar.resource_group)
az group create -l eastus -n $(setvar.resource_group_secondary)
- bash: |
group_no="all"
case "${{ parameters.MODULE_NAME }}" in
sanity)
gropu_no=sanity
;;
inventory_azure)
group_no=1
;;
azure_rm_*)
group_no=$(awk -F'shippable/azure/group' '/^shippable\/azure\/group/ { print $2 }' ./tests/integration/targets/${{ parameters.MODULE_NAME }}/aliases)
;;
*)
# "all" and "setup_azure"
;;
esac
echo "Active group number: $group_no"
displayName: "Determine the target ansible test group number"
- job: RunTests
dependsOn: InitializationTest
timeoutInMinutes: 180
variables:
TEST_RESOURCE_GROUP: $[ dependencies.InitializationTest.outputs['setvar.resource_group'] ]
TEST_RESOURCE_GROUP_SECONDARY: $[ dependencies.InitializationTest.outputs['setvar.resource_group_secondary'] ]
strategy:
matrix:
"Python${{ parameters.PYTHON_VER }}_sanity":
test.key: 'sanity'
"Python${{ parameters.PYTHON_VER }}_1":
test.key: '1'
"Python${{ parameters.PYTHON_VER }}_2":
test.key: '2'
"Python${{ parameters.PYTHON_VER }}_3":
test.key: '3'
"Python${{ parameters.PYTHON_VER }}_4":
test.key: '4'
"Python${{ parameters.PYTHON_VER }}_5":
test.key: '5'
"Python${{ parameters.PYTHON_VER }}_6":
test.key: '6'
"Python${{ parameters.PYTHON_VER }}_7":
test.key: '7'
"Python${{ parameters.PYTHON_VER }}_9":
test.key: '9'
"Python${{ parameters.PYTHON_VER }}_10":
test.key: '10'
"Python${{ parameters.PYTHON_VER }}_11":
test.key: '11'
"Python${{ parameters.PYTHON_VER }}_12":
test.key: '12'
"Python${{ parameters.PYTHON_VER }}_13":
test.key: '13'
"Python${{ parameters.PYTHON_VER }}_14":
test.key: '14'
"Python${{ parameters.PYTHON_VER }}_15":
test.key: '15'
steps:
- task: UsePythonVersion@0
displayName: 'Use Python ${{ parameters.PYTHON_VER }}'
inputs:
versionSpec: '${{ parameters.PYTHON_VER }}'
- script: tests/utils/ado/ado.sh $(test.key) ${{ parameters.ANSIBLE_VER }} ${{ parameters.MODULE_NAME }}
env:
SHIPPABLE_BUILD_DIR: $(Build.Repository.LocalPath)
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID)
AZURE_SECRET: $(AZURE_SECRET)
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
AZURE_SUBSCRIPTION_SEC_ID: $(AZURE_SUBSCRIPTION_SEC_ID)
AZURE_TENANT: $(AZURE_TENANT)
AZURE_PRINCIPAL_ID: $(AZURE_PRINCIPAL_ID)
AZURE_MANAGED_BY_TENANT_ID: $(AZURE_MANAGED_BY_TENANT_ID)
AZURE_ROLE_DEFINITION_ID: $(AZURE_ROLE_DEFINITION_ID)
RESOURCE_GROUP: $(TEST_RESOURCE_GROUP)
RESOURCE_GROUP_SECONDARY: $(TEST_RESOURCE_GROUP_SECONDARY)
displayName: 'Running Tests'
- job: CleanupResourceGroups
dependsOn:
- InitializationTest
- RunTests
condition: always()
variables:
TEST_RESOURCE_GROUP: $[ dependencies.InitializationTest.outputs['setvar.resource_group'] ]
TEST_RESOURCE_GROUP_SECONDARY: $[ dependencies.InitializationTest.outputs['setvar.resource_group_secondary'] ]
steps:
- task: AzureCLI@2
inputs:
azureSubscription: '$(SUBSCRIPTION_FULL_NAME)'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az group list --query "[?starts_with(name, '$(TEST_RESOURCE_GROUP)') || starts_with(name, '$(TEST_RESOURCE_GROUP_SECONDARY)')].name" -o tsv | while read rg;
do
echo "Deleting resource group: $rg"
az group delete --name "$rg" --yes --no-wait
done