def setUp(self): self.projects = [] self.dirs_to_delete = [] self.un = config.ADMIN_USER self.gu = GerritUtils( config.GATEWAY_URL, auth_cookie=config.USERS[self.un]['auth_cookie']) self.gu2 = GerritUtils( config.GATEWAY_URL, auth_cookie=config.USERS[config.USER_2]['auth_cookie']) self.ju = JenkinsUtils() self.gu.add_pubkey(config.USERS[self.un]["pubkey"]) priv_key_path = set_private_key(config.USERS[self.un]["privkey"]) self.gitu_admin = GerritGitUtils(self.un, priv_key_path, config.USERS[self.un]['email']) # Clone the config repo and make change to it # in order to test the new sample_project self.config_clone_dir = self.clone_as_admin("config") self.original_layout = file(os.path.join( self.config_clone_dir, "zuul/layout.yaml")).read() self.original_zuul_projects = file(os.path.join( self.config_clone_dir, "zuul/projects.yaml")).read() self.original_project = file(os.path.join( self.config_clone_dir, "jobs/projects.yaml")).read() # Put USER_2 as core for config project self.gu.add_group_member(config.USER_2, "config-core")
def setUp(self): super(TestProjectTestsWorkflow, self).setUp() self.projects = [] self.dirs_to_delete = [] self.un = config.ADMIN_USER self.gu = GerritUtils( config.GATEWAY_URL, auth_cookie=config.USERS[self.un]['auth_cookie']) self.gu2 = GerritUtils( config.GATEWAY_URL, auth_cookie=config.USERS[config.USER_2]['auth_cookie']) self.ju = JenkinsUtils() self.gu.add_pubkey(config.USERS[self.un]["pubkey"]) priv_key_path = set_private_key(config.USERS[self.un]["privkey"]) self.gitu_admin = GerritGitUtils(self.un, priv_key_path, config.USERS[self.un]['email']) # Clone the config repo and keep job/zuul config content self.config_clone_dir = self.clone_as_admin("config") self.original_zuul_projects = file(os.path.join( self.config_clone_dir, "zuul/projects.yaml")).read() self.original_project = file(os.path.join( self.config_clone_dir, "jobs/projects.yaml")).read() self.need_restore_config_repo = False # Put USER_2 as core for config project self.gu.add_group_member(config.USER_2, "config-core")
def setUpClass(cls): cookie = get_cookie(config.ADMIN_USER, config.ADMIN_PASSWORD) cls.cookie = {"auth_pubtkt": cookie} cls.ju = JenkinsUtils() cls.test_job = "test-sleep-" + rand_suffix() cls.ju.create_job(cls.test_job, TEST_PARAMETERIZED_JOB) cls.ju.run_job(cls.test_job, {'timeout': '1'}) cls.ju.wait_till_job_completes(cls.test_job, 1, 'lastBuild') cls.base_url = config.GATEWAY_URL + "/manage/jobs/"
def setUp(self): super(TestRepoxplorer, self).setUp() priv_key_path = set_private_key( config.USERS[config.ADMIN_USER]["privkey"]) self.gitu_admin = GerritGitUtils( config.ADMIN_USER, priv_key_path, config.USERS[config.ADMIN_USER]['email']) self.gu = GerritUtils( config.GATEWAY_URL, auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie']) self.ju = JenkinsUtils() self.dirs_to_delete = []
def __init__(self): with open("%s/resources.yaml" % pwd, 'r') as rsc: self.resources = yaml.load(rsc) config.USERS[config.ADMIN_USER]['auth_cookie'] = get_cookie( config.ADMIN_USER, config.USERS[config.ADMIN_USER]['password']) self.msu = ManageSfUtils(config.GATEWAY_URL) self.ggu = GerritGitUtils(config.ADMIN_USER, config.ADMIN_PRIV_KEY_PATH, config.USERS[config.ADMIN_USER]['email']) self.ju = JenkinsUtils() self.rm = RedmineUtils( config.GATEWAY_URL + "/redmine/", auth_cookie=config.USERS[config.ADMIN_USER]['auth_cookie'])
def __init__(self): with open("%s/resources.yaml" % pwd, 'r') as rsc: self.resources = yaml.load(rsc) config.USERS[config.ADMIN_USER]['auth_cookie'] = get_cookie( config.ADMIN_USER, config.USERS[config.ADMIN_USER]['password']) self.msu = ManageSfUtils(config.GATEWAY_URL) self.ru = ResourcesUtils() self.ggu = GerritGitUtils(config.ADMIN_USER, config.ADMIN_PRIV_KEY_PATH, config.USERS[config.ADMIN_USER]['email']) self.ju = JenkinsUtils() self.stb_client = SFStoryboard( config.GATEWAY_URL + "/storyboard_api", config.USERS[config.ADMIN_USER]['auth_cookie'])
def setUp(self): super(TestProjectReplication, self).setUp() self.ru = ResourcesUtils() self.un = config.ADMIN_USER self.ju = JenkinsUtils() self.gu = GerritUtils(config.GATEWAY_URL, auth_cookie=config.USERS[self.un]['auth_cookie']) self.gu2 = GerritUtils( config.GATEWAY_URL, auth_cookie=config.USERS[config.USER_2]['auth_cookie']) self.k_idx = self.gu2.add_pubkey(config.USERS[config.USER_2]["pubkey"]) priv_key_path = set_private_key(config.USERS[self.un]["privkey"]) self.gitu_admin = GerritGitUtils(self.un, priv_key_path, config.USERS[self.un]['email']) # Prepare environment for git clone on mirror repo self.mt = Tool() self.mt_tempdir = tempfile.mkdtemp() # Copy the service private key in a flat file priv_key = file(config.SERVICE_PRIV_KEY_PATH, 'r').read() priv_key_path = os.path.join(self.mt_tempdir, 'user.priv') file(priv_key_path, 'w').write(priv_key) os.chmod(priv_key_path, stat.S_IREAD | stat.S_IWRITE) # Prepare the ssh wrapper script ssh_wrapper = "ssh -o StrictHostKeyChecking=no -i %s \"$@\"" % ( priv_key_path) wrapper_path = os.path.join(self.mt_tempdir, 'ssh_wrapper.sh') file(wrapper_path, 'w').write(ssh_wrapper) os.chmod(wrapper_path, stat.S_IRWXU) # Set the wrapper as GIT_SSH env variable self.mt.env['GIT_SSH'] = wrapper_path self.config_clone_dir = None # Project we are going to configure the replication for self.pname = 'test/replication' # Remove artifacts of previous run if any self.delete_config_section(self.un, self.pname) self.delete_mirror_repo(self.pname)
def setUp(self): super(TestJenkinsBasic, self).setUp() self.ju = JenkinsUtils()
def test_check_zuul_operations(self): """ Test if zuul verifies project correctly through zuul-demo project """ # zuul-demo - test project used exclusively to test zuul installation # The necessary project descriptions are already declared in Jenkins # and zuul pname = 'zuul-demo' self.create_project(pname, config.ADMIN_USER) un = config.ADMIN_USER gu = GerritUtils( config.GATEWAY_URL, auth_cookie=config.USERS[un]['auth_cookie']) ju = JenkinsUtils() k_index = gu.add_pubkey(config.USERS[un]["pubkey"]) # Gerrit part self.assertTrue(gu.project_exists(pname)) priv_key_path = set_private_key(config.USERS[un]["privkey"]) gitu = GerritGitUtils(un, priv_key_path, config.USERS[un]['email']) url = "ssh://%s@%s:29418/%s" % (un, config.GATEWAY_HOST, pname) clone_dir = gitu.clone(url, pname) self.dirs_to_delete.append(os.path.dirname(clone_dir)) last_fail_build_num_ft = \ ju.get_last_build_number("zuul-demo-functional-tests", "lastFailedBuild") last_fail_build_num_ut = \ ju.get_last_build_number("zuul-demo-unit-tests", "lastFailedBuild") last_succeed_build_num_ft = \ ju.get_last_build_number("zuul-demo-functional-tests", "lastSuccessfulBuild") last_succeed_build_num_ut = \ ju.get_last_build_number("zuul-demo-unit-tests", "lastSuccessfulBuild") gitu.add_commit_and_publish(clone_dir, "master", "Test commit") change_ids = gu.get_my_changes_for_project(pname) self.assertEqual(len(change_ids), 1) change_id = change_ids[0] # Give some time for jenkins to work ju.wait_till_job_completes("zuul-demo-functional-tests", last_fail_build_num_ft, "lastFailedBuild") ju.wait_till_job_completes("zuul-demo-unit-tests", last_fail_build_num_ut, "lastFailedBuild") attempt = 0 while "jenkins" not in gu.get_reviewers(change_id): if attempt >= 90: break time.sleep(1) attempt += 1 attempt = 0 while gu.get_reviewer_approvals(change_id, 'jenkins')['Verified'] \ != '-1': if attempt >= 90: break time.sleep(1) attempt += 1 self.assertEqual( gu.get_reviewer_approvals(change_id, 'jenkins')['Verified'], '-1') # Add the test case files and resubmit for review data = "echo Working" files = ["run_functional-tests.sh", "run_tests.sh"] for f in files: file(os.path.join(clone_dir, f), 'w').write(data) os.chmod(os.path.join(clone_dir, f), 0755) gitu.add_commit_and_publish(clone_dir, "master", None, fnames=files) # Give some time for jenkins to work ju.wait_till_job_completes("zuul-demo-functional-tests", last_succeed_build_num_ft, "lastSuccessfulBuild") ju.wait_till_job_completes("zuul-demo-unit-tests", last_succeed_build_num_ut, "lastSuccessfulBuild") attempt = 0 while "jenkins" not in gu.get_reviewers(change_id): if attempt >= 90: break time.sleep(1) attempt += 1 attempt = 0 while gu.get_reviewer_approvals(change_id, 'jenkins')['Verified'] \ != '+1': if attempt >= 90: break time.sleep(1) attempt += 1 self.assertEqual( gu.get_reviewer_approvals(change_id, 'jenkins')['Verified'], '+1') gu.del_pubkey(k_index)
def setUp(self): self.ju = JenkinsUtils()