Skip to content

Commit d7ad7b2

Browse files
Merge pull request #500 from tnautiya/custom_rings
Test: add kuttl suite for swift with external rings
2 parents 87913af + c1f9d54 commit d7ad7b2

11 files changed

Lines changed: 139 additions & 0 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/00-deps.yaml
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This assertion verifies that the swift-ring-files ConfigMap was successfully created
2+
# by the 01-configmap.yaml step. It only checks for the existence of the ConfigMap resource.
3+
# The actual validation of ring file contents happens in 02-assert.yaml when checking
4+
apiVersion: v1
5+
kind: ConfigMap
6+
metadata:
7+
name: swift-ring-files
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
- script: |
5+
# Step 1: Create ConfigMap with compressed ring files
6+
7+
# Compress ring files
8+
mkdir -p /tmp/rings-compressed
9+
for ring in ./rings/*.ring; do
10+
gzip -c "$ring" > "/tmp/rings-compressed/$(basename $ring).gz"
11+
done
12+
13+
# Create the ConfigMap with compressed ring files
14+
oc create configmap swift-ring-files --from-file=/tmp/rings-compressed/ -n $NAMESPACE --dry-run=client -o yaml | oc apply -f -
15+
16+
# Cleanup temporary compressed files
17+
rm -rf /tmp/rings-compressed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Assert that the Swift CR is deployed and ready
2+
apiVersion: swift.openstack.org/v1beta1
3+
kind: Swift
4+
metadata:
5+
name: swift
6+
---
7+
# Verify that the Swift CR is ready and custom ring files are properly deployed
8+
apiVersion: kuttl.dev/v1beta1
9+
kind: TestAssert
10+
timeout: 600
11+
commands:
12+
- script: |
13+
# Wait for Swift CR to be Ready
14+
oc wait --for=condition=Ready swift/swift -n $NAMESPACE --timeout=300s
15+
16+
# Wait for swift-storage-0 pod to be Ready
17+
oc wait --for=condition=Ready pod/swift-storage-0 -n $NAMESPACE --timeout=300s
18+
19+
# Verify the live Swift deployment is using the externally generated object ring
20+
echo "Checking object.ring.gz..."
21+
if oc exec -n $NAMESPACE swift-storage-0 -c object-server -- zcat /etc/swift/object.ring.gz | grep -q -a "external ring testing"; then
22+
echo "object.ring.gz: External ring metadata found"
23+
else
24+
echo "object.ring.gz: External ring marker NOT found!"
25+
exit 1
26+
fi
27+
28+
# Verify account.ring.gz
29+
echo "Checking account.ring.gz..."
30+
if oc exec -n $NAMESPACE swift-storage-0 -c account-server -- zcat /etc/swift/account.ring.gz | grep -q -a "external ring testing"; then
31+
echo "account.ring.gz: External ring metadata found"
32+
else
33+
echo "account.ring.gz: External ring marker NOT found!"
34+
exit 1
35+
fi
36+
37+
# Verify container.ring.gz
38+
echo "Checking container.ring.gz..."
39+
if oc exec -n $NAMESPACE swift-storage-0 -c container-server -- zcat /etc/swift/container.ring.gz | grep -q -a "external ring testing"; then
40+
echo "container.ring.gz: External ring metadata found"
41+
else
42+
echo "container.ring.gz: External ring marker NOT found!"
43+
exit 1
44+
fi
45+
46+
echo "SUCCESS: All custom ring files validated"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
- script: |
5+
# Step 2: Deploy Swift application
6+
7+
# Pull a fresh sample configuration to overlay against
8+
cp ../../../../config/samples/swift_v1beta1_swift.yaml deploy/
9+
10+
# Deploy swift replica, custom-ring environment
11+
oc kustomize deploy | oc apply -n $NAMESPACE -f -
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
delete:
4+
- apiVersion: swift.openstack.org/v1beta1
5+
kind: Swift
6+
name: swift
7+
commands:
8+
- script: |
9+
# Delete ConfigMap
10+
oc delete configmap swift-ring-files -n $NAMESPACE --ignore-not-found=true
11+
12+
# Delete PVCs
13+
oc delete --ignore-not-found=true -n $NAMESPACE pvc swift-swift-storage-0
14+
15+
# Clean up Released PVs for reuse
16+
for pv in $(oc get pv | grep "Released.*swift" | cut -f 1 -d " "); do
17+
oc patch pv $pv -p '{"spec":{"claimRef": null}}'
18+
done
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: swift.openstack.org/v1beta1
2+
kind: Swift
3+
metadata:
4+
name: swift
5+
---
6+
apiVersion: v1
7+
kind: Pod
8+
metadata:
9+
labels:
10+
app.kubernetes.io/name: SwiftProxy
11+
---
12+
apiVersion: v1
13+
kind: Pod
14+
metadata:
15+
name: swift-storage-0
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- swift_v1beta1_swift.yaml
6+
7+
patches:
8+
- target:
9+
kind: Swift
10+
name: swift
11+
patch: |-
12+
- op: replace
13+
path: /spec/swiftProxy/replicas
14+
value: 1
15+
- op: replace
16+
path: /spec/swiftStorage/replicas
17+
value: 1
18+
- op: replace
19+
path: /spec/swiftRing/enabled
20+
value: false
21+
- op: add
22+
path: /spec/ringConfigMaps
23+
value:
24+
- swift-ring-files
2.28 KB
Binary file not shown.
2.28 KB
Binary file not shown.

0 commit comments

Comments
 (0)