def setUp(self): super(TestAssignmentHandling, self).setUp() self.base_directory = mkdtemp() self.computer_model = self.computer = BuildComputer.objects.create(hostname = "localhost", basedir=self.base_directory) self.job = job = Job.objects.create(slug='cthulhubot-sleep').get_domain_object() self.job.auto_discovery() self.assignment = create_job_assignment( computer = self.computer_model, job = job, project = self.project, ) self.assignment_second = create_job_assignment( computer = self.computer_model, job = job, project = self.project, ) self.project_client = ProjectClient.objects.all()[0] self.build_directory = os.path.join(self.base_directory, self.assignment.get_identifier()) self.transaction.commit()
def create_assignment(case, repository_dir=None): case.project_name = u"project" case.project = create_project(case, master_directory=case.base_directory, repository_uri=repository_dir) case.buildmaster = case.project.buildmaster_set.all()[0] case.computer_model = case.computer = BuildComputer.objects.create(hostname = "localhost", basedir=case.base_directory) case.job_test = Job.objects.create(slug='cthulhubot-bare-nose-tests').get_domain_object() case.job_test.auto_discovery() case.job_repository = Job.objects.create(slug='cthulhubot-save-repository-information').get_domain_object() case.job_repository.auto_discovery() case.assignment_test = create_job_assignment( computer = case.computer_model, job = case.job_test, project = case.project, params = { 'commands' : [{}, {}, {}] } ) case.assignment_repository = create_job_assignment( computer = case.computer_model, job = case.job_repository, project = case.project, params = { 'commands' : [{}, {}] } )
def test_unique_slaves_retrieved(self): # duplicate project@computer create_job_assignment(computer=self.computer_model, job=self.job, project=self.project) new_computer = BuildComputer.objects.create(name="blah", hostname="blah") create_job_assignment(computer=new_computer, job=self.job, project=self.project) self.assert_equals(2, len(self.buildmaster.get_config()["slaves"]))
def test_project_page_is_ok_even_when_computer_is_unreachable(self): s = self.selenium self.create_project() #self.assign_to_project() self.project = Project.objects.get(slug='rericha') self.unreachable_computer = BuildComputer.objects.create(hostname="this.hostname.shall.not.be.down.tld", basedir="/tmp", name="Unreachable") self.job = job = Job.objects.get(slug='cthulhubot-sleep').get_domain_object() self.bad_assignment = create_job_assignment( computer = self.unreachable_computer, job = job, project = self.project, ) self.transaction.commit() # navigate to project s.click(self.elements['menu']['projects']) s.wait_for_page_to_load(30000) self.assert_equals(1, int(s.get_xpath_count(self.elements['projects']['list']))) s.click(self.elements['projects']['project_link_single']) s.wait_for_page_to_load(30000) # verify we have one computer and it's unreachable self.assert_equals(ClientUnreachable.DEFAULT_STATUS, s.get_text(self.elements['project_detail']['single_computer_status']))
def test_upgraded_configuration_saved(self): def second_sleep(config): config['commands'][0]['command'] = 'cthulhubot-sleep' config['commands'][0]['parameters'] = { 'time' : '1' } return config self.job.upgrades = [] self.assignment = create_job_assignment( computer = self.computer_model, job = self.job, project = self.project, ) self.assert_equals([['sleep', '0.02']], self.assignment.get_shell_commands()) self.job.__class__.upgrades = [ second_sleep, ] self.assignment = JobAssignment.objects.get(pk = self.assignment.model.pk).get_domain_object() commands = self.assignment.get_shell_commands() self.assert_equals(1, self.assignment.configuration_version) self.assert_equals([['sleep', '1']], commands)
def test_newly_crated_assignment_has_proper_version(self): self.job.upgrades = [ lambda x: x, ] self.assignment = create_job_assignment( computer = self.computer_model, job = self.job, project = self.project, ) self.assert_equals(1, self.assignment.configuration_version)
def setUp(self): super(TestConfigGenerationForWire, self).setUp() self._mock_resolver() self.project_name = u"project" self.project = create_project( name=self.project_name, tracker_uri="http://example.com", repository_uri="/tmp/test" ) self.buildmaster = self.project.buildmaster_set.all()[0] self.computer_model = self.computer = BuildComputer.objects.create(name="localhost", hostname="localhost") self.job = Job.objects.create(slug="cthulhubot-sleep").get_domain_object() self.job.auto_discovery() self.assignment_model = create_job_assignment(computer=self.computer_model, job=self.job, project=self.project) self.config = self.buildmaster.get_config()
def test_retrieving_factory_config_updates_assignment(self): self.job.upgrades = [ lambda x: x, ] self.assignment = create_job_assignment( computer = self.computer_model, job = self.job, project = self.project, ) self.assignment.get_factory() self.assert_equals(1, self.assignment.configuration_version)
def setUp(self): super(TestMasterApi, self).setUp() self.computer_model = self.computer = BuildComputer.objects.create(hostname = "localhost", basedir=self.base_directory) self.job = job = Job.objects.create(slug='cthulhubot-debian-package-creation').get_domain_object() self.job.auto_discovery() self.assignment = create_job_assignment( computer = self.computer_model, job = job, project = self.project, params = { 'commands' : [ { 'command' : 'cthulhubot-git', 'parameters' : { 'repository' : '/tmp/repo.git', } }, {}, {}, { 'command' : 'cthulhubot-debian-package-ftp-upload', 'parameters' : { 'ftp_user' : 'xxx', 'ftp_password' : 'xxx', 'ftp_directory' : '', 'ftp_host' : '' } } ]} ) self.project_client = self.assignment.get_client() self.build_directory = os.path.join(self.base_directory, self.project_client.get_identifier()) self.transaction.commit() self.buildmaster.start() self.project_client.create_build_directory() self.project_client.start()
def test_one_client_per_assigned_computer(self): self.create_assignment() new_computer = BuildComputer.objects.create(name="blah", hostname="blah") create_job_assignment(computer = new_computer, job = self.job, project = self.project) self.assertEquals(2, len(ProjectClient.objects.all()))
def create_assignment(self): self.assignment_model = create_job_assignment( computer = self.computer_model, job = self.job, project = self.project, ).model