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 2015/11/23 18:20:38 UTC

[26/50] incubator-slider git commit: SLIDER-969 Add mock test to simulate AA failure and restart of AA request sequence

SLIDER-969 Add mock test to simulate AA failure and restart of AA request sequence


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

Branch: refs/heads/develop
Commit: 57638ff4e6ca24173106b0df98f512c6205fc869
Parents: e71ffbd
Author: Steve Loughran <st...@apache.org>
Authored: Tue Nov 17 21:12:54 2015 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Nov 17 21:12:54 2015 +0000

----------------------------------------------------------------------
 .../appstate/TestMockAppStateAAPlacement.groovy | 29 ++++++++++++++++++++
 .../TestMockAppStateRebuildOnAMRestart.groovy   | 14 ++--------
 2 files changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/57638ff4/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateAAPlacement.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateAAPlacement.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateAAPlacement.groovy
index cdfa9e2..4eff059 100644
--- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateAAPlacement.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateAAPlacement.groovy
@@ -23,7 +23,11 @@ import groovy.util.logging.Slf4j
 import org.apache.hadoop.yarn.api.records.Container
 import org.apache.hadoop.yarn.api.records.NodeState
 import org.apache.hadoop.yarn.client.api.AMRMClient
+import org.apache.slider.api.ResourceKeys
+import org.apache.slider.core.conf.ConfTreeOperations
+import org.apache.slider.providers.PlacementPolicy
 import org.apache.slider.server.appmaster.model.mock.MockAppState
+import org.apache.slider.server.appmaster.model.mock.MockFactory
 import org.apache.slider.server.appmaster.model.mock.MockNodeReport
 import org.apache.slider.server.appmaster.model.mock.MockRoles
 import org.apache.slider.server.appmaster.model.mock.MockYarnEngine
@@ -282,4 +286,29 @@ class TestMockAppStateAAPlacement extends BaseMockAppStateAATest
     } catch (IllegalArgumentException expected) {
     }
   }
+
+  @Test
+  public void testAMRestart() throws Throwable {
+    def desiredAA = 3
+    aaRole.desired = desiredAA
+    List<RoleInstance> instances = createAndStartNodes()
+    List<Container> containers = instances.collect { it.container }
+
+    // now destroy the app state
+    def bindingInfo = buildBindingInfo()
+    bindingInfo.instanceDefinition = factory.newInstanceDefinition(0, 0, desiredAA)
+    ConfTreeOperations cto = new ConfTreeOperations(bindingInfo.instanceDefinition.resources)
+    cto.setComponentOpt(ROLE2,
+        ResourceKeys.COMPONENT_PLACEMENT_POLICY,
+        PlacementPolicy.ANTI_AFFINITY_REQUIRED)
+    bindingInfo.liveContainers = containers
+    appState = new MockAppState(bindingInfo)
+
+    def aaRole = lookupRole(MockFactory.AAROLE_2.name)
+    def gpuRole = lookupRole(MockFactory.AAROLE_1_GPU.name)
+    appState.reviewRequestAndReleaseNodes()
+    assert aaRole.isAntiAffinePlacement()
+    assert aaRole.isAARequestOutstanding()
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/57638ff4/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateRebuildOnAMRestart.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateRebuildOnAMRestart.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateRebuildOnAMRestart.groovy
index 59cc2c8..0e526b6 100644
--- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateRebuildOnAMRestart.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/appstate/TestMockAppStateRebuildOnAMRestart.groovy
@@ -58,23 +58,15 @@ class TestMockAppStateRebuildOnAMRestart extends BaseMockAppStateTest implements
     assert instances.size() == clusterSize
 
     //clone the list
-    List<RoleInstance> cloned = [];
-    List<Container> containers = []
-    instances.each { RoleInstance elt ->
-      cloned.add(elt.clone() as RoleInstance)
-      containers.add(elt.container)
-    }
+    List<Container> containers = instances.collect { it.container }
     NodeMap nodemap = appState.roleHistory.cloneNodemap()
 
-    // now destroy the app state
-    appState = new MockAppState()
-
     //and rebuild
 
     def bindingInfo = buildBindingInfo()
     bindingInfo.instanceDefinition = factory.newInstanceDefinition(r0, r1, r2)
     bindingInfo.liveContainers = containers
-    appState.buildInstance(bindingInfo)
+    appState = new MockAppState(bindingInfo)
 
     assert appState.startedCountainerCount == clusterSize
 
@@ -107,7 +99,7 @@ class TestMockAppStateRebuildOnAMRestart extends BaseMockAppStateTest implements
     }
     assert 0 == appState.reviewRequestAndReleaseNodes().size()
 
-    def status = appState.getClusterStatus()
+    def status = appState.clusterStatus
     // verify the AM restart container count was set
     String restarted = status.getInfo(StatusKeys.INFO_CONTAINERS_AM_RESTART)
     assert restarted != null;