Skip to content

Commit

Permalink
Clean up template
Browse files Browse the repository at this point in the history
  • Loading branch information
vplauzon committed Oct 24, 2023
1 parent fb48e9b commit 2d30e0e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 295 deletions.
31 changes: 1 addition & 30 deletions .github/workflows/test-infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,6 @@ jobs:
echo "Do nothing"
fi
# perfTestClusterSetup:

# runs-on: ubuntu-latest

# steps:
# # Login
# - name: Azure Login
# run: az login --service-principal -u ${{ secrets.test_deploy_sp_id }} -p ${{ secrets.test_deploy_sp_secret }} --tenant ${{ secrets.test_tenant_id }}
# # Add Kusto extension to Azure CLI
# - name: Install Kusto extension
# run: az extension add -n kusto
# # Turn cluster on
# - name: Turn on cluster (if off)
# shell: bash
# run: |
# # Retrieve cluster name
# clusterName=$(az kusto cluster list -g ${{ secrets.test_rg }} --query "[?tags.testLevel=='perf'].name" -o tsv)
# state=$(az kusto cluster list -g ${{ secrets.test_rg }} --query "[?tags.testLevel=='perf'].state" -o tsv)
# echo "Cluster Name: $clusterName"
# echo "State: '$state'"
# if [ "$state" == "Stopped" ]
# then
# # Actually start the cluster
# echo "Start cluster"
# az kusto cluster start -n $clusterName -g ${{ secrets.test_rg }} -n $clusterName
# else
# echo "Do nothing"
# fi

deploy:

needs:
Expand All @@ -90,4 +61,4 @@ jobs:
- name: Deploy
run: |
cd deployment/integration-test
bash deploy-integration-test-infra.sh ${{ secrets.test_rg }} ${{ secrets.test_tenant_id }} ${{ secrets.TESTER_SP_ID }}
bash deploy-integration-test-infra.sh ${{ secrets.test_rg }}
9 changes: 1 addition & 8 deletions deployment/integration-test/deploy-integration-test-infra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@
## Parameters:
##
## 1- Name of resource group
## 2- Tenant ID
## 3- Service Principal Client ID (which should be cluster admin)

rg=$1
tenantId=$2
spid=$3

echo "Resource group: $rg"
echo "Tenant ID: $tenantId"
echo "Service Principal's Client ID: $spid"
echo "Current directory: $(pwd)"

echo
echo "Deploying ARM template"

az deployment group create -n "deploy-$(uuidgen)" -g $rg \
--template-file integration-test-infra-deploy.bicep \
--parameters tenantId=$tenantId clientId=$spid
--template-file integration-test-infra-deploy.bicep
257 changes: 0 additions & 257 deletions deployment/integration-test/integration-test-infra-deploy.bicep
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
/**************************************************/
// Deploy ADX clusters with multiple databases
// ready to accomodate integration tests
//
// A Logic App is deployed to shutdown the clusters
// within 2-5 hours

@description('Tenant ID (for client id)')
param tenantId string
@description('Service Principal Client ID (which should be cluster admin)')
param clientId string

var intTestDbCountPerPrefix = 100
// var perfTestDbCount = 5000
// var perfPartitionMaxSize = 800
// var perfTestDbPartitions = [for i in range(0, (perfTestDbCount / perfPartitionMaxSize) + 1): {
// name: 'kustoDbs-${i + 1}-${deployment().name}'
// dbIndices: range(i * perfPartitionMaxSize, min(perfPartitionMaxSize, perfTestDbCount - (i * perfPartitionMaxSize)))
// dbPrefix: 'db_'
// }]

