ci: add test for key rotation

This commit adds test for key rotation.

Signed-off-by: Rakshith R <rar@redhat.com>
(cherry picked from commit b9fc9a643e)
This commit is contained in:
Rakshith R authored and Mergify committed 2023-03-08 16:37:34 +00:00
1 parent 2e6ae0a958
commit f7c8cf3c93
2 files changed
+34 -5

No files matched your search

+25
View File
@@ -329,6 +329,31 @@ function wait_for_ceph_to_be_ready() {
kubectl -n rook-ceph get pods
}
function verify_key_rotation(){
pvc_name=$(kubectl get pvc -n rook-ceph -l ceph.rook.io/setIndex=0 -o jsonpath='{.items[0].metadata.name}')
old_key=$(kubectl -n rook-ceph get secrets -l "pvc_name=$pvc_name" -o jsonpath='{.items[0].data.'dmcrypt-key'}' | base64 --decode)
runtime="3 minutes"
endtime=$(date -ud "$runtime" +%s)
while [[ $(date -u +%s) -le $endtime ]]
do
echo "Time Now: `date +%H:%M:%S`"
new_key=$(kubectl -n rook-ceph get secrets -l "pvc_name=$pvc_name" -o jsonpath='{.items[0].data.'dmcrypt-key'}' | base64 --decode)
if [ "$old_key" != "$new_key" ]; then
echo "encryption passphrase is successfully rotated"
exit 0
fi
echo "encryption passphrase is not rotated, sleeping for 10 seconds"
sleep 10s
done
new_key=$(kubectl -n rook-ceph get secrets -l "pvc_name=$pvc_name" -o jsonpath='{.items[0].data.'dmcrypt-key'}' | base64 --decode)
if [ "$old_key" == "$new_key" ]; then
echo "encryption passphrase is not rotated"
exit 1
else
echo "encryption passphrase is successfully rotated"
fi
}
function check_ownerreferences() {
curl -L https://github.com/kubernetes-sigs/kubectl-check-ownerreferences/releases/download/v0.2.0/kubectl-check-ownerreferences-linux-amd64.tar.gz -o kubectl-check-ownerreferences-linux-amd64.tar.gz
tar xzvf kubectl-check-ownerreferences-linux-amd64.tar.gz