Skip to content

Instantly share code, notes, and snippets.

@stevenctl
stevenctl / sql2csv.py
Last active July 16, 2019 20:34
Quick script for generating a CSV from SQL DDL. Supports simple foreign keys and assumes sql file has formatting as you would get when exporting from datagrip.
#/usr/bin/env python
import re
def parse_fk(fk_str):
res = re.search("foreign key \(([^\)]+)\) references ([^ ]+) \(([^\)]+)\)", fk_str)
return res.group(1), res.group(2), res.group(3)
@stevenctl
stevenctl / imsplit.py
Created August 5, 2019 16:28
Image Splitter
#!/usr/bin/env python
from PIL import Image
image = Image.open("base.png")
def is_empty(line):
for x in range(line.width):
r, g, b, a = line.getpixel((x, 0))
if r + g + b + a > 0:
# triggers a new "b" pod to be created
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: b
spec:
replicas: 1
selector:
matchLabels:
# scales deployment a to 500 replicas
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: a
spec:
replicas: 500
selector:
matchLabels:
# sets up a, b, c deployments with services for a and b
---
apiVersion: v1
kind: Service
metadata:
name: a
labels:
app: a
spec:
ports:

Writing Good Tests

Keeping test times low

Re-use echos

Spinning up services for tests is one of the slower pieces of writing a test. Wherever possible, keep this setup in your suite's Setup to avoid long test times.

var (
@stevenctl
stevenctl / main.go
Last active October 15, 2020 01:58
Istio Kubeconfig Extension
package main
import (
"fmt"
"encoding/json"
"istio.io/istio/pkg/kube"
"k8s.io/apimachinery/pkg/runtime"
)
@stevenctl
stevenctl / test-framework.md
Last active December 28, 2020 22:21
Istio Test Framework Wiki Updates
#!/bin/bash
set -e
set -u
set -o pipefail
SERVICE="vm"
NAMESPACE="echo"
NETWORK=""
CLUSTER="Kubernetes"
package main
import (
"fmt"
"sync"
"time"
"go.uber.org/atomic"
"istio.io/istio/pkg/config/schema/collections"
kubelib "istio.io/istio/pkg/kube"