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

Williamd/region tests #1029

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
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
36 changes: 36 additions & 0 deletions .pipelines/azure-pipeline-aksdeploy-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
trigger:
- none

pool:
vmImage: windows-latest

stages:
- stage: Deploy
jobs:
- job: DeployJob
steps:
- template: azure-template-aksdeploy.yml
parameters:
azureSubscription: $(AZURESUBSCRIPTION)
resourceGroup: $(RESOURCE-GROUP)
deployParameters: ${env:PARAMETERS}
- task: PowerShell@2
displayName: "Wait"
inputs:
targetType: 'inline'
script: |
$sleepTime = ${env:SLEEPTIME_IN_SECONDS}
Get-Date
Write-host "Allowing cluster to run $sleepTime seconds before testing..."
Sleep -Seconds $sleepTime

- stage: Test
dependsOn: Deploy
jobs:
- job: TestJob
steps:
- template: azure-template-regionstest.yml
parameters:
azureSubscription: $(AZURESUBSCRIPTION)
resourceGroup: $(RESOURCE-GROUP)
clusterName: $(CLUSTERNAME)
17 changes: 17 additions & 0 deletions .pipelines/azure-pipeline-aksdeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- none

pool:
vmImage: windows-latest

steps:
- template: azure-template-aksdeploy.yml
parameters:
azureSubscription: $(AZURESUBSCRIPTION)
resourceGroup: $(RESOURCE-GROUP)
deployParameters: ${env:PARAMETERS}
18 changes: 18 additions & 0 deletions .pipelines/azure-pipeline-regionstest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- none

pool:
vmImage: windows-latest

steps:
- template: azure-template-regionstest.yml
parameters:
azureSubscription: $(AZURESUBSCRIPTION)
resourceGroup: $(RESOURCE-GROUP)
clusterName: $(CLUSTERNAME)

26 changes: 26 additions & 0 deletions .pipelines/azure-template-aksdeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
parameters:
- name: azureSubscription
type: string
default: 'ContainerInsights_Dev_Grace'
- name: resourceGroup
type: string
default: 'rg'
- name: deployParameters
type: string

steps:
- task: AzureCLI@2
displayName: "Deploy AKS cluster"
inputs:
azureSubscription: ${{ parameters.azureSubscription }}
scriptType: ps
scriptLocation: inlineScript
inlineScript: |+
az --version
az account show
az deployment group create `
--resource-group ${{ parameters.resourceGroup }} `
--name ClusterDeployment `
--template-file ".\otelcollector\test\ci-cd\ci-cd-cluster.json" `
--parameters ${{ parameters.deployParameters }}

63 changes: 63 additions & 0 deletions .pipelines/azure-template-regionstest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
parameters:
- name: azureSubscription
type: string
- name: resourceGroup
type: string
- name: clusterName
type: string

steps:
- task: Go@0
displayName: "go install ginkgo"
inputs:
command: 'install' # 'get' | 'build' | 'test' | 'custom'. Required. Command. Default: get.
#customCommand: # string. Required when command == custom. Custom command.
arguments: github.com/onsi/ginkgo/v2/ginkgo@latest # string. Arguments.
# Advanced
#workingDirectory: # string. Working directory.

- task: AzureCLI@2
displayName: "Aks Get-Credentials"
inputs:
azureSubscription: ${{ parameters.azureSubscription }}
scriptType: ps
scriptLocation: inlineScript
inlineScript: az aks get-credentials --resource-group ${{ parameters.resourceGroup }} --name ${{ parameters.clusterName }}

- task: AzureCLI@2
displayName: "Run ginkgo test suite"
inputs:
azureSubscription: ${{ parameters.azureSubscription }}
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
az extension add --name alertsmanagement --allow-preview true
az alerts-management prometheus-rule-group list -g ${{ parameters.resourceGroup }}

$o = az alerts-management prometheus-rule-group list -g ${{ parameters.resourceGroup }}
$s = [string]::Join("", $o)
"prometheus-rule-group - $s"
$j = convertfrom-json -InputObject $s
$rule = $j[0].rules[0].record
$rule

$clusterName = "${{ parameters.clusterName }}"
$amw = "$clusterName-amw"
$amw
$o = az resource show --resource-type "microsoft.monitor/accounts" -g ${{ parameters.resourceGroup }} -n $amw
$s = [string]::Join("", $o)
"microsoft.monitor/accounts - $s"
$j = convertfrom-json -InputObject $s
$endPoint = $j.properties.metrics.prometheusQueryEndpoint
$endPoint
$resourceId = $j.id
$resourceId
[Environment]::SetEnvironmentVariable("AMW_QUERY_ENDPOINT", $endPoint)

# Run Ginkgo
$cmd = "$([Environment]::GetEnvironmentVariable('userprofile'))\go\bin\ginkgo.exe -- -parmRuleName ""$rule"" -parmAmwResourceId ""$resourceId"""
"cmd - $cmd"
"AMW_QUERY_ENDPOINT - $([Environment]::GetEnvironmentVariable("AMW_QUERY_ENDPOINT"))"
Invoke-Expression -Command $cmd
workingDirectory: '.\otelcollector\test\ginkgo-e2e\regionTests'

46 changes: 46 additions & 0 deletions internal/docs/RegionTestsPipelineWiki.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

<style>
h1 {
color: deepskyblue;
}
</style>

# **azure-pipeline-aksdeploy.yml**

This "AksDeploy" pipeline deploys the AKS cluster, AMW workspace, DCR, DCE, DCRA, and Prometheus rule groups using the ci-cd-cluster ARM template found in the GitHub prometheus-collector repository.

## "AksDeploy" Pipeline Variables

+ AZURESUBSCRIPTION
+ RESOURCE-GROUP
+ PARAMETERS

# **azure-pipeline-regionstest.yml**

This "RegionsTest" pipeline runs the region tests on the specified cluster.

## "RegionsTest" Pipeline Variables

+ AZURESUBSCRIPTION
+ RESOURCE-GROUP
+ CLUSTERNAME

# **azure-pipeline-aksdeploy-test.yml**

The "Integrated" pipeline first deploys the resources and then runs the region tests.

## "Integrated" Pipeline Variables

+ AZURESUBSCRIPTION
+ RESOURCE-GROUP
+ PARAMETERS
+ CLUSTERNAME
+ SLEEPTIME_IN_SECONDS

# **Definition of Pipeline Variables**

+ AZURESUBSCRIPTION - The name of the subscription where resources are deployed.
+ RESOURCE-GROUP - The name of the resource group where resources are deployed
+ PARAMETERS - A Json object giving parameter values to override defaults in the ci-cd-cluster ARM template.
+ CLUSTERNAME - The name of the AKS cluster.
+ SLEEPTIME_IN_SECONDS - The time in seconds after deploying the cluster and AMW resoures to wait before running the tests. This should default to at least 2 hours.
Loading
Loading