Skip to content

Commit

Permalink
feat: add topology tests framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaitou786 committed Oct 17, 2022
1 parent e2bd98a commit bc318ca
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 19 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/topology_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
pull_request:
paths:
- 'chart/**'
- 'test/**'
- '**.go'
- '.github/workflows/topology_tests.yml'
name: Test Topology

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
.bin
key: cache-${{ hashFiles('**/go.sum') }}-${{ hashFiles('.bin/*') }}
restore-keys: |
cache-
- uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }} # only needed if version is 'latest'
id: install
- name: Setup Operator
run: |
./test/setup-operator.sh
2 changes: 2 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ spec:
labels:
{{- include "canary-checker.labels" . | nindent 10 }}
spec:
{{- if .Values.db.embedded.storageClass }}
storageClassName: {{ .Values.db.embedded.storageClass }}
{{- end }}
accessModes: ["ReadWriteOnce"]
resources:
requests:
Expand Down
2 changes: 2 additions & 0 deletions chart/templates/postgres-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ spec:
name: postgresql
spec:
accessModes: ["ReadWriteOnce"]
{{- if .Values.db.external.storageClass }}
storageClassName: {{ .Values.db.external.storageClass }}
{{- end }}
resources:
requests:
storage: {{ .Values.db.external.storage }}
Expand Down
2 changes: 2 additions & 0 deletions test/karina.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ kubernetes:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
authorization-mode: "AlwaysAllow"
canary-checker:
disabled: true
podSubnet: 100.200.0.0/16
serviceSubnet: 100.100.0.0/16
calico:
Expand Down
19 changes: 0 additions & 19 deletions test/patch1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,6 @@ spec:
---
apiVersion: apps/v1
kind: Deployment
metadata:
# Disable reload/all in tests
annotations: null
name: canary-checker
namespace: platform-system
spec:
template:
metadata:
annotations:
$patch: delete
spec:
containers:
- name: canary-checker
resources:
requests:
cpu: 10m
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: cert-manager-webhook
namespace: cert-manager
Expand Down
47 changes: 47 additions & 0 deletions test/setup_operator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# The script tests the push subcommand as well as postgres convectivity for canary-checker.

set -e

export KUBECONFIG=~/.kube/config
export KARINA="karina -c $(pwd)/test/karina.yaml"
export DOCKER_API_VERSION=1.39
export CLUSTER_NAME=kind-test
export PATH=$(pwd)/.bin:$PATH
export ROOT=$(pwd)

echo "::group::Provisioning"
if [[ ! -e .certs/root-ca.key ]]; then
$KARINA ca generate --name root-ca --cert-path .certs/root-ca.crt --private-key-path .certs/root-ca.key --password foobar --expiry 1
$KARINA ca generate --name ingress-ca --cert-path .certs/ingress-ca.crt --private-key-path .certs/ingress-ca.key --password foobar --expiry 1
$KARINA ca generate --name sealed-secrets --cert-path .certs/sealed-secrets-crt.pem --private-key-path .certs/sealed-secrets-key.pem --password foobar --expiry 1
fi

if $KARINA provision kind-cluster -e name=$CLUSTER_NAME -v ; then
echo "::endgroup::"
else
echo "::endgroup::"
exit 1
fi

kubectl config use-context kind-$CLUSTER_NAME

echo "::group::Operator Setup"

export IMG=docker.io/flanksource/canary-checker:test
make docker
kind load docker-image $IMG --name kind-$CLUSTER_NAME


helm dependency build $ROOT/chart
helm install -f $ROOT/test/values.yaml canary-checker $ROOT/chart -n default


sleep 90


kubectl get po -n default
kubectl logs -n default -l app.kubernetes.io/name=canary-checker

echo "::endgroup::"
76 changes: 76 additions & 0 deletions test/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Default values for canary-checker.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicas: 1

image:
repository: docker.io/flanksource/canary-checker
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "test"

dockerSocket: true
containerdSocket: false

# Turn on pprof /debug endpoint
debug: false
logLevel: "-v"

db:
embedded:
# If the database is embedded, setting this to true will persist the contents of the database
# through a persistent volume
persist: true

nameOverride: ""

ingress:
enabled: false
className: ""
annotations:
{}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
host: canary-checker
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

flanksource-ui:
enabled: false # Disable canary-checker-ui by default.
nameOverride: "canary-checker-ui"
fullnameOverride: "canary-checker-ui"
oryKratosURL: ""
backendURL: ""
ingress:
enabled: true
host: "canary-checker-ui.local"


resources:
requests:
cpu: 200m
memory: 200Mi
limits:
memory: 1512Mi

extra:
# nodeSelector:
# key: value
# tolerations:
# - key: "key1"
# operator: "Equal"
# value: "value1"
# effect: "NoSchedule"
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: kubernetes.io/e2e-az-name
# operator: In
# values:
# - e2e-az1
# - e2e-az2

0 comments on commit bc318ca

Please sign in to comment.