|
@@ -700,7 +700,6 @@ public class ServiceResourceProviderTest {
|
|
|
expect(ambariMetaInfo.getComponentCategory((String) anyObject(), (String) anyObject(),
|
|
|
(String) anyObject(), (String) anyObject())).andReturn(componentInfo).anyTimes();
|
|
|
|
|
|
- expect(componentInfo.isMaster()).andReturn(true);
|
|
|
expect(componentInfo.isMaster()).andReturn(false);
|
|
|
expect(componentInfo.isMaster()).andReturn(false);
|
|
|
|
|
@@ -860,6 +859,90 @@ public class ServiceResourceProviderTest {
|
|
|
verify(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testDefaultServiceState_ClientOnly_INSTALLED() throws Exception{
|
|
|
+ AmbariManagementController managementController = createMock(AmbariManagementController.class);
|
|
|
+ Clusters clusters = createNiceMock(Clusters.class);
|
|
|
+ Cluster cluster = createNiceMock(Cluster.class);
|
|
|
+ AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
|
|
|
+ StackId stackId = createNiceMock(StackId.class);
|
|
|
+ ComponentInfo componentInfo = createNiceMock(ComponentInfo.class);
|
|
|
+
|
|
|
+ ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse("C1", "PIG", "PIG", "Host100", "INSTALLED", "", null, null, null);
|
|
|
+
|
|
|
+ Set<ServiceComponentHostResponse> responses = new LinkedHashSet<ServiceComponentHostResponse>();
|
|
|
+ responses.add(shr1);
|
|
|
+
|
|
|
+ // set expectations
|
|
|
+ expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
|
|
|
+ expect(managementController.getClusters()).andReturn(clusters).anyTimes();
|
|
|
+ expect(clusters.getCluster("C1")).andReturn(cluster).anyTimes();
|
|
|
+ expect(managementController.getHostComponents((Set<ServiceComponentHostRequest>) anyObject())).andReturn(responses).anyTimes();
|
|
|
+ expect(cluster.getDesiredStackVersion()).andReturn(stackId);
|
|
|
+
|
|
|
+ expect(stackId.getStackName()).andReturn("S1").anyTimes();
|
|
|
+ expect(stackId.getStackVersion()).andReturn("V1").anyTimes();
|
|
|
+
|
|
|
+
|
|
|
+ expect(ambariMetaInfo.getComponentCategory((String) anyObject(), (String) anyObject(),
|
|
|
+ (String) anyObject(), (String) anyObject())).andReturn(componentInfo).anyTimes();
|
|
|
+
|
|
|
+ expect(componentInfo.isClient()).andReturn(true);
|
|
|
+
|
|
|
+ // replay
|
|
|
+ replay(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);
|
|
|
+
|
|
|
+ ServiceResourceProvider.ServiceState serviceState = new ServiceResourceProvider.DefaultServiceState();
|
|
|
+
|
|
|
+ State state = serviceState.getState(managementController, "C1", "PIG");
|
|
|
+ Assert.assertEquals(State.INSTALLED, state);
|
|
|
+
|
|
|
+ // verify
|
|
|
+ verify(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testDefaultServiceState_ClientOnly_INSTALL_FAILED() throws Exception{
|
|
|
+ AmbariManagementController managementController = createMock(AmbariManagementController.class);
|
|
|
+ Clusters clusters = createNiceMock(Clusters.class);
|
|
|
+ Cluster cluster = createNiceMock(Cluster.class);
|
|
|
+ AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
|
|
|
+ StackId stackId = createNiceMock(StackId.class);
|
|
|
+ ComponentInfo componentInfo = createNiceMock(ComponentInfo.class);
|
|
|
+
|
|
|
+ ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse("C1", "PIG", "PIG", "Host100", "INSTALL_FAILED", "", null, null, null);
|
|
|
+
|
|
|
+ Set<ServiceComponentHostResponse> responses = new LinkedHashSet<ServiceComponentHostResponse>();
|
|
|
+ responses.add(shr1);
|
|
|
+
|
|
|
+ // set expectations
|
|
|
+ expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
|
|
|
+ expect(managementController.getClusters()).andReturn(clusters).anyTimes();
|
|
|
+ expect(clusters.getCluster("C1")).andReturn(cluster).anyTimes();
|
|
|
+ expect(managementController.getHostComponents((Set<ServiceComponentHostRequest>) anyObject())).andReturn(responses).anyTimes();
|
|
|
+ expect(cluster.getDesiredStackVersion()).andReturn(stackId);
|
|
|
+
|
|
|
+ expect(stackId.getStackName()).andReturn("S1").anyTimes();
|
|
|
+ expect(stackId.getStackVersion()).andReturn("V1").anyTimes();
|
|
|
+
|
|
|
+
|
|
|
+ expect(ambariMetaInfo.getComponentCategory((String) anyObject(), (String) anyObject(),
|
|
|
+ (String) anyObject(), (String) anyObject())).andReturn(componentInfo).anyTimes();
|
|
|
+
|
|
|
+ expect(componentInfo.isClient()).andReturn(true);
|
|
|
+
|
|
|
+ // replay
|
|
|
+ replay(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);
|
|
|
+
|
|
|
+ ServiceResourceProvider.ServiceState serviceState = new ServiceResourceProvider.DefaultServiceState();
|
|
|
+
|
|
|
+ State state = serviceState.getState(managementController, "C1", "PIG");
|
|
|
+ Assert.assertEquals(State.INSTALL_FAILED, state);
|
|
|
+
|
|
|
+ // verify
|
|
|
+ verify(managementController, clusters, cluster, ambariMetaInfo, stackId, componentInfo);
|
|
|
+ }
|
|
|
+
|
|
|
public static ServiceResourceProvider getServiceProvider(AmbariManagementController managementController) {
|
|
|
Resource.Type type = Resource.Type.Service;
|
|
|
return new ServiceResourceProvider(PropertyHelper.getPropertyIds(type),
|