aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Checking for cron jobs in startJobUpdate()
Date Wed, 03 Sep 2014 20:54:17 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 5445dea9b -> 30b1d602f


Checking for cron jobs in startJobUpdate()

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


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

Branch: refs/heads/master
Commit: 30b1d602fe4de2cc647200507999340d1892bb1e
Parents: 5445dea
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Wed Sep 3 13:53:55 2014 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Wed Sep 3 13:53:55 2014 -0700

----------------------------------------------------------------------
 .../scheduler/thrift/SchedulerThriftInterface.java     |  6 ++++++
 .../scheduler/thrift/SchedulerThriftInterfaceTest.java | 13 +++++++++++++
 2 files changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/30b1d602/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
index 7a4640d..9171179 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -1339,6 +1339,12 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
           ConfigurationManager.validateAndPopulate(
               ITaskConfig.build(mutableRequest.getTaskConfig())).newBuilder()));
 
+      if (cronJobManager.hasJob(request.getJobKey())) {
+        return addMessage(
+            response,
+            INVALID_REQUEST,
+            "Cron jobs may only be updated by calling replaceCronTemplate.");
+      }
     } catch (AuthFailedException e) {
       return addMessage(response, AUTH_FAILED, e);
     } catch (TaskDescriptionException e) {

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/30b1d602/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
index f568280..1686d4b 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -1889,6 +1889,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
   @Test
   public void testStartUpdate() throws Exception {
     expectAuth(ROLE, true);
+    expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
     expect(lockManager.acquireLock(LOCK_KEY, USER)).andReturn(LOCK);
 
     IScheduledTask oldTask1 = buildScheduledTask(0, 5);
@@ -1937,6 +1938,16 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
   }
 
   @Test
+  public void testStartUpdateFailsForCronJob() throws Exception {
+    JobUpdateRequest request = buildJobUpdateRequest(populatedTask());
+    expectAuth(ROLE, true);
+    expect(cronJobManager.hasJob(JOB_KEY)).andReturn(true);
+
+    control.replay();
+    assertResponse(INVALID_REQUEST, thrift.startJobUpdate(request, SESSION));
+  }
+
+  @Test
   public void testStartUpdateFailsConfigValidation() throws Exception {
     JobUpdateRequest request = buildJobUpdateRequest(populatedTask().setJobName(null));
     expectAuth(ROLE, true);
@@ -1949,6 +1960,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
   public void testStartUpdateFailsLockValidation() throws Exception {
     JobUpdateRequest request = buildJobUpdateRequest(populatedTask());
     expectAuth(ROLE, true);
+    expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
     expect(lockManager.acquireLock(LOCK_KEY, USER)).andThrow(new LockException("lock failed"));
 
     control.replay();
@@ -1959,6 +1971,7 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
   @Test
   public void testStartUpdateFailsInController() throws Exception {
     expectAuth(ROLE, true);
+    expect(cronJobManager.hasJob(JOB_KEY)).andReturn(false);
     expect(lockManager.acquireLock(LOCK_KEY, USER)).andReturn(LOCK);
 
     IScheduledTask oldTask = buildScheduledTask(0, 5);


Mime
View raw message