def t16(home): pretty = '%s t16' % __file__ print(pretty) config_key = "auth" config_file = "jenkins.json" create_default(home.path) authkeys = load_jenkins(home.path) authkeys[config_key] = {JENKINS_WITH_AUTH: {'method': 'basic', 'user': '******', 'password': '******'}} path = os.path.join(home.path, '.ave', 'config', config_file) with open(path, 'w') as f: json.dump(authkeys, f, indent=4) w = Workspace(home=home.path) try: w.download_jenkins(JOB_ID, base=JENKINS_WITH_AUTH) except Exception, e: if "Invalid authentication to" not in str(e): print('FAIL %s: unexpected exception: %s' % (pretty, str(e))) return False return True
def t15(home): pretty = '%s t15' % __file__ print(pretty) # Making sure that we don't actually use real config that might have access create_default(home.path) w = Workspace(home=home.path) try: w.download_jenkins(JOB_ID, base=JENKINS_WITH_AUTH) except Exception, e: if "requires authentication" not in str(e) \ or "please add to jenkins.json" not in str(e): print('FAIL %s: unexpected exception: %s' % (pretty, str(e))) return False return True
def t13(): pretty = '%s t13' % __file__ print(pretty) base = 'http://android-ci.cnbj.sonyericsson.net' build = '7' # no artifacts in this build, for sure w = Workspace() try: w.download_jenkins(JOB_ID, build, timeout=300, base=base) print('FAIL %s: did not raise exception' % pretty) w.delete() return False except Exception, e: if not str(e).startswith('job has no artifacts'): print('FAIL %s: wrong error: %s' % (pretty, e)) w.delete() return False
def t05(): pretty = '%s t5' % __file__ print(pretty) w = Workspace() w.config['jenkins'] = JENKINS; try: path = w.download_jenkins(JOB_ID, dst='foo') except Exception, e: print('FAIL %s: download failed: %s' % (pretty, str(e))) return
def t10(): pretty = '%s t10' % __file__ print(pretty) w = Workspace() w.config['jenkins'] = JENKINS; dst = 'downloads' sameBase = w.config['jenkins'] try: path = w.download_jenkins(JOB_ID, base=sameBase, dst=dst) except Exception, e: print('FAIL %s: download failed: %s' % (pretty, str(e))) return
def t12(): pretty = '%s t12' % __file__ print(pretty) w = Workspace() dst = 'downloads' # Faulty base bananaBase = 'http://android-ci.bananas.net' nap = 5 exc = None try: path = w.download_jenkins(JOB_ID, base=bananaBase, dst=dst, timeout=nap) except Exception, e: exc = e
def t03(): pretty = '%s t3' % __file__ print(pretty) w = Workspace() w.config['jenkins'] = JENKINS; exc = None try: path = w.download_jenkins(JOB_ID, timeout=1) print('FAIL %s: download did not time out' % pretty) w.delete() return except Exception, e: exc = e pass
def t11(): pretty = '%s t11' % __file__ print(pretty) w = Workspace() dst = 'downloads' # The same job is available in both regular and platform cluster regularBase = 'http://android-ci.cnbj.sonyericsson.net' platformBase = 'http://android-ci-platform.cnbj.sonyericsson.net' if w.config['jenkins'] == regularBase: otherBase = platformBase else: otherBase = regularBase try: path = w.download_jenkins(JOB_ID, base=otherBase, dst=dst) except Exception, e: print('FAIL %s: download failed: %s' % (pretty, str(e))) return
def t02(): pretty = '%s t2' % __file__ print(pretty) w = Workspace() w.config['jenkins'] = JENKINS; # find a build id, not the latest job = ave.jenkins.JenkinsJob(w.config['jenkins'], JOB_ID) all_builds = job.all_builds() if len(all_builds) < 2: print( 'BLOCKED %s: no enough builds available to support the test: %d' % (pretty, len(all_builds)) ) w.delete() return build_id = None artifacts = None for b in all_builds: if (b.attributes['result'] == 'SUCCESS' and len(b.attributes['artifacts']) > 1): build_id = str(b.build) artifacts = [a['relativePath'] for a in b.attributes['artifacts']] break if not build_id: print('BLOCKED %s: no usable build to support the test' % pretty) w.delete() return # download the id'd build try: path = w.download_jenkins(JOB_ID, build_id, artifacts) except Exception, e: print('FAIL %s: download failed: %s' % (pretty, str(e))) w.delete() return