2 Library OperatingSystem
5 Library RequestsLibrary
6 Library backuprestore/JsonDiffTool.py
7 Resource ClusterManagement.robot
8 Resource ../variables/daexim/DaeximVariables.robot
9 Resource DaeximKeywords.robot
10 Resource ../variables/backuprestore/BackupRestoreVariables.robot
11 Resource ../variables/Variables.robot
16 Set Global Variable If It Does Not Exist
17 [Documentation] Checks whether a given variable has been defined. If it does not, sets the passed value to that global variable
18 [Arguments] ${name} ${value}
19 ${status} ${message}= Run Keyword And Ignore Error Variable Should Exist ${name}
20 IF "${status}" == "FAIL" Set Global Variable ${name} ${value}
23 [Documentation] schedule a basic export/backup, waiting for completion
25 [Arguments] ${controller_index}
26 DaeximKeywords.Schedule Export ${controller_index}
27 DaeximKeywords.Verify Export Status ${EXPORT_SCHEDULED_STATUS} ${controller_index}
28 Builtin.Wait Until Keyword Succeeds
31 ... DaeximKeywords.Verify Export Status
32 ... ${EXPORT_COMPLETE_STATUS}
33 ... ${controller_index}
34 DaeximKeywords.Verify Export Files ${controller_index}
36 ConditionalBackupRestoreCheck
37 [Documentation] When enabled, performs a datastore export, then a backup, then a restore, then an export. The check is considered to be failed when exports before and after are different (two different json path files can be passed in order to filter certain subtrees from the export files before / after the export)
38 [Arguments] ${exclusionsConfigBefore}=${EMPTY} ${exclusionsConfigAfter}=${EMPTY} ${exclusionsOperationalBefore}=${EMPTY} ${exclusionsOperationalAfter}=${EMPTY} ${odlControllerIndex}=${FIRST_CONTROLLER_INDEX}
39 Set Global Variable If It Does Not Exist \${BR_TESTING_ENABLED} FALSE
40 IF '${BR_TESTING_ENABLED}'!='true' RETURN
42 ... ${exclusionsConfigBefore}
43 ... ${exclusionsConfigAfter}
44 ... ${exclusionsOperationalBefore}
45 ... ${exclusionsOperationalAfter}
46 ... ${odlControllerIndex}
49 [Documentation] When enabled, performs a datastore export, then a backup, then a restore, then an export. The check is considered to be failed when exports before and after are different (two different json path files can be passed in order to filter certain subtrees from the export files before / after the export)
50 [Arguments] ${exclusionsConfigBefore}=${EMPTY} ${exclusionsConfigAfter}=${EMPTY} ${exclusionsOperationalBefore}=${EMPTY} ${exclusionsOperationalAfter}=${EMPTY} ${odlControllerIndex}=${FIRST_CONTROLLER_INDEX}
51 Log Performing backup-restore check
52 ${ARG_CONFIG_BEFORE}= Set Variable ' '
53 ${ARG_CONFIG_AFTER}= Set Variable ' '
54 ${ARG_OPER_BEFORE}= Set Variable ' '
55 ${ARG_OPER_AFTER}= Set Variable ' '
56 IF '${exclusionsConfigBefore}'!='${EMPTY}'
57 ${ARG_CONFIG_BEFORE}= '${exclusionsConfigBefore}'
59 ${ARG_CONFIG_BEFORE}= Set Variable ${None}
61 IF '${exclusionsConfigAfter}'!='${EMPTY}'
62 ${ARG_CONFIG_AFTER}= '${exclusionsConfigAfter}'
64 ${ARG_CONFIG_AFTER}= Set Variable ${None}
66 IF '${exclusionsOperationalBefore}'!='${EMPTY}'
67 ${ARG_OPER_BEFORE}= Normalize Path ${CURDIR}/${exclusionsOperationalBefore}
69 ${ARG_OPER_BEFORE}= Set Variable ${None}
71 IF '${exclusionsOperationalAfter}'!='${EMPTY}'
72 ${ARG_OPER_AFTER}= Normalize Path ${CURDIR}/${exclusionsOperationalAfter}
74 ${ARG_OPER_AFTER}= Set Variable ${None}
76 ${controller_index}= Builtin.Convert To Integer ${odlControllerIndex}
77 Perform Export ${controller_index}
78 ${host}= ClusterManagement.Resolve IP Address For Member ${controller_index}
79 ${directory_exist}= Builtin.Run Keyword And Return Status
80 ... OperatingSystem.Directory Should Exist
81 ... ${EXP_DIR}/${RELATIVE_BEFORE_BACKUP_DIR}
83 Cleanup Directory ${EXP_DIR}/${RELATIVE_BEFORE_BACKUP_DIR}
85 Copy Export Directory To Test VM ${host}
86 OperatingSystem.Move Directory ${EXP_DIR}${host} ${EXP_DIR}/${RELATIVE_BEFORE_BACKUP_DIR}
88 # TODO: Insert The Backup + Restore call here
90 Log doing the second export!
91 Perform Export ${controller_index}
92 Copy Export Directory To Test VM ${host}
93 ${directory_exist}= Builtin.Run Keyword And Return Status
94 ... OperatingSystem.Directory Should Exist
95 ... ${EXP_DIR}/${RELATIVE_AFTER_RESTORE_DIR}
97 Cleanup Directory ${EXP_DIR}/${RELATIVE_AFTER_RESTORE_DIR}
99 OperatingSystem.Move Directory ${EXP_DIR}${host} ${EXP_DIR}/${RELATIVE_AFTER_RESTORE_DIR}
100 log "Performing comparison"
101 ${differencesConfigDatastore}= Json Diff Check Keyword
102 ... ${EXP_DIR}/${RELATIVE_BEFORE_BACKUP_DIR}/${EXP_DATA_FILE}
103 ... ${EXP_DIR}/${RELATIVE_AFTER_RESTORE_DIR}/${EXP_DATA_FILE}
104 ... ${ARG_CONFIG_BEFORE}
105 ... ${ARG_CONFIG_AFTER}
106 ${differencesOperationalDatastore}= Json Diff Check Keyword
107 ... ${EXP_DIR}/${RELATIVE_BEFORE_BACKUP_DIR}/${EXP_OPER_FILE}
108 ... ${EXP_DIR}/${RELATIVE_AFTER_RESTORE_DIR}/${EXP_OPER_FILE}
109 ... ${ARG_OPER_BEFORE}
110 ... ${ARG_OPER_AFTER}
113 ... '${differencesConfigDatastore}'
114 ... Error: Diferences found in the config DS before backup / after restore
117 ... '${differencesOperationalDatastore}'
118 ... Error: Diferences found in the config DS before backup / after restore