diff options
-rwxr-xr-x | testresults-loc.py | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/testresults-loc.py b/testresults-loc.py new file mode 100755 index 0000000..3309545 --- /dev/null +++ b/testresults-loc.py @@ -0,0 +1,143 @@ +''' +Created on May 14, 2019 + +__author__ = "Vineela Tummalapalli" +__copyright__ = "Copyright 2019-2022 Intel Corp." +__credits__ = ["Vineela Tummalapalli"] +__license__ = "GPL" +__version__ = "2.0" +__maintainer__ = "Vineela Tummalapalli" +__email__ = "vineela.tummalapalli@intel.com" +''' + +''' +This script will clone the testResuls from the repository for each Release. Copies the +testResults to appropriate location which is testresults-intel. Will generate merged +testReport for all the tests using resulttool. Pushes the testreport to the repository. +''' + +import os +import os.path +import pygit2 +import sys +import datetime +import shutil +from shutil import rmtree, copyfile +from utils import where_am_i, split_thing, rejoin_thing +from rel_type import release_type +from pygit2 import Repository, clone_repository, RemoteCallbacks, Keypair + + +def get_repo(codename, repo_url): + #repo_url = 'git@push.yoctoproject.org:yocto-qa-testresults' + CWD = os.getcwd() + HOME = os.path.expanduser("~") + ID_RSA_PUB = os.path.join(HOME, '.ssh/id_rsa.pub') + ID_RSA = os.path.join(HOME, '.ssh/id_rsa') + if repo_url == 'git@push.yoctoproject.org:yocto-testresults-contrib': + repo_path = os.path.join(CWD, 'yocto-testresults-contrib') + repo_name = 'Qa-testResults' + #keypair = pygit2.Keypair("git", "/home/pokybuild/.ssh/id_rsa.pub", "/home/pokybuild/.ssh/id_rsa", "") + keypair = pygit2.Keypair("git", ID_RSA_PUB, ID_RSA, "") + callbacks = pygit2.RemoteCallbacks(credentials = keypair) + else: + repo_path = os.path.join(CWD, 'poky') + repo_name = 'poky' + callbacks = None + if os.path.exists(repo_path): + print "\n Found an existing repo. Nuking it." + rmtree(repo_path) + print "Cloning the repo: %s" %repo_name + print "repo_path: %s" %repo_path + # if you pass in a non-existant branch, this will fail. Lets catch it and exit gracefully. + try: + repo = clone_repository(repo_url,repo_path, callbacks=callbacks) + except: + print "could'nt checkout a %s repo with branch %s. Check the branch name you passed in" %(repo_name, codename) + sys.exit() + #Check if we are at the right repository and branch + head = repo.head + branch_name = head.name + print "We are now on branch: %s\n" %branch_name + return repo + + +if __name__ == '__main__': + + #get_repo('master', 'git@push.yoctoproject.org:yocto-qa-testresults') + #get_repo('master', 'http://git.yoctoproject.org/git/poky') + #get_repo('master', 'git://git.yoctoproject.org/git/poky') + os.system("clear") + print + + PATH_VARS = where_am_i() + VHOSTS = PATH_VARS['VHOSTS'] + AB_HOME = PATH_VARS['AB_HOME'] + AB_BASE = PATH_VARS['AB_BASE'] + DL_HOME = PATH_VARS['DL_HOME'] + DL_BASE = PATH_VARS['DL_BASE'] + + parser = optparse.OptionParser() + parser.add_option("-i", "--build-id", + type = "string", dest = "build" + help = "Required. Release candidate name including rc#. i.e. yocto-2.7.rc1, yocto-2.7_M1.rc3, etc.") + parser.add_option("-b", "--branch", + type = "string", dest = "branch" + help = "Required. Name of the branch like Sumo, Thud, Warrior, etc.") + parse.add_option("-p", "--poky-ver" + type = "string", dest = "poky", + help = "Required. Specify the poky version. i.e. 19.0.3, etc.") + (options, args) = parser.parse_args() + + if not (options.build and options.branch and options.poky): + print "You must specify the RC, branch and version." + print "Please use -h or --help for options." + sys.exit() + + if options.build: + VARS = release_type(options.build) + RC = VARS["RC"] + RELEASE = VARS["RELEASE"] + REL_ID = VARS["REL_ID"] + RC_DIR = VARS["RC_DIR"] + REL_TYPE = VARS["REL_TYPE"] + MILESTONE = VARS["MILESTONE"] + RC_SOURCE = os.path.join(AB_BASE, RC_DIR) + RELEASE_DIR = os.path.join(AB_BASE, RELEASE) + else: + print "Build Id is a required argument." + print "Please use -h or --help for options." + sys.exit() + + for thing in ['RC_DIR', 'RELEASE', 'RC', 'REL_ID', 'REL_TYPE', 'MILESTONE']: + print "%s: %s" %(thing, VARS[thing]) + print "RC_SOURCE: %s" %RC_SOURCE + print "RELEASE_DIR: %s" %RELEASE_DIR + + POKY_VER = options.poky + CODENAME = options.branch + BRANCH = CODENAME + DEFAULT_TAG = "-".join([BRANCH,POKY_VER]) + + HOME = os.getcwd() + POKY_REPO = os.path.join(HOME, "poky") + POKY_REPO_URL = 'http://git.yoctoproject.org/git/poky' + TEST_RESULTS_REPO = os.path.join(HOME, "yocto-testresults-contrib") + TEST_RESULTS_REPO_URL = 'git@push.yoctoproject.org:yocto-testresults-contrib' + TEST_RESULTS_DIR = os.path.join(TEST_RESULTS_REPO,'testresults-intel') + RESULT_TOOL = os.path.join(POKY_REPO,'/scripts/resulttool') + #Below Code block clones the repo yocto-qa-testresults, copies the testresults-intel to + #Releaes staging directory, creates a testreport using resulttool and appends it with header. + #Clone the staging yocto-qa-testresults repository + repo = get_repo(BRANCH, TEST_RESULTS_REPO_URL) + + #copy the testresults-intel to Release Directory + os.system ("cp -r %s %s" %(TEST_RESULTS_DIR, RELEASE_DIR)) + + #Generate final report using resulttool + get_repo(BRANCH, POKY_REPO_URL) + os.chdir(RELEASE_DIR) + os.system ("%s report . > testreport.txt" %RESULT_TOOL) + os.system ("cat %s/header.txt testreport.txt > testreport.txt" %TEST_RESULTS_REPO) + + #copy_testresults() |