diff options
author | Shwetha-H-Panduranga <shwetha@gluster.com> | 2011-09-12 14:17:46 +0530 |
---|---|---|
committer | Shwetha-H-Panduranga <shwetha@gluster.com> | 2011-09-12 14:17:46 +0530 |
commit | 5b847067495a65c71c56ad477780ed57e9e0fb2f (patch) | |
tree | 74bf52905a2032a268693eecca4e8f74e7dff693 /Libraries/Validate/ATFValidate.py | |
parent | 2bdd4eb2bef1f8611dc92c3c95a3d8e0d2c599a9 (diff) |
Adding ATF(Automated Tests Framework) files. This is the code developed for POC.
Diffstat (limited to 'Libraries/Validate/ATFValidate.py')
-rw-r--r-- | Libraries/Validate/ATFValidate.py | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/Libraries/Validate/ATFValidate.py b/Libraries/Validate/ATFValidate.py new file mode 100644 index 0000000..9cebbf8 --- /dev/null +++ b/Libraries/Validate/ATFValidate.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python + +import re +import ATFUtils + +def validate_replication(**arguments): + """ + Description: + Validate whether the files are replicated or not + + Parameters: + arguments: key=value pair. + key: file1..filen + value: host:exportdir:filename comabination + + Example:f1 = 'host1:export1:file1.txt', f2 = 'host1:export2:file1.txt + + Returns: + Success: 0 + Failure: 1 + """ + + Map = [] + command = "ls" + + for key in arguments.keys(): + value = arguments[key] + hostkey, exportkey, filename = re.split(":", value) + + host = ATFUtils.TestEnvObj.get_host(hostkey) + if (host == ''): + ATFUtils.Logger.error("Host %s Not defined in GlobalParam File" % + hostkey) + return 1 + + exportdir = ATFUtils.TestEnvObj.get_exportdir(exportkey) + if (exportdir == ''): + ATFUtils.Logger.error( + "ExportDir %s Not defined in GlobalParam File" % exportkey) + return 1 + else: + abspath = exportdir + "/" + filename + Map.append({'host':host, 'path':abspath}) + + + for item in Map: + arguments['host'] = item['host'] + arguments['user'] = 'root' + abspath = item['path'] + val_command = command + " " + abspath + + status, stdin, stdout, stderr = ATFUtils.execute_command(val_command, + **arguments) + + if ( status == 1): + ATFUtils.Logger.error("Error in Validation") + else: + status = False + readout = stdout.readlines() + readerr = stderr.readlines() + + if( len(readerr) == 0): + for line in readout: + if ( re.match(abspath, line)): + status = True + else: + status = False + + if (status == False): + ATFUtils.Logger.error("Validation Failed: Path Not found - %s" % abspath) + return + else: + continue + + if(status == True): + ATFUtils.Logger.info("Validate_replication Successfully Complete") + + return 0 + |