Validate payg-multivm offer #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validate payg-multivm offer | |
on: | |
workflow_dispatch: | |
inputs: | |
databaseType: | |
description: 'Database connection' | |
required: true | |
default: 'mssqlserver' | |
type: choice | |
options: | |
- mssqlserver | |
- oracle | |
- mysql | |
- postgresql | |
- none | |
deleteAzureResources: | |
description: 'Delete Azure resources at the end' | |
required: true | |
type: boolean | |
default: true | |
env: | |
azureCredentials: ${{ secrets.AZURE_CREDENTIALS_PAYG }} | |
location: eastus | |
domainResourceGroup: multivm-domain-${{ github.repository_owner }}-${{ github.run_id }}-${{ github.run_number }} | |
standaloneResourceGroup: multivm-standalone-${{ github.repository_owner }}-${{ github.run_id }}-${{ github.run_number }} | |
dependencyResourceGroup: multivm-dep-${{ github.repository_owner }}-${{ github.run_id }}-${{ github.run_number }} | |
vmName: ${{ github.run_id }}${{ github.run_number }}vm | |
asName: ${{ github.run_id }}${{ github.run_number }}as | |
adminUsername: azureadmin | |
password: ${{ secrets.VM_PASSWORD }} | |
numberOfInstances: 3 | |
domainOperatingMode: managed-domain | |
standaloneOperatingMode: standalone | |
domainBootStorageAccountName: ${{ github.run_id }}${{ github.run_number }}domainsa | |
standaloneBootStorageAccountName: ${{ github.run_id }}${{ github.run_number }}standsa | |
dbInstanceName: db${{ github.run_id }}${{ github.run_number }} | |
dbPassword: ${{ secrets.DATABASE_PASSWORD }} | |
jbossEAPUserName: jbossadmin | |
jbossEAPPassword: ${{ secrets.JBOSS_EAP_USER_PASSWORD }} | |
rhsmUserName: ${{ secrets.RHSM_USERNAME }} | |
rhsmPassword: ${{ secrets.RHSM_PASSWORD }} | |
rhsmPoolEAP: ${{ secrets.RHSM_POOL }} | |
gitUserName: ${{ secrets.USER_NAME }} | |
domainTestBranchName: domain-cicd-${{ github.run_id }}-${{ github.run_number }} | |
standaloneTestBranchName: standalone-cicd-${{ github.run_id }}-${{ github.run_number }} | |
gitEmail: ${{ secrets.USER_EMAIL }} | |
gitToken: ${{ secrets.GIT_TOKEN }} | |
scriptLocation: https://raw.githubusercontent.com/${{ secrets.USER_NAME }}/rhel-jboss-templates/$GITHUB_REF_NAME/utilities/ | |
offerName: "eap74-rhel8-payg-multivm" | |
jobs: | |
preflight: | |
outputs: | |
artifactName: ${{steps.build.outputs.artifactName}} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout rhel-jboss-templates | |
uses: actions/checkout@v4 | |
- name: build | |
id: build | |
uses: ./.github/actions/build | |
with: | |
offerName: ${{ env.offerName }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
workflowType: "validate" | |
deploy-dependent-resources: | |
needs: preflight | |
runs-on: ubuntu-latest | |
outputs: | |
sqlserverHost: ${{ steps.deploy-mssqlserver.outputs.sqlserverHost }} | |
oracleHost: ${{ steps.deploy-oracle.outputs.oracleHost }} | |
mysqlHost: ${{ steps.deploy-mysql.outputs.mysqlHost }} | |
postgresqlHost: ${{ steps.deploy-postgresql.outputs.postgresqlHost }} | |
steps: | |
- uses: azure/login@v1 | |
id: azure-login | |
with: | |
creds: ${{ env.azureCredentials }} | |
- name: Accept Image Terms | |
id: accept-terms | |
run: | | |
echo "accept terms for VM image" | |
az vm image terms accept --urn redhat:rh-jboss-eap:rh-jboss-eap74-rhel8:latest | |
- name: Create Resource Group | |
run: | | |
az group create -n ${{ env.dependencyResourceGroup}} -l ${{ env.location }} | |
- name: Deploy an instance of Azure SQL Database | |
id: deploy-mssqlserver | |
if: ${{ inputs.databaseType == 'mssqlserver' || github.event.client_payload.databaseType == 'mssqlserver' }} | |
run: | | |
az sql server create \ | |
--resource-group ${{ env.dependencyResourceGroup }} --name ${{ env.dbInstanceName }} \ | |
--admin-user testuser --admin-password ${{ env.dbPassword }} \ | |
--location ${{ env.location }} | |
host=$(az sql server show \ | |
--resource-group ${{ env.dependencyResourceGroup }} --name ${{ env.dbInstanceName }} \ | |
--query "fullyQualifiedDomainName" -o tsv) | |
# Allow Azure services to access | |
az sql server firewall-rule create \ | |
--resource-group ${{ env.dependencyResourceGroup }} --server ${{ env.dbInstanceName }} \ | |
--name "AllowAllAzureIps" --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0 | |
az sql db create --resource-group ${{ env.dependencyResourceGroup }} --server ${{ env.dbInstanceName }} --name testdb | |
echo "sqlserverHost=${host}" >> "$GITHUB_OUTPUT" | |
- name: Deploy an Oracle database server on Azure VM | |
id: deploy-oracle | |
if: ${{ inputs.databaseType == 'oracle' || github.event.client_payload.databaseType == 'oracle' }} | |
run: | | |
az group create -n ${{ env.dependencyResourceGroup }} -l ${{ env.location }} | |
az vm create \ | |
--resource-group ${{ env.dependencyResourceGroup }} --name ${{ env.dbInstanceName }} \ | |
--image Oracle:oracle-database-19-3:oracle-database-19-0904:latest --size Standard_DS2_v2 \ | |
--admin-username azureuser --generate-ssh-keys \ | |
--nsg-rule NONE --enable-agent true \ | |
--vnet-name ${{ env.dbInstanceName }}VNET --enable-auto-update false \ | |
--tags SkipASMAzSecPack=true SkipNRMSCorp=true SkipNRMSDatabricks=true SkipNRMSDB=true SkipNRMSHigh=true SkipNRMSMedium=true SkipNRMSRDPSSH=true SkipNRMSSAW=true SkipNRMSMgmt=true | |
az vm disk attach --name oradata01 --new --resource-group ${{ env.dependencyResourceGroup }} --vm-name ${{ env.dbInstanceName }} --size-gb 64 --sku StandardSSD_LRS | |
az vm open-port -g ${{ env.dependencyResourceGroup }} -n ${{ env.dbInstanceName }} --port 1521,5502 --priority 100 | |
az vm extension set --name CustomScript \ | |
--extension-instance-name install-oracle \ | |
--resource-group ${{ env.dependencyResourceGroup }} --vm-name ${{ env.dbInstanceName }} \ | |
--publisher Microsoft.Azure.Extensions --version 2.0 \ | |
--settings "{\"fileUris\": [\"${{ env.scriptLocation }}install-oracle-main.sh\", \"${{ env.scriptLocation }}install-oracle.sh\"]}" \ | |
--protected-settings "{\"commandToExecute\":\"bash install-oracle-main.sh ${{ env.dbPassword }}\"}" | |
host=$(az vm show -g ${{ env.dependencyResourceGroup }} -n ${{ env.dbInstanceName }} -d --query publicIps -o tsv) | |
echo "oracleHost=${host}" >> "$GITHUB_OUTPUT" | |
- name: Deploy an instance of Azure Database for MySQL | |
id: deploy-mysql | |
if: ${{ inputs.databaseType == 'mysql' || github.event.client_payload.databaseType == 'mysql' }} | |
run: | | |
az group create -n ${{ env.dependencyResourceGroup }} -l ${{ env.location }} | |
az mysql server create \ | |
--resource-group ${{ env.dependencyResourceGroup }} --name ${{ env.dbInstanceName }} \ | |
--admin-user myadmin --admin-password ${{ env.dbPassword }} \ | |
--sku-name GP_Gen5_2 --location ${{ env.location }} | |
# Allow Azure services to access | |
az mysql server firewall-rule create \ | |
--resource-group ${{ env.dependencyResourceGroup }} --server ${{ env.dbInstanceName }} \ | |
--name "AllowAllAzureIps" --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0 | |
# Allow current IP to access MySQL server | |
currentIp=$(curl -s https://icanhazip.com) | |
az mysql server firewall-rule create \ | |
--resource-group ${{ env.dependencyResourceGroup }} --server ${{ env.dbInstanceName }} \ | |
--name "AllowCurrentIp" --start-ip-address ${currentIp} --end-ip-address ${currentIp} | |
host=$(az mysql server show \ | |
--resource-group ${{ env.dependencyResourceGroup }} --name ${{ env.dbInstanceName }} \ | |
--query "fullyQualifiedDomainName" -o tsv) | |
echo "mysqlHost=${host}" >> "$GITHUB_OUTPUT" | |
mysql -h $host -u myadmin@${{ env.dbInstanceName }} -p${{ env.dbPassword }} << EOF | |
CREATE DATABASE testdb; | |
CREATE USER 'testuser'@'%' IDENTIFIED BY '${{ env.dbPassword }}'; | |
GRANT ALL PRIVILEGES ON testdb . * TO 'testuser'@'%'; | |
FLUSH PRIVILEGES; | |
EOF | |
- name: Deploy an instance of Azure Database for PostgreSQL | |
id: deploy-postgresql | |
if: ${{ inputs.databaseType == 'postgresql' || github.event.client_payload.databaseType == 'postgresql' }} | |
run: | | |
az postgres server create \ | |
--resource-group ${{ env.dependencyResourceGroup}} --name ${{ env.dbInstanceName }} \ | |
--admin-user testuser --admin-password ${{ env.dbPassword }} \ | |
--location ${{ env.location }} | |
host=$(az postgres server show \ | |
--resource-group ${{ env.dependencyResourceGroup}} --name ${{ env.dbInstanceName }} \ | |
--query "fullyQualifiedDomainName" -o tsv) | |
# Allow Azure services to access | |
az postgres server firewall-rule create \ | |
--resource-group ${{ env.dependencyResourceGroup}} --server ${{ env.dbInstanceName }} \ | |
--name "AllowAllAzureIps" --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0 | |
az postgres db create --resource-group ${{ env.dependencyResourceGroup}} --server ${{ env.dbInstanceName }} --name testdb | |
echo "postgresqlHost=${host}" >> "$GITHUB_OUTPUT" | |
deploy-multivm-domain: | |
needs: | |
- preflight | |
- deploy-dependent-resources | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get versions of external dependencies | |
run: | | |
curl -Lo external-deps-versions.properties https://raw.githubusercontent.com/Azure/azure-javaee-iaas/main/external-deps-versions.properties | |
source external-deps-versions.properties | |
echo "azCliVersion=${AZ_CLI_VERSION}" >> "$GITHUB_ENV" | |
echo "bicepVersion=${BICEP_VERSION}" >> "$GITHUB_ENV" | |
- name: Checkout rhel-jboss-templates | |
uses: actions/checkout@v4 | |
with: | |
path: rhel-jboss-templates | |
- name: Download artifact for deployment | |
uses: actions/download-artifact@v1 | |
with: | |
name: ${{needs.preflight.outputs.artifactName}} | |
path: rhel-jboss-templates-dev | |
- name: Create a new branch with built artifact | |
run: | | |
current=`pwd` | |
echo "current=${current}" >> "$GITHUB_ENV" | |
cd rhel-jboss-templates | |
git config --global core.longpaths true | |
git config --global user.email $gitEmail | |
git config --global user.name $gitUserName | |
echo "create branch $domainTestBranchName" | |
git checkout -b $domainTestBranchName | |
rm -r -f $current/rhel-jboss-templates/eap74-rhel8-payg-multivm/src/main/* | |
cp -r -f $current/rhel-jboss-templates-dev/* $current/rhel-jboss-templates/eap74-rhel8-payg-multivm/ | |
git add . | |
git status | |
git commit -m "test branch for pipeline" | |
git push https://[email protected]/${GITHUB_REPOSITORY}.git -f | |
- uses: azure/login@v1 | |
id: azure-login | |
with: | |
creds: ${{ env.azureCredentials }} | |
- name: Prepare parameter file | |
run: | | |
enableDB=false | |
databaseType=postgresql | |
dsConnectionURL=jdbc:postgresql://contoso.postgres.database:5432/testdb | |
dbUser=contosoDbUser | |
dbPassword=contosoDbPwd | |
if ${{ inputs.databaseType == 'mssqlserver' || github.event.client_payload.databaseType == 'mssqlserver' }}; then | |
enableDB=true | |
databaseType=mssqlserver | |
dsConnectionURL="jdbc:sqlserver://${{ needs.deploy-dependent-resources.outputs.sqlserverHost }}:1433;database=testdb" | |
dbUser=testuser@${{ env.dbInstanceName }} | |
dbPassword=${{ env.dbPassword }} | |
elif ${{ inputs.databaseType == 'oracle' || github.event.client_payload.databaseType == 'oracle' }}; then | |
enableDB=true | |
databaseType=oracle | |
dsConnectionURL=jdbc:oracle:thin:@${{ needs.deploy-dependent-resources.outputs.oracleHost }}:1521/oratest1 | |
dbUser=testuser | |
dbPassword=${{ env.dbPassword }} | |
elif ${{ inputs.databaseType == 'mysql' || github.event.client_payload.databaseType == 'mysql' }}; then | |
enableDB=true | |
databaseType=mysql | |
dsConnectionURL=jdbc:mysql://${{ needs.deploy-dependent-resources.outputs.mysqlHost }}:3306/testdb | |
dbUser=testuser@${{ env.dbInstanceName }} | |
dbPassword=${{ env.dbPassword }} | |
elif ${{ inputs.databaseType == 'postgresql' || github.event.client_payload.databaseType == 'postgresql' }}; then | |
enableDB=true | |
databaseType=postgresql | |
dsConnectionURL="jdbc:postgresql://${{ needs.deploy-dependent-resources.outputs.postgresqlHost }}:5432/testdb" | |
dbUser=testuser@${{ env.dbInstanceName }} | |
dbPassword=${{ env.dbPassword }} | |
fi | |
echo "enableDB=${enableDB}" >> "$GITHUB_ENV" | |
echo "generate parameter file for domain mode" | |
# Generate parameters for db template deployment | |
bash rhel-jboss-templates/eap74-rhel8-payg-multivm/src/test/scripts/gen-parameters.sh \ | |
<<< "rhel-jboss-templates/eap74-rhel8-payg-multivm/src/test/parameters-test-domain.json \ | |
${gitUserName} \ | |
${domainTestBranchName} \ | |
${location} \ | |
${vmName} \ | |
${asName} \ | |
${adminUsername} \ | |
${password} \ | |
${numberOfInstances} \ | |
${domainOperatingMode} \ | |
${domainResourceGroup} \ | |
${domainBootStorageAccountName} \ | |
${domainResourceGroup} \ | |
${jbossEAPUserName} \ | |
${jbossEAPPassword} \ | |
${rhsmUserName} \ | |
${rhsmPassword} \ | |
${rhsmPoolEAP} \ | |
${enableDB} \ | |
${databaseType} \ | |
java:jboss/datasources/JavaEECafeDB \ | |
${dsConnectionURL} \ | |
${dbUser} \ | |
${dbPassword}" | |
- name: Archive parameters-test-domain.json | |
uses: actions/upload-artifact@v1 | |
if: success() | |
with: | |
name: parameters-test-domain | |
path: rhel-jboss-templates/eap74-rhel8-payg-multivm/src/test/parameters-test-domain.json | |
- name: Create Resource Group | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: ${{ env.azCliVersion }} | |
inlineScript: | | |
echo "create resource group" ${{ env.domainResourceGroup }} | |
az group create --verbose --name ${{ env.domainResourceGroup }} --location ${{ env.location }} | |
- name: Deploy JBoss EAP domain cluster | |
id: deploy-multivm-managed-domain | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: ${{ env.azCliVersion }} | |
inlineScript: | | |
az deployment group create \ | |
--verbose \ | |
--resource-group ${{ env.domainResourceGroup }} \ | |
--name multivm-managed-domain \ | |
--parameters @rhel-jboss-templates/eap74-rhel8-payg-multivm/src/test/parameters-test-domain.json \ | |
--template-file rhel-jboss-templates/eap74-rhel8-payg-multivm/mainTemplate.json | |
- name: Build javaee cafe | |
run: | | |
if ${{ env.enableDB != 'true' }}; then | |
sed -i "s/java:jboss\/datasources\/JavaEECafeDB/java:jboss\/datasources\/ExampleDS/g" rhel-jboss-templates/eap-coffee-app/src/main/resources/META-INF/persistence.xml | |
fi | |
mvn clean install --file rhel-jboss-templates/eap-coffee-app/pom.xml | |
if ${{ env.enableDB != 'true' }}; then | |
sed -i "s/java:jboss\/datasources\/ExampleDS/java:jboss\/datasources\/JavaEECafeDB/g" rhel-jboss-templates/eap-coffee-app/src/main/resources/META-INF/persistence.xml | |
fi | |
- name: Create a container and uploading cafe app | |
id: upload_cafe_app | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: ${{ env.azCliVersion }} | |
inlineScript: | | |
# create a container | |
az storage container create --name cafeapp --account-name ${{ env.domainBootStorageAccountName }} | |
# upload cafe app | |
az storage blob upload \ | |
--account-name ${{ env.domainBootStorageAccountName }} \ | |
--container-name cafeapp \ | |
--name javaee-cafe.war \ | |
--file rhel-jboss-templates/eap-coffee-app/target/javaee-cafe.war | |
# query the app url | |
sasTokenValidTime=3600 | |
expiryData=$(( `date +%s`+${sasTokenValidTime})) | |
sasEnd=`date -d@"$expiryData" -u '+%Y-%m-%dT%H:%MZ'` | |
sasToken=$(az storage account generate-sas \ | |
--permissions r \ | |
--account-name ${{ env.domainBootStorageAccountName }} \ | |
--services b \ | |
--resource-types sco \ | |
--expiry $sasEnd -o tsv) | |
appbloburl=$(az storage blob url \ | |
--container-name cafeapp \ | |
--name javaee-cafe.war \ | |
--account-name ${{ env.domainBootStorageAccountName }} \ | |
--sas-token ${sasToken} -o tsv) | |
echo "appbloburl=${appbloburl}" >> "$GITHUB_OUTPUT" | |
- name: Query public ip of admin VM | |
id: query_admin_public_ip | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: ${{ env.azCliVersion }} | |
inlineScript: | | |
# query public ip address of admin VM | |
publicip=$(az vm show --resource-group ${{ env.domainResourceGroup }} --name ${{ github.run_id }}${{ github.run_number }}vm-adminVM -d --query publicIps -o tsv) | |
echo "publicip=${publicip}" >> "$GITHUB_OUTPUT" | |
- name: Deploy cafe application | |
run: | | |
appbloburl="${{steps.upload_cafe_app.outputs.appbloburl}}" | |
echo "appbloburl: " $appbloburl | |
publicip=${{steps.query_admin_public_ip.outputs.publicip}} | |
echo "publicip: " $publicip | |
curl --digest -L -D - http://${publicip}:9990/management --header "Content-Type: application/json" -u ${jbossEAPUserName}:${jbossEAPPassword} -d "{\"operation\" : \"add\", \"address\" : {\"deployment\" : \"javaee-cafe.war\"}, \"content\" : [{\"url\" : \"${appbloburl}\"}],\"json.pretty\":1}" | |
curl --digest -L -D - http://${publicip}:9990/management --header "Content-Type: application/json" -u ${jbossEAPUserName}:${jbossEAPPassword} -d "{\"operation\" : \"add\", \"address\" : {\"server-group\" : \"main-server-group\",\"deployment\":\"javaee-cafe.war\"},\"json.pretty\":1}" | |
curl --digest -L -D - http://${publicip}:9990/management --header "Content-Type: application/json" -u ${jbossEAPUserName}:${jbossEAPPassword} -d "{\"operation\" : \"deploy\", \"address\" : {\"server-group\" : \"main-server-group\",\"deployment\":\"javaee-cafe.war\"},\"json.pretty\":1}" | |
- name: Query public ip of Application Gateway | |
id: query_app_gateway_public_ip | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: ${{ env.azCliVersion }} | |
inlineScript: | | |
# query public ip address of Application Gateway | |
publicip=$(az network public-ip show --name gwip \ | |
--resource-group $domainResourceGroup --query dnsSettings.fqdn -o tsv) | |
echo "publicip=${publicip}" >> "$GITHUB_OUTPUT" | |
- name: Verify cafe application | |
run: | | |
publicip=${{steps.query_app_gateway_public_ip.outputs.publicip}} | |
echo "publicip: " $publicip | |
CURL_RETRY_PARMS="--connect-timeout 60 --max-time 180 --retry 10 --retry-delay 30 --retry-max-time 180 --retry-connrefused" | |
echo "Verifying Cafe is deployed as expected" | |
curl --verbose http://${publicip}/javaee-cafe/ | |
response=$(curl ${CURL_RETRY_PARMS} --write-out '%{http_code}' --silent --output /dev/null http://${publicip}/javaee-cafe/) | |
echo "$response" | |
if [ "$response" -ne 200 ]; then | |
echo "Cafe is not accessible" | |
exit 1 | |
else | |
echo "Cafe is accessible" | |
fi | |
exit 0 | |
- name: Unregister before deleting resources | |
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.deleteAzureResources) }} | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: ${{ env.azCliVersion }} | |
inlineScript: | | |
echo "Unregister admin VM" | |
az vm run-command invoke -g ${domainResourceGroup} -n ${vmName}-adminVM --command-id RunShellScript --scripts "sudo subscription-manager unregister" | |
for ((i = 1; i < numberOfInstances; i++)); do | |
echo "Unregister ${vmName}${i}" | |
az vm run-command invoke -g ${domainResourceGroup} -n ${vmName}${i} --command-id RunShellScript --scripts "sudo subscription-manager unregister" | |
done | |
deploy-multivm-standalone: | |
needs: | |
- preflight | |
- deploy-dependent-resources | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout rhel-jboss-templates | |
uses: actions/checkout@v4 | |
- name: Get versions of external dependencies | |
run: | | |
curl -Lo external-deps-versions.properties https://raw.githubusercontent.com/Azure/azure-javaee-iaas/main/external-deps-versions.properties | |
source external-deps-versions.properties | |
echo "azCliVersion=${AZ_CLI_VERSION}" >> "$GITHUB_ENV" | |
echo "bicepVersion=${BICEP_VERSION}" >> "$GITHUB_ENV" | |
- name: Checkout rhel-jboss-templates | |
uses: actions/checkout@v4 | |
with: | |
path: rhel-jboss-templates | |
- name: Download artifact for test branch | |
uses: actions/download-artifact@v1 | |
with: | |
name: ${{needs.preflight.outputs.artifactName}} | |
path: rhel-jboss-templates-dev | |
- name: Create a new branch with built artifact | |
run: | | |
current=`pwd` | |
echo "current=${current}" >> "$GITHUB_ENV" | |
cd rhel-jboss-templates | |
git config --global core.longpaths true | |
git config --global user.email $gitEmail | |
git config --global user.name $gitUserName | |
echo "create branch $standaloneTestBranchName" | |
git checkout -b $standaloneTestBranchName | |
rm -r -f $current/rhel-jboss-templates/eap74-rhel8-payg-multivm/src/main/* | |
cp -r -f $current/rhel-jboss-templates-dev/* $current/rhel-jboss-templates/eap74-rhel8-payg-multivm/ | |
git add . | |
git status | |
git commit -m "test branch for pipeline" | |
git push https://[email protected]/${GITHUB_REPOSITORY}.git -f | |
- uses: azure/login@v1 | |
id: azure-login | |
with: | |
creds: ${{ env.azureCredentials }} | |
- name: Prepare parameter file | |
run: | | |
enableDB=false | |
databaseType=postgresql | |
dsConnectionURL=jdbc:postgresql://contoso.postgres.database:5432/testdb | |
dbUser=contosoDbUser | |
dbPassword=contosoDbPwd | |
if ${{ inputs.databaseType == 'mssqlserver' || github.event.client_payload.databaseType == 'mssqlserver' }}; then | |
enableDB=true | |
databaseType=mssqlserver | |
dsConnectionURL="jdbc:sqlserver://${{ needs.deploy-dependent-resources.outputs.sqlserverHost }}:1433;database=testdb" | |
dbUser=testuser@${{ env.dbInstanceName }} | |
dbPassword=${{ env.dbPassword }} | |
elif ${{ inputs.databaseType == 'oracle' || github.event.client_payload.databaseType == 'oracle' }}; then | |
enableDB=true | |
databaseType=oracle | |
dsConnectionURL=jdbc:oracle:thin:@${{ needs.deploy-dependent-resources.outputs.oracleHost }}:1521/oratest1 | |
dbUser=testuser | |
dbPassword=${{ env.dbPassword }} | |
elif ${{ inputs.databaseType == 'mysql' || github.event.client_payload.databaseType == 'mysql' }}; then | |
enableDB=true | |
databaseType=mysql | |
dsConnectionURL=jdbc:mysql://${{ needs.deploy-dependent-resources.outputs.mysqlHost }}:3306/testdb | |
dbUser=testuser@${{ env.dbInstanceName }} | |
dbPassword=${{ env.dbPassword }} | |
elif ${{ inputs.databaseType == 'postgresql' || github.event.client_payload.databaseType == 'postgresql' }}; then | |
enableDB=true | |
databaseType=postgresql | |
dsConnectionURL="jdbc:postgresql://${{ needs.deploy-dependent-resources.outputs.postgresqlHost }}:5432/testdb" | |
dbUser=testuser@${{ env.dbInstanceName }} | |
dbPassword=${{ env.dbPassword }} | |
fi | |
echo "generate parameter file for standalone mode" | |
bash rhel-jboss-templates/eap74-rhel8-payg-multivm/src/test/scripts/gen-parameters.sh \ | |
<<< "rhel-jboss-templates/eap74-rhel8-payg-multivm/src/test/parameters-test-standalone.json \ | |
${gitUserName} \ | |
${standaloneTestBranchName} \ | |
${location} \ | |
${vmName} \ | |
${asName} \ | |
${adminUsername} \ | |
${password} \ | |
${numberOfInstances} \ | |
${standaloneOperatingMode} \ | |
${standaloneResourceGroup} \ | |
${standaloneBootStorageAccountName} \ | |
${standaloneResourceGroup} \ | |
${jbossEAPUserName} \ | |
${jbossEAPPassword} \ | |
${rhsmUserName} \ | |
${rhsmPassword} \ | |
${rhsmPoolEAP} \ | |
${enableDB} \ | |
${databaseType} \ | |
java:jboss/datasources/JavaEECafeDB \ | |
${dsConnectionURL} \ | |
${dbUser} \ | |
${dbPassword}" | |
- name: Archive parameters-test-standalone.json | |
uses: actions/upload-artifact@v1 | |
if: success() | |
with: | |
name: parameters-test-standalone | |
path: rhel-jboss-templates/eap74-rhel8-payg-multivm/src/test/parameters-test-standalone.json | |
- name: Create Resource Group | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: ${{ env.azCliVersion }} | |
inlineScript: | | |
echo "create resource group" ${{ env.standaloneResourceGroup }} | |
az group create --verbose --name ${{ env.standaloneResourceGroup }} --location ${{ env.location }} | |
- name: Deploy JBoss EAP standalone cluster | |
id: deploy-multivm-managed-standalone | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: ${{ env.azCliVersion }} | |
inlineScript: | | |
az deployment group create \ | |
--verbose \ | |
--resource-group ${{ env.standaloneResourceGroup }} \ | |
--name multivm-standalone \ | |
--parameters @rhel-jboss-templates/eap74-rhel8-payg-multivm/src/test/parameters-test-standalone.json \ | |
--template-file rhel-jboss-templates/eap74-rhel8-payg-multivm/mainTemplate.json | |
- name: Query public ip of Application Gateway | |
id: query_app_gateway_public_ip | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: ${{ env.azCliVersion }} | |
inlineScript: | | |
# query public ip address of Application Gateway | |
publicip=$(az network public-ip show --name gwip \ | |
--resource-group $standaloneResourceGroup --query dnsSettings.fqdn -o tsv) | |
echo "publicip=${publicip}" >> "$GITHUB_OUTPUT" | |
- name: Verify eap-session-replication application | |
run: | | |
publicip=${{steps.query_app_gateway_public_ip.outputs.publicip}} | |
echo "publicip: " $publicip | |
CURL_RETRY_PARMS="--connect-timeout 60 --max-time 180 --retry 10 --retry-delay 30 --retry-max-time 180 --retry-connrefused" | |
echo "Verifying eap-session-replication is deployed as expected" | |
curl --verbose http://${publicip}/eap-session-replication/ | |
response=$(curl ${CURL_RETRY_PARMS} --write-out '%{http_code}' --silent --output /dev/null http://${publicip}/eap-session-replication/) | |
echo "$response" | |
if [ "$response" -ne 200 ]; then | |
echo "eap-session-replication is not accessible" | |
exit 1 | |
else | |
echo "eap-session-replication is accessible" | |
fi | |
exit 0 | |
- name: Unregister before deleting resources | |
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.deleteAzureResources) }} | |
uses: azure/CLI@v1 | |
with: | |
azcliversion: ${{ env.azCliVersion }} | |
inlineScript: | | |
for ((i = 0; i < numberOfInstances; i++)); do | |
echo "Unregister ${vmName}${i}" | |
az vm run-command invoke -g ${standaloneResourceGroup} -n ${vmName}${i} --command-id RunShellScript --scripts "sudo subscription-manager unregister" | |
done | |
resources-cleanup: | |
needs: | |
- preflight | |
- deploy-dependent-resources | |
- deploy-multivm-domain | |
- deploy-multivm-standalone | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- uses: azure/login@v1 | |
id: azure-login | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS_PAYG }} | |
- name: Checkout rhel-jboss-templates | |
uses: actions/checkout@v4 | |
with: | |
path: rhel-jboss-templates | |
- name: Delete Dependent Resource Group | |
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.deleteAzureResources) }} | |
run: | | |
az group delete --yes --no-wait --name ${{ env.dependencyResourceGroup }} | |
- name: Delete Standalone Resource Group | |
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.deleteAzureResources) }} | |
id: delete-standalone-resource-group | |
run: | | |
echo "delete... " $standaloneResourceGroup | |
az group delete --yes --no-wait --verbose --name $standaloneResourceGroup | |
- name: Delete Domain Resource Group | |
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.deleteAzureResources) }} | |
id: delete-domain-resource-group | |
run: | | |
echo "delete... " $domainResourceGroup | |
az group delete --yes --no-wait --verbose --name $domainResourceGroup | |
- name: Delete Testing Branch | |
if: always() | |
run: | | |
cd rhel-jboss-templates | |
git push https://[email protected]/${GITHUB_REPOSITORY}.git -f --delete $standaloneTestBranchName | |
git push https://[email protected]/${GITHUB_REPOSITORY}.git -f --delete $domainTestBranchName |