Skip to content

Commit ac1d946

Browse files
committed
Revamp MAKEFILE and local-env.sh to support multi-version
1 parent 6f3c462 commit ac1d946

File tree

3 files changed

+75
-10
lines changed

3 files changed

+75
-10
lines changed

Makefile

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,28 @@ generate_mocks: ## TODO: auto install go install go.uber.org/mock/mockgen@latest
237237
mkdir -p ${GEN_DIR}
238238
mockgen -destination ${GEN_DIR}/${NETBOX_MOCKS_OUTPUT_FILE} -source=${INTERFACE_DEFITIONS_DIR}
239239

240-
.PHONY: test-e2e
241-
test-e2e: install-$(GO_PACKAGE_NAME_CHAINSAW)
240+
# e2e tests
241+
242+
.PHONY: create-kind-3.7.8
243+
create-kind-3.7.8:
244+
./kind/local-env.sh --version 3.7.8
245+
246+
.PHONY: test-e2e-3.7.8
247+
test-e2e-3.7.8: create-kind-3.7.8 deploy-kind install-$(GO_PACKAGE_NAME_CHAINSAW)
248+
chainsaw test --namespace e2e
249+
250+
.PHONY: create-kind-4.0.11
251+
create-kind-4.0.11:
252+
./kind/local-env.sh --version 4.0.11
253+
254+
.PHONY: test-e2e-4.0.11
255+
test-e2e-4.0.11: create-kind-4.0.11 deploy-kind install-$(GO_PACKAGE_NAME_CHAINSAW)
256+
chainsaw test --namespace e2e
257+
258+
.PHONY: create-kind-4.1.7
259+
create-kind-4.1.7:
260+
./kind/local-env.sh --version 4.1.7
261+
262+
.PHONY: test-e2e-4.1.7
263+
test-e2e-4.1.7: create-kind-4.1.7 deploy-kind install-$(GO_PACKAGE_NAME_CHAINSAW)
242264
chainsaw test --namespace e2e

kind/load-data-job/load-data.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
2+
3+
set -e -u -o pipefail
24

35
TMP_SQL_FILE=$(mktemp /tmp/netbox-data-dump.XXXXXXX.sql) || exit 1
46
curl -k https://raw.githubusercontent.com/netbox-community/netbox-demo-data/master/sql/netbox-demo-v4.1.sql > "${TMP_SQL_FILE}"

kind/local-env.sh

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,56 @@
1-
#!/bin/bash
2-
set -o errexit
1+
#!/usr/bin/env bash
32

4-
kind create cluster || echo "cluster already exists, continuing..."
3+
set -e -u -o pipefail
4+
5+
NAMESPACE=""
6+
VERSION="4.1.7" # default value (latest)
7+
while [[ $# -gt 0 ]]; do
8+
case $1 in
9+
-n|--namespace)
10+
NAMESPACE="$2"
11+
shift # past argument
12+
shift # past value
13+
;;
14+
-v|--version)
15+
VERSION="$2"
16+
shift # past argument
17+
shift # past value
18+
;;
19+
-*|--*)
20+
echo "Unknown option $1"
21+
exit 1
22+
;;
23+
esac
24+
done
525

6-
if [ -z "$1" ]; then
7-
echo "Using default namespace."
26+
echo "=======Parsed arguments======="
27+
echo "Namespace = ${NAMESPACE}"
28+
echo "Version = ${VERSION}"
29+
echo "=============================="
30+
31+
# aurgment check / init
32+
if [ -z "$NAMESPACE" ]; then
33+
echo "Using default namespace"
834
NAMESPACE="default"
935
else
10-
echo "Using namespace: $1"
11-
NAMESPACE="$1"
36+
echo "Using namespace: $NAMESPACE"
1237
fi
38+
39+
if [[ "${VERSION}" == "3.7.8" ]] ;then
40+
echo "Using version ${VERSION}"
41+
elif [[ "${VERSION}" == "4.0.11" ]] ;then
42+
echo "Using version ${VERSION}"
43+
elif [[ "${VERSION}" == "4.1.7" ]] ;then
44+
echo "Using version ${VERSION}"
45+
else
46+
echo "Unknown version ${VERSION}"
47+
exit 1
48+
if
49+
50+
# create a kind cluster
51+
kind create cluster || echo "cluster already exists, continuing..."
52+
53+
# deal with namespace
1354
if ! kubectl get namespaces | grep -q "^${NAMESPACE} "; then
1455
echo "Namespace ${NAMESPACE} does not exist."
1556
exit 1

0 commit comments

Comments
 (0)