def step_impl(context):
    host = PlatformHelper.get_hostname().upper()

    context.kpi = KPI(testcase=context.tc.name,
                      category="Web",
                      start_time=strftime("%Y-%m-%dT%H:%M:%SZ", gmtime()),
                      name="Frejya View Machine",
                      result="Fail",
                      hostname=context.tc.machine_hostname,
                      ip=context.tc.machine_ip,
                      env=context.env)

    result = FreyjaPage.click_machine(host)

    try:
        (result).should.be(True)
    except AssertionError:
        context.kpi.message = "Frejya fail to view machine."
        FreyjaPage.quit()
    else:
        context.kpi.result = "SUCCESS"
    finally:
        context.kpi.end_time = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())
        context.kpi.write_to_elasticsearch(context.senddb)
        context.kpi = None
    context.execute_steps(unicode("When I wait 5 seconds"))
Example #2
0
    def setUpClass(cls):
        cls.start_time = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())
        cls.hostname = PlatformHelper.get_hostname()
        cls.ip = PlatformHelper.get_ip_address()

        cls.tr_id = "Test_Run"
        cls.tr = TestRun(cls.tr_id,
                         cls.start_time,
                         qa_env="QA12",
                         build=123,
                         client="Windows",
                         oem="MozyEnterprise",
                         runby="*****@*****.**")
        cls.tr.save_to_elasticsearch()

        cls.tc_id = "KAL-A"
        cls.tc = TestCase(testrun=cls.tr.name,
                          start_time=cls.start_time,
                          hostname=cls.hostname,
                          product="mozypro",
                          ip=cls.ip,
                          tags=["smoke", "activate", "windows", "keyless"],
                          _id=cls.tc_id,
                          build="111")
        result = cls.tc.write_to_elasticsearch()
 def __init__(self,
              testrun=None,
              start_time=None,
              duration=None,
              tags=None,
              feature=None,
              summary=None,
              ip=None,
              hostname=None,
              logfile=None,
              product=None,
              _id=None,
              build=None,
              error=None,
              end_time=None,
              thost=None):
     self.testrun = testrun
     self.start_time = start_time or strftime("%Y-%m-%dT%H:%M:%SZ",
                                              gmtime())
     self.duration = duration or 0
     self.tags = tags or []
     self.summary = summary
     self.feature = feature
     self.logfile = logfile
     self.machine_ip = ip or PlatformHelper.get_ip_address()
     self.machine_hostname = hostname or PlatformHelper.get_hostname()
     self.product = product
     self.test_result = "unknown"
     self.id = _id
     self.name = self.id
     self.build = build or "-999"
     self.error = error
     self.thost = thost
     self.end_time = end_time
def before_scenario(context, scenario):

    testrun = RUNNER_CONFIG.get('TESTRUN') or 'testrun'
    context.log_starttime = strftime("%Y-%m-%dT%H:%M:%SZ", localtime())
    start_time = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())
    hostname = PlatformHelper.get_hostname()
    ip = PlatformHelper.get_ip_address()

    product = RUNNER_CONFIG.get("PRODUCT")
    build = RUNNER_CONFIG.get('BUILD')
    context.senddb = RUNNER_CONFIG.get('DATABASE_ENABLED')
    context.env = RUNNER_CONFIG.get('ENVIRONMENT')

    logger_path = os.path.join(ConfigAdapter.get_log_path(), testrun)
    tc_prefix = ConfigAdapter.get_testlink_prefix(product)

    match = filter(lambda x: x.find(tc_prefix) >= 0, scenario.tags)

    if len(match)>0:
        # differentiate scenarios in scenario outline
        if hasattr(context, 'active_outline') and type(context.active_outline) == behave.model.Row:
            suffix = match.pop()
            for example_key in context.active_outline:
                suffix += ".%s" % (example_key)
            tc_id = testrun + "_" + suffix
        else:
            tc_id = testrun + "_" + match.pop()
    else:
        #no test link project id foud
        tc_id = hashlib.md5(testrun + "_" + scenario.name.encode()).hexdigest()

    if not FileHelper.dir_exist(logger_path):
        FileHelper.create_directory(logger_path)
    logger_filename = "%s.log" % (tc_id)
    logfile = os.path.join(logger_path, logger_filename)

    client_ip = PlatformHelper.get_ip_address()

    LogHelper.create_logger(logfile, fmt=client_ip+" %(asctime)s %(levelname)s " + product+" | %(message)s |")

    tc = TestCase(testrun=testrun, start_time=start_time, hostname=hostname, product=product,
                  ip=ip, summary=scenario.name, feature=scenario.filename, tags=scenario.tags, logfile=logfile, _id=tc_id, build=build)
    context.tc = tc

    LogHelper.info("test start: " + scenario.name)
Example #5
0
    def __init__(self,
                 _id=None,
                 testcase=None,
                 category=None,
                 name=None,
                 apimethod=None,
                 result=None,
                 start_time=None,
                 end_time=None,
                 apicode=None,
                 exterrorcode=None,
                 message=None,
                 throughput=None,
                 duration=None,
                 thost=None,
                 ip=None,
                 hostname=None,
                 env=None,
                 client=None):
        self.testcase = testcase or "Unknown"
        self.env = env or "PROD"
        self.client = client
        self.category = category
        self.name = name
        self.apimethod = apimethod
        self.apicode = apicode
        self.exterrorcode = exterrorcode
        self.result = result
        self.message = message

        self.start_time = start_time or strftime("%Y-%m-%dT%H:%M:%SZ",
                                                 gmtime())
        self.end_time = end_time or strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())

        self.machine_hostname = hostname or PlatformHelper.get_hostname()
        self.machine_ip = ip or PlatformHelper.get_ip_address()

        self.throughput = throughput
        self.duration = duration
        self.thost = thost
        self.id = _id