Skip to content

Instantly share code, notes, and snippets.

@heoelri
heoelri / prometheus.tf
Created December 22, 2022 14:24
AzAPI resource definition to deploy the azure monitor workspace
resource "azapi_resource" "prometheus" {
type = "microsoft.monitor/accounts@2021-06-03-preview"
name = "prometheus-workspace"
parent_id = "/resource/group/resource/id" # replace with ResourceId
location = "uksouth"
response_export_values = ["*"]
}
@heoelri
heoelri / aro.tf
Created February 28, 2022 14:13
Deploy Azure Red Hat OpenShift via Terraform azurerm
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "2.98.0"
}
azuread = {
source = "hashicorp/azuread"
version = "~> 2.18.0"
@heoelri
heoelri / updateDependabot.yml
Created January 7, 2022 10:18
updateDependabot.yml GitHub Actions workflow executing update-dependabot.ps1
name: Update Dependabot config
on: push
jobs:
UpdateDependabot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@heoelri
heoelri / update-dependabot.ps1
Created January 7, 2022 10:08
This PowerShell file scans a repository for components that can be monitored by dependabot and auto-generates a dependabot.yml file for your GitHub repository.
[CmdletBinding()] # indicate that this is advanced function (with additional params automatically added)
param (
[string] $outputFile,
[string] $targetBranch = "main" # default = main
)
$files = Get-Childitem -Recurse
function packageEcosystem() {
@heoelri
heoelri / loadtest-baseline.json
Created January 5, 2022 10:25
Example baseline for Compare-LocustStats.ps1
[
{
"name": "POST new game result",
"operator": "le",
"values": {
"Failure Count":"3",
"Average Response Time": "175",
"Median Response Time": "175"
}
},
@heoelri
heoelri / Compare-LocustStats.ps1
Created January 5, 2022 10:24
This PowerShell core script compares a given locust stats csv against a baseline json
function Compare-LocustStats {
[CmdletBinding()] # indicate that this is advanced function (with additional params automatically added)
param (
$statsFile,
$baselineFile
)
if (Test-Path -Path "$baselineFile") {
@heoelri
heoelri / parse_loadtest_results.yaml
Created January 5, 2022 10:21
This YAML pipeline template calls a powershell script to analyze our locust results
parameters:
- name: customPrefix
type: string
default: ""
- name: statsPath # this directory path contains the locust *_stats.csv
type: string
steps:
- task: PowerShell@2
displayName: "Analyze Results from the load and chaos tests"
@heoelri
heoelri / deploy-locust.yaml
Created January 4, 2022 14:44
stage template for Azure DevOps used to deploy Locust
parameters:
- name: terraformWorkingDirectory
type: string
default: ''
- name: customPrefix
type: string
- name: locustTargetUrl
type: string
default: ''
- name: numberOfWorkerNodes
@heoelri
heoelri / locust_main.tf
Created January 4, 2022 12:05
Locust main TF file specifying the master nodes
resource "azurerm_container_group" "master" {
count = var.locust_workers >= 1 ? 1 : 0
name = "${local.prefix}-loadtest-master-ci"
location = azurerm_resource_group.deployment.location
resource_group_name = azurerm_resource_group.deployment.name
ip_address_type = "Public"
dns_name_label = "${local.prefix}-loadtest-master"
os_type = "Linux"
restart_policy = "Never" # Locust stops the master once the test is done. A restart_policy other than 'Never' and ACI will restart the container - and the test would run again from start.
@heoelri
heoelri / locust_locals.tf
Last active January 4, 2022 12:08
Locust locals.tf file with definitions for headless and standalone
# see https://docs.locust.io/en/stable/configuration.html for details on individual Locust configuration options
environment_variables_common = {
"LOCUST_LOCUSTFILE" = "/home/locust/locust/${azurerm_storage_share_file.locustfile.name}"
}
# values which are needed when the Locust master schedules a load test
environment_variables_master = {
"LOCUST_HOST" = var.targeturl,
"LOCUST_MODE_MASTER" = "true"
"LOCUST_LOGFILE" = "/home/locust/locust/logs/${local.prefix}.log"