incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1406489 [17/19] - in /incubator/ambari/branches/AMBARI-666: ./ ambari-agent/ ambari-agent/conf/ ambari-agent/conf/unix/ ambari-agent/src/main/puppet/manifestloader/ ambari-agent/src/main/puppet/modules/configgenerator/manifests/ ambari-age...
Date Wed, 07 Nov 2012 08:13:24 GMT
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java Wed Nov  7 08:13:12 2012
@@ -38,12 +38,12 @@ public class JMXPropertyProviderTest {
   public void testGetResources() throws Exception {
 
     TestStreamProvider  streamProvider = new TestStreamProvider();
-    Map<String, String> hostMap        = TestHostMappingProvider.getHostMap();
+      TestJMXHostProvider hostProvider = new TestJMXHostProvider();
 
     JMXPropertyProvider propertyProvider = new JMXPropertyProvider(
         PropertyHelper.getJMXPropertyIds(Resource.Type.HostComponent),
         streamProvider,
-        hostMap);
+        hostProvider);
 
     // namenode
     Resource resource = new ResourceImpl(Resource.Type.HostComponent);
@@ -101,4 +101,13 @@ public class JMXPropertyProviderTest {
     Assert.assertEquals(59, resource.getPropertyValue(PropertyHelper.getPropertyId("threadsWaiting", "metrics/jvm")));
     Assert.assertNull(resource.getPropertyValue(PropertyHelper.getPropertyId("gcCount", "metrics/jvm")));
   }
+
+
+
+  private static class TestJMXHostProvider implements JMXHostProvider {
+    @Override
+    public Map<String, String> getHostMapping(String hostName) {
+      return TestHostMappingProvider.getHostMap();
+    }
+  }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/AndPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/AndPredicateTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/AndPredicateTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/AndPredicateTest.java Wed Nov  7 08:13:12 2012
@@ -18,6 +18,8 @@
 package org.apache.ambari.server.controller.predicate;
 
 import junit.framework.Assert;
+import org.apache.ambari.server.controller.internal.PropertyIdImpl;
+import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.spi.PropertyId;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.junit.Test;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/EqualsPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/EqualsPredicateTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/EqualsPredicateTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/EqualsPredicateTest.java Wed Nov  7 08:13:12 2012
@@ -18,6 +18,8 @@
 package org.apache.ambari.server.controller.predicate;
 
 import junit.framework.Assert;
+import org.apache.ambari.server.controller.internal.PropertyIdImpl;
+import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.PropertyId;
 import org.apache.ambari.server.controller.spi.Resource;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicateTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicateTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicateTest.java Wed Nov  7 08:13:12 2012
@@ -18,6 +18,8 @@
 package org.apache.ambari.server.controller.predicate;
 
 import junit.framework.Assert;
+import org.apache.ambari.server.controller.internal.PropertyIdImpl;
+import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.PropertyId;
 import org.apache.ambari.server.controller.spi.Resource;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterPredicateTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterPredicateTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/GreaterPredicateTest.java Wed Nov  7 08:13:12 2012
@@ -18,6 +18,8 @@
 package org.apache.ambari.server.controller.predicate;
 
 import junit.framework.Assert;
+import org.apache.ambari.server.controller.internal.PropertyIdImpl;
+import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.PropertyId;
 import org.apache.ambari.server.controller.spi.Resource;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicateTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicateTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicateTest.java Wed Nov  7 08:13:12 2012
@@ -18,6 +18,8 @@
 package org.apache.ambari.server.controller.predicate;
 
 import junit.framework.Assert;
+import org.apache.ambari.server.controller.internal.PropertyIdImpl;
+import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.PropertyId;
 import org.apache.ambari.server.controller.spi.Resource;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessPredicateTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessPredicateTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/LessPredicateTest.java Wed Nov  7 08:13:12 2012
@@ -18,6 +18,8 @@
 package org.apache.ambari.server.controller.predicate;
 
 import junit.framework.Assert;
+import org.apache.ambari.server.controller.internal.PropertyIdImpl;
+import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.PropertyId;
 import org.apache.ambari.server.controller.spi.Resource;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/NotPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/NotPredicateTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/NotPredicateTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/NotPredicateTest.java Wed Nov  7 08:13:12 2012
@@ -18,6 +18,8 @@
 package org.apache.ambari.server.controller.predicate;
 
 import junit.framework.Assert;
+import org.apache.ambari.server.controller.internal.PropertyIdImpl;
+import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.spi.PropertyId;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.junit.Test;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/OrPredicateTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/OrPredicateTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/OrPredicateTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/OrPredicateTest.java Wed Nov  7 08:13:12 2012
@@ -18,6 +18,8 @@
 package org.apache.ambari.server.controller.predicate;
 
 import junit.framework.Assert;
+import org.apache.ambari.server.controller.internal.PropertyIdImpl;
+import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.spi.PropertyId;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.junit.Test;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/PredicateVisitorTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/PredicateVisitorTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/PredicateVisitorTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/predicate/PredicateVisitorTest.java Wed Nov  7 08:13:12 2012
@@ -18,6 +18,7 @@
 package org.apache.ambari.server.controller.predicate;
 
 import junit.framework.Assert;
+import org.apache.ambari.server.controller.internal.PropertyIdImpl;
 import org.junit.Test;
 
 /**

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java Wed Nov  7 08:13:12 2012
@@ -11,6 +11,12 @@ public class InMemoryDefaultTestModule e
   protected void configure() {
     Properties properties = new Properties();
     properties.setProperty(Configuration.PERSISTENCE_IN_MEMORY_KEY, "true");
-    install(new ControllerModule(properties));
+    properties.setProperty(Configuration.METADETA_DIR_PATH,
+        "src/test/resources/stacks");
+    try {
+      install(new ControllerModule(properties));
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
   }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/TestOrmImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/TestOrmImpl.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/TestOrmImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/orm/TestOrmImpl.java Wed Nov  7 08:13:12 2012
@@ -234,4 +234,74 @@ public class TestOrmImpl extends Assert 
     assertEquals(0L, stageDAO.getLastRequestId());
   }
 
+  @Test
+  public void testConcurrentModification() throws InterruptedException {
+    final ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
+    ClusterEntity clusterEntity = new ClusterEntity();
+    clusterEntity.setClusterName("cluster1");
+    clusterDAO.create(clusterEntity);
+
+    clusterEntity = clusterDAO.findById(clusterEntity.getClusterId());
+    assertEquals("cluster1", clusterEntity.getClusterName());
+
+    Thread thread = new Thread(){
+      @Override
+      public void run() {
+        ClusterEntity clusterEntity1 = clusterDAO.findByName("cluster1");
+        clusterEntity1.setClusterName("anotherName");
+        clusterDAO.merge(clusterEntity1);
+      }
+    };
+
+    thread.start();
+    thread.join();
+
+    clusterEntity = clusterDAO.findById(clusterEntity.getClusterId());
+    assertEquals("anotherName", clusterEntity.getClusterName());
+
+    thread = new Thread(){
+      @Override
+      public void run() {
+        clusterDAO.removeByName("anotherName");
+      }
+    };
+
+    thread.start();
+    thread.join();
+
+    assertNull(clusterDAO.findById(clusterEntity.getClusterId()));
+
+    List<ClusterEntity> result = clusterDAO.findAll();
+
+    thread = new Thread(){
+      @Override
+      public void run() {
+        ClusterEntity temp = new ClusterEntity();
+        temp.setClusterName("temp_cluster");
+        clusterDAO.create(temp);
+      }
+    };
+
+    thread.start();
+    thread.join();
+
+    assertEquals(result.size() + 1, (result = clusterDAO.findAll()).size());
+
+
+    thread = new Thread(){
+      @Override
+      public void run() {
+        ClusterEntity temp = new ClusterEntity();
+        temp.setClusterName("temp_cluster2");
+        clusterDAO.create(temp);
+      }
+    };
+
+    thread.start();
+    thread.join();
+
+    assertEquals(result.size() + 1, (clusterDAO.findAll()).size());
+
+  }
+
 }

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/TestUsers.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/TestUsers.java?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/TestUsers.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/TestUsers.java Wed Nov  7 08:13:12 2012
@@ -0,0 +1,126 @@
+/*
+ * 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.ambari.server.security.authorization;
+
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.persist.PersistService;
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.actionmanager.ActionDBAccessorImpl;
+import org.apache.ambari.server.actionmanager.ActionManager;
+import org.apache.ambari.server.agent.ActionQueue;
+import org.apache.ambari.server.orm.GuiceJpaInitializer;
+import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.orm.dao.RoleDAO;
+import org.apache.ambari.server.orm.dao.UserDAO;
+import org.apache.ambari.server.orm.entities.UserEntity;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.security.crypto.password.PasswordEncoder;
+
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+public class TestUsers {
+  private Injector injector;
+
+  @Inject
+  protected Users users;
+  @Inject
+  protected UserDAO userDAO;
+  @Inject
+  protected RoleDAO roleDAO;
+  @Inject
+  protected PasswordEncoder passwordEncoder;
+
+  @Before
+  public void setup() throws AmbariException {
+    injector = Guice.createInjector(new InMemoryDefaultTestModule());
+    injector.getInstance(GuiceJpaInitializer.class);
+    injector.injectMembers(this);
+    users.createDefaultRoles();
+  }
+
+  @After
+  public void tearDown() throws AmbariException {
+    injector.getInstance(PersistService.class).stop();
+  }
+
+  @Test
+  public void testGetAllUsers() throws Exception {
+    users.createUser("user", "user");
+    users.createUser("admin", "admin");
+
+    List<User> userList = users.getAllUsers();
+
+    assertEquals(2, userList.size());
+
+    for (User user : userList) {
+      assertEquals(false, user.isLdapUser());
+    }
+
+    assertEquals(2, userDAO.findAll().size());
+
+    UserEntity userEntity = userDAO.findLocalUserByName("user");
+    assertNotNull("user", userEntity.getUserPassword());
+
+    users.modifyPassword("user", "user", "resu");
+
+    assertNotSame(userEntity.getUserPassword(), userDAO.findLocalUserByName("user").getUserPassword());
+  }
+
+  @Test(expected = AmbariException.class)
+  public void testModifyPassword() throws Exception {
+    users.createUser("user", "user");
+
+    UserEntity userEntity = userDAO.findLocalUserByName("user");
+
+    assertNotSame("user", userEntity.getUserPassword());
+    assertTrue(passwordEncoder.matches("user", userEntity.getUserPassword()));
+
+    users.modifyPassword("user", "user", "resu");
+
+    assertNotSame(userEntity.getUserPassword(), userDAO.findLocalUserByName("user").getUserPassword());
+
+    users.modifyPassword("user", "error", "new");
+
+    fail("Exception was not thrown");
+  }
+
+  @Test
+  public void testPromoteUser() throws Exception {
+    users.createUser("admin", "admin");
+    User user = users.getLocalUser("admin");
+    assertTrue(user.getRoles().contains(users.getUserRole()));
+    assertFalse(user.getRoles().contains(users.getAdminRole()));
+
+    users.promoteToAdmin(user);
+
+    user = users.getLocalUser("admin");
+    assertTrue(user.getRoles().contains(users.getAdminRole()));
+
+    users.demoteAdmin(user);
+
+    user = users.getLocalUser("admin");
+    assertFalse(user.getRoles().contains(users.getAdminRole()));
+
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java Wed Nov  7 08:13:12 2012
@@ -122,6 +122,6 @@ public class TestStagePlanner {
     for (Stage s: outStages) {
       System.out.println(s.toString());
     }
-    assertEquals(5, outStages.size());
+    assertEquals(4, outStages.size());
   }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java Wed Nov  7 08:13:12 2012
@@ -26,6 +26,7 @@ import java.util.Map;
 import junit.framework.Assert;
 
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.ServiceComponentResponse;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
@@ -57,9 +58,10 @@ public class ServiceComponentTest {
   private ServiceFactory serviceFactory;
   private ServiceComponentFactory serviceComponentFactory;
   private ServiceComponentHostFactory serviceComponentHostFactory;
+  private AmbariMetaInfo metaInfo;
 
   @Before
-  public void setup() throws AmbariException {
+  public void setup() throws Exception {
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
     injector.getInstance(GuiceJpaInitializer.class);
     clusters = injector.getInstance(Clusters.class);
@@ -68,10 +70,14 @@ public class ServiceComponentTest {
         ServiceComponentFactory.class);
     serviceComponentHostFactory = injector.getInstance(
         ServiceComponentHostFactory.class);
+    metaInfo = injector.getInstance(AmbariMetaInfo.class);
+    metaInfo.init();
+
     clusterName = "foo";
-    serviceName = "s1";
+    serviceName = "HDFS";
     clusters.addCluster(clusterName);
     cluster = clusters.getCluster(clusterName);
+    cluster.setDesiredStackVersion(new StackId("HDP-0.1"));
     Assert.assertNotNull(cluster);
     Service s = serviceFactory.createNew(cluster, serviceName);
     cluster.addService(s);
@@ -87,7 +93,7 @@ public class ServiceComponentTest {
 
   @Test
   public void testCreateServiceComponent() throws AmbariException {
-    String componentName = "sc1";
+    String componentName = "DATANODE2";
     ServiceComponent component = serviceComponentFactory.createNew(service,
         componentName);
     service.addServiceComponent(component);
@@ -103,14 +109,14 @@ public class ServiceComponentTest {
     Assert.assertEquals(cluster.getClusterName(),
         sc.getClusterName());
     Assert.assertEquals(State.INIT, sc.getDesiredState());
-    Assert.assertTrue(
-        sc.getDesiredStackVersion().getStackVersion().isEmpty());
+    Assert.assertFalse(
+        sc.getDesiredStackVersion().getStackId().isEmpty());
   }
 
 
   @Test
   public void testGetAndSetServiceComponentInfo() throws AmbariException {
-    String componentName = "sc1";
+    String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service,
         componentName);
     service.addServiceComponent(component);
@@ -123,8 +129,8 @@ public class ServiceComponentTest {
     sc.setDesiredState(State.INSTALLED);
     Assert.assertEquals(State.INSTALLED, sc.getDesiredState());
 
-    sc.setDesiredStackVersion(new StackVersion("1.0.0"));
-    Assert.assertEquals("1.0.0", sc.getDesiredStackVersion().getStackVersion());
+    sc.setDesiredStackVersion(new StackId("HDP-1.0.0"));
+    Assert.assertEquals("HDP-1.0.0", sc.getDesiredStackVersion().getStackId());
 
     ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO =
         injector.getInstance(ServiceComponentDesiredStateDAO.class);
@@ -142,8 +148,8 @@ public class ServiceComponentTest {
         serviceComponentDesiredStateEntity);
     Assert.assertNotNull(sc1);
     Assert.assertEquals(State.INSTALLED, sc1.getDesiredState());
-    Assert.assertEquals("1.0.0",
-        sc1.getDesiredStackVersion().getStackVersion());
+    Assert.assertEquals("HDP-1.0.0",
+        sc1.getDesiredStackVersion().getStackId());
 
   }
 
@@ -168,7 +174,7 @@ public class ServiceComponentTest {
 
   @Test
   public void testAddAndGetServiceComponentHosts() throws AmbariException {
-    String componentName = "sc1";
+    String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service,
         componentName);
     service.addServiceComponent(component);
@@ -229,9 +235,9 @@ public class ServiceComponentTest {
     sch3.persist();
     Assert.assertNotNull(sc.getServiceComponentHost("h3"));
 
-    sch1.setDesiredStackVersion(new StackVersion("1.1.0"));
+    sch1.setDesiredStackVersion(new StackId("HDP-1.1.0"));
     sch1.setState(State.STARTING);
-    sch1.setStackVersion(new StackVersion("1.0.0"));
+    sch1.setStackVersion(new StackId("HDP-1.0.0"));
     sch1.setDesiredState(State.STARTED);
 
     HostComponentDesiredStateDAO desiredStateDAO = injector.getInstance(
@@ -263,15 +269,15 @@ public class ServiceComponentTest {
     Assert.assertNotNull(sch);
     Assert.assertEquals(State.STARTING, sch.getState());
     Assert.assertEquals(State.STARTED, sch.getDesiredState());
-    Assert.assertEquals("1.0.0",
-        sch.getStackVersion().getStackVersion());
-    Assert.assertEquals("1.1.0",
-        sch.getDesiredStackVersion().getStackVersion());
+    Assert.assertEquals("HDP-1.0.0",
+        sch.getStackVersion().getStackId());
+    Assert.assertEquals("HDP-1.1.0",
+        sch.getDesiredStackVersion().getStackId());
   }
 
   @Test
   public void testConvertToResponse() throws AmbariException {
-    String componentName = "sc1";
+    String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service,
         componentName);
     service.addServiceComponent(component);
@@ -280,14 +286,14 @@ public class ServiceComponentTest {
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
     sc.setDesiredState(State.INSTALLED);
-    sc.setDesiredStackVersion(new StackVersion("1.0.0"));
+    sc.setDesiredStackVersion(new StackId("HDP-1.0.0"));
 
     ServiceComponentResponse r = sc.convertToResponse();
     Assert.assertEquals(sc.getClusterName(), r.getClusterName());
     Assert.assertEquals(sc.getClusterId(), r.getClusterId().longValue());
     Assert.assertEquals(sc.getName(), r.getComponentName());
     Assert.assertEquals(sc.getServiceName(), r.getServiceName());
-    Assert.assertEquals(sc.getDesiredStackVersion().getStackVersion(),
+    Assert.assertEquals(sc.getDesiredStackVersion().getStackId(),
         r.getDesiredStackVersion());
     Assert.assertEquals(sc.getDesiredState().toString(),
         r.getDesiredState());

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java Wed Nov  7 08:13:12 2012
@@ -30,6 +30,7 @@ import com.google.inject.persist.Persist
 import junit.framework.Assert;
 
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.ServiceResponse;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
@@ -45,18 +46,22 @@ public class ServiceTest {
   private Injector injector;
   private ServiceFactory serviceFactory;
   private ServiceComponentFactory serviceComponentFactory;
+  private AmbariMetaInfo metaInfo;
 
   @Before
-  public void setup() throws AmbariException {
+  public void setup() throws Exception {
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
     injector.getInstance(GuiceJpaInitializer.class);
     clusters = injector.getInstance(Clusters.class);
     serviceFactory = injector.getInstance(ServiceFactory.class);
     serviceComponentFactory = injector.getInstance(
         ServiceComponentFactory.class);
+    metaInfo = injector.getInstance(AmbariMetaInfo.class);
+    metaInfo.init();
     clusterName = "foo";
     clusters.addCluster(clusterName);
     cluster = clusters.getCluster(clusterName);
+    cluster.setDesiredStackVersion(new StackId("HDP-0.1"));
     Assert.assertNotNull(cluster);
   }
 
@@ -80,8 +85,8 @@ public class ServiceTest {
     Assert.assertEquals(cluster.getClusterName(),
         service.getCluster().getClusterName());
     Assert.assertEquals(State.INIT, service.getDesiredState());
-    Assert.assertTrue(
-        service.getDesiredStackVersion().getStackVersion().isEmpty());
+    Assert.assertFalse(
+        service.getDesiredStackVersion().getStackId().isEmpty());
   }
 
   @Test
@@ -94,9 +99,9 @@ public class ServiceTest {
     Service service = cluster.getService(serviceName);
     Assert.assertNotNull(service);
 
-    service.setDesiredStackVersion(new StackVersion("1.1.0"));
-    Assert.assertEquals("1.1.0",
-        service.getDesiredStackVersion().getStackVersion());
+    service.setDesiredStackVersion(new StackId("HDP-1.1.0"));
+    Assert.assertEquals("HDP-1.1.0",
+        service.getDesiredStackVersion().getStackId());
 
     service.setDesiredState(State.INSTALLING);
     Assert.assertEquals(State.INSTALLING, service.getDesiredState());
@@ -108,7 +113,7 @@ public class ServiceTest {
 
   @Test
   public void testAddAndGetServiceComponents() throws AmbariException {
-    String serviceName = "s1";
+    String serviceName = "HDFS";
     Service s = serviceFactory.createNew(cluster, serviceName);
     cluster.addService(s);
     s.persist();
@@ -120,11 +125,11 @@ public class ServiceTest {
     Assert.assertTrue(s.getServiceComponents().isEmpty());
 
     ServiceComponent sc1 =
-        serviceComponentFactory.createNew(s, "sc1");
+        serviceComponentFactory.createNew(s, "NAMENODE");
     ServiceComponent sc2 =
-        serviceComponentFactory.createNew(s, "sc2");
+        serviceComponentFactory.createNew(s, "DATANODE1");
     ServiceComponent sc3 =
-        serviceComponentFactory.createNew(s, "sc3");
+        serviceComponentFactory.createNew(s, "DATANODE2");
 
     Map<String, ServiceComponent> comps = new
         HashMap<String, ServiceComponent>();
@@ -150,10 +155,11 @@ public class ServiceTest {
     sc2.persist();
     sc3.persist();
 
-    ServiceComponent sc4 = s.addServiceComponent("sc4");
+    ServiceComponent sc4 = s.addServiceComponent("HDFS_CLIENT");
     Assert.assertNotNull(s.getServiceComponent(sc4.getName()));
     Assert.assertEquals(State.INIT,
-        s.getServiceComponent("sc4").getDesiredState());
+        s.getServiceComponent("HDFS_CLIENT").getDesiredState());
+    Assert.assertTrue(sc4.isClientComponent());
     sc4.persist();
 
     Assert.assertEquals(4, s.getServiceComponents().size());
@@ -168,7 +174,7 @@ public class ServiceTest {
 
     sc4.setDesiredState(State.INSTALLING);
     Assert.assertEquals(State.INSTALLING,
-        s.getServiceComponent("sc4").getDesiredState());
+        s.getServiceComponent("HDFS_CLIENT").getDesiredState());
 
   }
 
@@ -194,18 +200,18 @@ public class ServiceTest {
     Assert.assertEquals(s.getName(), r.getServiceName());
     Assert.assertEquals(s.getCluster().getClusterName(),
         r.getClusterName());
-    Assert.assertEquals(s.getDesiredStackVersion().getStackVersion(),
+    Assert.assertEquals(s.getDesiredStackVersion().getStackId(),
         r.getDesiredStackVersion());
     Assert.assertEquals(s.getDesiredState().toString(),
         r.getDesiredState());
 
-    service.setDesiredStackVersion(new StackVersion("1.1.0"));
+    service.setDesiredStackVersion(new StackId("HDP-1.1.0"));
     service.setDesiredState(State.INSTALLING);
     r = s.convertToResponse();
     Assert.assertEquals(s.getName(), r.getServiceName());
     Assert.assertEquals(s.getCluster().getClusterName(),
         r.getClusterName());
-    Assert.assertEquals(s.getDesiredStackVersion().getStackVersion(),
+    Assert.assertEquals(s.getDesiredStackVersion().getStackId(),
         r.getDesiredStackVersion());
     Assert.assertEquals(s.getDesiredState().toString(),
         r.getDesiredState());

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/action/JobTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/action/JobTest.java?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/action/JobTest.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/action/JobTest.java Wed Nov  7 08:13:12 2012
@@ -0,0 +1,153 @@
+/**
+ * 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.ambari.server.state.action;
+
+import org.apache.ambari.server.state.action.Action;
+import org.apache.ambari.server.state.action.ActionCompletedEvent;
+import org.apache.ambari.server.state.action.ActionEvent;
+import org.apache.ambari.server.state.action.ActionFailedEvent;
+import org.apache.ambari.server.state.action.ActionId;
+import org.apache.ambari.server.state.action.ActionImpl;
+import org.apache.ambari.server.state.action.ActionProgressUpdateEvent;
+import org.apache.ambari.server.state.action.ActionState;
+import org.apache.ambari.server.state.action.ActionType;
+import org.apache.ambari.server.state.action.ActionInitEvent;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class JobTest {
+
+  private Action createNewJob(long id, String jobName, long startTime) {
+    ActionId jId = new ActionId(id, new ActionType(jobName));
+    Action job = new ActionImpl(jId, startTime);
+    return job;
+  }
+
+  private Action getRunningJob(long id, String jobName, long startTime)
+      throws Exception {
+    Action job = createNewJob(id, jobName, startTime);
+    verifyProgressUpdate(job, ++startTime);
+    return job;
+  }
+
+  private Action getCompletedJob(long id, String jobName, long startTime,
+      boolean failedJob) throws Exception {
+    Action job = getRunningJob(1, "JobNameFoo", startTime);
+    completeJob(job, failedJob, ++startTime);
+    return job;
+  }
+
+  private void verifyNewJob(Action job, long startTime) {
+    Assert.assertEquals(ActionState.INIT, job.getState());
+    Assert.assertEquals(startTime, job.getStartTime());
+  }
+
+
+  @Test
+  public void testNewJob() {
+    long currentTime = System.currentTimeMillis();
+    Action job = createNewJob(1, "JobNameFoo", currentTime);
+    verifyNewJob(job, currentTime);
+  }
+
+  private void verifyProgressUpdate(Action job, long updateTime)
+      throws Exception {
+    ActionProgressUpdateEvent e = new ActionProgressUpdateEvent(job.getId(),
+        updateTime);
+    job.handleEvent(e);
+    Assert.assertEquals(ActionState.IN_PROGRESS, job.getState());
+    Assert.assertEquals(updateTime, job.getLastUpdateTime());
+  }
+
+
+  @Test
+  public void testJobProgressUpdates() throws Exception {
+    long currentTime = 1;
+    Action job = createNewJob(1, "JobNameFoo", currentTime);
+    verifyNewJob(job, currentTime);
+
+    verifyProgressUpdate(job, ++currentTime);
+    verifyProgressUpdate(job, ++currentTime);
+    verifyProgressUpdate(job, ++currentTime);
+
+  }
+
+  private void completeJob(Action job, boolean failJob, long endTime)
+      throws Exception {
+    ActionEvent e = null;
+    ActionState endState = null;
+    if (failJob) {
+      e = new ActionFailedEvent(job.getId(), endTime);
+      endState = ActionState.FAILED;
+    } else {
+      e = new ActionCompletedEvent(job.getId(), endTime);
+      endState = ActionState.COMPLETED;
+    }
+    job.handleEvent(e);
+    Assert.assertEquals(endState, job.getState());
+    Assert.assertEquals(endTime, job.getLastUpdateTime());
+    Assert.assertEquals(endTime, job.getCompletionTime());
+  }
+
+
+  @Test
+  public void testJobSuccessfulCompletion() throws Exception {
+    long currentTime = 1;
+    Action job = getRunningJob(1, "JobNameFoo", currentTime);
+    completeJob(job, false, ++currentTime);
+  }
+
+  @Test
+  public void testJobFailedCompletion() throws Exception {
+    long currentTime = 1;
+    Action job = getRunningJob(1, "JobNameFoo", currentTime);
+    completeJob(job, true, ++currentTime);
+  }
+
+  @Test
+  public void completeNewJob() throws Exception {
+    long currentTime = 1;
+    Action job = createNewJob(1, "JobNameFoo", currentTime);
+    verifyNewJob(job, currentTime);
+    completeJob(job, false, ++currentTime);
+  }
+
+  @Test
+  public void failNewJob() throws Exception {
+    long currentTime = 1;
+    Action job = createNewJob(1, "JobNameFoo", currentTime);
+    verifyNewJob(job, currentTime);
+    completeJob(job, true, ++currentTime);
+  }
+
+  @Test
+  public void reInitCompletedJob() throws Exception {
+    Action job = getCompletedJob(1, "JobNameFoo", 1, false);
+    ActionId jId = new ActionId(2, new ActionType("JobNameFoo"));
+    ActionInitEvent e = new ActionInitEvent(jId, 100);
+    job.handleEvent(e);
+    Assert.assertEquals(ActionState.INIT, job.getState());
+    Assert.assertEquals(100, job.getStartTime());
+    Assert.assertEquals(-1, job.getLastUpdateTime());
+    Assert.assertEquals(-1, job.getCompletionTime());
+    Assert.assertEquals(2, job.getId().actionId);
+  }
+
+
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java Wed Nov  7 08:13:12 2012
@@ -32,6 +32,7 @@ import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.agent.DiskInfo;
 import org.apache.ambari.server.agent.HostInfo;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.ClusterResponse;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
@@ -46,7 +47,7 @@ import org.apache.ambari.server.state.Se
 import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.ServiceComponentHostFactory;
 import org.apache.ambari.server.state.ServiceFactory;
-import org.apache.ambari.server.state.StackVersion;
+import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
 import org.apache.ambari.server.state.host.HostHealthyHeartbeatEvent;
 import org.apache.ambari.server.state.host.HostRegistrationRequestEvent;
@@ -62,9 +63,10 @@ public class ClusterTest {
   private ServiceFactory serviceFactory;
   private ServiceComponentFactory serviceComponentFactory;
   private ServiceComponentHostFactory serviceComponentHostFactory;
+  private AmbariMetaInfo metaInfo;
 
   @Before
-  public void setup() throws AmbariException {
+  public void setup() throws Exception {
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
     injector.getInstance(GuiceJpaInitializer.class);
     clusters = injector.getInstance(Clusters.class);
@@ -73,6 +75,8 @@ public class ClusterTest {
         ServiceComponentFactory.class);
     serviceComponentHostFactory = injector.getInstance(
         ServiceComponentHostFactory.class);
+    metaInfo = injector.getInstance(AmbariMetaInfo.class);
+    metaInfo.init();
     clusters.addCluster("c1");
     c1 = clusters.getCluster("c1");
     Assert.assertEquals("c1", c1.getClusterName());
@@ -83,6 +87,7 @@ public class ClusterTest {
     host.setIPv6("ipv6");
     host.persist();
     clusters.mapHostToCluster("h1", "c1");
+    c1.setDesiredStackVersion(new StackId("HDP-0.1"));
   }
 
   @After
@@ -177,11 +182,11 @@ public class ClusterTest {
     Assert.assertEquals("foo2", c2.getClusterName());
 
     Assert.assertNotNull(c2.getDesiredStackVersion());
-    Assert.assertEquals("", c2.getDesiredStackVersion().getStackVersion());
+    Assert.assertEquals("", c2.getDesiredStackVersion().getStackId());
 
-    StackVersion stackVersion = new StackVersion("1.0");
+    StackId stackVersion = new StackId("HDP-1.0");
     c2.setDesiredStackVersion(stackVersion);
-    Assert.assertEquals("1.0", c2.getDesiredStackVersion().getStackVersion());
+    Assert.assertEquals("HDP-1.0", c2.getDesiredStackVersion().getStackId());
   }
 
   @Test
@@ -233,10 +238,10 @@ public class ClusterTest {
     // TODO write unit tests
     // public List<ServiceComponentHost> getServiceComponentHosts(String hostname);
 
-    Service s = serviceFactory.createNew(c1, "s");
+    Service s = serviceFactory.createNew(c1, "HDFS");
     c1.addService(s);
     s.persist();
-    ServiceComponent sc = serviceComponentFactory.createNew(s, "sc");
+    ServiceComponent sc = serviceComponentFactory.createNew(s, "NAMENODE");
     s.addServiceComponent(sc);
     sc.persist();
     ServiceComponentHost sch =

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java Wed Nov  7 08:13:12 2012
@@ -24,10 +24,14 @@ import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
 
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.ServiceComponentNotFoundException;
+import org.apache.ambari.server.ServiceNotFoundException;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.ServiceComponentHostResponse;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.state.*;
+import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostImpl;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostInstallEvent;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostOpFailedEvent;
@@ -42,6 +46,7 @@ import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.mortbay.log.Log;
 
 public class ServiceComponentHostTest {
 
@@ -55,15 +60,21 @@ public class ServiceComponentHostTest {
   private ServiceComponentFactory serviceComponentFactory;
   @Inject
   private ServiceComponentHostFactory serviceComponentHostFactory;
+  @Inject
+  private AmbariMetaInfo metaInfo;
 
   @Before
-  public void setup() throws AmbariException {
+  public void setup() throws Exception {
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
     injector.getInstance(GuiceJpaInitializer.class);
     injector.injectMembers(this);
     clusters.addCluster("C1");
     clusters.addHost("h1");
     clusters.mapHostToCluster("h1","C1");
+    clusters.getHost("h1").persist();
+    clusters.getCluster("C1").setDesiredStackVersion(
+        new StackId("HDP-0.1"));
+    metaInfo.init();
   }
 
   @After
@@ -76,10 +87,30 @@ public class ServiceComponentHostTest {
       String svcComponent,
       String hostName, boolean isClient) throws AmbariException{
     Cluster c = clusters.getCluster("C1");
-    Service s = serviceFactory.createNew(c, svc);
-    ServiceComponent sc = serviceComponentFactory.createNew(s, svcComponent);
+    Service s = null;
+
+    try {
+      s = c.getService(svc);
+    } catch (ServiceNotFoundException e) {
+      Log.debug("Calling service create"
+          + ", serviceName=" + svc);
+      s = serviceFactory.createNew(c, svc);
+      c.addService(s);
+      s.persist();
+    }
+
+    ServiceComponent sc = null;
+    try {
+      sc = s.getServiceComponent(svcComponent);
+    } catch (ServiceComponentNotFoundException e) {
+      sc = serviceComponentFactory.createNew(s, svcComponent);
+      s.addServiceComponent(sc);
+      sc.persist();
+    }
+
     ServiceComponentHost impl = serviceComponentHostFactory.createNew(
         sc, hostName, isClient);
+    impl.persist();
     Assert.assertEquals(State.INIT,
         impl.getState());
     Assert.assertEquals(State.INIT,
@@ -89,17 +120,17 @@ public class ServiceComponentHostTest {
     Assert.assertEquals(s.getName(), impl.getServiceName());
     Assert.assertEquals(sc.getName(), impl.getServiceComponentName());
     Assert.assertEquals(hostName, impl.getHostName());
-    Assert.assertTrue(
-        impl.getDesiredStackVersion().getStackVersion().isEmpty());
-    Assert.assertTrue(impl.getStackVersion().getStackVersion().isEmpty());
+    Assert.assertFalse(
+        impl.getDesiredStackVersion().getStackId().isEmpty());
+    Assert.assertTrue(impl.getStackVersion().getStackId().isEmpty());
 
     return impl;
   }
 
   @Test
-  public void testNewServiceComponentHostImpl() throws AmbariException{
-    createNewServiceComponentHost("svc", "svcComp", "h1", false);
-    createNewServiceComponentHost("svc", "svcComp", "h1", true);
+  public void testNewServiceComponentHost() throws AmbariException{
+    createNewServiceComponentHost("HDFS", "NAMENODE", "h1", false);
+    createNewServiceComponentHost("HDFS", "HDFS_CLIENT", "h1", true);
   }
 
   private ServiceComponentHostEvent createEvent(ServiceComponentHostImpl impl,
@@ -272,7 +303,7 @@ public class ServiceComponentHostTest {
   @Test
   public void testClientStateFlow() throws Exception {
     ServiceComponentHostImpl impl = (ServiceComponentHostImpl)
-        createNewServiceComponentHost("svc", "svcComp", "h1", true);
+        createNewServiceComponentHost("HDFS", "HDFS_CLIENT", "h1", true);
 
     runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
         State.INIT,
@@ -310,7 +341,7 @@ public class ServiceComponentHostTest {
   @Test
   public void testDaemonStateFlow() throws Exception {
     ServiceComponentHostImpl impl = (ServiceComponentHostImpl)
-        createNewServiceComponentHost("svc", "svcComp", "h1", false);
+        createNewServiceComponentHost("HDFS", "DATANODE", "h1", false);
 
     runStateChanges(impl, ServiceComponentHostEventType.HOST_SVCCOMP_INSTALL,
         State.INIT,
@@ -363,36 +394,36 @@ public class ServiceComponentHostTest {
   @Test
   public void testGetAndSetBasicInfo() throws AmbariException {
     ServiceComponentHost sch =
-        createNewServiceComponentHost("svc", "svcComp", "h1", false);
+        createNewServiceComponentHost("HDFS", "NAMENODE", "h1", false);
     sch.setDesiredState(State.INSTALLED);
     sch.setState(State.INSTALLING);
-    sch.setStackVersion(new StackVersion("1.0.0"));
-    sch.setDesiredStackVersion(new StackVersion("1.1.0"));
+    sch.setStackVersion(new StackId("HDP-1.0.0"));
+    sch.setDesiredStackVersion(new StackId("HDP-1.1.0"));
 
     Assert.assertEquals(State.INSTALLING, sch.getState());
     Assert.assertEquals(State.INSTALLED, sch.getDesiredState());
-    Assert.assertEquals("1.0.0",
-        sch.getStackVersion().getStackVersion());
-    Assert.assertEquals("1.1.0",
-        sch.getDesiredStackVersion().getStackVersion());
+    Assert.assertEquals("HDP-1.0.0",
+        sch.getStackVersion().getStackId());
+    Assert.assertEquals("HDP-1.1.0",
+        sch.getDesiredStackVersion().getStackId());
   }
 
   @Test
   public void testConvertToResponse() throws AmbariException {
     ServiceComponentHost sch =
-        createNewServiceComponentHost("svc", "svcComp", "h1", false);
+        createNewServiceComponentHost("HDFS", "DATANODE", "h1", false);
     sch.setDesiredState(State.INSTALLED);
     sch.setState(State.INSTALLING);
-    sch.setStackVersion(new StackVersion("1.0.0"));
+    sch.setStackVersion(new StackId("HDP-1.0.0"));
     ServiceComponentHostResponse r =
         sch.convertToResponse();
-    Assert.assertEquals("svc", r.getServiceName());
-    Assert.assertEquals("svcComp", r.getComponentName());
+    Assert.assertEquals("HDFS", r.getServiceName());
+    Assert.assertEquals("DATANODE", r.getComponentName());
     Assert.assertEquals("h1", r.getHostname());
     Assert.assertEquals("C1", r.getClusterName());
     Assert.assertEquals(State.INSTALLED.toString(), r.getDesiredState());
     Assert.assertEquals(State.INSTALLING.toString(), r.getLiveState());
-    Assert.assertEquals("1.0.0", r.getStackVersion());
+    Assert.assertEquals("HDP-1.0.0", r.getStackVersion());
 
     // TODO check configs
 
@@ -401,4 +432,54 @@ public class ServiceComponentHostTest {
     Assert.assertFalse(sb.toString().isEmpty());
   }
 
+  @Test
+  public void testStopInVariousStates() throws AmbariException,
+      InvalidStateTransitionException {
+    ServiceComponentHost sch =
+        createNewServiceComponentHost("HDFS", "DATANODE", "h1", false);
+    ServiceComponentHostImpl impl =  (ServiceComponentHostImpl) sch;
+
+    sch.setDesiredState(State.STARTED);
+    sch.setState(State.START_FAILED);
+
+    long timestamp = 0;
+
+    ServiceComponentHostEvent stopEvent = createEvent(impl, ++timestamp,
+        ServiceComponentHostEventType.HOST_SVCCOMP_STOP);
+
+    long startTime = timestamp;
+    impl.handleEvent(stopEvent);
+    Assert.assertEquals(startTime, impl.getLastOpStartTime());
+    Assert.assertEquals(-1, impl.getLastOpLastUpdateTime());
+    Assert.assertEquals(-1, impl.getLastOpEndTime());
+    Assert.assertEquals(State.STOPPING,
+        impl.getState());
+
+    sch.setState(State.INSTALL_FAILED);
+
+    boolean exceptionThrown = false;
+    try {
+      impl.handleEvent(stopEvent);
+    } catch (Exception e) {
+      exceptionThrown = true;
+    }
+    Assert.assertTrue("Exception not thrown on invalid event", exceptionThrown);
+
+    Assert.assertEquals(startTime, impl.getLastOpStartTime());
+    Assert.assertEquals(-1, impl.getLastOpLastUpdateTime());
+    Assert.assertEquals(-1, impl.getLastOpEndTime());
+
+    sch.setState(State.INSTALLED);
+    ServiceComponentHostEvent stopEvent2 = createEvent(impl, ++timestamp,
+        ServiceComponentHostEventType.HOST_SVCCOMP_STOP);
+
+    startTime = timestamp;
+    impl.handleEvent(stopEvent2);
+    Assert.assertEquals(startTime, impl.getLastOpStartTime());
+    Assert.assertEquals(-1, impl.getLastOpLastUpdateTime());
+    Assert.assertEquals(-1, impl.getLastOpEndTime());
+    Assert.assertEquals(State.STOPPING,
+        impl.getState());
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java Wed Nov  7 08:13:12 2012
@@ -20,7 +20,6 @@ package org.apache.ambari.server.utils;
 import static org.junit.Assert.assertEquals;
 
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -29,16 +28,19 @@ import javax.xml.bind.JAXBException;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.agent.ExecutionCommand;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.cluster.ClustersImpl;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostImpl;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.map.JsonMappingException;
+import org.junit.Before;
 import org.junit.Test;
 
 import com.google.inject.Guice;
@@ -46,13 +48,28 @@ import com.google.inject.Injector;
 
 public class TestStageUtils {
   private static Log LOG = LogFactory.getLog(TestStageUtils.class);
-  
+
+  private AmbariMetaInfo ambariMetaInfo;
+
+  private Injector injector;
+
+  @Before
+  public void setup() throws Exception {
+    injector = Guice.createInjector(new InMemoryDefaultTestModule());
+    injector.getInstance(GuiceJpaInitializer.class);
+    ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
+    ambariMetaInfo.init();
+
+  }
+
+
   public static void addHdfsService(Cluster cl, String [] hostList,
       Injector injector) throws AmbariException {
+    cl.setDesiredStackVersion(new StackId("HDP-0.1"));
     cl.addService("HDFS");
     cl.getService("HDFS").addServiceComponent("NAMENODE");
     cl.getService("HDFS").addServiceComponent("DATANODE");
-    cl.getService("HDFS").addServiceComponent("SNAMENODE");
+    cl.getService("HDFS").addServiceComponent("SECONDARY_NAMENODE");
     cl.getService("HDFS")
         .getServiceComponent("NAMENODE")
         .addServiceComponentHost(
@@ -60,10 +77,10 @@ public class TestStageUtils {
                 .getServiceComponent("NAMENODE"), hostList[0], false,
                 injector));
     cl.getService("HDFS")
-        .getServiceComponent("SNAMENODE")
+        .getServiceComponent("SECONDARY_NAMENODE")
         .addServiceComponentHost(
             new ServiceComponentHostImpl(cl.getService("HDFS")
-                .getServiceComponent("SNAMENODE"), hostList[1], false,
+                .getServiceComponent("SECONDARY_NAMENODE"), hostList[1], false,
                 injector));
     for (int i = 1; i < hostList.length; i++) {
       cl.getService("HDFS")
@@ -74,9 +91,10 @@ public class TestStageUtils {
                   injector));
     }
   }
-  
+
   public static void addHbaseService(Cluster cl, String [] hostList,
       Injector injector) throws AmbariException {
+    cl.setDesiredStackVersion(new StackId("HDP-0.2"));
     cl.addService("HBASE");
     cl.getService("HBASE").addServiceComponent("HBASE_MASTER");
     cl.getService("HBASE").addServiceComponent("HBASE_REGIONSERVER");
@@ -95,7 +113,7 @@ public class TestStageUtils {
                   injector));
     }
   }
-  
+
   @Test
   public void testGetATestStage() {
     Stage s = StageUtils.getATestStage(1, 2, "host2");
@@ -107,7 +125,7 @@ public class TestStageUtils {
       assertEquals(hostname, cmd.getHostname());
     }
   }
-  
+
   @Test
   public void testJaxbToString() throws Exception {
     Stage s = StageUtils.getATestStage(1, 2, "host1");
@@ -129,12 +147,9 @@ public class TestStageUtils {
     assertEquals(cmd.toString(), cmdDes.toString());
     assertEquals(cmd, cmdDes);
   }
-  
+
   @Test
   public void testGetClusterHostInfo() throws AmbariException {
-    Injector injector;
-    injector = Guice.createInjector(new InMemoryDefaultTestModule());
-    injector.getInstance(GuiceJpaInitializer.class);
     Clusters fsm = new ClustersImpl(injector);
     fsm.addCluster("c1");
     fsm.addHost("h1");
@@ -146,7 +161,7 @@ public class TestStageUtils {
     String [] hostList = {"h1", "h2", "h3" };
     fsm.getHost("h1").persist();
     fsm.getHost("h2").persist();
-    fsm.getHost("h3").persist();    
+    fsm.getHost("h3").persist();
     addHdfsService(fsm.getCluster("c1"), hostList, injector);
     addHbaseService(fsm.getCluster("c1"), hostList, injector);
     Map<String, List<String>> info = StageUtils.getClusterHostInfo(fsm

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/data.db
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/data.db?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
Binary files - no diff available.

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/repos/repoinfo.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/repos/repoinfo.xml?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/repos/repoinfo.xml (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/repos/repoinfo.xml Wed Nov  7 08:13:12 2012
@@ -0,0 +1,57 @@
+<?xml version="1.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.
+-->
+<reposinfo>
+  <os type="centos6">
+    <repo>
+      <baseurl>http://public-repo-1.hortonworks.com/HDP-1.1.1.16/repos/centos6</baseurl>
+      <repoid>HDP-1.1.1.16</repoid>
+      <reponame>HDP</reponame>
+    </repo>
+    <repo>
+      <baseurl>http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.15/repos/centos6</baseurl>
+      <repoid>HDP-UTILS-1.1.0.15</repoid>
+      <reponame>HDP-UTILS</reponame>
+      <mirrorslist></mirrorslist>
+    </repo>
+    <repo>
+      <baseurl></baseurl>
+      <repoid>epel</repoid>
+      <reponame>epel</reponame>
+      <mirrorslist><![CDATA[https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch]]></mirrorslist>
+    </repo>
+  </os>
+  <os type="centos5">
+    <repo>
+      <baseurl>http://public-repo-1.hortonworks.com/HDP-1.1.1.16/repos/centos5</baseurl>
+      <repoid>HDP-1.1.1.16</repoid>
+      <reponame>HDP</reponame>
+    </repo>
+    <repo>
+      <baseurl>http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.15/repos/centos5</baseurl>
+      <repoid>HDP-UTILS-1.1.0.15</repoid>
+      <reponame>HDP-UTILS</reponame>
+      <mirrorslist></mirrorslist>
+    </repo>
+    <repo>
+      <baseurl></baseurl>
+      <repoid>epel</repoid>
+      <reponame>epel</reponame>
+      <mirrorslist><![CDATA[https://mirrors.fedoraproject.org/metalink?repo=epel-5&arch=$basearch]]></mirrorslist>
+    </repo>
+  </os>
+</reposinfo>

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/HDFS/configuration/hbase-site.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/HDFS/configuration/hbase-site.xml?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/HDFS/configuration/hbase-site.xml (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/HDFS/configuration/hbase-site.xml Wed Nov  7 08:13:12 2012
@@ -0,0 +1,137 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.
+ */
+-->
+<configuration>
+  <property>
+    <name>hbase.regionserver.msginterval</name>
+    <value>1000</value>
+    <description>Interval between messages from the RegionServer to HMaster
+    in milliseconds.  Default is 15. Set this value low if you want unit
+    tests to be responsive.
+    </description>
+  </property>
+  <property>
+    <name>hbase.client.pause</name>
+    <value>5000</value>
+    <description>General client pause value.  Used mostly as value to wait
+    before running a retry of a failed get, region lookup, etc.</description>
+  </property>
+  <property>
+    <name>hbase.master.meta.thread.rescanfrequency</name>
+    <value>10000</value>
+    <description>How long the HMaster sleeps (in milliseconds) between scans of
+    the root and meta tables.
+    </description>
+  </property>
+  <property>
+    <name>hbase.server.thread.wakefrequency</name>
+    <value>1000</value>
+    <description>Time to sleep in between searches for work (in milliseconds).
+    Used as sleep interval by service threads such as META scanner and log roller.
+    </description>
+  </property>
+  <property>
+    <name>hbase.regionserver.handler.count</name>
+    <value>5</value>
+    <description>Count of RPC Server instances spun up on RegionServers
+    Same property is used by the HMaster for count of master handlers.
+    Default is 10.
+    </description>
+  </property>
+  <property>
+    <name>hbase.master.lease.period</name>
+    <value>6000</value>
+    <description>Length of time the master will wait before timing out a region
+    server lease. Since region servers report in every second (see above), this
+    value has been reduced so that the master will notice a dead region server
+    sooner. The default is 30 seconds.
+    </description>
+  </property>
+  <property>
+    <name>hbase.master.info.port</name>
+    <value>-1</value>
+    <description>The port for the hbase master web UI
+    Set to -1 if you do not want the info server to run.
+    </description>
+  </property>
+  <property>
+    <name>hbase.regionserver.info.port</name>
+    <value>-1</value>
+    <description>The port for the hbase regionserver web UI
+    Set to -1 if you do not want the info server to run.
+    </description>
+  </property>
+  <property>
+    <name>hbase.regionserver.info.port.auto</name>
+    <value>true</value>
+    <description>Info server auto port bind. Enables automatic port
+    search if hbase.regionserver.info.port is already in use.
+    Enabled for testing to run multiple tests on one machine.
+    </description>
+  </property>
+  <property>
+    <name>hbase.master.lease.thread.wakefrequency</name>
+    <value>3000</value>
+    <description>The interval between checks for expired region server leases.
+    This value has been reduced due to the other reduced values above so that
+    the master will notice a dead region server sooner. The default is 15 seconds.
+    </description>
+  </property>
+  <property>
+    <name>hbase.regionserver.optionalcacheflushinterval</name>
+    <value>10000</value>
+    <description>
+    Amount of time to wait since the last time a region was flushed before
+    invoking an optional cache flush. Default 60,000.
+    </description>
+  </property>
+  <property>
+    <name>hbase.regionserver.safemode</name>
+    <value>false</value>
+    <description>
+    Turn on/off safe mode in region server. Always on for production, always off
+    for tests.
+    </description>
+  </property>
+  <property>
+    <name>hbase.hregion.max.filesize</name>
+    <value>67108864</value>
+    <description>
+    Maximum desired file size for an HRegion.  If filesize exceeds
+    value + (value / 2), the HRegion is split in two.  Default: 256M.
+
+    Keep the maximum filesize small so we split more often in tests.
+    </description>
+  </property>
+  <property>
+    <name>hadoop.log.dir</name>
+    <value>${user.dir}/../logs</value>
+  </property>
+  <property>
+    <name>hbase.zookeeper.property.clientPort</name>
+    <value>21818</value>
+    <description>Property from ZooKeeper's config zoo.cfg.
+    The port at which the clients will connect.
+    </description>
+  </property>
+</configuration>

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/HDFS/configuration/hdfs-site.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/HDFS/configuration/hdfs-site.xml?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/HDFS/configuration/hdfs-site.xml (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/HDFS/configuration/hdfs-site.xml Wed Nov  7 08:13:12 2012
@@ -0,0 +1,403 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+
+<!--
+   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.
+-->
+
+<!-- Put site-specific property overrides in this file. -->
+
+<configuration>
+
+<!-- file system properties -->
+
+  <property>
+    <name>dfs.name.dir</name>
+    <!-- cluster variant -->
+    <value>/mnt/hmc/hadoop/hdfs/namenode</value>
+    <description>Determines where on the local filesystem the DFS name node
+      should store the name table.  If this is a comma-delimited list
+      of directories then the name table is replicated in all of the
+      directories, for redundancy. </description>
+    <final>true</final>
+  </property>
+
+  <property>
+    <name>dfs.support.append</name>
+    <value>true</value>
+    <description>to enable dfs append</description>
+    <final>true</final>
+  </property>
+
+  <property>
+    <name>dfs.webhdfs.enabled</name>
+    <value>false</value>
+    <description>to enable webhdfs</description>
+    <final>true</final>
+  </property>
+
+  <property>
+    <name>dfs.datanode.failed.volumes.tolerated</name>
+    <value>0</value>
+    <description>#of failed disks dn would tolerate</description>
+    <final>true</final>
+  </property>
+
+  <property>
+    <name>dfs.block.local-path-access.user</name>
+    <value>hbase</value>
+    <description>the user who is allowed to perform short
+    circuit reads.
+    </description>
+    <final>true</final>
+  </property>
+
+  <property>
+    <name>dfs.data.dir</name>
+    <value>/mnt/hmc/hadoop/hdfs/data</value>
+    <description>Determines where on the local filesystem an DFS data node
+  should store its blocks.  If this is a comma-delimited
+  list of directories, then data will be stored in all named
+  directories, typically on different devices.
+  Directories that do not exist are ignored.
+  </description>
+    <final>true</final>
+  </property>
+
+  <property>
+    <name>dfs.hosts.exclude</name>
+    <value>/etc/hadoop/conf/dfs.exclude</value>
+    <description>Names a file that contains a list of hosts that are
+    not permitted to connect to the namenode.  The full pathname of the
+    file must be specified.  If the value is empty, no hosts are
+    excluded.</description>
+  </property>
+
+  <property>
+    <name>dfs.hosts</name>
+    <value>/etc/hadoop/conf/dfs.include</value>
+    <description>Names a file that contains a list of hosts that are
+    permitted to connect to the namenode. The full pathname of the file
+    must be specified.  If the value is empty, all hosts are
+    permitted.</description>
+  </property>
+
+  <property>
+    <name>dfs.replication.max</name>
+    <value>50</value>
+    <description>Maximal block replication.
+  </description>
+  </property>
+
+  <property>
+    <name>dfs.replication</name>
+    <value>3</value>
+    <description>Default block replication.
+  </description>
+  </property>
+
+  <property>
+    <name>dfs.heartbeat.interval</name>
+    <value>3</value>
+    <description>Determines datanode heartbeat interval in seconds.</description>
+  </property>
+
+  <property>
+    <name>dfs.safemode.threshold.pct</name>
+    <value>1.0f</value>
+    <description>
+        Specifies the percentage of blocks that should satisfy
+        the minimal replication requirement defined by dfs.replication.min.
+        Values less than or equal to 0 mean not to start in safe mode.
+        Values greater than 1 will make safe mode permanent.
+        </description>
+  </property>
+
+  <property>
+    <name>dfs.balance.bandwidthPerSec</name>
+    <value>6250000</value>
+    <description>
+        Specifies the maximum amount of bandwidth that each datanode
+        can utilize for the balancing purpose in term of
+        the number of bytes per second.
+  </description>
+  </property>
+
+  <property>
+    <name>dfs.datanode.address</name>
+    <value>0.0.0.0:50010</value>
+  </property>
+
+  <property>
+    <name>dfs.datanode.http.address</name>
+    <value>0.0.0.0:50075</value>
+  </property>
+
+  <property>
+    <name>dfs.block.size</name>
+    <value>134217728</value>
+    <description>The default block size for new files.</description>
+  </property>
+
+  <property>
+    <name>dfs.http.address</name>
+    <value>hdp1.cybervisiontech.com.ua:50070</value>
+<description>The name of the default file system.  Either the
+literal string "local" or a host:port for NDFS.</description>
+<final>true</final>
+</property>
+
+<property>
+<name>dfs.datanode.du.reserved</name>
+<!-- cluster variant -->
+<value>1073741824</value>
+<description>Reserved space in bytes per volume. Always leave this much space free for non dfs use.
+</description>
+</property>
+
+<property>
+<name>dfs.datanode.ipc.address</name>
+<value>0.0.0.0:8010</value>
+<description>
+The datanode ipc server address and port.
+If the port is 0 then the server will start on a free port.
+</description>
+</property>
+
+<property>
+<name>dfs.blockreport.initialDelay</name>
+<value>120</value>
+<description>Delay for first block report in seconds.</description>
+</property>
+
+<property>
+<name>dfs.datanode.du.pct</name>
+<value>0.85f</value>
+<description>When calculating remaining space, only use this percentage of the real available space
+</description>
+</property>
+
+<property>
+<name>dfs.namenode.handler.count</name>
+<value>40</value>
+<description>The number of server threads for the namenode.</description>
+</property>
+
+<property>
+<name>dfs.datanode.max.xcievers</name>
+<value>1024</value>
+<description>PRIVATE CONFIG VARIABLE</description>
+</property>
+
+<!-- Permissions configuration -->
+
+<property>
+<name>dfs.umaskmode</name>
+<value>077</value>
+<description>
+The octal umask used when creating files and directories.
+</description>
+</property>
+
+<property>
+<name>dfs.web.ugi</name>
+<!-- cluster variant -->
+<value>gopher,gopher</value>
+<description>The user account used by the web interface.
+Syntax: USERNAME,GROUP1,GROUP2, ...
+</description>
+</property>
+
+<property>
+<name>dfs.permissions</name>
+<value>true</value>
+<description>
+If "true", enable permission checking in HDFS.
+If "false", permission checking is turned off,
+but all other behavior is unchanged.
+Switching from one parameter value to the other does not change the mode,
+owner or group of files or directories.
+</description>
+</property>
+
+<property>
+<name>dfs.permissions.supergroup</name>
+<value>hdfs</value>
+<description>The name of the group of super-users.</description>
+</property>
+
+<property>
+<name>dfs.namenode.handler.count</name>
+<value>100</value>
+<description>Added to grow Queue size so that more client connections are allowed</description>
+</property>
+
+<property>
+<name>ipc.server.max.response.size</name>
+<value>5242880</value>
+</property>
+<property>
+<name>dfs.block.access.token.enable</name>
+<value>true</value>
+<description>
+If "true", access tokens are used as capabilities for accessing datanodes.
+If "false", no access tokens are checked on accessing datanodes.
+</description>
+</property>
+
+<property>
+<name>dfs.namenode.kerberos.principal</name>
+<value>nn/_HOST@</value>
+<description>
+Kerberos principal name for the NameNode
+</description>
+</property>
+
+<property>
+<name>dfs.secondary.namenode.kerberos.principal</name>
+<value>nn/_HOST@</value>
+    <description>
+        Kerberos principal name for the secondary NameNode.
+    </description>
+  </property>
+
+
+<!--
+  This is KRB DOMAIN specific. The FQDN of the namenode has to be mentioned.
+-->
+  <property>
+    <name>dfs.namenode.kerberos.https.principal</name>
+    <value>host/_HOST@</value>
+     <description>The Kerberos principal for the host that the NameNode runs on.</description>
+
+  </property>
+
+  <property>
+    <name>dfs.secondary.namenode.kerberos.https.principal</name>
+    <value>host/_HOST@</value>
+    <description>The Kerberos principal for the hostthat the secondary NameNode runs on.</description>
+
+  </property>
+
+  <property>
+    <!-- cluster variant -->
+    <name>dfs.secondary.http.address</name>
+    <value>hdp2.cybervisiontech.com.ua:50090</value>
+    <description>Address of secondary namenode web server</description>
+  </property>
+
+  <property>
+    <name>dfs.secondary.https.port</name>
+    <value>50490</value>
+    <description>The https port where secondary-namenode binds</description>
+  </property>
+
+  <property>
+    <name>dfs.web.authentication.kerberos.principal</name>
+    <value>HTTP/_HOST@</value>
+    <description>
+      The HTTP Kerberos principal used by Hadoop-Auth in the HTTP endpoint.
+      The HTTP Kerberos principal MUST start with 'HTTP/' per Kerberos
+      HTTP SPENGO specification.
+    </description>
+  </property>
+
+  <property>
+    <name>dfs.web.authentication.kerberos.keytab</name>
+    <value>/nn.service.keytab</value>
+    <description>
+      The Kerberos keytab file with the credentials for the
+      HTTP Kerberos principal used by Hadoop-Auth in the HTTP endpoint.
+    </description>
+  </property>
+
+  <property>
+    <name>dfs.datanode.kerberos.principal</name>
+    <value>dn/_HOST@</value>
+ <description>
+        The Kerberos principal that the DataNode runs as. "_HOST" is replaced by the real host name.
+    </description>
+  </property>
+
+  <property>
+    <name>dfs.namenode.keytab.file</name>
+    <value>/nn.service.keytab</value>
+ <description>
+        Combined keytab file containing the namenode service and host principals.
+    </description>
+  </property>
+
+  <property>
+    <name>dfs.secondary.namenode.keytab.file</name>
+    <value>/nn.service.keytab</value>
+  <description>
+        Combined keytab file containing the namenode service and host principals.
+    </description>
+  </property>
+
+  <property>
+    <name>dfs.datanode.keytab.file</name>
+    <value>/dn.service.keytab</value>
+ <description>
+        The filename of the keytab file for the DataNode.
+    </description>
+  </property>
+
+  <property>
+    <name>dfs.https.port</name>
+    <value>50470</value>
+ <description>The https port where namenode binds</description>
+
+  </property>
+
+  <property>
+    <name>dfs.https.address</name>
+    <value>hdp1.cybervisiontech.com.ua:50470</value>
+  <description>The https address where namenode binds</description>
+
+  </property>
+
+  <property>
+    <name>dfs.datanode.data.dir.perm</name>
+    <value>750</value>
+<description>The permissions that should be there on dfs.data.dir
+directories. The datanode will not come up if the permissions are
+different on existing dfs.data.dir directories. If the directories
+don't exist, they will be created with this permission.</description>
+  </property>
+
+  <property>
+  <name>dfs.access.time.precision</name>
+  <value>0</value>
+  <description>The access time for HDFS file is precise upto this value.
+               The default value is 1 hour. Setting a value of 0 disables
+               access times for HDFS.
+  </description>
+</property>
+
+<property>
+ <name>dfs.cluster.administrators</name>
+ <value> hdfs</value>
+ <description>ACL for who all can view the default servlets in the HDFS</description>
+</property>
+
+<property>
+  <name>ipc.server.read.threadpool.size</name>
+  <value>5</value>
+  <description></description>
+</property>
+
+</configuration>

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/HDFS/metainfo.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/HDFS/metainfo.xml?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/HDFS/metainfo.xml (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/HDFS/metainfo.xml Wed Nov  7 08:13:12 2012
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<metainfo>
+    <user>root</user>
+    <comment>This is comment for HDFS service</comment>
+    <version>1.0</version>
+
+
+    <components>
+        <component>
+            <name>NAMENODE</name>
+            <category>MASTER</category>
+        </component>
+
+        <component>
+            <name>SECONDARY_NAMENODE</name>
+            <category>MASTER</category>
+        </component>
+
+        <component>
+            <name>DATANODE1</name>
+            <category>SLAVE</category>
+        </component>
+
+        <component>
+            <name>DATANODE2</name>
+            <category>SLAVE</category>
+        </component>
+
+        <component>
+            <name>DATANODE</name>
+            <category>SLAVE</category>
+        </component>
+
+        <component>
+            <name>HDFS_CLIENT</name>
+            <category>CLIENT</category>
+        </component>
+    </components>
+
+
+</metainfo>

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/MAPREDUCE/configuration/hbase-site.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/MAPREDUCE/configuration/hbase-site.xml?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/MAPREDUCE/configuration/hbase-site.xml (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/resources/stacks/HDP/0.1/services/MAPREDUCE/configuration/hbase-site.xml Wed Nov  7 08:13:12 2012
@@ -0,0 +1,137 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.
+ */
+-->
+<configuration>
+  <property>
+    <name>hbase.regionserver.msginterval</name>
+    <value>1000</value>
+    <description>Interval between messages from the RegionServer to HMaster
+    in milliseconds.  Default is 15. Set this value low if you want unit
+    tests to be responsive.
+    </description>
+  </property>
+  <property>
+    <name>hbase.client.pause</name>
+    <value>5000</value>
+    <description>General client pause value.  Used mostly as value to wait
+    before running a retry of a failed get, region lookup, etc.</description>
+  </property>
+  <property>
+    <name>hbase.master.meta.thread.rescanfrequency</name>
+    <value>10000</value>
+    <description>How long the HMaster sleeps (in milliseconds) between scans of
+    the root and meta tables.
+    </description>
+  </property>
+  <property>
+    <name>hbase.server.thread.wakefrequency</name>
+    <value>1000</value>
+    <description>Time to sleep in between searches for work (in milliseconds).
+    Used as sleep interval by service threads such as META scanner and log roller.
+    </description>
+  </property>
+  <property>
+    <name>hbase.regionserver.handler.count</name>
+    <value>5</value>
+    <description>Count of RPC Server instances spun up on RegionServers
+    Same property is used by the HMaster for count of master handlers.
+    Default is 10.
+    </description>
+  </property>
+  <property>
+    <name>hbase.master.lease.period</name>
+    <value>6000</value>
+    <description>Length of time the master will wait before timing out a region
+    server lease. Since region servers report in every second (see above), this
+    value has been reduced so that the master will notice a dead region server
+    sooner. The default is 30 seconds.
+    </description>
+  </property>
+  <property>
+    <name>hbase.master.info.port</name>
+    <value>-1</value>
+    <description>The port for the hbase master web UI
+    Set to -1 if you do not want the info server to run.
+    </description>
+  </property>
+  <property>
+    <name>hbase.regionserver.info.port</name>
+    <value>-1</value>
+    <description>The port for the hbase regionserver web UI
+    Set to -1 if you do not want the info server to run.
+    </description>
+  </property>
+  <property>
+    <name>hbase.regionserver.info.port.auto</name>
+    <value>true</value>
+    <description>Info server auto port bind. Enables automatic port
+    search if hbase.regionserver.info.port is already in use.
+    Enabled for testing to run multiple tests on one machine.
+    </description>
+  </property>
+  <property>
+    <name>hbase.master.lease.thread.wakefrequency</name>
+    <value>3000</value>
+    <description>The interval between checks for expired region server leases.
+    This value has been reduced due to the other reduced values above so that
+    the master will notice a dead region server sooner. The default is 15 seconds.
+    </description>
+  </property>
+  <property>
+    <name>hbase.regionserver.optionalcacheflushinterval</name>
+    <value>10000</value>
+    <description>
+    Amount of time to wait since the last time a region was flushed before
+    invoking an optional cache flush. Default 60,000.
+    </description>
+  </property>
+  <property>
+    <name>hbase.regionserver.safemode</name>
+    <value>false</value>
+    <description>
+    Turn on/off safe mode in region server. Always on for production, always off
+    for tests.
+    </description>
+  </property>
+  <property>
+    <name>hbase.hregion.max.filesize</name>
+    <value>67108864</value>
+    <description>
+    Maximum desired file size for an HRegion.  If filesize exceeds
+    value + (value / 2), the HRegion is split in two.  Default: 256M.
+
+    Keep the maximum filesize small so we split more often in tests.
+    </description>
+  </property>
+  <property>
+    <name>hadoop.log.dir</name>
+    <value>${user.dir}/../logs</value>
+  </property>
+  <property>
+    <name>hbase.zookeeper.property.clientPort</name>
+    <value>21818</value>
+    <description>Property from ZooKeeper's config zoo.cfg.
+    The port at which the clients will connect.
+    </description>
+  </property>
+</configuration>



Mime
View raw message