This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 223
/
Makefile
96 lines (77 loc) · 3.05 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
SHELL=/bin/bash -euo pipefail
KUBE_VERSION ?= 1.23
KIND_CONFIG ?= ./testdata/kind-$(KUBE_VERSION).yaml
TMP_DIR=tmp
.PHONY: json-schema
json-schema: charts/timescaledb-single/values.schema.json
charts/timescaledb-single/values.schema.json:
find charts/ -name values.schema.yaml -printf 'cat %p | gojsontoyaml -yamltojson | jq -r > $$(dirname %p)/values.schema.json' | sh
.PHONY: lint
lint: ## Lint helm chart using ct (chart-testing).
ct lint --config ct.yaml
.PHONY: clean
clean:
rm -rf $(TMP_DIR)
$(TMP_DIR):
mkdir -p $(TMP_DIR)
.PHONY: shellcheck
shellcheck:
for f in $$(find charts/ -name "*.sh" -type f); do \
echo Checking $$f; \
shellcheck $$f --exclude=SC1090,SC1091,SC2148 ;\
done
.PHONY: promscale-mixin
promscale-mixin:
./scripts/generate-promscale-alerts.sh
.PHONY: delete-kind
delete-kind: ## This is a phony target that is used to delete the local kubernetes kind cluster.
kind delete cluster && sleep 10
.PHONY: start-kind
start-kind: delete-kind ## This is a phony target that is used to create a local kubernetes kind cluster.
kind create cluster --config $(KIND_CONFIG)
kubectl wait --for=condition=Ready pods --all --all-namespaces --timeout=300s
.PHONY: load-images
load-images: ## Load images into the local kubernetes kind cluster.
./scripts/load-images.sh
.PHONY: install-db
install-db: ## Install the testing database into the local kubernetes kind cluster.
helm install \
--namespace ext-db \
--create-namespace db \
--wait \
--timeout 15m \
--debug \
charts/timescaledb-single \
--set replicaCount=1 \
--set secrets.credentials.PATRONI_SUPERUSER_PASSWORD="temporarypassword"
.PHONY: e2e
e2e: load-images ## Run e2e installation tests using ct (chart-testing).
ct install --config ct.yaml --exclude-deprecated
### TODO(paulfantom): remove this section once timescaledb-single is using `ct` and `helm test` for testing.
SINGLE_CHART_DIR := charts/timescaledb-single
SINGLE_VALUES_FILES := $(SINGLE_CHART_DIR)/values.yaml $(wildcard $(SINGLE_CHART_DIR)/values/*.yaml)
DEPLOYMENTS := $(SINGLE_VALUES_FILES)
K8S_NAMESPACE ?= citest
# We test sequentially, as in GitHub actions we do not have a lot of CPU available,
# so scheduling the pods concurrently does not work
.PHONY: test
test: prepare-ci
for f in $(SINGLE_VALUES_FILES); do \
./tests/verify_deployment.sh $${f}; \
done
.PHONY: prepare-ci
prepare-ci:
@kubectl create namespace $(K8S_NAMESPACE) || true
@kubectl config set-context --current --namespace $(K8S_NAMESPACE)
@kubectl apply -f tests/custom_pgbouncer_user_list.yaml
@kubectl apply -f tests/custom-init-scripts.yaml
@kubectl apply -f tests/custom_secrets.yaml
@for storageclass in gp2 slow; do \
kubectl get storageclass/$${storageclass} > /dev/null 2> /dev/null || \
kubectl get storageclass -o json \
| jq '[.items[] | select(.metadata.annotations."storageclass.kubernetes.io/is-default-class"=="true")] | .[0]' \
| jq ". | del(.metadata.annotations.\"storageclass.kubernetes.io/is-default-class\") | .metadata.name=\"$${storageclass}\"" \
| kubectl create -f - ; \
done ; \
exit 0
### END_OF_SECTION