Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nolancon committed May 23, 2024
1 parent fecd24e commit 9047798
Show file tree
Hide file tree
Showing 6 changed files with 3,204 additions and 9 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ LATEST_KUBE_VERSION ?= 1.29
LATEST_KIND_NODE ?= 1.29.2
REPO ?= provider-ceph

KIND_VERSION ?= v0.22.0
CROSSPLANE_VERSION ?= 1.15.0
LOCALSTACK_VERSION ?= 2.2
CERT_MANAGER_VERSION ?= 1.14.0
Expand Down Expand Up @@ -213,6 +214,13 @@ ceph-chainsaw: $(CHAINSAW_BIN) crossplane-cluster load-package
@$(OK) Running chainsaw test suite against ceph cluster
@$(MAKE) cluster-clean

.PHONY: chainsaw-edge
chainsaw-edge: $(CHAINSAW_BIN) generate-pkg generate-tests crossplane-cluster localstack-cluster load-package
@$(INFO) Running chainsaw test suite
$(CHAINSAW_BIN) test e2e/tests/edge-cases --config e2e/tests/edge-cases/.chainsaw.yaml
@$(OK) Running chainsaw test suite
# @$(MAKE) cluster-clean

# Spin up a Kind cluster and localstack and install Crossplane CRDs (not
# containerised Crossplane componenets).
# Install local provider-ceph CRDs.
Expand Down
15 changes: 15 additions & 0 deletions e2e/tests/edge-cases/.chainsaw.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/configuration-chainsaw-v1alpha1.json
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Configuration
metadata:
creationTimestamp: null
name: configuration
spec:
timeouts:
apply: 30s
assert: 60s
cleanup: 15s
delete: 30s
error: 30s
exec: 30s
skipDelete: true
292 changes: 292 additions & 0 deletions e2e/tests/edge-cases/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
# 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:
creationTimestamp: null
name: provider-ceph
spec:
steps:

- name: Assert that Crossplane has been installed.
try:
- assert:
resource:
apiVersion: apps/v1
kind: Deployment
metadata:
name: crossplane
namespace: crossplane-system
status:
readyReplicas: 1
- assert:
resource:
apiVersion: apps/v1
kind: Deployment
metadata:
name: crossplane-rbac-manager
namespace: crossplane-system
status:
readyReplicas: 1
- assert:
resource:
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: providerconfigs.ceph.crossplane.io

- name: Apply Localstack PCs. Assert Deployments are available and PCs are healthy.
try:
- command:
# We don't do this inline because we use the localstack provider config mainifest
# located in the localstack directory. We do this because this mainfes is used
# elsewhere and it's best to use the same one everywhere.
args:
- apply
- -f
- ../../localstack/localstack-provider-cfg.yaml
entrypoint: kubectl
# Assert that Localstack Deployments are available.
- assert:
resource:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
io.kompose.service: localstack-a
name: localstack-a
namespace: crossplane-system
status:
availableReplicas: 1
- assert:
resource:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
io.kompose.service: localstack-b
name: localstack-b
namespace: crossplane-system
status:
availableReplicas: 1
- assert:
resource:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
io.kompose.service: localstack-c
name: localstack-c
namespace: crossplane-system
status:
availableReplicas: 1

- name: Make localstack-a unreachable and therefore Unhealthy.
try:
- command:
args:
- patch
- service
- localstack-a
- -n
- crossplane-system
- --type=merge
- -p
- '{"spec":{"selector":{"io.kompose.service":"not-exists"}}}'
entrypoint: kubectl
- assert:
resource:
apiVersion: ceph.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
name: localstack-a
status:
conditions:
- reason: HealthCheckFail
status: "False"
type: Ready

- name: Make localstack-b unreachable and therefore Unhealthy.
try:
- command:
args:
- patch
- service
- localstack-b
- -n
- crossplane-system
- --type=merge
- -p
- '{"spec":{"selector":{"io.kompose.service":"not-exists"}}}'
entrypoint: kubectl
- assert:
resource:
apiVersion: ceph.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
name: localstack-b
status:
conditions:
- reason: HealthCheckFail
status: "False"
type: Ready

- name: Make localstack-c unreachable and therefore Unhealthy.
try:
- command:
args:
- patch
- service
- localstack-c
- -n
- crossplane-system
- --type=merge
- -p
- '{"spec":{"selector":{"io.kompose.service":"not-exists"}}}'
entrypoint: kubectl
- assert:
resource:
apiVersion: ceph.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
name: localstack-c
status:
conditions:
- reason: HealthCheckFail
status: "False"
type: Ready

- name: Apply auto-pause-bucket.
try:
- apply:
resource:
apiVersion: provider-ceph.ceph.crossplane.io/v1alpha1
kind: Bucket
metadata:
name: auto-pause-bucket
labels:
provider-ceph.crossplane.io/validation-required: "true"
spec:
autoPause: true
forProvider: {}

# Assert auto-pause-bucket has failed.
- assert:
resource:
apiVersion: provider-ceph.ceph.crossplane.io/v1alpha1
kind: Bucket
metadata:
name: auto-pause-bucket
status:
conditions:
- reason: Creating
status: "False"
type: Ready
- reason: ReconcileError
status: "False"
type: Synced

- name: Remove creation-failed annotation from auto-pause-bucket.
try:
- command:
args:
- patch
- bucket
- auto-pause-bucket
- --type=json
- -p
- '[{"op": "remove", "path": "/metadata/annotations/crossplane.io~1external-create-failed"}]'
entrypoint: kubectl


- name: Make localstack-a reachable again and therefore Healthy.
try:
- command:
args:
- patch
- service
- localstack-a
- -n
- crossplane-system
- --type=merge
- -p
- '{"spec":{"selector":{"io.kompose.service":"localstack-a"}}}'
entrypoint: kubectl
- assert:
resource:
apiVersion: ceph.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
name: localstack-a
status:
conditions:
- reason: HealthCheckSuccess
status: "True"
type: Ready

- name: Make localstack-b reachable again and therefore Healthy.
try:
- command:
args:
- patch
- service
- localstack-b
- -n
- crossplane-system
- --type=merge
- -p
- '{"spec":{"selector":{"io.kompose.service":"localstack-b"}}}'
entrypoint: kubectl
- assert:
resource:
apiVersion: ceph.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
name: localstack-b
status:
conditions:
- reason: HealthCheckSuccess
status: "True"
type: Ready

- name: Make localstack-c reachable again and therefore Healthy.
try:
- command:
args:
- patch
- service
- localstack-c
- -n
- crossplane-system
- --type=merge
- -p
- '{"spec":{"selector":{"io.kompose.service":"localstack-c"}}}'
entrypoint: kubectl
- assert:
resource:
apiVersion: ceph.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
name: localstack-c
status:
conditions:
- reason: HealthCheckSuccess
status: "True"
type: Ready

- name: Apply auto-pause-bucket.
try:
# Assert auto-pause-bucket has been created successfully.
- assert:
resource:
apiVersion: provider-ceph.ceph.crossplane.io/v1alpha1
kind: Bucket
metadata:
name: auto-pause-bucket
status:
conditions:
- reason: Available
status: "True"
type: Ready
- reason: ReconcileSuccess
status: "True"
type: Synced
Loading

0 comments on commit 9047798

Please sign in to comment.