diff --git a/.gitignore b/.gitignore index 29d31af..ee83f89 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,4 @@ notes/ docs/public docs/resources/_gen/ docs/.hugo_build.lock -test/integration/clab-* \ No newline at end of file +test/integration/**/clab-* \ No newline at end of file diff --git a/lab/dev/http/targets.json b/lab/dev/http/targets.json new file mode 100644 index 0000000..882faae --- /dev/null +++ b/lab/dev/http/targets.json @@ -0,0 +1,13 @@ +[ + { + "address": "10.0.0.1:57000", + "name": "router1" + }, + { + "address": "10.0.0.2:57000", + "name": "router2", + "labels": { + "test": "asdf" + } + } +] \ No newline at end of file diff --git a/netbox.mk b/netbox.mk index 555c2f1..a133554 100644 --- a/netbox.mk +++ b/netbox.mk @@ -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 diff --git a/test.mk b/test.mk index 3497c2b..23c5983 100644 --- a/test.mk +++ b/test.mk @@ -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 @@ -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 diff --git a/test/integration/http/resources/configmap.yaml b/test/integration/http/resources/configmap.yaml new file mode 100644 index 0000000..f017566 --- /dev/null +++ b/test/integration/http/resources/configmap.yaml @@ -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" + } + } + ] \ No newline at end of file diff --git a/test/integration/http/resources/deployment.yaml b/test/integration/http/resources/deployment.yaml new file mode 100644 index 0000000..785c1e3 --- /dev/null +++ b/test/integration/http/resources/deployment.yaml @@ -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 \ No newline at end of file diff --git a/test/integration/http/resources/service.yaml b/test/integration/http/resources/service.yaml new file mode 100644 index 0000000..d4be4e7 --- /dev/null +++ b/test/integration/http/resources/service.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Service +metadata: + name: http-svc +spec: + selector: + app: http-target-inv + ports: + - port: 80 + targetPort: 80 \ No newline at end of file diff --git a/test/integration/netbox/initializers/device-roles.yaml b/test/integration/netbox/initializers/device-roles.yaml new file mode 100644 index 0000000..9167dab --- /dev/null +++ b/test/integration/netbox/initializers/device-roles.yaml @@ -0,0 +1,3 @@ +- name: Router + slug: router + color: ff0000 diff --git a/test/integration/netbox/initializers/device-types.yaml b/test/integration/netbox/initializers/device-types.yaml new file mode 100644 index 0000000..a6279ed --- /dev/null +++ b/test/integration/netbox/initializers/device-types.yaml @@ -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 diff --git a/test/integration/netbox/initializers/devices.yaml b/test/integration/netbox/initializers/devices.yaml new file mode 100644 index 0000000..17ed036 --- /dev/null +++ b/test/integration/netbox/initializers/devices.yaml @@ -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 diff --git a/test/integration/netbox/initializers/interfaces.yaml b/test/integration/netbox/initializers/interfaces.yaml new file mode 100644 index 0000000..05e8d24 --- /dev/null +++ b/test/integration/netbox/initializers/interfaces.yaml @@ -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 diff --git a/test/integration/netbox/initializers/ip-addresses.yaml b/test/integration/netbox/initializers/ip-addresses.yaml new file mode 100644 index 0000000..73453a8 --- /dev/null +++ b/test/integration/netbox/initializers/ip-addresses.yaml @@ -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 diff --git a/test/integration/netbox/initializers/manufacturers.yaml b/test/integration/netbox/initializers/manufacturers.yaml new file mode 100644 index 0000000..68627af --- /dev/null +++ b/test/integration/netbox/initializers/manufacturers.yaml @@ -0,0 +1,4 @@ +- name: Nokia + slug: nokia +- name: Arista + slug: arista diff --git a/test/integration/netbox/initializers/sites.yaml b/test/integration/netbox/initializers/sites.yaml new file mode 100644 index 0000000..bc8ed18 --- /dev/null +++ b/test/integration/netbox/initializers/sites.yaml @@ -0,0 +1,2 @@ +- name: Lab + slug: lab diff --git a/test/integration/resources/clusters/cluster1.yaml b/test/integration/resources/clusters/cluster1.yaml index 513b948..c01cc56 100644 --- a/test/integration/resources/clusters/cluster1.yaml +++ b/test/integration/resources/clusters/cluster1.yaml @@ -13,4 +13,4 @@ spec: memory: "500Mi" cpu: "1" targetDistribution: - podCapacity: 5 \ No newline at end of file + podCapacity: 10 \ No newline at end of file diff --git a/test/integration/resources/pipelines/pipeline1.yaml b/test/integration/resources/pipelines/pipeline1.yaml index 0dc67a3..82c0289 100644 --- a/test/integration/resources/pipelines/pipeline1.yaml +++ b/test/integration/resources/pipelines/pipeline1.yaml @@ -12,6 +12,8 @@ spec: - matchLabels: vendor: nokia_srlinux role: spine + - matchLabels: + operator.gnmic.dev/targetsource: http-ts subscriptionSelectors: - matchLabels: vendor: nokia_srlinux diff --git a/test/integration/resources/pipelines/pipeline2.yaml b/test/integration/resources/pipelines/pipeline2.yaml index 7420d7d..a361833 100644 --- a/test/integration/resources/pipelines/pipeline2.yaml +++ b/test/integration/resources/pipelines/pipeline2.yaml @@ -12,6 +12,8 @@ spec: - matchLabels: vendor: nokia_srlinux role: spine + - matchLabels: + operator.gnmic.dev/targetsource: http-ts subscriptionSelectors: - matchLabels: vendor: nokia_srlinux diff --git a/test/integration/resources/targetsources/http.yaml b/test/integration/resources/targetsources/http.yaml new file mode 100644 index 0000000..422cfdc --- /dev/null +++ b/test/integration/resources/targetsources/http.yaml @@ -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 \ No newline at end of file