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

Component tests #658

Draft
wants to merge 2 commits into
base: master
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
on: pull_request
on: push
name: Build
jobs:
build:
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ on:
- "**.jsx?"
- "**.tsx?"
- "chart/**"
pull_request:
paths:
- "**.go"
- "Makefile"
- "**.yaml"
- "**.yml"
- "**/github/workflows/lint.yml"
- "**/.eslint*"
- "**/package.json"
- "Makefile"
- "**.jsx?"
- "**.tsx?"
- "chart/**"
# pull_request:
# paths:
# - "**.go"
# - "Makefile"
# - "**.yaml"
# - "**.yml"
# - "**/github/workflows/lint.yml"
# - "**/.eslint*"
# - "**/package.json"
# - "Makefile"
# - "**.jsx?"
# - "**.tsx?"
# - "chart/**"
jobs:
golangci:
name: lint
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/postgres-and-push-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ on:
- "**.yaml"
- "**.yml"
- "test/**"
pull_request:
paths:
- "**.go"
- "Makefile"
- "**.yaml"
- "**.yml"
- "test/**"
# pull_request:
# paths:
# - "**.go"
# - "Makefile"
# - "**.yaml"
# - "**.yml"
# - "test/**"
name: Postgres-and-Push-Test
jobs:
test:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ on:
- "**.yaml"
- "**.yml"
- "test/**"
pull_request:
paths:
- "**.go"
- "Makefile"
- "**.yaml"
- "**.yml"
- "test/**"
# pull_request:
# paths:
# - "**.go"
# - "Makefile"
# - "**.yaml"
# - "**.yml"
# - "test/**"
name: Test
jobs:
test:
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/topology_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }} # only needed if version is 'latest'
id: install
- name: Install Karina
run: make .bin/karina
- name: Build and Cache Image
run: |
# pull image if exists
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker pull ghcr.io/$GITHUB_REPOSITORY/canary-checker:ci || true
Kaitou786 marked this conversation as resolved.
Show resolved Hide resolved
#build image from cache
docker build -f Dockerfile -t docker.io/flanksource/canary-checker:test --cache-from ghcr.io/$GITHUB_REPOSITORY/canary-checker:ci .
# update cache
docker tag docker.io/flanksource/canary-checker:test ghcr.io/$GITHUB_REPOSITORY/canary-checker:ci
docker push ghcr.io/$GITHUB_REPOSITORY/canary-checker:ci
- name: Test
run: |
./test/setup-operator.sh
- name: Setup upterm session
if: ${{ failure() }}
uses: lhotari/action-upterm@v1
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ CONTROLLER_GEN=$(GOBIN)/controller-gen
wget -nv https://github.com/atkrad/wait4x/releases/download/v0.3.0/wait4x-$(OS)-$(ARCH) -O .bin/wait4x && \
chmod +x .bin/wait4x

.bin/karina:
wget -q https://github.com/flanksource/karina/releases/download/v0.50.0/karina_$(OS)-$(ARCH) -O .bin/karina && \
.PHONY: .bin/karina
.bin/karina: .bin
wget -q https://github.com/flanksource/karina/releases/download/v0.67.0/karina_$(OS)-$(ARCH) -O .bin/karina && \
chmod +x .bin/karina

.bin/yq: .bin
Expand Down
4 changes: 3 additions & 1 deletion chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ spec:
labels:
{{- include "canary-checker.labels" . | nindent 10 }}
spec:
{{- if .Values.db.embedded.storageClass }}
storageClassName: {{ .Values.db.embedded.storageClass }}
{{- end }}
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: {{ .Values.db.embedded.storage }}
storage: {{ .Values.db.embedded.storage | default "10Gi"}}
{{- end }}
{{- end }}
template:
Expand Down
4 changes: 3 additions & 1 deletion chart/templates/postgres-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ spec:
name: postgresql
spec:
accessModes: ["ReadWriteOnce"]
{{- if .Values.db.external.storageClass }}
storageClassName: {{ .Values.db.external.storageClass }}
{{- end }}
resources:
requests:
storage: {{ .Values.db.external.storage }}
storage: {{ .Values.db.external.storage | default "10Gi" }}
{{- end }}
6 changes: 6 additions & 0 deletions test/karina.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ kubernetes:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
authorization-mode: "AlwaysAllow"
canaryChecker:
disabled: true
podSubnet: 100.200.0.0/16
serviceSubnet: 100.100.0.0/16
calico:
ipip: Never
vxlan: Never
version: v3.8.2
monitoring:
disabled: true
templateOperator:
disabled: true
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
52 changes: 52 additions & 0 deletions test/setup-operator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

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

set -e

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

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

## starting the postgres as docker container
docker run --rm -p 5432:5432 --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
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
$KARINA deploy bootstrap -vv || :

echo "::group::Operator Setup"

kubectl get nodes -o wide
kubectl wait node/$CLUSTER_NAME-control-plane --for condition=ready --timeout 5m

kind load docker-image $IMG --name $CLUSTER_NAME


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


sleep 180


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