Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 37 additions & 0 deletions .github/workflows/healthcheck-app-existingVnet-Lin-Thurs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information, see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

#The following workflow file triggers the Existing Virtual network deployment test "test_refarch_existing.py" every Thursday with platform as "Linux" in "Japaneast" region.

name: MATLAB Web App Server Ref Arch Azure Existing Virtual Network Health Check Test on linux in Japan East

on:
schedule:
- cron: '0 16 * * 4'
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/checkout@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r ./healthcheck/requirements.txt

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: MWAS ref Arch Existing Virtual Network Health check test on linux in Japan East
run: |
cd healthcheck
python test_refarch_existing.py ${{ secrets.TenantId }} ${{ secrets.ClientId }} ${{ secrets.ClientSecret }} ${{ secrets.SubscriptionId }} ${{ secrets.username }} ${{ secrets.password }} ${{ secrets.ipaddress }} ${{ secrets.sslcertificate }} ${{ secrets.sslkey }} "japaneast" "Linux"

37 changes: 37 additions & 0 deletions .github/workflows/healthcheck-app-existingVnet-Win-Tue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information, see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

# The following workflow file triggers the Existing Virtual Network deployment test "test_refarch_existing.py" every Tuesday with platform as "Windows" in "westeurope" region.

name: MATLAB Web App Server Ref Arch Azure Existing Virtual Network Health Check Test on Windows in West Eu

on:
schedule:
- cron: '0 16 * * 2'
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r ./healthcheck/requirements.txt

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: MWAS ref Arch Existing Virtual Network Health check test on Windows in West Eu
run: |
cd healthcheck
python test_refarch_existing.py ${{ secrets.TenantId }} ${{ secrets.ClientId }} ${{ secrets.ClientSecret }} ${{ secrets.SubscriptionId }} ${{ secrets.username }} ${{ secrets.password }} ${{ secrets.ipaddress }} ${{ secrets.sslcertificate }} ${{ secrets.sslkey }} "westeurope" "Windows"

37 changes: 37 additions & 0 deletions .github/workflows/healthcheck-app-newVnet-Lin-Wed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information, see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

# The following workflow file triggers the New Virtual Network deployment test "test_refarch_new" every Wednesday with platform as "Linux" in "westus" region.

name: MATLAB Web App Server Ref Arch Azure Health Check Test on Linux in West US

on:
schedule:
- cron: '0 16 * * 3'
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r ./healthcheck/requirements.txt

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Web App ref Arch New Virtual Network Health check test on Linux in West US
run: |
cd healthcheck
python test_refarch_new.py ${{ secrets.TenantId }} ${{ secrets.ClientId }} ${{ secrets.ClientSecret }} ${{ secrets.SubscriptionId }} ${{ secrets.username }} ${{ secrets.password }} ${{ secrets.ipaddress }} ${{ secrets.sslcertificate }} ${{ secrets.sslkey }} "westus" "Linux"

38 changes: 38 additions & 0 deletions .github/workflows/healthcheck-app-newVnet-Win-Mon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information, see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

# The following workflow file triggers the New Virtual Network deployment test "test_refarch_new" every Monday with platform as "Windows" in "eastus" region.

name: MATLAB Web App Server Ref Arch Azure Health Check Test on Windows in East US region

on:
push:
schedule:
- cron: '0 16 * * 1'
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r ./healthcheck/requirements.txt

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Web App ref Arch New Virtual Network Health check test on Windows in East US region
run: |
cd healthcheck
python test_refarch_new.py ${{ secrets.TenantId }} ${{ secrets.ClientId }} ${{ secrets.ClientSecret }} ${{ secrets.SubscriptionId }} ${{ secrets.username }} ${{ secrets.password }} ${{ secrets.ipaddress }} ${{ secrets.sslcertificate }} ${{ secrets.sslkey }} "eastus" "Windows"

