-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.mk
More file actions
119 lines (100 loc) · 4.38 KB
/
test.mk
File metadata and controls
119 lines (100 loc) · 4.38 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
CLAB_VERSION ?= 0.70.1
KIND_VERSION ?= v0.20.0
GNMIC_VERSION ?= 0.44.1
KUBECTL_VERSION ?= v1.31.0
TEST_CLUSTER_NAME ?= test-kind
CERT_MANAGER_VERSION ?= v1.19.3
.PHONY: install-kubectl
install-kubectl: ## Install kubectl if not present
@if ! command -v kubectl >/dev/null 2>&1; then \
echo "kubectl not found, installing..."; \
curl -LO "https://dl.k8s.io/release/$$(curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"; \
chmod +x kubectl; \
sudo mv kubectl /usr/local/bin/; \
else \
echo "kubectl is already installed."; \
fi
.PHONY: install-kind
install-kind: ## Install kind if not present
@if ! command -v kind >/dev/null 2>&1; then \
echo "kind not found, installing..."; \
curl -Lo ./kind https://kind.sigs.k8s.io/dl/$(KIND_VERSION)/kind-linux-amd64; \
chmod +x ./kind; \
sudo mv ./kind /usr/local/bin/; \
else \
echo "kind is already installed."; \
fi
.PHONY: install-gnmic
install-gnmic: ## Install gnmic if not present
@if ! command -v gnmic >/dev/null 2>&1; then \
echo "gnmic not found, installing..."; \
bash -c "$$(curl -sSL https://get-gnmic.openconfig.net)" -- -v $(GNMIC_VERSION); \
echo "Adding gnmic to PATH"; \
echo "PATH: $$PATH"; \
if [ -f $$HOME/bin/gnmic ]; then \
export PATH="$$HOME/bin:$$PATH"; \
elif [ -f /usr/local/bin/gnmic ]; then \
export PATH="/usr/local/bin:$$PATH"; \
fi; \
gnmic version || echo "gnmic not found in PATH after install"; \
else \
echo "gnmic is already installed."; \
fi
.PHONY: install-containerlab
install-containerlab: ## Install containerlab if not present
@if ! command -v containerlab >/dev/null 2>&1; then \
echo "containerlab not found, installing..."; \
curl -sSL https://github.com/srl-labs/containerlab/releases/download/v$(CLAB_VERSION)/containerlab_$(CLAB_VERSION)_linux_amd64.tar.gz -o containerlab.tar.gz; \
tar -xzf containerlab.tar.gz containerlab; \
chmod +x containerlab; \
sudo mv containerlab /usr/local/bin/; \
rm -f containerlab.tar.gz; \
containerlab version; \
else \
echo "containerlab is already installed."; \
fi
.PHONY: deploy-test-cluster
deploy-test-cluster: ## Deploy a kind cluster for testing
kind create cluster --name $(TEST_CLUSTER_NAME)
.PHONY: install-test-cluster-dependencies
install-test-cluster-dependencies: ## Install the dependencies for the test cluster
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/$(CERT_MANAGER_VERSION)/cert-manager.yaml
echo "waiting for cert manager to be ready..."
kubectl wait --namespace cert-manager --for=condition=Available deployment --all --timeout=180s
echo "cert manager ready"
.PHONY: undeploy-test-cluster
undeploy-test-cluster: ## Delete a kind cluster for testing
kind delete cluster --name $(TEST_CLUSTER_NAME) || true
.PHONY: load-test-image
load-test-image: ## Load the test image into the test cluster
kind load docker-image $(IMG) --name $(TEST_CLUSTER_NAME)
.PHONY: deploy-test-topology
deploy-test-topology: ## Deploy a test topology for testing
sudo containerlab deploy -t test/integration/t1.clab.yaml -c
.PHONY: undeploy-test-topology
undeploy-test-topology: ## Undeploy a test topology for testing
sudo containerlab destroy -t test/integration/t1.clab.yaml -c
.PHONY: apply-test-targets
apply-test-targets: ## Apply the test targets for testing
kubectl apply -f test/integration/resources/targets/profile
kubectl apply -f test/integration/resources/targets
.PHONY: apply-test-subscriptions
apply-test-subscriptions: ## Apply the test subscriptions for testing
kubectl apply -f test/integration/resources/subscriptions
.PHONY: apply-test-outputs
apply-test-outputs: ## Apply the test outputs for testing
kubectl apply -f test/integration/resources/outputs
.PHONY: apply-test-inputs
apply-test-inputs: ## Apply the test inputs for testing
kubectl apply -f test/integration/resources/inputs
.PHONY: apply-test-processors
apply-test-processors: ## Apply the test processors for testing
kubectl apply -f test/integration/resources/processors
.PHONY: apply-test-pipelines
apply-test-pipelines: ## Apply the test pipelines for testing
kubectl apply -f test/integration/resources/pipelines
.PHONY: apply-test-clusters
apply-test-clusters: ## Apply the test clusters for testing
kubectl apply -f test/integration/resources/clusters
.PHONY: apply-test-resources
apply-test-resources: apply-test-targets apply-test-subscriptions apply-test-outputs apply-test-pipelines apply-test-clusters