Repository: stratos
Updated Branches:
  refs/heads/tenant-isolation d1141f4b0 -> 96900b8bd


update sample update test with tenant


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

Branch: refs/heads/tenant-isolation
Commit: d9f93dc51ed816d7332243d4113074822b728f90
Parents: d1141f4
Author: gayangunarathne <[email protected]>
Authored: Tue Aug 18 20:02:35 2015 +0530
Committer: gayangunarathne <[email protected]>
Committed: Tue Aug 18 20:02:35 2015 +0530

----------------------------------------------------------------------
 .../application/ApplicationUpdateTest.java      | 61 +++++++++++++++++++-
 .../integration/tests/group/CartridgeTest.java  | 11 ++++
 .../tests/policies/AutoscalingPolicyTest.java   | 51 ++++++++++++++--
 3 files changed, 115 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/d9f93dc5/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
index 58a48de..e199055 100644
--- 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationUpdateTest.java
@@ -68,7 +68,6 @@ public class ApplicationUpdateTest extends 
StratosTestServerManager {
 
             
TopologyHandler.getInstance().assertApplicationForNonAvailability(applicationId,tenant2Id);
 
-
             boolean removedGroup = 
restClientTenant1.removeEntity(RestConstants.CARTRIDGE_GROUPS, 
"G1-application-update-test",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
             assertEquals(removedGroup, false);
@@ -83,12 +82,12 @@ public class ApplicationUpdateTest extends 
StratosTestServerManager {
             //Trying to remove the used network partition
             assertEquals(removedNet, false);
 
-            
testApplicationRuntimeForTenant(restClientTenant2,tenant2Id,autoscalingPolicyId);
-
             boolean removedDep = 
restClientTenant1.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
                     "deployment-policy-application-update-test", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
             assertEquals(removedDep, false);
 
+           // 
testApplicationRuntimeForTenant(restClientTenant2,tenant2Id,autoscalingPolicyId);
+
             //Un-deploying the application
             String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + 
"g-sc-G123-1-application-update-test" +
                     RestConstants.APPLICATIONS_UNDEPLOY;
@@ -165,6 +164,8 @@ public class ApplicationUpdateTest extends 
StratosTestServerManager {
                     "network-partition-application-update-test-2", 
RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedN2, true);
 
+           // 
testApplicationUndeplymentForTenant(restClientTenant2,tenant2Id,autoscalingPolicyId);
+
             log.info("-------------------------Ended application runtime 
update test case-------------------------");
 
         } catch (Exception e) {
@@ -253,4 +254,58 @@ public class ApplicationUpdateTest extends 
StratosTestServerManager {
         //Cluster active handling
         
TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId(), 
tenantId);
     }
+
+    private void testApplicationUndeplymentForTenant(RestClient 
restClientTenant,int tenantId,String autoscalingPolicyId){
+        boolean removed = 
restClientTenant.removeEntity(RestConstants.APPLICATIONS, 
"g-sc-G123-1-application-update-test",
+                RestConstants.APPLICATIONS_NAME);
+        assertEquals(removed, true);
+
+        ApplicationBean beanRemoved = (ApplicationBean) 
restClientTenant.getEntity(RestConstants.APPLICATIONS,
+                "g-sc-G123-1-application-update-test", ApplicationBean.class, 
RestConstants.APPLICATIONS_NAME);
+        assertEquals(beanRemoved, null);
+
+        boolean removedGroup = 
restClientTenant.removeEntity(RestConstants.CARTRIDGE_GROUPS, 
"G1-application-update-test",
+                RestConstants.CARTRIDGE_GROUPS_NAME);
+        assertEquals(removedGroup, true);
+
+        boolean removedC1 = 
restClientTenant.removeEntity(RestConstants.CARTRIDGES, 
"c1-application-update-test",
+                RestConstants.CARTRIDGES_NAME);
+        assertEquals(removedC1, true);
+
+        boolean removedC2 = 
restClientTenant.removeEntity(RestConstants.CARTRIDGES, 
"c2-application-update-test",
+                RestConstants.CARTRIDGES_NAME);
+        assertEquals(removedC2, true);
+
+        boolean removedC3 = 
restClientTenant.removeEntity(RestConstants.CARTRIDGES, 
"c3-application-update-test",
+                RestConstants.CARTRIDGES_NAME);
+        assertEquals(removedC3, true);
+
+        boolean removedAuto = 
restClientTenant.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+        assertEquals(removedAuto, true);
+
+        boolean removedDep = 
restClientTenant.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+                "deployment-policy-application-update-test", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
+        assertEquals(removedDep, true);
+
+        boolean removedNet = 
restClientTenant.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                "network-partition-application-update-test-1", 
RestConstants.NETWORK_PARTITIONS_NAME);
+        assertEquals(removedNet, false);
+
+        boolean removedN2 = 
restClientTenant.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                "network-partition-application-update-test-2", 
RestConstants.NETWORK_PARTITIONS_NAME);
+        assertEquals(removedN2, false);
+
+        boolean removeAppPolicy = 
restClientTenant.removeEntity(RestConstants.APPLICATION_POLICIES,
+                "application-policy-application-update-test", 
RestConstants.APPLICATION_POLICIES_NAME);
+        assertEquals(removeAppPolicy, true);
+
+        removedNet = 
restClientTenant.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                "network-partition-application-update-test-1", 
RestConstants.NETWORK_PARTITIONS_NAME);
+        assertEquals(removedNet, true);
+
+        removedN2 = 
restClientTenant.removeEntity(RestConstants.NETWORK_PARTITIONS,
+                "network-partition-application-update-test-2", 
RestConstants.NETWORK_PARTITIONS_NAME);
+        assertEquals(removedN2, true);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/d9f93dc5/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
index 20c07db..afbdc1a 100644
--- 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
@@ -171,6 +171,17 @@ public class CartridgeTest extends 
StratosTestServerManager {
                             CartridgeBean.class, 
RestConstants.CARTRIDGES_NAME);
             assertEquals(beanRemoved, null);
 
+            removed = restClientTenant2.removeEntity(RestConstants.CARTRIDGES, 
cartridgeType,
+                    RestConstants.CARTRIDGES_NAME);
+            assertEquals(removed, true);
+
+            beanRemoved = (CartridgeBean) restClientTenant2.
+                    getEntity(RestConstants.CARTRIDGES, cartridgeType,
+                            CartridgeBean.class, 
RestConstants.CARTRIDGES_NAME);
+            assertEquals(beanRemoved, null);
+
+
+
             log.info("---------------------------Ended Cartridge test 
case-------------------------");
         } catch (Exception e) {
             log.error("An error occurred while handling 
RESTConstants.CARTRIDGES_PATH", e);

http://git-wip-us.apache.org/repos/asf/stratos/blob/d9f93dc5/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java
index 8064156..895e5f6 100644
--- 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java
@@ -25,9 +25,7 @@ import org.apache.stratos.integration.tests.RestConstants;
 import org.apache.stratos.integration.tests.StratosTestServerManager;
 import org.testng.annotations.Test;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNull;
-import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.*;
 
 /**
  * Test to handle autoscaling policy CRUD operations
@@ -59,6 +57,28 @@ public class AutoscalingPolicyTest extends 
StratosTestServerManager {
             assertEquals(String.format("[autoscaling-policy-id] %s Load is not 
correct", policyId),
                     bean.getLoadThresholds().getLoadAverage().getThreshold(), 
25.0, 0.0);
 
+            bean = (AutoscalePolicyBean) restClientTenant2.
+                    getEntity(RestConstants.AUTOSCALING_POLICIES, policyId,
+                            AutoscalePolicyBean.class, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertNull("Auto scale policy exists for other tenant",bean);
+
+            boolean addedTenant2 = restClientTenant2.addEntity(RESOURCES_PATH 
+ RestConstants.AUTOSCALING_POLICIES_PATH + "/" + policyId + ".json",
+                    RestConstants.AUTOSCALING_POLICIES, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+
+            assertEquals(String.format("Autoscaling policy did not added: 
[autoscaling-policy-id] %s", policyId), addedTenant2, true);
+            bean = (AutoscalePolicyBean) restClientTenant2.
+                    getEntity(RestConstants.AUTOSCALING_POLICIES, policyId,
+                            AutoscalePolicyBean.class, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+
+            assertEquals(String.format("[autoscaling-policy-id] %s is not 
correct", bean.getId()),
+                    bean.getId(), policyId);
+            assertEquals(String.format("[autoscaling-policy-id] %s RIF is not 
correct", policyId),
+                    
bean.getLoadThresholds().getRequestsInFlight().getThreshold(), 35.0, 0.0);
+            assertEquals(String.format("[autoscaling-policy-id] %s Memory is 
not correct", policyId),
+                    
bean.getLoadThresholds().getMemoryConsumption().getThreshold(), 45.0, 0.0);
+            assertEquals(String.format("[autoscaling-policy-id] %s Load is not 
correct", policyId),
+                    bean.getLoadThresholds().getLoadAverage().getThreshold(), 
25.0, 0.0);
+
             boolean updated = restClientTenant1.updateEntity(RESOURCES_PATH + 
RestConstants.AUTOSCALING_POLICIES_PATH + "/" + policyId + "-v1.json",
                     RestConstants.AUTOSCALING_POLICIES, 
RestConstants.AUTOSCALING_POLICIES_NAME);
 
@@ -73,10 +93,20 @@ public class AutoscalingPolicyTest extends 
StratosTestServerManager {
             assertEquals(String.format("[autoscaling-policy-id] %s Memory is 
not correct", policyId),
                     
updatedBean.getLoadThresholds().getLoadAverage().getThreshold(), 20.0, 0.0);
 
-            updatedBean = (AutoscalePolicyBean) restClientTenant2.getEntity(
+            boolean updatedTenant2 = 
restClientTenant2.updateEntity(RESOURCES_PATH + 
RestConstants.AUTOSCALING_POLICIES_PATH + "/" + policyId + "-v1.json",
+                    RestConstants.AUTOSCALING_POLICIES, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+
+            assertEquals(String.format("[autoscaling-policy-id] %s update 
failed", policyId), updatedTenant2, true);
+            AutoscalePolicyBean updatedTenant2Bean = (AutoscalePolicyBean) 
restClientTenant2.getEntity(
                     RestConstants.AUTOSCALING_POLICIES, policyId,
                     AutoscalePolicyBean.class, 
RestConstants.AUTOSCALING_POLICIES_NAME);
-            assertNull("Auto scaling policy found in tenant 2",updatedBean);
+            assertEquals(String.format("[autoscaling-policy-id] %s RIF is not 
correct", policyId),
+                    
updatedTenant2Bean.getLoadThresholds().getRequestsInFlight().getThreshold(), 
30.0, 0.0);
+            assertEquals(String.format("[autoscaling-policy-id] %s Load is not 
correct", policyId),
+                    
updatedTenant2Bean.getLoadThresholds().getMemoryConsumption().getThreshold(), 
40.0, 0.0);
+            assertEquals(String.format("[autoscaling-policy-id] %s Memory is 
not correct", policyId),
+                    
updatedTenant2Bean.getLoadThresholds().getLoadAverage().getThreshold(), 20.0, 
0.0);
+
 
             boolean removed = 
restClientTenant1.removeEntity(RestConstants.AUTOSCALING_POLICIES,
                     policyId, RestConstants.AUTOSCALING_POLICIES_NAME);
@@ -88,6 +118,17 @@ public class AutoscalingPolicyTest extends 
StratosTestServerManager {
                     AutoscalePolicyBean.class, 
RestConstants.AUTOSCALING_POLICIES_NAME);
             assertEquals(String.format("[autoscaling-policy-id] %s didn't get 
removed successfully",
                     policyId), beanRemoved, null);
+
+            beanRemoved = (AutoscalePolicyBean) restClientTenant2.getEntity(
+                    RestConstants.AUTOSCALING_POLICIES, policyId,
+                    AutoscalePolicyBean.class, 
RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertNotNull("Auto scale policy not exist in other 
tenant",beanRemoved);
+
+            removed = 
restClientTenant2.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+                    policyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+            assertEquals(String.format("[autoscaling-policy-id] %s couldn't be 
removed", policyId),
+                    removed, true);
+
             log.info("-------------------------Ended autoscaling policy test 
case---------------------------");
         } catch (Exception e) {
             log.error("An error occurred while handling [autoscaling policy] " 
+ policyId, e);

Reply via email to