Skip to content
Open
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ notes/
docs/public
docs/resources/_gen/
docs/.hugo_build.lock
test/integration/clab-*
test/integration/**/clab-*
13 changes: 13 additions & 0 deletions lab/dev/http/targets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"address": "10.0.0.1:57000",
"name": "router1"
},
{
"address": "10.0.0.2:57000",
"name": "router2",
"labels": {
"test": "asdf"
}
}
]
2 changes: 1 addition & 1 deletion netbox.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ifndef NETBOX_CLUSTER_NAME
$(error NETBOX_CLUSTER_NAME is required. Usage: make netbox-deploy-cluster NETBOX_CLUSTER_NAME=cluster-name)
endif
kind get clusters | grep -q "$(NETBOX_CLUSTER_NAME)" || kind create cluster --name $(NETBOX_CLUSTER_NAME)
kubectl config use-context kind-$(CLUSTER_NAME)
kubectl config use-context kind-$(NETBOX_CLUSTER_NAME)

.PHONY: netbox-undeploy
netbox-undeploy: ## Undeploy the netbox cluster
Expand Down
38 changes: 38 additions & 0 deletions test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ GNMIC_VERSION ?= 0.44.1
KUBECTL_VERSION ?= v1.31.0
TEST_CLUSTER_NAME ?= test-kind
CERT_MANAGER_VERSION ?= v1.19.3
NETBOX_TEST_PORT ?= 8082


.PHONY: install-kubectl
install-kubectl: ## Install kubectl if not present
Expand Down Expand Up @@ -85,6 +87,42 @@ deploy-test-topology: ## Deploy a test topology for testing
undeploy-test-topology: ## Undeploy a test topology for testing
sudo containerlab destroy -t test/integration/t1.clab.yaml -c

.PHONY: deploy-test-http-server
deploy-test-http-server: ## Deploy a test http pod with a static file inventory for testing
kubectl apply -f test/integration/http/resources/

.PHONY: undeploy-test-http-server
undeploy-test-http-server: ## Undeploy the http pod for testing
kubectl delete -f test/integration/http/resources/

.PHONY: deploy-test-netbox-instance
deploy-test-netbox-instance: NETBOX_CLUSTER_NAME=$(TEST_CLUSTER_NAME) ## Deploy the test netbox instance for testing
deploy-test-netbox-instance: NETBOX_PASSWORD=Netbox123
deploy-test-netbox-instance: netbox-setup

.PHONY: deploy-test-netbox-topology
deploy-test-netbox-topology: ## Deploy the netbox test topology for testing
sudo containerlab deploy -t test/integration/netbox/netbox.clab.yaml -c
kubectl port-forward svc/netbox $(NETBOX_TEST_PORT):80 -n netbox --context kind-$(TEST_CLUSTER_NAME) --address=0.0.0.0 >/dev/null 2>&1 &

.PHONY: sync-netbox-test-data
sync-test-netbox-data: NETBOX_CLUSTER_NAME=$(TEST_CLUSTER_NAME) ## Sync the netbox instance with the test topology for testing
sync-test-netbox-data: NETBOX_URL=http://localhost:$(NETBOX_TEST_PORT)
sync-test-netbox-data: NETBOX_INIT=test/integration/netbox/initializers
sync-test-netbox-data: netbox-sync-data

.PHONY: undeploy-test-netbox-instance
undeploy-test-netbox-instance: NETBOX_CLUSTER_NAME=$(TEST_CLUSTER_NAME) ## Undeploy the netbox instance from the test cluster
undeploy-test-netbox-instance: netbox-delete

.PHONY: undeploy-test-netbox-topology
undeploy-test-netbox-topology: ## Undeploy the netbox test topology for testing
sudo containerlab destroy -t test/integration/netbox/netbox.clab.yaml -c

.PHONY: apply-test-targetsources
apply-test-targetsources: ## Apply the test targetsources for testing
kubectl apply -f test/integration/resources/targetsources

