Skip to content

Instantly share code, notes, and snippets.

View clarenceb's full-sized avatar

Clarence Bakirtzidis clarenceb

View GitHub Profile
@clarenceb
clarenceb / basic-test.py
Created May 17, 2024 03:53
Basic Locust load testing script
from locust import HttpUser, task, between
class UserBehavior(HttpUser):
"""
Represents the user behavior for load testing.
This class defines the tasks that the user will perform during the load testing.
It is functionally similar to the JMeter test plan (SampleApp.jmx), where the user performs a series of tasks to simulate real-world
"""
@clarenceb
clarenceb / SampleApp.py
Created May 17, 2024 03:52
Locust load test script with custom load shaping.
import os
from locust import HttpUser, LoadTestShape, TaskSet, between, task
class UserTasks(TaskSet):
"""
Represents the user tasks for load testing (not sequential).
This class defines the tasks that the user will perform during the load testing.
It is functionally similar to the JMeter test plan (SampleApp.jmx), where the user performs a series of tasks to simulate real-world
@clarenceb
clarenceb / gist:f44a6e808bbd6a57a3a5e1f552fa5c78
Created February 20, 2024 22:21
WSL2 login to Azure Subscription for Azure CLI using Windows browser and Azure AD SSO
#!/bin/bash
TENANT="<your-tenant>.onmicrosoft.com"
SUBSCRIPTION_ID="<your-azure-subscription-id>"
BROWSER="/usr/bin/wslview"
export BROWSER
# Fix WSL2 clock synchronisation drift which commonly occurs
sudo ntpdate pool.ntp.org

I have found a way to build Windows container images without Docker - It doesn't use a Dockerfile though.

The way I got this to work is using crane from Google (https://github.com/google/go-containerregistry/blob/main/cmd/crane/doc/crane.md) which lets you append image layers to a base image. You can build Windows images on either Linux or Windows or inside of a container (Linux/Windows) - however, you'll need to build any artefacts (e.g. EXE, DLLs) on a Windows machine since this approach is using Crane to assemble a Windows container image on a Linux host (container).

Here is a quick PoC I did to prove it works (using Docker Desktop with Windows Container mode on my laptop):

dotnet --version
# 7.0.102
@clarenceb
clarenceb / lab5-release-annotations
Created March 21, 2019 04:26
Lab 5: Create release annotations to see impact of changes
Note: currently, release annotations only work with the classic metrics explorer.
# Guidance/Steps:
- Enable Application Insights for the prod web app
- Ensure the App Insights Instrumentation Key is correct in the web app Application Settings, set APPINSIGHTS_INSTRUMENTATIONKEY (to be extra safe, also add Keys:ApplicationInsights:InstrumentationKey with the same value since the code looks that setting up)
- Restart the web app (prod) and navigate to a few URLs in the web app, check that you can see metrics (server response time) appears in App Insights (prod) – reduce time scale to 30 mins
## Add release annotations
- See: https://docs.microsoft.com/en-us/azure/azure-monitor/app/annotations
- Edit the prod stage in the release pipeline
@clarenceb
clarenceb / lab6-release-gates
Last active April 9, 2019 21:42
Lab 6: Block releases when there are active alerts
Note: The Azure DevOps Pipelines release gates for Azure Monitor alerts appear to (currently) only support Classic Alerts.
# Guidance/Steps:
Pre-requisites (Lab 5) – app insights enable, server delay introduced
## Setup the alert
- From App Insights (prod), go to Configure / Alerts, then click “View classic alerts” from the top nav bar
- Click “Add metric alert (classic)”
- Enter name “slow-server”
- Select the prod App Insights instance
@clarenceb
clarenceb / gist:4594bad9da2cc8b4ced0e5a2ecbe0918
Last active March 18, 2018 11:30
570-hcdev-dump-json refactor test
package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
"time"
{
"dht_changes": [
{
"index": 1,
"message": {
"fingerprint": "QmQd25y1KU7wj978m3NpP5bDorX7YTjBwvoFMXevisFGef",
"content": "PUT_REQUEST @ 2018-02-12 09:37:22.3644 +1100 AEDT From:<peer.ID cXesBJ> Body:{QmcXesBJFTpgutGnnsqmK1kNVM88Hkn7rQraHousYWJedK 0 <nil>}"
},
"data": {
"type": "%%key",
@clarenceb
clarenceb / dht.json
Last active February 20, 2018 10:16
Proposed DHT dump as JSON
{
"dht_changes": [
{
"index": 1,
"message": {
"fingerprint": "QmdSrGJt5jto2PzEUoFHm9xzs5ChT2FJjoXcZ1vTWV9Z3k",
"content": "PUT_REQUEST @ 2018-02-12 09:37:22.3644 +1100 AEDT From:<peer.ID cXesBJ> Body:{QmcXesBJFTpgutGnnsqmK1kNVM88Hkn7rQraHousYWJedK 0 <nil>}"
},
"data": {
"type": "%%key",
{
"%dna": {
"header": {
"type": "%dna",
"hash": "QmbUdrQoiTzKTzZiJ8BzPeeGye7BPiVUruyQZiBqXNDruk",
"time": "2018-02-08 14:54:25.976547 +1100 AEDT",
"nextHeader": "1",
"next": "%dna: 1",
"entry": "QmSMg4wV1iuvw5V6MwWTD6ppYBeJqBSWyy4M6vm5deqCQ5"
},