You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/05/30 20:57:14 UTC

[07/12] git commit: SLIDER-94 purge obsolete groovy tests -now that they've been migrated to java

SLIDER-94 purge obsolete groovy tests -now that they've been migrated to java


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

Branch: refs/heads/develop
Commit: 901a01cf9b9ecb65b70efb404c170c6bff9877df
Parents: daf0f53
Author: Steve Loughran <st...@apache.org>
Authored: Thu May 29 19:23:58 2014 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Thu May 29 19:23:58 2014 +0100

----------------------------------------------------------------------
 .../server/services/utility/MockService.groovy  |  73 ---------
 .../services/utility/TestCompoundService.groovy | 160 -------------------
 .../services/utility/TestMockService.groovy     |  94 -----------
 .../services/utility/TestSequenceService.groovy | 145 -----------------
 4 files changed, 472 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/901a01cf/slider-core/src/test/groovy/org/apache/slider/server/services/utility/MockService.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/services/utility/MockService.groovy b/slider-core/src/test/groovy/org/apache/slider/server/services/utility/MockService.groovy
deleted file mode 100644
index 2c1bb8f..0000000
--- a/slider-core/src/test/groovy/org/apache/slider/server/services/utility/MockService.groovy
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.services.utility
-
-import org.apache.hadoop.service.AbstractService
-import org.apache.hadoop.service.ServiceStateException
-import org.apache.slider.core.main.ExitCodeProvider
-
-/**
- * Little mock service to simulate delays
- */
-class MockService extends AbstractService implements ExitCodeProvider {
-
-  boolean fail = false;
-  int exitCode;
-  int lifespan = -1;
-
-  MockService() {
-    super("mock");
-  }
-
-  MockService(String name, boolean fail, int lifespan) {
-    super(name);
-    this.fail = fail;
-    this.lifespan = lifespan;
-  }
-
-  @Override
-  protected void serviceStart() throws Exception {
-    //act on the lifespan here
-    if (lifespan > 0) {
-      Thread.start {
-        Thread.sleep(lifespan);
-        finish();
-      }
-    } else {
-      if (lifespan == 0) {
-        finish();
-      } else {
-        //continue until told not to
-      }
-    }
-  }
-
-  void finish() {
-    if (fail) {
-      ServiceStateException e = new ServiceStateException(getName() + " failed");
-      
-      noteFailure(e);
-      stop();
-      throw e;
-    } else {
-      stop();
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/901a01cf/slider-core/src/test/groovy/org/apache/slider/server/services/utility/TestCompoundService.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/services/utility/TestCompoundService.groovy b/slider-core/src/test/groovy/org/apache/slider/server/services/utility/TestCompoundService.groovy
deleted file mode 100644
index 9e34d41..0000000
--- a/slider-core/src/test/groovy/org/apache/slider/server/services/utility/TestCompoundService.groovy
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.services.utility
-
-import groovy.util.logging.Slf4j
-import org.apache.hadoop.conf.Configuration
-import org.apache.hadoop.service.Service
-import org.apache.slider.core.main.ServiceLauncherBaseTest
-import org.apache.slider.server.services.workflow.ServiceParent
-import org.apache.slider.server.services.workflow.WorkflowCompositeService
-import org.apache.slider.server.services.workflow.WorkflowEventCallback
-import org.apache.slider.server.services.workflow.WorkflowEventNotifyingService
-import org.junit.Test
-
-@Slf4j
-class TestCompoundService extends ServiceLauncherBaseTest {
-
-
-  @Test
-  public void testSingleCompound() throws Throwable {
-    WorkflowCompositeService parent = startService([new MockService()])
-    parent.stop();
-  }
-  
-  
-  @Test
-  public void testSingleCompoundTerminating() throws Throwable {
-    WorkflowCompositeService parent = startService([new MockService("1",false,100)])
-    assert waitForParentToStop(parent);
-  }
-
-  public boolean waitForParentToStop(WorkflowCompositeService parent) {
-    boolean stop = parent.waitForServiceToStop(1000);
-    if (!stop) {
-      log.error("Service failed to stop $parent");
-      logState(parent)
-    }
-    return stop;
-  }
-
-
-  @Test
-  public void testSingleCompoundFailing() throws Throwable {
-    WorkflowCompositeService parent = startService([new MockService("1",true,100)]);
-    assert parent.waitForServiceToStop(1000);
-    assert parent.getFailureCause() != null;
-  }
-  
-  @Test
-  public void testCompound() throws Throwable {
-    MockService one = new MockService("one", false, 100);
-    MockService two = new MockService("two", false, 100);
-    WorkflowCompositeService parent = startService([one, two]);
-    assert waitForParentToStop(parent);
-    assert one.isInState(Service.STATE.STOPPED);
-    assert two.isInState(Service.STATE.STOPPED);
-  }
-
-  @Test
-  public void testCompoundOneLongLived() throws Throwable {
-    MockService one = new MockService("one", false, 500)
-    MockService two = new MockService("two", false, 100)
-    WorkflowCompositeService parent = startService([one, two]);
-    assert waitForParentToStop(parent);
-    assert one.isInState(Service.STATE.STOPPED);
-    assert two.isInState(Service.STATE.STOPPED);
-  }
-
-  
-  @Test
-  public void testNotificationInCompound() throws Throwable {
-    boolean notified = false;
-    WorkflowEventCallback ecb = new WorkflowEventCallback() {
-      @Override
-      void eventCallbackEvent() {
-        log.info("EventCallback");
-        notified = true;
-      }
-    }
-    MockService one = new MockService("one", false, 100);
-    WorkflowEventNotifyingService ens = new WorkflowEventNotifyingService(ecb, 100);
-    MockService two = new MockService("two", false, 100);
-    WorkflowCompositeService parent = startService([one, ens, two]);
-    assert waitForParentToStop(parent);
-    assert one.isInState(Service.STATE.STOPPED);
-    assert ens.isInState(Service.STATE.STOPPED);
-    assert two.isInState(Service.STATE.STOPPED);
-    assert notified;
-  }
-
-  @Test
-  public void testFailingCompound() throws Throwable {
-    MockService one = new MockService("one", true, 100)
-    MockService two = new MockService("two", false, 100)
-    WorkflowCompositeService parent = startService([one, two])
-    assert waitForParentToStop(parent);
-    assert one.isInState(Service.STATE.STOPPED)
-    assert one.failureCause != null
-    assert two.isInState(Service.STATE.STOPPED)
-  }
-  
-
-
-
-  @Test
-  public void testCompoundInCompound() throws Throwable {
-    MockService one = new MockService("one", false, 100)
-    MockService two = new MockService("two", false, 100)
-    WorkflowCompositeService parent = buildService([one, two])
-    WorkflowCompositeService outer = startService([parent])
-        assert outer.waitForServiceToStop(1000);
-    assert one.isInState(Service.STATE.STOPPED)
-    assert two.isInState(Service.STATE.STOPPED)
-  }
-
-  public WorkflowCompositeService startService(List<Service> services) {
-    WorkflowCompositeService parent = buildService(services)
-    //expect service to start and stay started
-    parent.start();
-    return parent
-  }
-
-  public WorkflowCompositeService buildService(List<Service> services) {
-    WorkflowCompositeService parent = new WorkflowCompositeService("test")
-    services.each { parent.addService(it) }
-    parent.init(new Configuration())
-    return parent
-  }
-
-
-  void logState(ServiceParent p) {
-    logService(p)
-    for (Service s : p.services) {
-      logService(s)
-    }
-  }
-
-  public void logService(Service s) {
-    log.info(s.toString())
-    if (s.getFailureCause()) {
-      log.info("Failed in state ${s.getFailureState()} with $s.failureCause")
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/901a01cf/slider-core/src/test/groovy/org/apache/slider/server/services/utility/TestMockService.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/services/utility/TestMockService.groovy b/slider-core/src/test/groovy/org/apache/slider/server/services/utility/TestMockService.groovy
deleted file mode 100644
index 537f6b1..0000000
--- a/slider-core/src/test/groovy/org/apache/slider/server/services/utility/TestMockService.groovy
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.services.utility
-
-import org.apache.hadoop.conf.Configuration
-import org.apache.hadoop.service.Service
-import org.apache.hadoop.service.ServiceStateException
-import org.junit.Test
-
-class TestMockService {
-
-  @Test
-  public void testSimpleLifecycle() throws Throwable {
-    MockService s = new MockService("1",false,-1);
-    s.init(new Configuration())
-    s.start();
-    assert s.isInState(Service.STATE.STARTED)
-  }
-  
-  @Test
-  public void testSimpleLifecycleWait() throws Throwable {
-    MockService s = new MockService("1",false,-1);
-    s.init(new Configuration())
-    s.start();
-    assert s.isInState(Service.STATE.STARTED)
-    s.stop();
-    s.waitForServiceToStop(0);
-  }
-  
-  @Test
-  public void testStoppingService() throws Throwable {
-    MockService s = new MockService("1",false,100);
-    s.init(new Configuration())
-    s.start();
-    Thread.sleep(1000);
-    assert s.isInState(Service.STATE.STOPPED)
-  }
-  
-  @Test
-  public void testStoppingWaitService() throws Throwable {
-    MockService s = new MockService("1",false,100);
-    s.init(new Configuration())
-    s.start();
-    s.waitForServiceToStop(0);
-    assert s.isInState(Service.STATE.STOPPED)
-  }
-    
-  
-  
-  @Test
-  public void testFailingService() throws Throwable {
-    MockService s = new MockService("1",true,100);
-    s.init(new Configuration())
-    s.start();
-    s.waitForServiceToStop(0);
-
-    assert s.isInState(Service.STATE.STOPPED)
-    assert s.failureCause != null
-  }
-      
-  @Test
-  public void testFailingInStart() throws Throwable {
-    MockService s = new MockService("1",true,0);
-    s.init(new Configuration())
-    try {
-      s.start();
-      //failure, raise a fault with some text
-      assert null == s
-    } catch (ServiceStateException e) {
-      //expected
-    }
-    assert s.isInState(Service.STATE.STOPPED)
-    assert s.failureCause != null
-    s.waitForServiceToStop(0);
-  }
-  
-  
-}

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/901a01cf/slider-core/src/test/groovy/org/apache/slider/server/services/utility/TestSequenceService.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/services/utility/TestSequenceService.groovy b/slider-core/src/test/groovy/org/apache/slider/server/services/utility/TestSequenceService.groovy
deleted file mode 100644
index ee39798..0000000
--- a/slider-core/src/test/groovy/org/apache/slider/server/services/utility/TestSequenceService.groovy
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.services.utility
-
-import groovy.util.logging.Slf4j
-import org.apache.hadoop.conf.Configuration
-import org.apache.hadoop.service.Service
-import org.apache.slider.core.main.ServiceLauncherBaseTest
-import org.apache.slider.server.services.workflow.WorkflowEventCallback
-import org.apache.slider.server.services.workflow.WorkflowEventNotifyingService
-import org.apache.slider.server.services.workflow.WorkflowSequenceService
-import org.junit.Test
-
-@Slf4j
-class TestSequenceService extends ServiceLauncherBaseTest {
-
-
-  @Test
-  public void testSingleSequence() throws Throwable {
-    WorkflowSequenceService ss = startService([new MockService()]);
-    ss.stop();
-  }
-
-  @Test
-  public void testSequence() throws Throwable {
-    MockService one = new MockService("one", false, 100);
-    MockService two = new MockService("two", false, 100);
-    WorkflowSequenceService ss = startService([one, two]);
-    assert ss.waitForServiceToStop(1000);
-    assert one.isInState(Service.STATE.STOPPED);
-    assert two.isInState(Service.STATE.STOPPED);
-    assert ss.previousService == two
-  }
-
-  @Test
-  public void testNotificationInSequence() throws Throwable {
-    boolean notified = false;
-    WorkflowEventCallback ecb = new WorkflowEventCallback() {
-      @Override
-      void eventCallbackEvent() {
-        log.info("EventCallback")
-        notified = true;
-      }
-    }
-    MockService one = new MockService("one", false, 100)
-    WorkflowEventNotifyingService ens = new WorkflowEventNotifyingService(ecb, 100);
-    MockService two = new MockService("two", false, 100)
-    WorkflowSequenceService ss = startService([one, ens, two])
-    assert ss.waitForServiceToStop(1000);
-    assert one.isInState(Service.STATE.STOPPED)
-    assert ens.isInState(Service.STATE.STOPPED)
-    assert two.isInState(Service.STATE.STOPPED)
-    assert notified
-  }
-
-  @Test
-  public void testFailingSequence() throws Throwable {
-    MockService one = new MockService("one", true, 100)
-    MockService two = new MockService("two", false, 100)
-    WorkflowSequenceService ss = startService([one, two])
-    assert ss.waitForServiceToStop(1000);
-    assert one.isInState(Service.STATE.STOPPED)
-    assert two.isInState(Service.STATE.NOTINITED)
-    assert ss.previousService == one
-
-  }
-  
-
-
-  @Test
-  public void testFailInStartNext() throws Throwable {
-    MockService one = new MockService("one", false, 100)
-    MockService two = new MockService("two", true, 0)
-    MockService three = new MockService("3", false, 0)
-    WorkflowSequenceService ss = startService([one, two, three])
-    assert ss.waitForServiceToStop(1000);
-    assert one.isInState(Service.STATE.STOPPED)
-    assert two.isInState(Service.STATE.STOPPED)
-    Throwable failureCause = two.failureCause
-    assert failureCause != null;
-    Throwable masterFailureCause = ss.failureCause
-    assert masterFailureCause != null;
-    assert masterFailureCause == failureCause
-
-    assert three.isInState(Service.STATE.NOTINITED)
-  }
-
-  @Test
-  public void testSequenceInSequence() throws Throwable {
-    MockService one = new MockService("one", false, 100)
-    MockService two = new MockService("two", false, 100)
-    WorkflowSequenceService ss = buildService([one, two])
-    WorkflowSequenceService outer = startService([ss])
-    
-    assert outer.waitForServiceToStop(1000);
-    assert one.isInState(Service.STATE.STOPPED)
-    assert two.isInState(Service.STATE.STOPPED)
-  }
-
-
-  @Test
-  public void testVarargsCtor() throws Throwable {
-    MockService one = new MockService("one", false, 100);
-    MockService two = new MockService("two", false, 100);
-    WorkflowSequenceService ss = new WorkflowSequenceService("test", one, two);
-    ss.init(new Configuration());
-    ss.start();
-    assert ss.waitForServiceToStop(1000);
-    assert one.isInState(Service.STATE.STOPPED);
-    assert two.isInState(Service.STATE.STOPPED);
-
-
-  }
-  public WorkflowSequenceService startService(List<Service> services) {
-    WorkflowSequenceService ss = buildService(services)
-    //expect service to start and stay started
-    ss.start();
-    return ss
-  }
-
-  public WorkflowSequenceService buildService(List<Service> services) {
-    WorkflowSequenceService ss = new WorkflowSequenceService("test");
-    services.each { ss.addService(it) }
-    ss.init(new Configuration());
-    return ss;
-  }
-
-
-}