You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ma...@apache.org on 2014/03/28 00:07:11 UTC

git commit: Filtering out non-prod tasks for domain sla calculations.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master a0c21cdd4 -> a7e0db6eb


Filtering out non-prod tasks for domain sla calculations.

Bugs closed: AURORA-287

Reviewed at https://reviews.apache.org/r/19550/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/a7e0db6e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/a7e0db6e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/a7e0db6e

Branch: refs/heads/master
Commit: a7e0db6ebe944a3da81356a5c4a563c69831f2e0
Parents: a0c21cd
Author: Maxim Khutornenko <ma...@apache.org>
Authored: Thu Mar 27 16:06:56 2014 -0700
Committer: Maxim Khutornenko <ma...@apache.org>
Committed: Thu Mar 27 16:06:56 2014 -0700

----------------------------------------------------------------------
 src/main/python/apache/aurora/client/api/sla.py |  7 ++--
 .../python/apache/aurora/client/api/test_sla.py | 35 ++++++++++++++++++--
 2 files changed, 37 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a7e0db6e/src/main/python/apache/aurora/client/api/sla.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/sla.py b/src/main/python/apache/aurora/client/api/sla.py
index a615092..45153c7 100644
--- a/src/main/python/apache/aurora/client/api/sla.py
+++ b/src/main/python/apache/aurora/client/api/sla.py
@@ -245,9 +245,10 @@ class DomainUpTimeSlaVector(object):
     jobs = defaultdict(list)
     hosts = defaultdict(list)
     for task in self._tasks:
-      job_key = job_key_from_scheduled(task, self._cluster)
-      jobs[job_key].append(task)
-      hosts[task.assignedTask.slaveHost].append(job_key)
+      if task.assignedTask.task.production:
+        job_key = job_key_from_scheduled(task, self._cluster)
+        jobs[job_key].append(task)
+        hosts[task.assignedTask.slaveHost].append(job_key)
 
     return jobs, hosts
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a7e0db6e/src/test/python/apache/aurora/client/api/test_sla.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_sla.py b/src/test/python/apache/aurora/client/api/test_sla.py
index 74c0ac3..ff11b1f 100644
--- a/src/test/python/apache/aurora/client/api/test_sla.py
+++ b/src/test/python/apache/aurora/client/api/test_sla.py
@@ -61,13 +61,13 @@ class SlaTest(unittest.TestCase):
     resp.result = Result(scheduleStatusResult=ScheduleStatusResult(tasks=tasks))
     self._scheduler.getTasksStatus.return_value = resp
 
-  def create_task(self, duration, id, host=None, name=None):
+  def create_task(self, duration, id, host=None, name=None, prod=None):
     return ScheduledTask(
         assignedTask=AssignedTask(
             instanceId=id,
             slaveHost=host,
             task=TaskConfig(
-                production=True,
+                production=prod if prod is not None else True,
                 jobName=name or self._name,
                 owner=Identity(role=self._role),
                 environment=self._env)),
@@ -266,6 +266,26 @@ class SlaTest(unittest.TestCase):
     }
     self.assert_safe_domain_result('h1', 50, 400, in_limit=job_override)
 
+  def test_domain_uptime_not_production(self):
+    self.mock_get_tasks([
+      self.create_task(100, 1, 'h1', self._name, False),
+      self.create_task(200, 2, 'h2', self._name, False),
+      self.create_task(100, 1, 'h2', self._name, False)
+    ])
+
+    vector = self._sla.get_domain_uptime_vector(self._cluster)
+    assert 0 == len(vector.get_safe_hosts(50, 200)), 'Length must be empty.'
+    self.expect_task_status_call_cluster_scoped()
+
+  def test_domain_uptime_production_not_set(self):
+    task = self.create_task(500, 1, 'h1', self._name)
+    task.assignedTask.task.production = None
+    self.mock_get_tasks([task])
+
+    vector = self._sla.get_domain_uptime_vector(self._cluster)
+    assert 0 == len(vector.get_safe_hosts(50, 200)), 'Length must be empty.'
+    self.expect_task_status_call_cluster_scoped()
+
 
   def test_probe_hosts_no_tasks(self):
     self.mock_get_tasks([])
@@ -307,6 +327,17 @@ class SlaTest(unittest.TestCase):
     ])
     self.assert_probe_hosts_result('h1', 80, 300, 50.0, False, None)
 
+  def test_probe_hosts_non_prod_ignored(self):
+    self.mock_get_tasks([
+        self.create_task(100, 1, 'h1', self._name, False),
+        self.create_task(200, 2, 'h2', self._name, False),
+        self.create_task(300, 3, 'h3', self._name, False),
+        self.create_task(400, 4, 'h4', self._name, False),
+    ])
+    vector = self._sla.get_domain_uptime_vector(self._cluster)
+    assert 0 == len(vector.probe_hosts(50, 80, ['h1']))
+    self.expect_task_status_call_cluster_scoped()
+
 
   def test_get_domain_uptime_vector_with_hosts(self):
     with patch('apache.aurora.client.api.sla.task_query', return_value=TaskQuery()) as (mock_query):