Skip to content

Commit a418ac7

Browse files
committed
test: migrate workload-api-acceptance from infra
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.
1 parent 7f880e5 commit a418ac7

5 files changed

Lines changed: 126 additions & 0 deletions

File tree

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,26 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated
8181
# }
8282
# go test ./test/e2e/ -v -ginkgo.v
8383

84+
# WIP: proposed chainsaw-based API-contract e2e harness. Migrated from
85+
# datum-cloud/infra#3006. Runs live-env chainsaw contract tests against a local
86+
# kind cluster. Compute-team to confirm chainsaw vs. extending the Go e2e suite.
87+
KIND_CLUSTER ?= compute-e2e
88+
TMPDIR ?= /tmp
89+
90+
.PHONY: test-chainsaw
91+
test-chainsaw: chainsaw ## WIP: run chainsaw API-contract e2e tests against a kind cluster.
92+
@command -v kind >/dev/null 2>&1 || { \
93+
echo "Kind is not installed. Please install Kind manually."; \
94+
exit 1; \
95+
}
96+
@kind get clusters | grep -q '$(KIND_CLUSTER)' || { \
97+
echo "No '$(KIND_CLUSTER)' kind cluster found. Create it before running chainsaw e2e."; \
98+
exit 1; \
99+
}
100+
$(KIND) get kubeconfig --name $(KIND_CLUSTER) > $(TMPDIR)/.kind-$(KIND_CLUSTER).yaml
101+
$(CHAINSAW) test ./test/e2e \
102+
--cluster $(KIND_CLUSTER)=$(TMPDIR)/.kind-$(KIND_CLUSTER).yaml
103+
84104
.PHONY: lint
85105
lint: golangci-lint ## Run golangci-lint linter
86106
$(GOLANGCI_LINT) run
@@ -171,6 +191,8 @@ DEFAULTER_GEN ?= $(LOCALBIN)/defaulter-gen
171191
ENVTEST ?= $(LOCALBIN)/setup-envtest
172192
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
173193
CRDOC ?= $(LOCALBIN)/crdoc
194+
KIND ?= $(LOCALBIN)/kind
195+
CHAINSAW ?= $(LOCALBIN)/chainsaw
174196

175197
## Tool Versions
176198
KUSTOMIZE_VERSION ?= v5.5.0
@@ -182,6 +204,12 @@ GOLANGCI_LINT_VERSION ?= v2.12.2
182204
# renovate: datasource=go depName=fybrik.io/crdoc
183205
CRDOC_VERSION ?= v0.6.4
184206

207+
# renovate: datasource=go depName=sigs.k8s.io/kind
208+
KIND_VERSION ?= v0.27.0
209+
210+
# renovate: datasource=go depName=github.com/kyverno/chainsaw
211+
CHAINSAW_VERSION ?= v0.2.15
212+
185213
.PHONY: kustomize
186214
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
187215
$(KUSTOMIZE): $(LOCALBIN)
@@ -211,6 +239,16 @@ $(GOLANGCI_LINT): $(LOCALBIN)
211239
crdoc: ## Download crdoc locally if necessary.
212240
$(call go-install-tool,$(CRDOC),fybrik.io/crdoc,$(CRDOC_VERSION))
213241

242+
.PHONY: kind
243+
kind: $(KIND) ## Download kind locally if necessary.
244+
$(KIND): $(LOCALBIN)
245+
$(call go-install-tool,$(KIND),sigs.k8s.io/kind,$(KIND_VERSION))
246+
247+
.PHONY: chainsaw
248+
chainsaw: $(CHAINSAW) ## Download chainsaw locally if necessary.
249+
$(CHAINSAW): $(LOCALBIN)
250+
$(call go-install-tool,$(CHAINSAW),github.com/kyverno/chainsaw,$(CHAINSAW_VERSION))
251+
214252
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
215253
# $1 - target path with name of binary
216254
# $2 - package url which can be installed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
2+
apiVersion: chainsaw.kyverno.io/v1alpha1
3+
kind: Test
4+
metadata:
5+
name: workload-api-acceptance
6+
spec:
7+
cluster: compute-e2e
8+
steps:
9+
- name: Apply networking fixtures
10+
try:
11+
- apply:
12+
timeout: 1m
13+
file: location.yaml
14+
- apply:
15+
timeout: 1m
16+
file: network.yaml
17+
- assert:
18+
resource:
19+
apiVersion: networking.datumapis.com/v1alpha
20+
kind: Network
21+
metadata:
22+
name: e2e-acceptance-network
23+
24+
- name: Apply Workload and assert acceptance
25+
try:
26+
- apply:
27+
timeout: 1m
28+
file: workload.yaml
29+
- assert:
30+
resource:
31+
apiVersion: compute.datumapis.com/v1alpha
32+
kind: Workload
33+
metadata:
34+
name: e2e-acceptance-workload
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: networking.datumapis.com/v1alpha
2+
kind: Location
3+
metadata:
4+
name: us-central1-a
5+
labels:
6+
topology.datum.net/city-code: ORD
7+
spec:
8+
provider:
9+
gcp:
10+
projectId: datum-cloud-staging
11+
region: us-central1
12+
zone: us-central1-a
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: networking.datumapis.com/v1alpha
2+
kind: Network
3+
metadata:
4+
name: e2e-acceptance-network
5+
namespace: default
6+
spec:
7+
ipam:
8+
mode: Auto
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apiVersion: compute.datumapis.com/v1alpha
2+
kind: Workload
3+
metadata:
4+
name: e2e-acceptance-workload
5+
namespace: default
6+
spec:
7+
template:
8+
spec:
9+
runtime:
10+
resources:
11+
instanceType: datumcloud/d1-standard-2
12+
sandbox:
13+
containers:
14+
- name: httpbin
15+
image: kennethreitz/httpbin
16+
ports:
17+
- name: http
18+
port: 80
19+
networkInterfaces:
20+
- network:
21+
name: e2e-acceptance-network
22+
networkPolicy:
23+
ingress:
24+
- ports:
25+
- port: 80
26+
from:
27+
- ipBlock:
28+
cidr: 0.0.0.0/0
29+
placements:
30+
- name: central
31+
cityCodes:
32+
- ORD
33+
scaleSettings:
34+
minReplicas: 1

0 commit comments

Comments
 (0)