def is_build_complete(self, build_task_id):
   jita=JitaRest()
   status = jita.get_build_task(build_task_id).get_status()
   if status not in ["passed", "failed", "skipped", "aborted"]:
     return False
   else:
     return True
  def wait_for_jita_test_results(self, job_info, timeout=18000,
                                 poll_period=600):
    # Sleep for 10 minutes before starting polling for results.
    expired_time = 0
    unfinished_jobs = job_info.values()

    jita = JitaRest()
    while len(unfinished_jobs) and expired_time < timeout:
      for job_id in job_info.values():
        if self.did_jita_task_finish(job_id):
          if job_id in unfinished_jobs:
            unfinished_jobs.remove(job_id)

      time.sleep(poll_period)
      expired_time += poll_period

    for commit, job_id in job_info.iteritems():
      response = jita.get_task(job_id)
      if response.get_status() not in ["passed", "completed"]:
        self.global_results_dict[commit] = False
      else:
        test_results = response.get_test_results()
        #test_results = response.get_test_result_dict()
        for test, result in test_results.test_result_dict.iteritems():
          if result.get_status() != "Succeeded":
            INFO("Test %s failed with status %s" % (test, result.get_status()))
            self.global_results_dict[commit] = False
            break
          self.global_results_dict[commit] = True

    return True
 def did_jita_task_finish(self, job_id):
   jita = JitaRest()
   response = jita.get_task(job_id)
   status = response.get_status()
   if status in ["passed", "killed", "failed", "completed"]:
     return True
   else:
     return False
  def run_test_on_jita(
    self, cluster, commit_id=None, build_url=None, job_ids_list=None,
    index=None, hypervisor=None, hypervisor_version=None, branch=None,
    input_type="build_url", build_type="opt", test=None, username=None,
    test_upgrade=None, base_commit=None):

    # NEEDS CHANGE
    if not hypervisor:
      hypervisor = FLAGS.hypervisor 
    if not hypervisor_version:
      hypervisor_version = FLAGS.hypervisor_version
    if not branch:
      branch = FLAGS.branch
    if not test:
      test = FLAGS.test_name
    if not username:
      username = USERNAME
    test_framework = FLAGS.test_framework

    if test_upgrade is None:
      test_upgrade = FLAGS.upgrade_test
      base_commit=FLAGS.upgrade_base_commit

    if test_upgrade:
      phoenix_commit = base_commit
    else:
      phoenix_commit = commit_id

    if not self.image_cluster( cluster, phoenix_commit, build_url, USERNAME,
                              hypervisor, hypervisor_version, branch,
                              build_type):
      job_ids_list[index] = False
      ERROR("Imaging failed on cluster %s" % cluster)
      return False

    jita = JitaRest()
    jita_test = jita.get_test(test,test_framework)
    if test_upgrade:
      svm_installer_url = self.get_svm_installer(commit_id, branch, build_type)
      INFO("Found build %s " % svm_installer_url)
      if not svm_installer_url:
        return False

      args_map = {"target_rel" : svm_installer_url}
    else:
      args_map = None

    INFO("Going to submit task for commit id: %s" % commit_id)
    response_obj = jita.submit_task(
      cluster, commit_id, branch, [jita_test.get_id()],
      test_framework=test_framework, label="auto_bisector", args_map=args_map)

    if response_obj.is_success():
      job_ids_list[index] = response_obj.get_task_id()
      return True
    else:
      ERROR("Task submit failed: %s" % response_obj.get_message())
      return False
  def wait_for_build_to_complete(self, build_task_id, timeout=7200,
                                 poll_period=180):
    expired_time = 0
    while expired_time < timeout:
      if self.is_build_complete(build_task_id):
        break
      time.sleep(poll_period)
      expired_time += poll_period

    jita=JitaRest()
    status = jita.get_build_task(build_task_id).get_status()
    if status != "passed":
      ERROR("Timed out waiting for build to complete or build failed. Status:"
            " %s" % status)
      return False
    return True
  def get_svm_installer(self, commit_id, branch, build_type):
    """
    Get the build location for th given commit id and branch.
    """  
    INFO("Getting installer for commit %s" % commit_id)
    filer = FLAGS.lab
    jita=JitaRest()
    build_url = jita.get_build_url(commit_id, build_type, filer)
    if build_url:
      INFO("Found build %s" % build_url)
      return build_url

    INFO("Checking if build is in progress")
    build_task_id = jita.check_build_in_progress(commit_id, branch, build_type,
                                                 filer)

    if build_task_id:
      status = jita.get_build_task(build_task_id).get_status()

    if not build_task_id or status in ["failed", "aborted", "skipped"]:
      INFO("Could not find an existing build. Hence requesting build")
      res = jita.request_build(commit_id, branch, build_type, filer)
      if res.get_status():
        build_task_id = res.get_build_task_id()
      else:
        ERROR("Build request for commit id %s failed" % commit_id)
        return False

    if self.wait_for_build_to_complete(build_task_id):
      return jita.get_build_url(commit_id, build_type, filer)

    return False
예제 #7
0
def get_commits_in_range(self, first_commit, last_commit, branch="master"):
    """
    Get all the commits in the range of the two commits.
    """
    jita = JitaRest()
    commits = jita.get_commits(branch=branch, num_commits=50)
    commit_range = []
    flag = False
    for commit in commits:
        if commit['commit_id'] == last_commit:
            flag = True
        elif commit['commit_id'] == first_commit:
            commit_range.append(commit['commit_id'])
            break

        if flag:
            commit_range.append(commit['commit_id'])
    return commit_range
예제 #8
0
def get_latest_commit():
    jita = JitaRest()
    commit = jita.get_commits(branch="master")[0]
    return commit['commit_id']