1 change: 1 addition & 0 deletions healthcheck/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This section of repository is to contain the tests for health check of published MATLAB Web App Server Ref Arch Azure health check. It will be scheduled to run everyday nightly and confirm the deployment can be done successfully, and links that we published to github are in good health.
8 changes: 8 additions & 0 deletions healthcheck/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
azure-functions
azure-mgmt-resource==8.0.1
azure-mgmt-marketplaceordering==0.1.0
azure-mgmt-compute==4.6.2
azure-mgmt-network==10.2.0
azure-common==1.1.24
adal==1.2.2
msrestazure==0.6.2
104 changes: 104 additions & 0 deletions healthcheck/test_refarch_existing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import unittest
import os
import time
import re
import requests
import random
import sys
from datetime import date
import datetime

import testtools.AzureAuthentication as AzureAuth
import testtools.deploy as DeployOp
from azure.mgmt.network import NetworkManagementClient

def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, username, password, ipAddress, sslCertificate, sslPrivateKey, location_arg, platform_arg):

# Deploy template
# Reference architecture in production.
ref_arch_name = 'matlab-web-app-server-on-azure'

# Common parameters for template deployment.
tenant_id = tenant_id_arg
client_id = client_id_arg
client_secret = client_secret_arg
credentials = AzureAuth.authenticate_client_key(tenant_id, client_id, client_secret)
subscription_id = subscription_id_arg
location = location_arg

# Subnets & virtual network info
subnets_cidr = ['10.0.0.0/24']
vnet_cidr = '10.0.0.0/16'

# Resource group where virtual network is created
resource_name_vnet = 'vnet_resource_group'

# Deploy a resource group with a virtual network and specified number of subnets
try:
subnet_name, vnet_name = DeployOp.create_vnet(credentials,
subscription_id,
location,
subnets_cidr,
resource_name_vnet,
vnet_cidr)

except Exception as e:
raise(e)
print(subnet_name[0])
# Parameters for deployment
parameters = {
"IP Addresses Permitted to Remote into Server VM in CIDR Notation": "0.0.0.0/0",
"IP Addresses Allowed to Access MATLAB Web App Server Apps Home Page in CIDR Notation": ipAddress,
"Base64 Encoded SSL Certificate": sslCertificate,
"Base64 Encoded SSL Private Key": sslPrivateKey,
"Username to Remote into Server VM and Network License Manager Web Interface": username,
"Password to Remote into Server VM and Network License Manager Web Interface": password,
"Deploy to New or Existing Virtual Network": "existing",
"Name of Virtual Network Where MATLAB Web App Server Will Be Deployed": vnet_name,
"Virtual Network CIDR Range": vnet_cidr,
"Name of Subnet for MATLAB Web App Server": subnet_name[0],
"Server Subnet CIDR Range": subnets_cidr[0],
"Resource Group Name Of Virtual Network": resource_name_vnet,
"Operating System": platform_arg
}

print(parameters)

# Find latest MATLAB release from Github page and get template json path.
res = requests.get(
f"https://github.com/mathworks-ref-arch/{ref_arch_name}/tree/main/releases/"
)
latest_releases = [re.findall("releases/(R\d{4}[ab]\\b)", res.text)[-1], re.findall("releases/(R\d{4}[ab]\\b)", res.text)[-2]]
for i in range(2):
matlab_release = latest_releases[i]
print("Testing Health Check Release: " + matlab_release + "\n")
github_base_dir = "https://raw.githubusercontent.com/mathworks-ref-arch"
jsonpath = f"{matlab_release}/templates/mainTemplate.json"
template_name = f"{github_base_dir}/{ref_arch_name}/main/releases/{jsonpath}"
resource_group_name = "webapp-refarch-health-check-" + matlab_release + date.today().strftime('%m-%d-%Y') + str(random.randint(1,101))
ct = datetime.datetime.now()
print("Date time before deployment of stack:-", ct)

try:
deployment_result = DeployOp.deploy_webapp_template(credentials,
subscription_id,
resource_group_name,
location,
ref_arch_name,
template_name,
parameters
)
except Exception as e:
raise(e)

