Skip to content

Commit

Permalink
Merge pull request #11 from ekarlso/add-chart-testing
Browse files Browse the repository at this point in the history
feat: Add chart-testing
  • Loading branch information
Darach Ennis authored Oct 17, 2022
2 parents 3aa6d90 + 8d9a109 commit da140f7
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on:
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.3.1

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=yes" >> $GITHUB_ENV
fi
- name: Run chart-testing (lint)
run: ct lint --target-branch ${{ github.event.repository.default_branch }}

- name: Run chart-testing (install)
if: env.changed == 'yes'
run: |
bash -xe ./e2e-test.sh
4 changes: 2 additions & 2 deletions charts/tremor/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ appVersion: "1.0"
description: "Chart to deploy a tremor instance"
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/tremor/horizontal/color/tremor-horizontal-color.png
name: "tremor"
version: "0.1.1"
version: "0.1.2"
maintainers:
- name: Tremor Team
- name: tremor-rs
88 changes: 88 additions & 0 deletions e2e-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash

export K8S_VERSION="${K8S_VERSION:-v1.23.12}"
export CLUSTER_NAME=${CLUSTER_NAME:-chart-testing}

# function wait_for_daemonset() {
# ns="$1"
# name="$2"

# retries=10
# while [[ $retries -ge 0 ]];do
# sleep 3
# ready=$(kubectl -n $ns get daemonset $name -o jsonpath="{.status.numberReady}")
# required=$(kubectl -n $ns get daemonset $name -o jsonpath="{.status.desiredNumberScheduled}")
# echo "$kind $ns/$name: rdy $ready req $required"

# if [[ $ready -eq $required ]];then
# echo "Succeeded"
# break
# fi
# ((retries--))
# done
# }

get_tremor_pod() {
kubectl get pod -n $1 -l app=tremor -o jsonpath='{ .items[0].metadata.name }'
}

wait_for_pod() {
pod=$(get_tremor_pod $1)
kubectl wait pods -n $1 $pod --for condition=Ready --timeout=90s
}

collect_info() {
pod=$(get_tremor_pod $1)

kubectl describe pod -n $1 $pod
kubectl logs -n $1 $pod
}

create_kind_cluster() {
if kubectl cluster-info >/dev/null 2>&1; then
return 0
fi

kind create cluster --name "$CLUSTER_NAME" --image "kindest/node:$K8S_VERSION" --wait 60s

kubectl cluster-info || kubectl cluster-info dump
echo

kubectl get nodes
echo

echo 'Cluster ready!'
echo
}

cleanup() {
kind delete cluster --name "$CLUSTER_NAME"
echo 'Done!'
}

generate_ns_name() {
awk -F '-' '{print $5}'< /proc/sys/kernel/random/uuid
}

test_daemonset() {
namespace=e2e-$(generate_ns_name)

helm upgrade -i --create-namespace -n "$namespace" tremor ./charts/tremor

wait_for_pod $namespace
collect_info $namespace
}

test_deployment() {
namespace=`generate_ns_name`

helm upgrade -i --create-namespace -n "$namespace" tremor ./charts/tremor --set=kind=Deployment

wait_for_pod $namespace
collect_info $namespace
}

create_kind_cluster

test_daemonset
test_deployment

0 comments on commit da140f7

Please sign in to comment.