Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Commit

Permalink
[changes] Specify cluster too in the config
Browse files Browse the repository at this point in the history
Summary:
Address kyle's comment re: cluster.

I had verified that cluster is not used for selecting the node and so assumed that we need not pass it. But after the request is sent, jenkins tried to find a machine with the given CLUSTER tag. So we need to pass the right cluster info

Test Plan: unit tests

Reviewers: kylec, vishal

Reviewed By: vishal

Subscribers: wwu

Differential Revision: https://tails.corp.dropbox.com/D84153
  • Loading branch information
Akhil Ravidas committed Jan 14, 2015
1 parent c98a93c commit 2beb0ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion changes/backends/jenkins/generic_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class JenkinsGenericBuilder(JenkinsBuilder):
def __init__(self, master_urls=None, *args, **kwargs):
self.script = kwargs.pop('script')
self.cluster = kwargs.pop('cluster')
self.diff_cluster = kwargs.pop('diff_cluster', None)
self.path = kwargs.pop('path', '')
self.workspace = kwargs.pop('workspace', '')

Expand Down Expand Up @@ -38,12 +39,17 @@ def get_job_parameters(self, job, script=None, target_id=None, path=None):
else:
repo_url = repository.url

cluster = self.cluster
is_diff = not job.source.is_commit()
if is_diff and self.diff_cluster:
cluster = self.diff_cluster

params.extend([
{'name': 'CHANGES_PID', 'value': project.slug},
{'name': 'REPO_URL', 'value': repo_url},
{'name': 'SCRIPT', 'value': script},
{'name': 'REPO_VCS', 'value': repository.backend.name},
{'name': 'CLUSTER', 'value': self.cluster},
{'name': 'CLUSTER', 'value': cluster},
{'name': 'WORK_PATH', 'value': path},
{'name': 'C_WORKSPACE', 'value': self.workspace},
])
Expand Down
13 changes: 13 additions & 0 deletions tests/changes/backends/jenkins/test_generic_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class JenkinsGenericBuilderTest(BaseTestCase):
'job_name': 'server',
'script': 'py.test',
'cluster': 'default',
'diff_cluster': 'diff_cluster',
}

def test_get_job_parameters(self):
Expand All @@ -35,3 +36,15 @@ def test_get_job_parameters(self):
result = builder.get_job_parameters(job)
assert {'name': 'WORK_PATH', 'value': ''} in result
assert {'name': 'C_WORKSPACE', 'value': ''} in result

def test_get_job_parameters_diff(self):
project = self.create_project()
patch = self.create_patch()
source = self.create_source(project, patch=patch)
build = self.create_build(project, source=source)
job = self.create_job(build)

builder = self.get_builder()

result = builder.get_job_parameters(job, path='foo')
assert {'name': 'CLUSTER', 'value': self.builder_options['diff_cluster']} in result

0 comments on commit 2beb0ef

Please sign in to comment.