stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From isu...@apache.org
Subject git commit: adding parsing tests for applicaitons with groups
Date Mon, 13 Oct 2014 06:03:02 GMT
Repository: stratos
Updated Branches:
  refs/heads/4.0.0-grouping a456b4e22 -> c063ac59f


adding parsing tests for applicaitons with groups


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/c063ac59
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/c063ac59
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/c063ac59

Branch: refs/heads/4.0.0-grouping
Commit: c063ac59fedd7362f0d49f8319971301eed811c8
Parents: a456b4e
Author: Isuru Haththotuwa <isuruh@apache.org>
Authored: Mon Oct 13 11:30:05 2014 +0530
Committer: Isuru Haththotuwa <isuruh@apache.org>
Committed: Mon Oct 13 11:30:05 2014 +0530

----------------------------------------------------------------------
 .../application/parser/ParserUtils.java         |   4 +-
 .../CompositeApplicationParseTest.java          | 209 +++++++++++++++++++
 2 files changed, 211 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/c063ac59/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java
index edc0486..23b0bab 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java
@@ -49,8 +49,8 @@ public class ParserUtils {
 
         for (String startupOrder : Arrays.asList(commaSeparatedStartupOrder.split(",")))
{
             startupOrder = startupOrder.trim();
-            if (!startupOrder.startsWith("cartridge.")) {
-                throw new ApplicationDefinitionException("Incorrect Startup Order specified,
should start with 'cartridge.'");
+            if (!startupOrder.startsWith("cartridge.") && !startupOrder.startsWith("group."))
{
+                throw new ApplicationDefinitionException("Incorrect Startup Order specified,
should start with 'cartridge.' or 'group.'");
             }
 
             startupOrders.add(startupOrder);

http://git-wip-us.apache.org/repos/asf/stratos/blob/c063ac59/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java
b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java
index 1859c72..d6f7928 100644
--- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java
+++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java
@@ -285,6 +285,215 @@ public class CompositeApplicationParseTest {
         applicationParser.parse(simpleAppCtxt);
     }
 
+    @Test
+    public void testAppWithOneCartridgeAndOneGroup () throws ApplicationDefinitionException
{
+
+        ApplicationParser applicationParser = new DefaultApplicationParser();
+        ApplicationContext simpleAppCtxt = new ApplicationContext();
+        // app id
+        simpleAppCtxt.setApplicationId("simpleApp");
+        simpleAppCtxt.setAlias("simpleAppAlias");
+        // tenant info
+        simpleAppCtxt.setTenantId(-1234);
+        // components
+        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+        // top level cartridges
+        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
+        simpleAppSubscribableContext.setType("php");
+        simpleAppSubscribableContext.setAlias("myphp");
+        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
+        // top level group
+        GroupContext simpleGroupContext = new GroupContext();
+        simpleGroupContext.setName("group1");
+        simpleGroupContext.setAlias("mygroup1");
+        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
+        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
+        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
+        groupSubscribableCtxt.setType("mysql");
+        groupSubscribableCtxt.setAlias("mygroup1mysql");
+        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
+        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
+        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+        // subscribable information
+        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
+        simpleAppSubscribableInfoCtxt.setAlias("myphp");
+        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
+        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
+        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
+
+        SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext();
+        simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql");
+        simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy");
+        simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy");
+
+        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt,
+                simpleAppGroupSubscribableInfoCtxt});
+
+        // parse
+        applicationParser.parse(simpleAppCtxt);
+    }
+
+    @Test
+    public void testAppWithOneCartridgeAndOneGroupWithDependencies () throws ApplicationDefinitionException
{
+
+        ApplicationParser applicationParser = new DefaultApplicationParser();
+        ApplicationContext simpleAppCtxt = new ApplicationContext();
+        // app id
+        simpleAppCtxt.setApplicationId("simpleApp");
+        simpleAppCtxt.setAlias("simpleAppAlias");
+        // tenant info
+        simpleAppCtxt.setTenantId(-1234);
+        // components
+        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+        // top level cartridges
+        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
+        simpleAppSubscribableContext.setType("php");
+        simpleAppSubscribableContext.setAlias("myphp");
+        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
+        // top level group
+        GroupContext simpleGroupContext = new GroupContext();
+        simpleGroupContext.setName("group1");
+        simpleGroupContext.setAlias("mygroup1");
+        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
+        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
+        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
+        groupSubscribableCtxt.setType("mysql");
+        groupSubscribableCtxt.setAlias("mygroup1mysql");
+        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
+        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
+        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+        // dependencies
+        DependencyContext simpleAppDependecyCtxt = new DependencyContext();
+        simpleAppDependecyCtxt.setKillBehaviour("kill-dependents");
+        simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group.group1,cartridge.myphp"});
+        simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt);
+        // subscribable information
+        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
+        simpleAppSubscribableInfoCtxt.setAlias("myphp");
+        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
+        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
+        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
+
+        SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext();
+        simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql");
+        simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy");
+        simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy");
+
+        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt,
+                simpleAppGroupSubscribableInfoCtxt});
+
+        // parse
+        applicationParser.parse(simpleAppCtxt);
+    }
+
+    @Test (expected = ApplicationDefinitionException.class)
+    public void testAppWithOneCartridgeAndOneGroupWithInvalidDependencies () throws ApplicationDefinitionException
{
+
+        ApplicationParser applicationParser = new DefaultApplicationParser();
+        ApplicationContext simpleAppCtxt = new ApplicationContext();
+        // app id
+        simpleAppCtxt.setApplicationId("simpleApp");
+        simpleAppCtxt.setAlias("simpleAppAlias");
+        // tenant info
+        simpleAppCtxt.setTenantId(-1234);
+        // components
+        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+        // top level cartridges
+        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
+        simpleAppSubscribableContext.setType("php");
+        simpleAppSubscribableContext.setAlias("myphp");
+        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
+        // top level group
+        GroupContext simpleGroupContext = new GroupContext();
+        simpleGroupContext.setName("group1");
+        simpleGroupContext.setAlias("mygroup1");
+        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
+        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
+        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
+        groupSubscribableCtxt.setType("mysql");
+        groupSubscribableCtxt.setAlias("mygroup1mysql");
+        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
+        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
+        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+        // dependencies
+        DependencyContext simpleAppDependecyCtxt = new DependencyContext();
+        simpleAppDependecyCtxt.setKillBehaviour("kill-dependents");
+        // invalid startup order, starting with 'group1'
+        simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group1.group1,cartridge.myphp"});
+        simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt);
+        // subscribable information
+        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
+        simpleAppSubscribableInfoCtxt.setAlias("myphp");
+        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
+        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
+        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
+
+        SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext();
+        simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql");
+        simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy");
+        simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy");
+
+        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt,
+                simpleAppGroupSubscribableInfoCtxt});
+
+        // parse
+        applicationParser.parse(simpleAppCtxt);
+    }
+
+    @Test (expected = ApplicationDefinitionException.class)
+    public void testAppWithOneCartridgeAndOneGroupWithNoSubcribableInfoForGroup () throws
ApplicationDefinitionException {
+
+        ApplicationParser applicationParser = new DefaultApplicationParser();
+        ApplicationContext simpleAppCtxt = new ApplicationContext();
+        // app id
+        simpleAppCtxt.setApplicationId("simpleApp");
+        simpleAppCtxt.setAlias("simpleAppAlias");
+        // tenant info
+        simpleAppCtxt.setTenantId(-1234);
+        // components
+        ComponentContext simpleAppComponentCtxt = new ComponentContext();
+        // top level cartridges
+        SubscribableContext simpleAppSubscribableContext = new SubscribableContext();
+        simpleAppSubscribableContext.setType("php");
+        simpleAppSubscribableContext.setAlias("myphp");
+        simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext});
+        // top level group
+        GroupContext simpleGroupContext = new GroupContext();
+        simpleGroupContext.setName("group1");
+        simpleGroupContext.setAlias("mygroup1");
+        simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1");
+        simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1");
+        SubscribableContext groupSubscribableCtxt = new SubscribableContext();
+        groupSubscribableCtxt.setType("mysql");
+        groupSubscribableCtxt.setAlias("mygroup1mysql");
+        simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt});
+        simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext});
+        simpleAppCtxt.setComponents(simpleAppComponentCtxt);
+        // subscribable information
+        SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext();
+        simpleAppSubscribableInfoCtxt.setAlias("myphp");
+        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1");
+        simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1");
+        simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git");
+        simpleAppSubscribableInfoCtxt.setPrivateRepo(true);
+        simpleAppSubscribableInfoCtxt.setRepoUsername("admin");
+        simpleAppSubscribableInfoCtxt.setRepoUrl("admin123");
+
+        simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt});
+
+        // parse
+        applicationParser.parse(simpleAppCtxt);
+    }
+
     @AfterClass
     public static void tearDownAfterClass() {
 


Mime
View raw message