Skip to content

Commit

Permalink
ci: support cifs on pytest and e2e
Browse files Browse the repository at this point in the history
longhorn/longhorn-9699

Signed-off-by: Chris <[email protected]>
  • Loading branch information
chriscchien committed Oct 30, 2024
1 parent 942e57e commit 88cd8b8
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 9 deletions.
3 changes: 2 additions & 1 deletion e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ curl -sSfL https://raw.githubusercontent.com/longhorn/longhorn/master/scripts/en
1. Deploy all backupstore servers (including `NFS` server and `Minio` as s3 server) for test purposes.
```
kubectl create -f https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/minio-backupstore.yaml \
-f https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/nfs-backupstore.yaml
-f https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/nfs-backupstore.yaml \
-f https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/cifs-backupstore.yaml
```

1. Expose Longhorn API:
Expand Down
3 changes: 2 additions & 1 deletion manager/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Run the test:
1. Deploy all backupstore servers(including `NFS` server and `Minio` as s3 server) for test purposes.
```
kubectl create -f https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/minio-backupstore.yaml \
-f https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/nfs-backupstore.yaml
-f https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/nfs-backupstore.yaml \
-f https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/cifs-backupstore.yaml
```
2. Deploy the test script to the Kubernetes cluster.
```
Expand Down
2 changes: 1 addition & 1 deletion manager/integration/deploy/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
- name: LONGHORN_JUNIT_REPORT_PATH
value: /tmp/test-report/longhorn-test-junit-report.xml
- name: LONGHORN_BACKUPSTORES
value: "s3://backupbucket@us-east-1/backupstore$minio-secret, nfs://longhorn-test-nfs-svc.default:/opt/backupstore"
value: "s3://backupbucket@us-east-1/backupstore$minio-secret, nfs://longhorn-test-nfs-svc.default:/opt/backupstore, cifs://longhorn-test-cifs-svc.default/backupstore$cifs-secret"
- name: LONGHORN_BACKUPSTORE_POLL_INTERVAL
value: "30"
- name: LONGHORN_DISK_TYPE
Expand Down
15 changes: 15 additions & 0 deletions manager/integration/tests/backupstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from common import cleanup_all_volumes
from common import is_backupTarget_s3
from common import is_backupTarget_nfs
from common import is_backupTarget_cifs
from common import get_longhorn_api_client
from common import delete_backup_volume
from common import delete_backup_backing_image
Expand Down Expand Up @@ -64,6 +65,8 @@ def set_random_backupstore(request, client):
elif request.param == "nfs":
set_backupstore_nfs(client)
mount_nfs_backupstore(client)
elif request.param == "cifs":
set_backupstore_cifs(client)

yield
cleanup_all_volumes(client)
Expand Down Expand Up @@ -116,6 +119,18 @@ def set_backupstore_nfs(client):
break


def set_backupstore_cifs(client):
backupstores = get_backupstore_url()
poll_interval = get_backupstore_poll_interval()
for backupstore in backupstores:
if is_backupTarget_cifs(backupstore):
backupsettings = backupstore.split("$")
set_backupstore_url(client, backupsettings[0])
set_backupstore_credential_secret(client, backupsettings[1])
set_backupstore_poll_interval(client, poll_interval)
break


def set_backupstore_url(client, url):
backup_target_setting = client.by_id_setting(SETTING_BACKUP_TARGET)
backup_target_setting = client.update(backup_target_setting,
Expand Down
4 changes: 4 additions & 0 deletions manager/integration/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3895,6 +3895,10 @@ def is_backupTarget_nfs(s):
return s.startswith("nfs://")


def is_backupTarget_cifs(s):
return s.startswith("cifs://")


def wait_for_backup_volume(client, vol_name, backing_image=""):
for _ in range(RETRY_BACKUP_COUNTS):
bv = client.by_id_backupVolume(vol_name)
Expand Down
10 changes: 9 additions & 1 deletion pipelines/gke/scripts/longhorn-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ create_longhorn_namespace(){
install_backupstores(){
MINIO_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/minio-backupstore.yaml"
NFS_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/nfs-backupstore.yaml"
CIFS_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/cifs-backupstore.yaml"
kubectl create -f ${MINIO_BACKUPSTORE_URL} \
-f ${NFS_BACKUPSTORE_URL}
-f ${NFS_BACKUPSTORE_URL} \
-f ${CIFS_BACKUPSTORE_URL}
}


Expand Down Expand Up @@ -178,6 +180,9 @@ run_longhorn_upgrade_test(){
elif [[ $BACKUP_STORE_TYPE = "nfs" ]]; then
BACKUP_STORE_FOR_TEST=`yq e 'select(.spec.containers[0] != null).spec.containers[0].env[1].value' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH} | awk -F ',' '{print $2}' | sed 's/ *//'`
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${BACKUP_STORE_FOR_TEST}'"' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH}
elif [[ $BACKUP_STORE_TYPE = "cifs" ]]; then
BACKUP_STORE_FOR_TEST=`yq e 'select(.spec.containers[0] != null).spec.containers[0].env[1].value' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH} | awk -F ',' '{print $3}' | sed 's/ *//'`
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${BACKUP_STORE_FOR_TEST}'"' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH}
fi

yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[4].value="'${LONGHORN_UPGRADE_TYPE}'"' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH}
Expand Down Expand Up @@ -226,6 +231,9 @@ run_longhorn_tests(){
elif [[ $BACKUP_STORE_TYPE = "nfs" ]]; then
BACKUP_STORE_FOR_TEST=`yq e 'select(.spec.containers[0] != null).spec.containers[0].env[1].value' ${LONGHORN_TESTS_MANIFEST_FILE_PATH} | awk -F ',' '{print $2}' | sed 's/ *//'`
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${BACKUP_STORE_FOR_TEST}'"' ${LONGHORN_TESTS_MANIFEST_FILE_PATH}
elif [[ $BACKUP_STORE_TYPE = "cifs" ]]; then
BACKUP_STORE_FOR_TEST=`yq e 'select(.spec.containers[0] != null).spec.containers[0].env[1].value' ${LONGHORN_TESTS_MANIFEST_FILE_PATH} | awk -F ',' '{print $3}' | sed 's/ *//'`
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${BACKUP_STORE_FOR_TEST}'"' ${LONGHORN_TESTS_MANIFEST_FILE_PATH}
fi

# set MANAGED_K8S_CLUSTER to true
Expand Down
6 changes: 4 additions & 2 deletions pipelines/utilities/install_backupstores.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
install_backupstores(){
MINIO_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/minio-backupstore.yaml"
NFS_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/nfs-backupstore.yaml"
CIFS_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/cifs-backupstore.yaml"
kubectl create -f ${MINIO_BACKUPSTORE_URL} \
-f ${NFS_BACKUPSTORE_URL}
}
-f ${NFS_BACKUPSTORE_URL} \
-f ${CIFS_BACKUPSTORE_URL}
}
5 changes: 5 additions & 0 deletions pipelines/utilities/run_longhorn_e2e_test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
S3_BACKUP_STORE='s3://backupbucket@us-east-1/backupstore$minio-secret'
NFS_BACKUP_STORE='nfs://longhorn-test-nfs-svc.default:/opt/backupstore'
CIFS_BACKUP_STORE='cifs://longhorn-test-cifs-svc.default/backupstore$cifs-secret'

run_longhorn_e2e_test(){

Expand All @@ -22,6 +23,8 @@ run_longhorn_e2e_test(){
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${S3_BACKUP_STORE}'"' ${LONGHORN_TESTS_MANIFEST_FILE_PATH}
elif [[ $BACKUP_STORE_TYPE = "nfs" ]]; then
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${NFS_BACKUP_STORE}'"' ${LONGHORN_TESTS_MANIFEST_FILE_PATH}
elif [[ $BACKUP_STORE_TYPE = "cifs" ]]; then
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${CIFS_BACKUP_STORE}'"' ${LONGHORN_TESTS_MANIFEST_FILE_PATH}
fi

if [[ "${TF_VAR_use_hdd}" == true ]]; then
Expand Down Expand Up @@ -75,6 +78,8 @@ run_longhorn_e2e_test_out_of_cluster(){
LONGHORN_BACKUPSTORES=${S3_BACKUP_STORE}
elif [[ $BACKUP_STORE_TYPE = "nfs" ]]; then
LONGHORN_BACKUPSTORES=${NFS_BACKUP_STORE}
elif [[ $BACKUP_STORE_TYPE = "cifs" ]]; then
LONGHORN_BACKUPSTORES=${CIFS_BACKUP_STORE}
fi
LONGHORN_BACKUPSTORE_POLL_INTERVAL="30"

Expand Down
6 changes: 6 additions & 0 deletions pipelines/utilities/run_longhorn_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ run_longhorn_test(){
elif [[ $BACKUP_STORE_TYPE = "nfs" ]]; then
BACKUP_STORE_FOR_TEST=`yq e 'select(.spec.containers[0] != null).spec.containers[0].env[1].value' ${LONGHORN_TESTS_MANIFEST_FILE_PATH} | awk -F ',' '{print $2}' | sed 's/ *//'`
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${BACKUP_STORE_FOR_TEST}'"' ${LONGHORN_TESTS_MANIFEST_FILE_PATH}
elif [[ $BACKUP_STORE_TYPE = "cifs" ]]; then
BACKUP_STORE_FOR_TEST=`yq e 'select(.spec.containers[0] != null).spec.containers[0].env[1].value' ${LONGHORN_TESTS_MANIFEST_FILE_PATH} | awk -F ',' '{print $3}' | sed 's/ *//'`
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${BACKUP_STORE_FOR_TEST}'"' ${LONGHORN_TESTS_MANIFEST_FILE_PATH}
fi

if [[ "${TF_VAR_use_hdd}" == true ]]; then
Expand Down Expand Up @@ -107,6 +110,9 @@ run_longhorn_upgrade_test(){
elif [[ $BACKUP_STORE_TYPE = "nfs" ]]; then
BACKUP_STORE_FOR_TEST=`yq e 'select(.spec.containers[0] != null).spec.containers[0].env[1].value' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH} | awk -F ',' '{print $2}' | sed 's/ *//'`
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${BACKUP_STORE_FOR_TEST}'"' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH}
elif [[ $BACKUP_STORE_TYPE = "cifs" ]]; then
BACKUP_STORE_FOR_TEST=`yq e 'select(.spec.containers[0] != null).spec.containers[0].env[1].value' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH} | awk -F ',' '{print $3}' | sed 's/ *//'`
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${BACKUP_STORE_FOR_TEST}'"' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH}
fi

yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[4].value="'${LONGHORN_UPGRADE_TYPE}'"' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH}
Expand Down
10 changes: 9 additions & 1 deletion test_framework/scripts/longhorn-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,10 @@ create_longhorn_namespace(){
install_backupstores(){
MINIO_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/minio-backupstore.yaml"
NFS_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/nfs-backupstore.yaml"
CIFS_BACKUPSTORE_URL="https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/backupstores/cifs-backupstore.yaml"
kubectl create -f ${MINIO_BACKUPSTORE_URL} \
-f ${NFS_BACKUPSTORE_URL}
-f ${NFS_BACKUPSTORE_URL} \
-f ${CIFS_BACKUPSTORE_URL}
}


Expand Down Expand Up @@ -396,6 +398,9 @@ run_longhorn_upgrade_test(){
elif [[ $BACKUP_STORE_TYPE = "nfs" ]]; then
BACKUP_STORE_FOR_TEST=`yq e 'select(.spec.containers[0] != null).spec.containers[0].env[1].value' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH} | awk -F ',' '{print $2}' | sed 's/ *//'`
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${BACKUP_STORE_FOR_TEST}'"' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH}
elif [[ $BACKUP_STORE_TYPE = "cifs" ]]; then
BACKUP_STORE_FOR_TEST=`yq e 'select(.spec.containers[0] != null).spec.containers[0].env[1].value' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH} | awk -F ',' '{print $3}' | sed 's/ *//'`
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${BACKUP_STORE_FOR_TEST}'"' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH}
fi

yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[4].value="'${LONGHORN_UPGRADE_TYPE}'"' ${LONGHORN_UPGRADE_TESTS_MANIFEST_FILE_PATH}
Expand Down Expand Up @@ -450,6 +455,9 @@ run_longhorn_tests(){
elif [[ $BACKUP_STORE_TYPE = "nfs" ]]; then
BACKUP_STORE_FOR_TEST=`yq e 'select(.spec.containers[0] != null).spec.containers[0].env[1].value' ${LONGHORN_TESTS_MANIFEST_FILE_PATH} | awk -F ',' '{print $2}' | sed 's/ *//'`
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${BACKUP_STORE_FOR_TEST}'"' ${LONGHORN_TESTS_MANIFEST_FILE_PATH}
elif [[ $BACKUP_STORE_TYPE = "cifs" ]]; then
BACKUP_STORE_FOR_TEST=`yq e 'select(.spec.containers[0] != null).spec.containers[0].env[1].value' ${LONGHORN_TESTS_MANIFEST_FILE_PATH} | awk -F ',' '{print $3}' | sed 's/ *//'`
yq e -i 'select(.spec.containers[0] != null).spec.containers[0].env[1].value="'${BACKUP_STORE_FOR_TEST}'"' ${LONGHORN_TESTS_MANIFEST_FILE_PATH}
fi

if [[ "${TF_VAR_use_hdd}" == true ]]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
sudo systemctl restart guestregister # Sometimes registration fails on first boot.
sudo zypper ref
sudo zypper install -y -t pattern devel_basis
sudo zypper install -y open-iscsi nfs-client cryptsetup device-mapper
sudo zypper install -y open-iscsi nfs-client cryptsetup device-mapper samba
sudo systemctl -q enable iscsid
sudo systemctl start iscsid

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
sudo systemctl restart guestregister # Sometimes registration fails on first boot.
sudo zypper ref
sudo zypper install -y -t pattern devel_basis
sudo zypper install -y open-iscsi nfs-client cryptsetup device-mapper
sudo zypper install -y open-iscsi nfs-client cryptsetup device-mapper samba
sudo systemctl -q enable iscsid
sudo systemctl start iscsid

Expand Down

0 comments on commit 88cd8b8

Please sign in to comment.