check backup ouptut json (#2926)
<!-- PR description--> with update in CLI output, have updated the sanity checks #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [ ] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
6f99bba624
commit
55be2f4e2e
44
.github/workflows/sanity-test.yaml
vendored
44
.github/workflows/sanity-test.yaml
vendored
@ -103,14 +103,17 @@ jobs:
|
||||
run: |
|
||||
./corso backup create exchange \
|
||||
--user "${CORSO_M365_TEST_USER_ID}" \
|
||||
--hide-progress 2>&1 | tee $TEST_RESULT/backup_exchange.txt
|
||||
--hide-progress --json 2>&1 | tee $TEST_RESULT/backup_exchange.txt
|
||||
|
||||
if ! grep -q 'Completed' $TEST_RESULT/backup_exchange.txt
|
||||
then
|
||||
resultjson=$(sed -e '1,/Completed Backups/d' $TEST_RESULT/backup_exchange.txt )
|
||||
|
||||
if [[ $( echo $resultjson | jq -r '.[0] | .errorCount') -ne 0 ]]; then
|
||||
echo "backup was not successfull"
|
||||
exit 1
|
||||
fi
|
||||
echo result=$(grep -i -e 'Completed' $TEST_RESULT/backup_exchange.txt | awk '{print $2}') >> $GITHUB_OUTPUT
|
||||
|
||||
data=$( echo $resultjson | jq -r '.[0] | .id' )
|
||||
echo result=$data >> $GITHUB_OUTPUT
|
||||
|
||||
# list the backup exhange
|
||||
- name: Backup exchange list test
|
||||
@ -150,15 +153,16 @@ jobs:
|
||||
set -euo pipefail
|
||||
./corso backup create exchange \
|
||||
--user "${CORSO_M365_TEST_USER_ID}" \
|
||||
--hide-progress 2>&1 | tee $TEST_RESULT/backup_exchange_incremental.txt
|
||||
--hide-progress --json 2>&1 | tee $TEST_RESULT/backup_exchange_incremental.txt
|
||||
|
||||
if ! grep -q 'Completed' $TEST_RESULT/backup_exchange_incremental.txt
|
||||
then
|
||||
echo "backup was not successful"
|
||||
resultjson=$(sed -e '1,/Completed Backups/d' $TEST_RESULT/backup_exchange_incremental.txt )
|
||||
|
||||
if [[ $( echo $resultjson | jq -r '.[0] | .errorCount') -ne 0 ]]; then
|
||||
echo "backup was not successfull"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo result=$(grep -i -e 'Completed' $TEST_RESULT/backup_exchange_incremental.txt | awk '{print $2}') >> $GITHUB_OUTPUT
|
||||
echo result=$( echo $resultjson | jq -r '.[0] | .id' ) >> $GITHUB_OUTPUT
|
||||
|
||||
# test exchange restore
|
||||
- name: Backup incremantal exchange restore
|
||||
@ -188,15 +192,17 @@ jobs:
|
||||
set -euo pipefail
|
||||
./corso backup create onedrive \
|
||||
--user "${CORSO_M365_TEST_USER_ID}" \
|
||||
--hide-progress 2>&1 | tee $TEST_RESULT/backup_onedrive.txt
|
||||
--hide-progress --json 2>&1 | tee $TEST_RESULT/backup_onedrive.txt
|
||||
|
||||
if ! grep -q 'Completed' $TEST_RESULT/backup_onedrive.txt
|
||||
then
|
||||
resultjson=$(sed -e '1,/Completed Backups/d' $TEST_RESULT/backup_onedrive.txt )
|
||||
|
||||
if [[ $( echo $resultjson | jq -r '.[0] | .errorCount') -ne 0 ]]; then
|
||||
echo "backup was not successfull"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo result=$(grep 'Completed' $TEST_RESULT/backup_onedrive.txt | awk '{print $2}') >> $GITHUB_OUTPUT
|
||||
data=$( echo $resultjson | jq -r '.[0] | .id' )
|
||||
echo result=$data >> $GITHUB_OUTPUT
|
||||
|
||||
# list the bakcup onedrive
|
||||
- name: Backup onedrive list test
|
||||
@ -233,16 +239,18 @@ jobs:
|
||||
set -euo pipefail
|
||||
./corso backup create onedrive \
|
||||
--user "${CORSO_M365_TEST_USER_ID}"\
|
||||
--hide-progress 2>&1 | tee $TEST_RESULT/backup_onedrive_incremental.txt
|
||||
--hide-progress --json 2>&1 | tee $TEST_RESULT/backup_onedrive_incremental.txt
|
||||
|
||||
if ! grep -q 'Completed' $TEST_RESULT/backup_onedrive_incremental.txt
|
||||
then
|
||||
resultjson=$(sed -e '1,/Completed Backups/d' $TEST_RESULT/backup_onedrive_incremental.txt )
|
||||
|
||||
if [[ $( echo $resultjson | jq -r '.[0] | .errorCount') -ne 0 ]]; then
|
||||
echo "backup was not successfull"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo result=$(grep -i -e 'Completed' $TEST_RESULT/backup_onedrive_incremental.txt | awk '{print $2}') >> $GITHUB_OUTPUT
|
||||
|
||||
data=$( echo $resultjson | jq -r '.[0] | .id' )
|
||||
echo result=$data >> $GITHUB_OUTPUT
|
||||
|
||||
# test onedrive restore
|
||||
- name: Backup onedrive restore
|
||||
id: onedrive-incremental-restore-test
|
||||
|
||||
@ -158,7 +158,15 @@ func getAllSubFolder(
|
||||
user := client.UsersById(testUser)
|
||||
folder := user.MailFoldersById(folderID)
|
||||
|
||||
childFolder, err := folder.ChildFolders().Get(context.Background(), nil)
|
||||
var count int32 = 99
|
||||
|
||||
childFolder, err := folder.ChildFolders().Get(
|
||||
context.Background(),
|
||||
&users.ItemMailFoldersItemChildFoldersRequestBuilderGetRequestConfiguration{
|
||||
QueryParameters: &users.ItemMailFoldersItemChildFoldersRequestBuilderGetQueryParameters{
|
||||
Top: &count,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Printf("Error getting the drive: %v\n", err)
|
||||
os.Exit(1)
|
||||
@ -201,7 +209,15 @@ func checkAllSubFolder(
|
||||
user := client.UsersById(testUser)
|
||||
folder := user.MailFoldersById(folderID)
|
||||
|
||||
childFolder, err := folder.ChildFolders().Get(context.Background(), nil)
|
||||
var count int32 = 99
|
||||
|
||||
childFolder, err := folder.ChildFolders().Get(
|
||||
context.Background(),
|
||||
&users.ItemMailFoldersItemChildFoldersRequestBuilderGetRequestConfiguration{
|
||||
QueryParameters: &users.ItemMailFoldersItemChildFoldersRequestBuilderGetQueryParameters{
|
||||
Top: &count,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Printf("Error getting the drive: %v\n", err)
|
||||
os.Exit(1)
|
||||
@ -327,21 +343,23 @@ func checkFileData(
|
||||
|
||||
itemBuilder := client.DrivesById(driveID).ItemsById(*restoreData.GetId())
|
||||
|
||||
permissionColl, err := itemBuilder.Permissions().Get(context.TODO(), nil)
|
||||
if err != nil {
|
||||
fmt.Printf("Error getting permission: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if restoreData.GetFolder() != nil {
|
||||
permissionColl, err := itemBuilder.Permissions().Get(context.TODO(), nil)
|
||||
if err != nil {
|
||||
fmt.Printf("Error getting permission: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
userPermission := []string{}
|
||||
userPermission := []string{}
|
||||
|
||||
for _, perm := range permissionColl.GetValue() {
|
||||
userPermission = perm.GetRoles()
|
||||
}
|
||||
for _, perm := range permissionColl.GetValue() {
|
||||
userPermission = perm.GetRoles()
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(folderPermission[restoreName], userPermission) {
|
||||
fmt.Printf("Permission mismatch for %s.", restoreName)
|
||||
os.Exit(1)
|
||||
if !reflect.DeepEqual(folderPermission[restoreName], userPermission) {
|
||||
fmt.Printf("Permission mismatch for %s.", restoreName)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user