From a418ac7a3812b9de325715daa62fc7a8ee51900f Mon Sep 17 00:00:00 2001 From: Evan Vetere Date: Wed, 1 Jul 2026 15:04:17 -0400 Subject: [PATCH] test: migrate workload-api-acceptance from infra MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migrate the Workload API-acceptance contract test out of datum-cloud/infra into the owning repo, per datum-cloud/infra#3006. That issue consolidates infra's live-env Chainsaw suite into one "construct" group and evacuates single-service compute.datumapis.com contract tests to compute, run against the local kind harness pre-merge. This test applies a Workload (plus networking Location/Network fixtures) and asserts the control plane accepts and stores the Workload — API schema and admission only, no wait for VM provisioning. Key changes: - Add test/e2e/workload-api-acceptance/ with the chainsaw test and the location.yaml / network.yaml / workload.yaml fixtures copied from infra. - Drop the datumctl auth update-kubeconfig setup step and the project control-plane cluster block; target a local kind cluster via spec.cluster, mirroring datum-cloud/network-services-operator. - Remove spec.skip: true. - Introduce a minimal, WIP chainsaw harness to the Makefile: kind + chainsaw tool vars, install targets, and a test-chainsaw target that runs chainsaw against the kind cluster. Compute has no chainsaw setup today; this is a proposed harness pending compute-team decision on chainsaw vs. extending the existing Go e2e suite. --- Makefile | 38 +++++++++++++++++++ .../chainsaw-test.yaml | 34 +++++++++++++++++ .../e2e/workload-api-acceptance/location.yaml | 12 ++++++ test/e2e/workload-api-acceptance/network.yaml | 8 ++++ .../e2e/workload-api-acceptance/workload.yaml | 34 +++++++++++++++++ 5 files changed, 126 insertions(+) create mode 100644 test/e2e/workload-api-acceptance/chainsaw-test.yaml create mode 100644 test/e2e/workload-api-acceptance/location.yaml create mode 100644 test/e2e/workload-api-acceptance/network.yaml create mode 100644 test/e2e/workload-api-acceptance/workload.yaml diff --git a/Makefile b/Makefile index 3d6a3e2e..23528b33 100644 --- a/Makefile +++ b/Makefile @@ -81,6 +81,26 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated # } # go test ./test/e2e/ -v -ginkgo.v +# WIP: proposed chainsaw-based API-contract e2e harness. Migrated from +# datum-cloud/infra#3006. Runs live-env chainsaw contract tests against a local +# kind cluster. Compute-team to confirm chainsaw vs. extending the Go e2e suite. +KIND_CLUSTER ?= compute-e2e +TMPDIR ?= /tmp + +.PHONY: test-chainsaw +test-chainsaw: chainsaw ## WIP: run chainsaw API-contract e2e tests against a kind cluster. + @command -v kind >/dev/null 2>&1 || { \ + echo "Kind is not installed. Please install Kind manually."; \ + exit 1; \ + } + @kind get clusters | grep -q '$(KIND_CLUSTER)' || { \ + echo "No '$(KIND_CLUSTER)' kind cluster found. Create it before running chainsaw e2e."; \ + exit 1; \ + } + $(KIND) get kubeconfig --name $(KIND_CLUSTER) > $(TMPDIR)/.kind-$(KIND_CLUSTER).yaml + $(CHAINSAW) test ./test/e2e \ + --cluster $(KIND_CLUSTER)=$(TMPDIR)/.kind-$(KIND_CLUSTER).yaml + .PHONY: lint lint: golangci-lint ## Run golangci-lint linter $(GOLANGCI_LINT) run @@ -171,6 +191,8 @@ DEFAULTER_GEN ?= $(LOCALBIN)/defaulter-gen ENVTEST ?= $(LOCALBIN)/setup-envtest GOLANGCI_LINT = $(LOCALBIN)/golangci-lint CRDOC ?= $(LOCALBIN)/crdoc +KIND ?= $(LOCALBIN)/kind +CHAINSAW ?= $(LOCALBIN)/chainsaw ## Tool Versions KUSTOMIZE_VERSION ?= v5.5.0 @@ -182,6 +204,12 @@ GOLANGCI_LINT_VERSION ?= v2.12.2 # renovate: datasource=go depName=fybrik.io/crdoc CRDOC_VERSION ?= v0.6.4 +# renovate: datasource=go depName=sigs.k8s.io/kind +KIND_VERSION ?= v0.27.0 + +# renovate: datasource=go depName=github.com/kyverno/chainsaw +CHAINSAW_VERSION ?= v0.2.15 + .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. $(KUSTOMIZE): $(LOCALBIN) @@ -211,6 +239,16 @@ $(GOLANGCI_LINT): $(LOCALBIN) crdoc: ## Download crdoc locally if necessary. $(call go-install-tool,$(CRDOC),fybrik.io/crdoc,$(CRDOC_VERSION)) +.PHONY: kind +kind: $(KIND) ## Download kind locally if necessary. +$(KIND): $(LOCALBIN) + $(call go-install-tool,$(KIND),sigs.k8s.io/kind,$(KIND_VERSION)) + +.PHONY: chainsaw +chainsaw: $(CHAINSAW) ## Download chainsaw locally if necessary. +$(CHAINSAW): $(LOCALBIN) + $(call go-install-tool,$(CHAINSAW),github.com/kyverno/chainsaw,$(CHAINSAW_VERSION)) + # go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist # $1 - target path with name of binary # $2 - package url which can be installed diff --git a/test/e2e/workload-api-acceptance/chainsaw-test.yaml b/test/e2e/workload-api-acceptance/chainsaw-test.yaml new file mode 100644 index 00000000..737dbb93 --- /dev/null +++ b/test/e2e/workload-api-acceptance/chainsaw-test.yaml @@ -0,0 +1,34 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: workload-api-acceptance +spec: + cluster: compute-e2e + steps: + - name: Apply networking fixtures + try: + - apply: + timeout: 1m + file: location.yaml + - apply: + timeout: 1m + file: network.yaml + - assert: + resource: + apiVersion: networking.datumapis.com/v1alpha + kind: Network + metadata: + name: e2e-acceptance-network + + - name: Apply Workload and assert acceptance + try: + - apply: + timeout: 1m + file: workload.yaml + - assert: + resource: + apiVersion: compute.datumapis.com/v1alpha + kind: Workload + metadata: + name: e2e-acceptance-workload diff --git a/test/e2e/workload-api-acceptance/location.yaml b/test/e2e/workload-api-acceptance/location.yaml new file mode 100644 index 00000000..288d30d1 --- /dev/null +++ b/test/e2e/workload-api-acceptance/location.yaml @@ -0,0 +1,12 @@ +apiVersion: networking.datumapis.com/v1alpha +kind: Location +metadata: + name: us-central1-a + labels: + topology.datum.net/city-code: ORD +spec: + provider: + gcp: + projectId: datum-cloud-staging + region: us-central1 + zone: us-central1-a diff --git a/test/e2e/workload-api-acceptance/network.yaml b/test/e2e/workload-api-acceptance/network.yaml new file mode 100644 index 00000000..9026fb28 --- /dev/null +++ b/test/e2e/workload-api-acceptance/network.yaml @@ -0,0 +1,8 @@ +apiVersion: networking.datumapis.com/v1alpha +kind: Network +metadata: + name: e2e-acceptance-network + namespace: default +spec: + ipam: + mode: Auto diff --git a/test/e2e/workload-api-acceptance/workload.yaml b/test/e2e/workload-api-acceptance/workload.yaml new file mode 100644 index 00000000..1abac6bb --- /dev/null +++ b/test/e2e/workload-api-acceptance/workload.yaml @@ -0,0 +1,34 @@ +apiVersion: compute.datumapis.com/v1alpha +kind: Workload +metadata: + name: e2e-acceptance-workload + namespace: default +spec: + template: + spec: + runtime: + resources: + instanceType: datumcloud/d1-standard-2 + sandbox: + containers: + - name: httpbin + image: kennethreitz/httpbin + ports: + - name: http + port: 80 + networkInterfaces: + - network: + name: e2e-acceptance-network + networkPolicy: + ingress: + - ports: + - port: 80 + from: + - ipBlock: + cidr: 0.0.0.0/0 + placements: + - name: central + cityCodes: + - ORD + scaleSettings: + minReplicas: 1