# Delete the deployment which is deployed using existing virtual network
deployment_deletion = DeployOp.delete_resourcegroup(credentials, subscription_id, resource_group_name)
print("Deleted the deployment which is deployed using existing virtual network")
# Wait for above deployment deletion
time.sleep(900)
# Delete deployment with virtual network
DeployOp.delete_resourcegroup(credentials, subscription_id, resource_name_vnet)
print("Deleted the deployment which contains the virtual network")

if __name__ == '__main__':
main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7], sys.argv[8], sys.argv[9], sys.argv[10], sys.argv[11])
71 changes: 71 additions & 0 deletions healthcheck/test_refarch_new.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import os
import sys
import time
import re
import requests
import random
import traceback

import testtools.AzureAuthentication as AzureAuth
import testtools.deploy as DeployOp

from datetime import date
import datetime

def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, username, password, ipAddress, sslCertificate, sslPrivateKey, location_arg, platform_arg):
# Reference architectures in production.
ref_arch_name = 'matlab-web-app-server-on-azure'

# Common parameters for template deployment.
tenant_id = tenant_id_arg
client_id = client_id_arg
client_secret = client_secret_arg
credentials = AzureAuth.authenticate_client_key(tenant_id, client_id, client_secret)
subscription_id = subscription_id_arg
location = location_arg

parameters = {
"IP Addresses Allowed to Access MATLAB Web App Server Apps Home Page in CIDR Notation": ipAddress,
"IP Addresses Permitted to Remote into Server VM in CIDR Notation": ipAddress,
"Base64 Encoded SSL Certificate": sslCertificate,
"Base64 Encoded SSL Private Key": sslPrivateKey,
"Username to Remote into Server VM and Network License Manager Web Interface": username,
"Password to Remote into Server VM and Network License Manager Web Interface": password,
"Deploy to New or Existing Virtual Network": "new",
"Operating System": platform_arg
}

# Find latest MATLAB release from Github page and get template json path.
res = requests.get(
f"https://github.com/mathworks-ref-arch/{ref_arch_name}/tree/main/releases/"
)
latest_releases = [re.findall("releases/(R\d{4}[ab]\\b)", res.text)[-1], re.findall("releases/(R\d{4}[ab]\\b)", res.text)[-2]]
for i in range(2):
matlab_release = latest_releases[i]
print("Testing Health Check Release: " + matlab_release + "\n")
github_base_dir = "https://raw.githubusercontent.com/mathworks-ref-arch"
jsonpath = f"{matlab_release}/templates/mainTemplate.json"
template_name = f"{github_base_dir}/{ref_arch_name}/main/releases/{jsonpath}"
resource_group_name = "webapp-refarch-health-check-" + matlab_release + date.today().strftime('%m-%d-%Y') + str(random.randint(1,101))
ct = datetime.datetime.now()
print("Date time before deployment of stack:-", ct)

try:
deployment_result = DeployOp.deploy_webapp_template(credentials,
subscription_id,
resource_group_name,
location,
ref_arch_name,
template_name,
parameters
)
except Exception as e:
raise (e)

# delete the deployment
DeployOp.delete_resourcegroup(credentials, subscription_id, resource_group_name)
ct = datetime.datetime.now()
print("Date time after deployment and deletion of stack:-", ct)

if __name__ == '__main__':
main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7], sys.argv[8], sys.argv[9], sys.argv[10], sys.argv[11])
19 changes: 19 additions & 0 deletions healthcheck/testtools/AzureAuthentication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from azure.common import credentials
from azure.common.credentials import ServicePrincipalCredentials
from msrestazure.azure_active_directory import AADTokenCredentials
import adal

def authenticate_client_key(tenant_id, client_id, client_secret):

"""
Authenticate using service principal w/ key.
"""
authority_host_uri = 'https://login.microsoftonline.com'
authority_uri = authority_host_uri + '/' + tenant_id
resource_uri = 'https://management.core.windows.net/'

context = adal.AuthenticationContext(authority_uri, api_version=None)
mgmt_token = context.acquire_token_with_client_credentials(resource_uri, client_id, client_secret)
credentials = AADTokenCredentials(mgmt_token, client_id)

return credentials
Empty file.
Loading