diff --git a/tests/kuttl/common/00-deps.yaml b/tests/kuttl/common/00-deps.yaml new file mode 100644 index 00000000..1f725683 --- /dev/null +++ b/tests/kuttl/common/00-deps.yaml @@ -0,0 +1,7 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + if ! [[ `oc get crd openstackdataplanenodesets.dataplane.openstack.org` ]]; then + oc apply -f ../../deps/dataplane.openstack.org_openstackdataplanenodesets.yaml + fi diff --git a/tests/kuttl/common/scripts/check_ring_rebalance_output.sh b/tests/kuttl/common/scripts/check_ring_rebalance_output.sh new file mode 100755 index 00000000..d8ba329b --- /dev/null +++ b/tests/kuttl/common/scripts/check_ring_rebalance_output.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Check that all storage pods were included in the rebalance job +oc wait --for=condition=complete -n $NAMESPACE job swift-ring-rebalance +LOGS=$(oc logs -n $NAMESPACE job/swift-ring-rebalance) +PODS=$(oc get pods -n $NAMESPACE -l component=swift-storage -o name | cut -f 2 -d "/") + +for pod in $PODS; do + echo $LOGS | grep -q $pod || exit 1 +done diff --git a/tests/kuttl/tests/basic-deploy/00-deps.yaml b/tests/kuttl/tests/basic-deploy/00-deps.yaml deleted file mode 100644 index 1f725683..00000000 --- a/tests/kuttl/tests/basic-deploy/00-deps.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: | - if ! [[ `oc get crd openstackdataplanenodesets.dataplane.openstack.org` ]]; then - oc apply -f ../../deps/dataplane.openstack.org_openstackdataplanenodesets.yaml - fi diff --git a/tests/kuttl/tests/basic-deploy/00-deps.yaml b/tests/kuttl/tests/basic-deploy/00-deps.yaml new file mode 120000 index 00000000..edb929eb --- /dev/null +++ b/tests/kuttl/tests/basic-deploy/00-deps.yaml @@ -0,0 +1 @@ +../../common/00-deps.yaml \ No newline at end of file diff --git a/tests/kuttl/tests/basic-deploy/01-assert-deploy-swift.yaml b/tests/kuttl/tests/basic-deploy/01-assert-deploy-swift.yaml index f0b7adb7..3816c4ea 100644 --- a/tests/kuttl/tests/basic-deploy/01-assert-deploy-swift.yaml +++ b/tests/kuttl/tests/basic-deploy/01-assert-deploy-swift.yaml @@ -1,3 +1,4 @@ +--- apiVersion: swift.openstack.org/v1beta1 kind: Swift metadata: @@ -50,3 +51,93 @@ status: reason: Ready status: "True" type: SwiftStorageReady +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + component: swift-proxy + service: swift +status: + containerStatuses: + - name: proxy-httpd + ready: true + started: true + - name: proxy-server + ready: true + started: true + - name: ring-sync + ready: true + started: true +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + component: swift-storage + service: swift + name: swift-storage-0 +status: + containerStatuses: + - name: account-auditor + ready: true + started: true + - name: account-reaper + ready: true + started: true + - name: account-replicator + ready: true + started: true + - name: account-server + ready: true + started: true + - name: container-auditor + ready: true + started: true + - name: container-replicator + ready: true + started: true + - name: container-server + ready: true + started: true + - name: container-updater + ready: true + started: true + - name: object-auditor + ready: true + started: true + - name: object-expirer + ready: true + started: true + - name: object-replicator + ready: true + started: true + - name: object-server + ready: true + started: true + - name: object-updater + ready: true + started: true + - name: ring-sync + ready: true + started: true + - name: rsync + ready: true + started: true + - name: swift-recon-cron + ready: true + started: true +--- +apiVersion: batch/v1 +kind: Job +metadata: + labels: + job-name: swift-ring-rebalance + name: swift-ring-rebalance +status: + succeeded: 1 +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: + - script: $SWIFT_KUTTL_DIR/../common/scripts/check_ring_rebalance_output.sh diff --git a/tests/kuttl/tests/basic-deploy_tls/00-deps.yaml b/tests/kuttl/tests/basic-deploy_tls/00-deps.yaml deleted file mode 100644 index 1f725683..00000000 --- a/tests/kuttl/tests/basic-deploy_tls/00-deps.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: | - if ! [[ `oc get crd openstackdataplanenodesets.dataplane.openstack.org` ]]; then - oc apply -f ../../deps/dataplane.openstack.org_openstackdataplanenodesets.yaml - fi diff --git a/tests/kuttl/tests/basic-deploy_tls/00-deps.yaml b/tests/kuttl/tests/basic-deploy_tls/00-deps.yaml new file mode 120000 index 00000000..edb929eb --- /dev/null +++ b/tests/kuttl/tests/basic-deploy_tls/00-deps.yaml @@ -0,0 +1 @@ +../../common/00-deps.yaml \ No newline at end of file diff --git a/tests/kuttl/tests/replication/00-deps.yaml b/tests/kuttl/tests/replication/00-deps.yaml new file mode 120000 index 00000000..edb929eb --- /dev/null +++ b/tests/kuttl/tests/replication/00-deps.yaml @@ -0,0 +1 @@ +../../common/00-deps.yaml \ No newline at end of file diff --git a/tests/kuttl/tests/replication/01-assert-deploy-swift.yaml b/tests/kuttl/tests/replication/01-assert-deploy-swift.yaml new file mode 100644 index 00000000..e1ba66d8 --- /dev/null +++ b/tests/kuttl/tests/replication/01-assert-deploy-swift.yaml @@ -0,0 +1,53 @@ +--- +apiVersion: swift.openstack.org/v1beta1 +kind: Swift +metadata: + name: swift +spec: + swiftRing: + ringReplicas: 3 + swiftStorage: + storageClass: local-storage + replicas: 3 + swiftProxy: + replicas: 1 + passwordSelectors: + service: SwiftPassword +status: + conditions: + - message: Setup complete + reason: Ready + status: "True" + type: Ready + - message: " Memcached instance has been provisioned" + reason: Ready + status: "True" + type: MemcachedReady + - message: RoleBinding created + reason: Ready + status: "True" + type: RoleBindingReady + - message: Role created + reason: Ready + status: "True" + type: RoleReady + - message: ServiceAccount created + reason: Ready + status: "True" + type: ServiceAccountReady + - message: Service config create completed + reason: Ready + status: "True" + type: ServiceConfigReady + - message: Setup complete + reason: Ready + status: "True" + type: SwiftProxyReady + - message: Setup complete + reason: Ready + status: "True" + type: SwiftRingReady + - message: Setup complete + reason: Ready + status: "True" + type: SwiftStorageReady diff --git a/tests/kuttl/tests/replication/01-deploy-swift.yaml b/tests/kuttl/tests/replication/01-deploy-swift.yaml new file mode 100644 index 00000000..e27d8341 --- /dev/null +++ b/tests/kuttl/tests/replication/01-deploy-swift.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + cp ../../../../config/samples/swift_v1beta1_swift.yaml deploy + oc kustomize deploy | oc apply -n $NAMESPACE -f - diff --git a/tests/kuttl/tests/replication/02-assert-store-data.yaml b/tests/kuttl/tests/replication/02-assert-store-data.yaml new file mode 100644 index 00000000..a30cd640 --- /dev/null +++ b/tests/kuttl/tests/replication/02-assert-store-data.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: + - script: | + oc debug -n $NAMESPACE --keep-labels=true job/swift-ring-rebalance -- /bin/sh -c 'swift-ring-tool get && swift-dispersion-report --object-only' | grep '100.00% of object copies found' diff --git a/tests/kuttl/tests/replication/02-store-data.yaml b/tests/kuttl/tests/replication/02-store-data.yaml new file mode 100644 index 00000000..49da3522 --- /dev/null +++ b/tests/kuttl/tests/replication/02-store-data.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + oc debug -n $NAMESPACE --keep-labels=true job/swift-ring-rebalance -- /bin/sh -c 'swift-ring-tool get && swift-dispersion-populate --object-only' diff --git a/tests/kuttl/tests/replication/03-assert-force-replication.yaml b/tests/kuttl/tests/replication/03-assert-force-replication.yaml new file mode 100644 index 00000000..a30cd640 --- /dev/null +++ b/tests/kuttl/tests/replication/03-assert-force-replication.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: + - script: | + oc debug -n $NAMESPACE --keep-labels=true job/swift-ring-rebalance -- /bin/sh -c 'swift-ring-tool get && swift-dispersion-report --object-only' | grep '100.00% of object copies found' diff --git a/tests/kuttl/tests/replication/03-force-replication.yaml b/tests/kuttl/tests/replication/03-force-replication.yaml new file mode 100644 index 00000000..e5ece63a --- /dev/null +++ b/tests/kuttl/tests/replication/03-force-replication.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + oc rsh -n $NAMESPACE pod/swift-storage-0 /bin/sh -c 'rm -rf /srv/node/d1/* || true' diff --git a/tests/kuttl/tests/replication/04-cleanup.yaml b/tests/kuttl/tests/replication/04-cleanup.yaml new file mode 100644 index 00000000..eb0b694c --- /dev/null +++ b/tests/kuttl/tests/replication/04-cleanup.yaml @@ -0,0 +1,11 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +delete: +- apiVersion: swift.openstack.org/v1beta1 + kind: Swift + name: swift +commands: +- script: | + oc delete --ignore-not-found=true -n $NAMESPACE pvc srv-swift-storage-0 + oc delete --ignore-not-found=true -n $NAMESPACE pvc srv-swift-storage-1 + oc delete --ignore-not-found=true -n $NAMESPACE pvc srv-swift-storage-2 diff --git a/tests/kuttl/tests/replication/04-errors-cleanup.yaml b/tests/kuttl/tests/replication/04-errors-cleanup.yaml new file mode 100644 index 00000000..635ca804 --- /dev/null +++ b/tests/kuttl/tests/replication/04-errors-cleanup.yaml @@ -0,0 +1,15 @@ +apiVersion: swift.openstack.org/v1beta1 +kind: Swift +metadata: + name: swift +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + app.kubernetes.io/name: SwiftProxy +--- +apiVersion: v1 +kind: Pod +metadata: + name: swift-storage-0 diff --git a/tests/kuttl/tests/replication/deploy/kustomization.yaml b/tests/kuttl/tests/replication/deploy/kustomization.yaml new file mode 100644 index 00000000..f4d16598 --- /dev/null +++ b/tests/kuttl/tests/replication/deploy/kustomization.yaml @@ -0,0 +1,14 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- ./swift_v1beta1_swift.yaml +patches: +- patch: |- + - op: replace + path: /spec/swiftRing/ringReplicas + value: 3 + - op: replace + path: /spec/swiftStorage/replicas + value: 3 + target: + kind: Swift