.PHONY: apply-test-targets
apply-test-targets: ## Apply the test targets for testing
kubectl apply -f test/integration/resources/targets/profile
Expand Down
32 changes: 32 additions & 0 deletions test/integration/http/resources/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: http-target-cfg
data:
targets.json: |
[
{
"address": "clab-t1-spine1:57400",
"name": "spine1",
"labels": {
"vendor": "nokia_srlinux",
"role": "spine"
}
},
{
"address": "clab-t1-leaf1:57400",
"name": "leaf1",
"labels": {
"vendor": "nokia_srlinux",
"role": "leaf"
}
},
{
"address": "clab-t1-leaf2:57400",
"name": "leaf2",
"labels": {
"vendor": "nokia_srlinux",
"role": "leaf"
}
}
]
24 changes: 24 additions & 0 deletions test/integration/http/resources/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: http-target-inv
spec:
replicas: 1
selector:
matchLabels:
app: http-target-inv
template:
metadata:
labels:
app: http-target-inv
spec:
containers:
- name: nginx
image: nginx:alpine
volumeMounts:
- name: data
mountPath: /usr/share/nginx/html
volumes:
- name: data
configMap:
name: http-target-cfg
10 changes: 10 additions & 0 deletions test/integration/http/resources/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: http-svc
spec:
selector:
app: http-target-inv
ports:
- port: 80
targetPort: 80
3 changes: 3 additions & 0 deletions test/integration/netbox/initializers/device-roles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: Router
slug: router
color: ff0000
16 changes: 16 additions & 0 deletions test/integration/netbox/initializers/device-types.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- model: ixr-d2l
slug: arista-ixr-d2l
manufacturer:
name: Arista
- model: ixr-d2l
slug: nokia-ixr-d2l
manufacturer:
name: Nokia
- model: ixr-d2l-leaf
slug: nokia-ixr-d2l-leaf
manufacturer:
name: Nokia
- model: ixr-d3l
slug: nokia-ixr-d3l
manufacturer:
name: Nokia
36 changes: 36 additions & 0 deletions test/integration/netbox/initializers/devices.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
- name: ceos1
role:
slug: router
manufacturer:
name: Arista
device_type:
slug: arista-ixr-d2l
site:
name: Lab
- name: leaf1
role:
slug: router
manufacturer:
name: Nokia
device_type:
slug: nokia-ixr-d2l
site:
name: Lab
- name: leaf2
role:
slug: router
manufacturer:
name: Nokia
device_type:
slug: nokia-ixr-d2l-leaf
site:
name: Lab
- name: spine1
role:
slug: router
manufacturer:
name: Nokia
device_type:
slug: nokia-ixr-d3l
site:
name: Lab
40 changes: 40 additions & 0 deletions test/integration/netbox/initializers/interfaces.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
- device:
name: spine1
name: e1-1
type: 1000base-t
- device:
name: leaf1
name: e1-49
type: 1000base-t
- device:
name: spine1
name: e1-2
type: 1000base-t
- device:
name: leaf2
name: e1-49
type: 1000base-t
- device:
name: spine1
name: e1-3
type: 1000base-t
- device:
name: ceos1
name: eth1
type: 1000base-t
- device:
name: spine1
name: mgmt0
type: 1000base-t
- device:
name: leaf1
name: mgmt0
type: 1000base-t
- device:
name: leaf2
name: mgmt0
type: 1000base-t
- device:
name: ceos1
name: mgmt0
type: 1000base-t
24 changes: 24 additions & 0 deletions test/integration/netbox/initializers/ip-addresses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- address: clab-t1-spine1
assigned_object:
device:
name: spine1
name: mgmt0
status: active
primary: true
dns_name: t2-nodes-spine1
- address: clab-t1-leaf1
assigned_object:
device:
name: leaf1
name: mgmt0
status: active
primary: true
dns_name: t2-nodes-leaf1
- address: clab-t1-leaf2
assigned_object:
device:
name: leaf2
name: mgmt0
status: active
primary: true
dns_name: t2-nodes-leaf2
4 changes: 4 additions & 0 deletions test/integration/netbox/initializers/manufacturers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- name: Nokia
slug: nokia
- name: Arista
slug: arista
2 changes: 2 additions & 0 deletions test/integration/netbox/initializers/sites.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: Lab
slug: lab
2 changes: 1 addition & 1 deletion test/integration/resources/clusters/cluster1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ spec:
memory: "500Mi"
cpu: "1"
targetDistribution:
podCapacity: 5
podCapacity: 10
2 changes: 2 additions & 0 deletions test/integration/resources/pipelines/pipeline1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spec:
- matchLabels:
vendor: nokia_srlinux
role: spine
- matchLabels:
operator.gnmic.dev/targetsource: http-ts
subscriptionSelectors:
- matchLabels:
vendor: nokia_srlinux
Expand Down
2 changes: 2 additions & 0 deletions test/integration/resources/pipelines/pipeline2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spec:
- matchLabels:
vendor: nokia_srlinux
role: spine
- matchLabels:
operator.gnmic.dev/targetsource: http-ts
subscriptionSelectors:
- matchLabels:
vendor: nokia_srlinux
Expand Down
11 changes: 11 additions & 0 deletions test/integration/resources/targetsources/http.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: operator.gnmic.dev/v1alpha1
kind: TargetSource
metadata:
name: http-ts
spec:
provider:
http:
url: http://http-svc.default.svc/targets.json
targetLabels:
integrationtest: http
targetProfile: default
Loading