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 index 7b8ce704..d8ba329b 100755 --- a/tests/kuttl/common/scripts/check_ring_rebalance_output.sh +++ b/tests/kuttl/common/scripts/check_ring_rebalance_output.sh @@ -5,5 +5,5 @@ 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 + 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_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