diff --git a/src/test/grayscale_upgrade/upgradeCheck.py b/src/test/grayscale_upgrade/upgradeCheck.py index 48b5354c5..495d63171 100644 --- a/src/test/grayscale_upgrade/upgradeCheck.py +++ b/src/test/grayscale_upgrade/upgradeCheck.py @@ -211,12 +211,12 @@ class Pterodb(): def spliceSqlFile(self, fileDir, scriptType="_"): try: - NewVersionNum = self.getNewVersionNum() + NewVersionNum = self.getNewVersionNum() #Version number and file handling BaseVersionNum = self.upgrade_from - fileAllList = os.listdir(fileDir) + fileAllList = os.listdir(fileDir) #File and directory operations privateFileAllList = [] keyElement = [] - if fileDir != check_upgrade_path: + if fileDir != check_upgrade_path: #Filter the script privateFileAllList = os.listdir(private_dict[fileDir]) commonScriptList = list(set(fileAllList) & set(privateFileAllList)) commonScriptList = [script for script in commonScriptList if "407" not in script] @@ -237,7 +237,7 @@ class Pterodb(): if key not in name: errMsg = "The script {0} name does not meet the specifications, it needs to contain {1}".format(name, key) self.writeLogFile(errMsg) - raise Exception(errMsg) + raise Exception(errMsg) #Exception handling result = [] if len(allList) != 0: @@ -264,9 +264,9 @@ class Pterodb(): file.write("START TRANSACTION;") file.write(os.linesep) file.write("SET IsInplaceUpgrade = on;") - file.write(os.linesep) - self.writeLogFile("fileDir is {0}, The list of files being written is {1}".format(fileDir, fileList)) - for each_file in fileList: + file.write(os.linesep) #Open the file and write the transaction and setting statements + self.writeLogFile("fileDir is {0}, The list of files being written is {1}".format(fileDir, fileList)) #Write file information + for each_file in fileList: #Process each file if os.path.isfile("%s/%s" % (fileDir, each_file)): each_file_with_path = "%s/%s" % (fileDir, each_file) elif os.path.isfile("%s/%s" % (private_dict[fileDir], each_file)): @@ -278,27 +278,34 @@ class Pterodb(): for txt in open(each_file_with_path,'r'): file.write(txt) file.write(os.linesep) - file.write("COMMIT;") + file.write("COMMIT;") #Write a transaction commit statement file.write(os.linesep) - file.close() + file.close() #Close the file and complete the information record self.writeLogFile("Complate file {0} with the list:{1}".format(fileName, fileList)) - def checkSqlResult(self, Type = "upgrade"): + def checkSqlResult(self, Type = "upgrade"): #Check whether the SQL execution results contain ERROR cmd = "grep ERROR " + exec_sql_log (status, output) = commands.getstatusoutput(cmd) if(output.find("ERROR") != -1): raise Exception("Failed to execute catalog %s" % Type) - cmd = "grep PANIC " + exec_sql_log + cmd = "grep PANIC " + exec_sql_log #Check whether the SQL execution results contain PANIC (status, output) = commands.getstatusoutput(cmd) if(output.find("PANIC") != -1): raise Exception("Failed to execute catalog %s" % Type) - cmd = "grep FATAL " + exec_sql_log + cmd = "grep FATAL " + exec_sql_log #Check whether the execution result contains FATAL (status, output) = commands.getstatusoutput(cmd) - if(output.find("FATAL") != -1): + if(output.find("FATAL") != -1): raise Exception("Failed to execute catalog %s" % Type) def upgrade_one_database(self, db_name): """ + Upgrade a database + + Parameters : + db _ name ( str ) : Database name + + Anomaly : + Exception : An exception is thrown when the upgrade directory fails """ try: if db_name == "postgres": @@ -321,6 +328,13 @@ class Pterodb(): def rollback_one_database(self, db_name): """ + Roll back a database. + + Args: + db_name (str): The name of the database. + + Raises: + Exception: If rolling back the catalogs fails. """ try: if db_name == "postgres":