Esempio n. 1
0
 def test_02(self, ctx):
     fzero = False
     fexts = False
     if not ctx.get('dry_run', False):
         title = TITLE
         os0.trace_debug("- Inititializing ...")
         os0.set_debug_mode(False)
         os0.trace_debug("TEST FAILED!!!!")
         os0.set_debug_mode(True)
         os0.trace_debug("- Inititializing (2) ...")
         os0.wlog(title)
         os0.wlog("- os0 version:", os0.version)
         os0.wlog("- platform:", _platform)
         os0.set_tlog_file("os0_test.log", echo=ctx['opt_echo'])
         try:
             tlog_fd = open(os0.tlog_fn, 'r')
             fexts = True
             tlog_fd.seek(0, os.SEEK_END)
             if tlog_fd.tell() == 0:
                 fzero = True
             tlog_fd.close()
         except:
             pass
     sts = self.Z.test_result(ctx, "Check for empty tracelog", True, fexts)
     if sts == TEST_SUCCESS:
         sts = self.Z.test_result(ctx, "Check for empty tracelog", True,
                                  fzero)
     return sts
Esempio n. 2
0
 def main(self):
     """Unit test main."""
     # Check for target software version
     required_version = os.environ.get(self.module_id.upper() + '_VERSION')
     if not required_version:
         required_version = REQ_TEST_VERSION
     pkg_version = build.version()
     if required_version and pkg_version.find(required_version) < 0:
         print "Test not executable: invalid version!"
         print "Required version:", required_version
         print "Package version:", pkg_version
         return TEST_FAILED
     # Need debug mode to avoid security fault in Linux
     os0.set_debug_mode(True)
     title = "%s regression test. Version: %s" % (self.module_id,
                                                  REQ_TEST_VERSION)
     # Remove test log file if executed previous crashed test
     tlog_fn = self.module_id + "_test.log"
     os0.set_tlog_file(tlog_fn)
     tlog_pathname = os0.tlog_fn
     # Set no file log
     os0.set_tlog_file('', echo=True)
     if os.path.isfile(tlog_pathname):
         os.remove(tlog_pathname)
     # Test if running in travis-ci emulator (DEV_ENVIRONMENT)
     if 'DEV_ENVIRONMENT' in os.environ \
             and os.environ['DEV_ENVIRONMENT'].find(self.module_id):
         LOCAL_ECHO = False
     else:
         LOCAL_ECHO = True
     tlog_fn = './' + self.module_id + "_test.log"
     os0.set_tlog_file(tlog_fn, new=True, echo=LOCAL_ECHO)
     os0.wlog(title)
     # Test execution body
     test_num = 0
     sts = 0
     for i in range(MAX_TEST_NUM):
         tname = "test_{0:02}".format(test_num)
         if hasattr(self, tname):
             sts = getattr(self, tname)(test_num)
             if sts:
                 break
         test_num += 1
     # Result
     if sts == 0:
         os0.wlog("Ran {0} {1} tests".format(self.test_ctr, MODULE_ID))
     else:
         os0.wlog("****** Test {0} failed ******".format(MODULE_ID))
     return sts
Esempio n. 3
0
def main(module_id):
    """Unit test main."""
    # pdb.set_trace()
    # Check for target software version
    required_version = os.environ.get(module_id.upper() + '_VERSION')
    if not required_version:
        required_version = REQ_TEST_VERSION
    # pkg_version = lxml.version()
    # if required_version and pkg_version.find(required_version) < 0:
    #     os0.wlog("Test not executable: invalid version!")
    #     os0.wlog("Required version:", required_version)
    #     os0.wlog("Package version:", pkg_version)
    #     return TEST_FAILED
    # Need debug mode to avoid security fault in Linux
    os0.set_debug_mode(True)
    T = Z0tester_lxml(module_id, REQ_TEST_VERSION, ctr=0)
    return T.all_tests()
