Skip to content
Draft
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
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions test/e2e/workload-api-acceptance/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions test/e2e/workload-api-acceptance/location.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions test/e2e/workload-api-acceptance/network.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: networking.datumapis.com/v1alpha
kind: Network
metadata:
name: e2e-acceptance-network
namespace: default
spec:
ipam:
mode: Auto
34 changes: 34 additions & 0 deletions test/e2e/workload-api-acceptance/workload.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading