Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Barbican kuttl tests #46

Merged
Merged
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
1 change: 0 additions & 1 deletion config/samples/barbican_v1beta1_barbican.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ spec:
optional_policy.json: |
{"some": "custom policy"}
barbicanKeystoneListener:
containerImage: quay.io/podified-antelope-centos9/openstack-barbican-keystone-listener:current-podified
nodeSelector:
optional_override: here
customServiceConfig: |
Expand Down
4 changes: 3 additions & 1 deletion kuttl-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
# - chmod 755 /usr/local/bin/kubectl-kuttl
# 2. An OCP 4.10+ CRC cluster with Podified Operators has been deployed
# 3. CLI user has access to $KUBECONFIG
# 4. The environment variable INSTALL_YAMLS is set to the the path of the
# install_yamls repo

apiVersion: kuttl.dev/v1beta1
kind: TestSuite
reportFormat: JSON
reportName: kuttl-test-barbican
namespace: barbican-kuttl-tests
namespace: barbican-kuttl-tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: blank space at end of the line

timeout: 180
parallel: 1
suppress:
Expand Down
51 changes: 51 additions & 0 deletions test/kuttl/common/assert_sample_deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: barbican.openstack.org/v1beta1
kind: Barbican
metadata:
name: barbican
spec:
serviceUser: barbican
customServiceConfig: |
[DEFAULT]
debug = True
databaseInstance: openstack
databaseUser: barbican
rabbitMqClusterName: rabbitmq
barbicanAPI:
replicas: 1
barbicanWorker:
replicas: 1
barbicanKeystoneListener:
replicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican-api-api
ownerReferences:
- apiVersion: barbican.openstack.org/v1beta1
blockOwnerDeletion: true
controller: true
kind: BarbicanAPI
name: barbican-api
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican-keystone-listener-keystone-listener
ownerReferences:
- apiVersion: barbican.openstack.org/v1beta1
blockOwnerDeletion: true
controller: true
kind: BarbicanKeystoneListener
name: barbican-keystone-listener
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican-worker-worker
ownerReferences:
- apiVersion: barbican.openstack.org/v1beta1
blockOwnerDeletion: true
controller: true
kind: BarbicanWorker
name: barbican-worker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need these deployment objects to be defined here? Isn't it sufficient to simply have the first stanza (lines 1-18) I think we specifically say NOT to deploy the sub-components - which is why we add the top level component to the finalizers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vakwetu
The mentioned remaining lines can be removed from the test YAML files, but one of the tests scales all Barbican's components to zero. If we do not deploy them at the beginning of the tests, we need to pick one of the options below:

  1. Deploy the components again after the "scale down to zero" test.
  2. Remove the "scale down to zero" test.

Which approach should we choose?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused -- why wouldn't we have to redeploy the components after the scale to zero test?

Maybe thats precisely the point here - when you add an additional deployments, its not altogether clear what we are deploying.

As for the above question, there is option 3 - which is to make the scale to zero test the last test. Then you won't have to deploy. Or you can do a scale up test after the scale down test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "scale down to zero" test is already the last one. It makes sense to be like this.

On the local environment I'm using to test the tests, they are running on the same namespace where the other CRs are deployed (Memcached, Redis, RabbitMQ, ...) since to be able to work, they need such components to be present at first.

I said we need to manually redeploy the components simply because the "scale down to zero" test deletes them. May I understand we won't need the CRs after they are deleted, considering the namespace statement above? I think a quick sync on this would be better than exchanging comments here. :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, I realized while we chatted that this is an assert-file. So everything I said about removing the deployments is wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So keep them, but also make sure to test using install_yamls.

1 change: 1 addition & 0 deletions test/kuttl/tests/barbican_scale/01-assert.yaml
6 changes: 6 additions & 0 deletions test/kuttl/tests/barbican_scale/01-deploy-barbican.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
cp ../../../../config/samples/barbican_v1beta1_barbican.*yaml deploy
oc kustomize deploy | oc apply -n $NAMESPACE -f -
49 changes: 49 additions & 0 deletions test/kuttl/tests/barbican_scale/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# Check for:
# - Barbican CRs with 2 replicas for each one
# - BarbicanAPI barbican-api Deployment with 2 replicas
# - BarbicanKeystoneListener barbican-keystone-listener Deployment with 2 replicas
# - BarbicanWorker barbican-worker Deployment with 2 replicas


apiVersion: barbican.openstack.org/v1beta1
kind: Barbican
metadata:
name: barbican
spec:
barbicanAPI:
replicas: 2
barbicanKeystoneListener:
replicas: 2
barbicanWorker:
replicas: 2
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican-api-api
spec:
replicas: 2
status:
availableReplicas: 2
replicas: 2
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican-keystone-listener-keystone-listener
spec:
replicas: 2
status:
availableReplicas: 2
replicas: 2
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican-worker-worker
spec:
replicas: 2
status:
availableReplicas: 2
replicas: 2
7 changes: 7 additions & 0 deletions test/kuttl/tests/barbican_scale/02-scale-barbican.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
oc patch Barbican -n $NAMESPACE barbican --type='json' -p='[{"op": "replace", "path": "/spec/barbicanAPI/replicas", "value":2}]'
oc patch Barbican -n $NAMESPACE barbican --type='json' -p='[{"op": "replace", "path": "/spec/barbicanKeystoneListener/replicas", "value":2}]'
oc patch Barbican -n $NAMESPACE barbican --type='json' -p='[{"op": "replace", "path": "/spec/barbicanWorker/replicas", "value":2}]'
49 changes: 49 additions & 0 deletions test/kuttl/tests/barbican_scale/03-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# Check for:
# - Barbican CRs with12 replicas for each one
# - BarbicanAPI barbican-api Deployment with 1 replica
# - BarbicanKeystoneListener barbican-keystone-listener Deployment with 1 replica
# - BarbicanWorker barbican-worker Deployment with 1 replica


apiVersion: barbican.openstack.org/v1beta1
kind: Barbican
metadata:
name: barbican
spec:
barbicanAPI:
replicas: 1
barbicanKeystoneListener:
replicas: 1
barbicanWorker:
replicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican-api-api
spec:
replicas: 1
status:
availableReplicas: 1
replicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican-keystone-listener-keystone-listener
spec:
replicas: 1
status:
availableReplicas: 1
replicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican-worker-worker
spec:
replicas: 1
status:
availableReplicas: 1
replicas: 1
7 changes: 7 additions & 0 deletions test/kuttl/tests/barbican_scale/03-scale-down-barbican.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
oc patch Barbican -n $NAMESPACE barbican --type='json' -p='[{"op": "replace", "path": "/spec/barbicanAPI/replicas", "value":1}]'
oc patch Barbican -n $NAMESPACE barbican --type='json' -p='[{"op": "replace", "path": "/spec/barbicanKeystoneListener/replicas", "value":1}]'
oc patch Barbican -n $NAMESPACE barbican --type='json' -p='[{"op": "replace", "path": "/spec/barbicanWorker/replicas", "value":1}]'
40 changes: 40 additions & 0 deletions test/kuttl/tests/barbican_scale/04-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Check for:
# - Barbican CRs with 0 replicas for each one
# - BarbicanAPI barbican-api Deployment with 0 replicas
# - BarbicanKeystoneListener barbican-keystone-listener Deployment with 0 replicas
# - BarbicanWorker barbican-worker Deployment with 0 replicas


apiVersion: barbican.openstack.org/v1beta1
kind: Barbican
metadata:
name: barbican
spec:
barbicanAPI:
replicas: 0
barbicanKeystoneListener:
replicas: 0
barbicanWorker:
replicas: 0
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican-api-api
spec:
replicas: 0
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican-keystone-listener-keystone-listener
spec:
replicas: 0
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican-worker-worker
spec:
replicas: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
oc patch Barbican -n $NAMESPACE barbican --type='json' -p='[{"op": "replace", "path": "/spec/barbicanAPI/replicas", "value":0}]'
oc patch Barbican -n $NAMESPACE barbican --type='json' -p='[{"op": "replace", "path": "/spec/barbicanKeystoneListener/replicas", "value":0}]'
oc patch Barbican -n $NAMESPACE barbican --type='json' -p='[{"op": "replace", "path": "/spec/barbicanWorker/replicas", "value":0}]'
6 changes: 6 additions & 0 deletions test/kuttl/tests/barbican_scale/05-cleanup-barbican.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
oc kustomize deploy | oc delete -n $NAMESPACE -f -
rm deploy/barbican_v1beta1_barbican.yaml
17 changes: 17 additions & 0 deletions test/kuttl/tests/barbican_scale/05-errors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Check for:
#
# No BarbicanAPI CR
# No Deployment for BarbicanAPI CR
# No Pods in barbican Deployment
# No Barbican Services
#
apiVersion: barbican.openstack.org/v1beta1
kind: Barbican
metadata:
name: barbican
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: barbican
13 changes: 13 additions & 0 deletions test/kuttl/tests/barbican_scale/deploy/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./barbican_v1beta1_barbican.yaml
patches:
- patch: |-
- op: replace
path: /spec/secret
value: osp-secret
- op: replace
path: /metadata/namespace
target:
kind: Barbican
66 changes: 0 additions & 66 deletions tests/kuttl/common/assert-sample-deployment.yaml

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions tests/kuttl/tests/basic-deployment/01-deploy-barbican.yaml

This file was deleted.

Loading