Esempio n. 4
0
 def __init__(self, ctx):
     self.hostname = ctx['hostname']
     os0.set_debug_mode(ctx['dbg_mode'])
     self.prodhost = ctx['production_host']
     self.devhost = ctx['development_host']
     self.mirrorhost = ctx['mirror_host']
     self.pgdir = ctx['pg_dir']
     self.mysqldir = ctx['mysql_dir']
     homedir = os.path.expanduser("~")
     self.ftp_cfn = homedir + "/" + ctx['ftp_script']
     self.flist = homedir + "/" + ctx['list_file']
     os0.set_tlog_file(ctx['logfn'])
     # Log begin execution
     os0.wlog("Restore configuration files", __version__)
     # Simulate backup
     self.dry_run = ctx['dry_run']
     if ctx['saveset'] == "bckdb" or \
             ctx['saveset'] == "bckconf" or \
             ctx['saveset'] == "bckwww":
         if self.hostname == self.prodhost:
             os0.wlog("Running on production machine")
             if ctx['alt']:
                 self.bck_host = self.mirrorhost
                 self.fconf = homedir + "/" + \
                     ctx['no_translation']
             else:
                 self.bck_host = self.devhost
                 self.fconf = homedir + "/" + \
                     ctx['data_translation']
         elif self.hostname == self.mirrorhost:
             os0.wlog("Running on mirror machine")
             if ctx['alt']:
                 self.bck_host = self.prodhost
                 self.fconf = homedir + "/" + \
                     ctx['no_translation']
             else:
                 self.bck_host = self.devhost
                 self.fconf = homedir + "/" + \
                     ctx['data_translation']
         elif self.hostname == self.devhost:
             os0.wlog("This command cannot run on development machine")
             if not ctx['dry_run']:
                 raise Exception("Command aborted due invalid machine")
         else:
             os0.wlog("Unknown machine - Command aborted")
             if not ctx['dry_run']:
                 raise Exception("Command aborted due unknown machine")
     elif ctx['saveset'] == "restdb" or \
             ctx['saveset'] == "restconf" or \
             ctx['saveset'] == "restwww":
         if self.hostname == self.prodhost:
             os0.wlog("This command cannot run on production machine")
             if not ctx['dry_run']:
                 raise Exception("Command aborted due production machine")
         elif self.hostname == self.mirrorhost:
             os0.wlog("Running on mirror machine")
             if ctx['alt']:
                 self.bck_host = self.prodhost
                 self.fconf = homedir + "/" + \
                     ctx['no_translation']
             else:
                 self.bck_host = self.devhost
                 self.fconf = homedir + "/" + \
                     ctx['data_translation']
         elif self.hostname == self.devhost:
             os0.wlog("Running on development machine")
             if ctx['alt']:
                 self.bck_host = self.mirrorhost
                 self.fconf = homedir + "/" + \
                     ctx['data_translation']
             else:
                 self.bck_host = self.devhost
                 self.fconf = homedir + "/" + \
                     ctx['data_translation']
         else:
             os0.wlog("Unknown machine - Command aborted")
             if not ctx['dry_run']:
                 raise Exception("Command aborted due unknown machine")
     # May be (.gz or .bz2)
     self.tar_ext = ctx['tar_ext']
     # May be (z or j)
     self.tar_opt = ctx['tar_opt']
     # May be (null or .sql)
     self.pre_ext = ctx['pre_ext']
     # May be (null or .sql)
     self.sql_ext = ctx['sql_ext']
     self.psql_uu = ctx['pgsql_user']
     self.psql_db = ctx['pgsql_def_db']
     self.mysql_uu = ctx['mysql_user']
     self.mysql_db = ctx['mysql_def_db']
     self.pid = os.getpid()
     self.ftp_rootdir = ""
     self.ftp_dir = ""
     self.dbtype = ""
     self.create_dict()
Esempio n. 5
0
 def SetUp(self, ctx):
     """Remove test log file if executed previous crashed test"""
     # Need debug mode to avoid security fault in Linux
     os0.set_debug_mode(True)