var uniqueId = uniqueString(resourceGroup().id, 'delta-kusto')
var prefixes = [
Expand All @@ -31,7 +16,6 @@ resource intTestCluster 'Microsoft.Kusto/clusters@2022-12-29' = {
name: 'intTests${uniqueId}'
location: resourceGroup().location
tags: {
'autoShutdown': 'true'
'testLevel': 'integration'
}
sku: {
Expand All @@ -51,244 +35,3 @@ resource intTestDbs 'Microsoft.Kusto/clusters/databases@2022-12-29' = [for i in
parent: intTestCluster
kind: 'ReadWrite'
}]

// resource perfTestCluster 'Microsoft.Kusto/clusters@2022-12-29' = {
// name: 'perfTests${uniqueId}'
// location: resourceGroup().location
// tags: {
// 'autoShutdown': 'true'
// 'testLevel': 'perf'
// }
// sku: {
// 'name': 'Dev(No SLA)_Standard_E2a_v4'
// 'tier': 'Basic'
// 'capacity': 1
// }

// resource admin 'principalAssignments' = {
// name: 'main-admin'
// properties: {
// principalId: clientId
// principalType: 'App'
// role: 'AllDatabasesAdmin'
// tenantId: tenantId
// }
// }
// }

// // Delegate to a module to work around the 800 resources per deployment limitation
// module perfTestDbs 'dbs-deploy.bicep' = [for p in perfTestDbPartitions: {
// name: p.name
// params: {
// clusterName: perfTestCluster.name
// dbIndices: p.dbIndices
// dbPrefix: 'db_'
// }
// }]

// resource autoShutdown 'Microsoft.Logic/workflows@2019-05-01' = {
// name: 'shutdownWorkflow${uniqueId}'
// location: resourceGroup().location
// identity: {
// type: 'SystemAssigned'
// }
// properties: {
// state: 'Enabled'
// definition: {
// '$schema': 'https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#'
// contentVersion: '1.0.0.0'
// parameters: {}
// triggers: {
// Recurrence: {
// recurrence: {
// frequency: 'Hour'
// interval: 2
// }
// evaluatedRecurrence: {
// frequency: 'Hour'
// interval: 2
// }
// type: 'Recurrence'
// }
// }
// actions: {
// 'for-each-cluster': {
// foreach: '@body(\'get-clusters\').value'
// actions: {
// 'if-should-shut-down': {
// actions: {
// 'stop-cluster': {
// runAfter: {
// wait: [
// 'Succeeded'
// ]
// }
// type: 'Http'
// inputs: {
// authentication: {
// audience: environment().authentication.audiences[0]
// type: 'ManagedServiceIdentity'
// }
// method: 'POST'
// uri: '@{outputs(\'stop-cluster-url\')}'
// }
// }
// 'stop-cluster-url': {
// runAfter: {}
// type: 'Compose'
// inputs: '@concat(\'${environment().resourceManager}subscriptions/${subscription().subscriptionId}/resourceGroups/${resourceGroup().name}/providers/Microsoft.Kusto/clusters/\', body(\'parse-payload\')?[\'name\'], \'/stop?api-version=2021-01-01\')'
// }
// wait: {
// runAfter: {
// 'stop-cluster-url': [
// 'Succeeded'
// ]
// }
// type: 'Wait'
// inputs: {
// interval: {
// count: 1
// unit: 'Hour'
// }
// }
// }
// }
// runAfter: {
// 'parse-payload': [
// 'Succeeded'
// ]
// }
// expression: {
// and: [
// {
// equals: [
// '@body(\'parse-payload\')?[\'tags\']?[\'autoShutdown\']'
// 'true'
// ]
// }
// {
// equals: [
// '@body(\'parse-payload\')?[\'properties\']?[\'state\']'
// 'Running'
// ]
// }
// ]
// }
// type: 'If'
// }
// 'parse-payload': {
// runAfter: {}
// type: 'ParseJson'
// inputs: {
// content: '@items(\'for-each-cluster\')'
// schema: {
// properties: {
// id: {
// type: 'string'
// }
// name: {
// type: 'string'
// }
// properties: {
// properties: {
// state: {
// type: 'string'
// }
// }
// type: 'object'
// }
// tags: {
// properties: {
// 'auto-shutdown': {
// type: 'string'
// }
// }
// type: 'object'
// }
// }
// type: 'object'
// }
// }
// }
// }
// runAfter: {
// 'get-clusters': [
// 'Succeeded'
// ]
// }
// type: 'Foreach'
// runtimeConfiguration: {
// concurrency: {
// repetitions: 50
// }
// }
// }
// 'get-clusters': {
// runAfter: {}
// type: 'Http'
// inputs: {
// authentication: {
// audience: environment().authentication.audiences[0]
// type: 'ManagedServiceIdentity'
// }
// method: 'GET'
// uri: '${environment().resourceManager}subscriptions/${subscription().subscriptionId}/resourceGroups/${resourceGroup().name}/providers/Microsoft.Kusto/clusters?api-version=2021-01-01'
// }
// }
// }
// outputs: {}
// }
// }
// }

// // Authorize WF as contributor on clusters
// // Role list: https://docs.microsoft.com/en-us/azure/role-based-access-control/built-in-roles
// var contributorId = 'b24988ac-6180-42a0-ab88-20f7382dd24c'
// var fullContributorId = '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/${contributorId}'
// var intTestClusterRoleAssignmentName = '${resourceGroup().id}${autoShutdown.name}${fullContributorId}${intTestCluster.name}'
// // var perfTestClusterRoleAssignmentName = '${resourceGroup().id}${autoShutdown.name}${fullContributorId}${perfTestCluster.name}'

// resource autoShutdownIntTestClusterAuthorization 'Microsoft.Authorization/roleAssignments@2021-04-01-preview' = {
// name: '${guid(intTestClusterRoleAssignmentName)}'
// // See https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/scope-extension-resources
// // for scope for extension
// scope: intTestCluster
// properties: {
// description: 'Give contributor on the cluster'
// principalId: autoShutdown.identity.principalId
// // Fix the issue of the principal not being ready when deployment the assignment
// principalType: 'ServicePrincipal'
// roleDefinitionId: fullContributorId
// }
// }

// resource autoShutdownPerfTestClusterAuthorization 'Microsoft.Authorization/roleAssignments@2021-04-01-preview' = {
// name: '${guid(perfTestClusterRoleAssignmentName)}'
// // See https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/scope-extension-resources
// // for scope for extension
// scope: perfTestCluster
// properties: {
// description: 'Give contributor on the cluster'
// principalId: autoShutdown.identity.principalId
// // Fix the issue of the principal not being ready when deployment the assignment
// principalType: 'ServicePrincipal'
// roleDefinitionId: fullContributorId
// }
// }

// Authorize WF as reader on resource group
// var readerId = 'acdd72a7-3385-48ef-bd42-f606fba81ae7'
// var fullReaderId = '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/${readerId}'
// var rgRoleAssignmentName = '${resourceGroup().id}${autoShutdown.name}${fullReaderId}'

// resource autoShutdownRgAuthorization 'Microsoft.Authorization/roleAssignments@2021-04-01-preview' = {
// name: '${guid(rgRoleAssignmentName)}'
// scope: resourceGroup()
// properties: {
// description: 'Give reader on the resource group'
// principalId: autoShutdown.identity.principalId
// // Fix the issue of the principal not being ready when deployment the assignment
// principalType: 'ServicePrincipal'
// roleDefinitionId: fullReaderId
// }
// }

0 comments on commit 2d30e0e

Please sign in to comment.