You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ga...@apache.org on 2015/08/10 13:03:17 UTC
[1/6] stratos git commit: Add the updated integration tests
Repository: stratos
Updated Branches:
refs/heads/tenant-isolation 6ce6d5470 -> 366babaf2
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/autoscaling-policies/autoscaling-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/autoscaling-policies/autoscaling-policy-1.json b/products/stratos/modules/integration/src/test/resources/autoscaling-policies/autoscaling-policy-1.json
deleted file mode 100644
index f82403b..0000000
--- a/products/stratos/modules/integration/src/test/resources/autoscaling-policies/autoscaling-policy-1.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "id": "autoscaling-policy-1",
- "loadThresholds": {
- "requestsInFlight": {
- "threshold": 35
- },
- "memoryConsumption": {
- "threshold": 45
- },
- "loadAverage": {
- "threshold": 25
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/autoscaling-policies/autoscaling-policy-c0.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/autoscaling-policies/autoscaling-policy-c0.json b/products/stratos/modules/integration/src/test/resources/autoscaling-policies/autoscaling-policy-c0.json
deleted file mode 100644
index 4bcef26..0000000
--- a/products/stratos/modules/integration/src/test/resources/autoscaling-policies/autoscaling-policy-c0.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "id": "autoscaling-policy-c0",
- "loadThresholds": {
- "requestsInFlight": {
- "threshold": 35
- },
- "memoryConsumption": {
- "threshold": 45
- },
- "loadAverage": {
- "threshold": 25
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/autoscaling-policies/update/autoscaling-policy-c0.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/autoscaling-policies/update/autoscaling-policy-c0.json b/products/stratos/modules/integration/src/test/resources/autoscaling-policies/update/autoscaling-policy-c0.json
deleted file mode 100644
index 31c2b84..0000000
--- a/products/stratos/modules/integration/src/test/resources/autoscaling-policies/update/autoscaling-policy-c0.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "id": "autoscaling-policy-c0",
- "loadThresholds": {
- "requestsInFlight": {
- "threshold": 30
- },
- "memoryConsumption": {
- "threshold": 40
- },
- "loadAverage": {
- "threshold": 20
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json b/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json
deleted file mode 100644
index 6020e1e..0000000
--- a/products/stratos/modules/integration/src/test/resources/cartridges-groups/cartrdige-nested.json
+++ /dev/null
@@ -1,50 +0,0 @@
-{
- "name": "G1",
- "dependencies": {
- "terminationBehaviour": "terminate-none",
- "startupOrders": [
- {
- "aliases": [
- "group.group2",
- "cartridge.c1-1x0"
- ]
- }
- ]
- },
- "cartridges": [
- "c1"
- ],
- "groups": [
- {
- "name": "G2",
- "dependencies": {
- "terminationBehaviour": "terminate-dependents",
- "startupOrders": [
- {
- "aliases": [
- "group.group3",
- "cartridge.c2-1x0"
- ]
- }
- ]
- },
- "cartridges": [
- "c2"
- ],
- "groups": [
- {
- "name": "G3",
- "dependencies": {
- "terminationBehaviour": "terminate-all",
- "startupOrders": []
- },
- "cartridges": [
- "c3"
- ],
- "groups": []
- }
- ]
- }
- ]
-}
-
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/cartridges-groups/update/cartrdige-nested.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges-groups/update/cartrdige-nested.json b/products/stratos/modules/integration/src/test/resources/cartridges-groups/update/cartrdige-nested.json
deleted file mode 100644
index 6020e1e..0000000
--- a/products/stratos/modules/integration/src/test/resources/cartridges-groups/update/cartrdige-nested.json
+++ /dev/null
@@ -1,50 +0,0 @@
-{
- "name": "G1",
- "dependencies": {
- "terminationBehaviour": "terminate-none",
- "startupOrders": [
- {
- "aliases": [
- "group.group2",
- "cartridge.c1-1x0"
- ]
- }
- ]
- },
- "cartridges": [
- "c1"
- ],
- "groups": [
- {
- "name": "G2",
- "dependencies": {
- "terminationBehaviour": "terminate-dependents",
- "startupOrders": [
- {
- "aliases": [
- "group.group3",
- "cartridge.c2-1x0"
- ]
- }
- ]
- },
- "cartridges": [
- "c2"
- ],
- "groups": [
- {
- "name": "G3",
- "dependencies": {
- "terminationBehaviour": "terminate-all",
- "startupOrders": []
- },
- "cartridges": [
- "c3"
- ],
- "groups": []
- }
- ]
- }
- ]
-}
-
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/cartridges/mock/c0.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges/mock/c0.json b/products/stratos/modules/integration/src/test/resources/cartridges/mock/c0.json
deleted file mode 100755
index 44066e1..0000000
--- a/products/stratos/modules/integration/src/test/resources/cartridges/mock/c0.json
+++ /dev/null
@@ -1,124 +0,0 @@
-{
- "category": "Application",
- "description": "c0 Cartridge",
- "displayName": "c0",
- "host": "qmog.cisco.com",
- "iaasProvider": [
- {
- "imageId": "RegionOne/16e7e35b-0c88-4605-90ce-cbef9e9dde0f",
- "maxInstanceLimit": "4",
- "networkInterfaces": [
- {
- "floatingNetworks": [
- {
- "name": "public",
- "networkUuid": "26b4aa2b-06bc-4e4f-a6eb-c19fbc211af6"
- }
- ],
- "name": "core",
- "networkUuid": "5e107fbd-4820-47ad-84ea-6f135496f889"
- }
- ],
- "property": [
- {
- "name": "instanceType",
- "value": "RegionOne/2cdbd576-8c9b-4c2d-8b1a-0f79dc4fb809"
- },
- {
- "name": "keyPair",
- "value": "phoenix"
- },
- {
- "name": "autoAssignIp",
- "value": "false"
- },
- {
- "name": "securityGroups",
- "value": "default"
- }
- ],
- "type": "mock"
- }
- ],
- "multiTenant": "false",
- "portMapping": [
- {
- "port": "22",
- "protocol": "http",
- "proxyPort": "8280"
- }
- ],
- "property": [
- {
- "name": "payload_parameter.MB_IP",
- "value": "octl.qmog.cisco.com"
- },
- {
- "name": "payload_parameter.MB_PORT",
- "value": "61616"
- },
- {
- "name": "payload_parameter.CEP_IP",
- "value": "octl.qmog.cisco.com"
- },
- {
- "name": "payload_parameter.CEP_PORT",
- "value": "7611"
- },
- {
- "name": "payload_parameter.CEP_ADMIN_USERNAME",
- "value": "admin"
- },
- {
- "name": "payload_parameter.CEP_ADMIN_PASSWORD",
- "value": "admin"
- },
- {
- "name": "payload_parameter.CERT_TRUSTSTORE",
- "value": "/opt/apache-stratos-cartridge-agent/security/client-truststore.jks"
- },
- {
- "name": "payload_parameter.TRUSTSTORE_PASSWORD",
- "value": "wso2carbon"
- },
- {
- "name": "payload_parameter.ENABLE_DATA_PUBLISHER",
- "value": "false"
- },
- {
- "name": "payload_parameter.MONITORING_SERVER_IP",
- "value": "octl.qmog.cisco.com"
- },
- {
- "name": "payload_parameter.MONITORING_SERVER_PORT",
- "value": "7611"
- },
- {
- "name": "payload_parameter.MONITORING_SERVER_SECURE_PORT",
- "value": "7711"
- },
- {
- "name": "payload_parameter.MONITORING_SERVER_ADMIN_USERNAME",
- "value": "admin"
- },
- {
- "name": "payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD",
- "value": "admin"
- },
- {
- "name": "payload_parameter.QTCM_DNS_SEGMENT",
- "value": "test"
- },
- {
- "name": "payload_parameter.QTCM_NETWORK_COUNT",
- "value": "1"
- },
- {
- "name": "payload_parameter.SIMPLE_PROPERTY",
- "value": "value"
- }
- ],
- "provider": "cisco",
- "type": "c0",
- "version": "1.0"
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/cartridges/mock/c1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges/mock/c1.json b/products/stratos/modules/integration/src/test/resources/cartridges/mock/c1.json
deleted file mode 100755
index 145e2ce..0000000
--- a/products/stratos/modules/integration/src/test/resources/cartridges/mock/c1.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "type": "c1",
- "provider": "apache",
- "host": "stratos.apache.org",
- "category": "data",
- "displayName": "c1",
- "description": "c1 Cartridge",
- "version": "7",
- "multiTenant": "false",
- "portMapping": [
- {
- "name": "http-22",
- "protocol": "http",
- "port": "22",
- "proxyPort": "8280"
- }
- ],
- "deployment": {
- },
- "iaasProvider": [
- {
- "type": "mock",
- "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
- "networkInterfaces": [
- {
- "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
- }
- ],
- "property": [
- {
- "name": "instanceType",
- "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
- },
- {
- "name": "keyPair",
- "value": "vishanth-key"
- },
- {
- "name": "securityGroups",
- "value": "default"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/cartridges/mock/c2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges/mock/c2.json b/products/stratos/modules/integration/src/test/resources/cartridges/mock/c2.json
deleted file mode 100755
index fd85892..0000000
--- a/products/stratos/modules/integration/src/test/resources/cartridges/mock/c2.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "type": "c2",
- "provider": "apache",
- "host": "stratos.apache.org",
- "category": "data",
- "displayName": "c2",
- "description": "c2 Cartridge",
- "version": "7",
- "multiTenant": "false",
- "portMapping": [
- {
- "name": "http-22",
- "protocol": "http",
- "port": "22",
- "proxyPort": "8280"
- }
- ],
- "deployment": {
- },
- "iaasProvider": [
- {
- "type": "mock",
- "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
- "networkInterfaces": [
- {
- "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
- }
- ],
- "property": [
- {
- "name": "instanceType",
- "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
- },
- {
- "name": "keyPair",
- "value": "vishanth-key"
- },
- {
- "name": "securityGroups",
- "value": "default"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/cartridges/mock/c3.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges/mock/c3.json b/products/stratos/modules/integration/src/test/resources/cartridges/mock/c3.json
deleted file mode 100755
index 937e8d3..0000000
--- a/products/stratos/modules/integration/src/test/resources/cartridges/mock/c3.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "type": "c3",
- "provider": "apache",
- "host": "stratos.apache.org",
- "category": "data",
- "displayName": "c3",
- "description": "c3 Cartridge",
- "version": "7",
- "multiTenant": "false",
- "portMapping": [
- {
- "name": "http-22",
- "protocol": "http",
- "port": "22",
- "proxyPort": "8280"
- }
- ],
- "deployment": {
- },
- "iaasProvider": [
- {
- "type": "mock",
- "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
- "networkInterfaces": [
- {
- "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
- }
- ],
- "property": [
- {
- "name": "instanceType",
- "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
- },
- {
- "name": "keyPair",
- "value": "vishanth-key"
- },
- {
- "name": "securityGroups",
- "value": "default"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/cartridges/mock/update/c0.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridges/mock/update/c0.json b/products/stratos/modules/integration/src/test/resources/cartridges/mock/update/c0.json
deleted file mode 100755
index 6d922a9..0000000
--- a/products/stratos/modules/integration/src/test/resources/cartridges/mock/update/c0.json
+++ /dev/null
@@ -1,124 +0,0 @@
-{
- "category": "Data",
- "description": "c0 Cartridge",
- "displayName": "c0",
- "host": "qmog.cisco.com12",
- "iaasProvider": [
- {
- "imageId": "RegionOne/16e7e35b-0c88-4605-90ce-cbef9e9d123",
- "maxInstanceLimit": "4",
- "networkInterfaces": [
- {
- "floatingNetworks": [
- {
- "name": "private",
- "networkUuid": "26b4aa2b-06bc-4e4f-a6eb-c19fbc2112121"
- }
- ],
- "name": "core1",
- "networkUuid": "5e107fbd-4820-47ad-84ea-6f1354961212"
- }
- ],
- "property": [
- {
- "name": "instanceType",
- "value": "RegionOne/2cdbd576-8c9b-4c2d-8b1a-0f79dc4fb812"
- },
- {
- "name": "keyPair",
- "value": "phoenix12"
- },
- {
- "name": "autoAssignIp",
- "value": "true"
- },
- {
- "name": "securityGroups",
- "value": "default123"
- }
- ],
- "type": "mock"
- }
- ],
- "multiTenant": "false",
- "portMapping": [
- {
- "port": "22",
- "protocol": "http",
- "proxyPort": "8280"
- }
- ],
- "property": [
- {
- "name": "payload_parameter.MB_IP",
- "value": "octl.qmog.cisco.com123"
- },
- {
- "name": "payload_parameter.MB_PORT",
- "value": "61617"
- },
- {
- "name": "payload_parameter.CEP_IP",
- "value": "octl.qmog.cisco.com123"
- },
- {
- "name": "payload_parameter.CEP_PORT",
- "value": "7612"
- },
- {
- "name": "payload_parameter.CEP_ADMIN_USERNAME",
- "value": "admin"
- },
- {
- "name": "payload_parameter.CEP_ADMIN_PASSWORD",
- "value": "admin123"
- },
- {
- "name": "payload_parameter.CERT_TRUSTSTORE",
- "value": "/opt/apache-stratos-cartridge-agent/security/client-truststore.jks"
- },
- {
- "name": "payload_parameter.TRUSTSTORE_PASSWORD",
- "value": "wso2carbon"
- },
- {
- "name": "payload_parameter.ENABLE_DATA_PUBLISHER",
- "value": "false"
- },
- {
- "name": "payload_parameter.MONITORING_SERVER_IP",
- "value": "octl.qmog.cisco.com123"
- },
- {
- "name": "payload_parameter.MONITORING_SERVER_PORT",
- "value": "7612"
- },
- {
- "name": "payload_parameter.MONITORING_SERVER_SECURE_PORT",
- "value": "7712"
- },
- {
- "name": "payload_parameter.MONITORING_SERVER_ADMIN_USERNAME",
- "value": "admin"
- },
- {
- "name": "payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD",
- "value": "admin123"
- },
- {
- "name": "payload_parameter.QTCM_DNS_SEGMENT",
- "value": "test123"
- },
- {
- "name": "payload_parameter.QTCM_NETWORK_COUNT",
- "value": "3"
- },
- {
- "name": "payload_parameter.SIMPLE_PROPERTY",
- "value": "value"
- }
- ],
- "provider": "apache",
- "type": "c0",
- "version": "1.0"
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/deployment-policies/deployment-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/deployment-policies/deployment-policy-1.json b/products/stratos/modules/integration/src/test/resources/deployment-policies/deployment-policy-1.json
deleted file mode 100644
index e186690..0000000
--- a/products/stratos/modules/integration/src/test/resources/deployment-policies/deployment-policy-1.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "id": "deployment-policy-1",
- "networkPartitions": [
- {
- "id": "network-partition-1",
- "partitionAlgo": "one-after-another",
- "partitions": [
- {
- "id": "partition-1",
- "partitionMax": 20
- }
- ]
- },
- {
- "id": "network-partition-2",
- "partitionAlgo": "round-robin",
- "partitions": [
- {
- "id": "network-partition-2-partition-1",
- "partitionMax": 10
- },
- {
- "id": "network-partition-2-partition-2",
- "partitionMax": 9
- }
- ]
- }
- ]
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/deployment-policies/update/deployment-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/deployment-policies/update/deployment-policy-1.json b/products/stratos/modules/integration/src/test/resources/deployment-policies/update/deployment-policy-1.json
deleted file mode 100644
index 2ba5eb3..0000000
--- a/products/stratos/modules/integration/src/test/resources/deployment-policies/update/deployment-policy-1.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "id": "deployment-policy-1",
- "networkPartitions": [
- {
- "id": "network-partition-1",
- "partitionAlgo": "one-after-another",
- "partitions": [
- {
- "id": "partition-1",
- "partitionMax": 25
- },
- {
- "id": "partition-2",
- "partitionMax": 20
- }
- ]
- },
- {
- "id": "network-partition-2",
- "partitionAlgo": "round-robin",
- "partitions": [
- {
- "id": "network-partition-2-partition-1",
- "partitionMax": 15
- },
- {
- "id": "network-partition-2-partition-2",
- "partitionMax": 5
- }
- ]
- }
- ]
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-1.json b/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-1.json
deleted file mode 100644
index 3fbeeac..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-1.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "id": "network-partition-1",
- "provider": "ec2",
- "partitions": [
- {
- "id": "partition-1",
- "property": [
- {
- "name": "region",
- "value": "ap-southeast-1"
- },
- {
- "name": "zone",
- "value": "ap-southeast-1a"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-2.json b/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-2.json
deleted file mode 100644
index 02f9b1d..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/ec2/network-partition-2.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "id": "network-partition-2",
- "partitions": [
- {
- "id": "partition-2",
- "provider": "ec2",
- "property": [
- {
- "name": "region",
- "value": "ap-southeast-2"
- },
- {
- "name": "region",
- "value": "ap-southeast-2b"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/gce/network-partition-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/gce/network-partition-1.json b/products/stratos/modules/integration/src/test/resources/network-partitions/gce/network-partition-1.json
deleted file mode 100644
index 177e7d2..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/gce/network-partition-1.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id": "network-partition-1",
- "provider": "gce",
- "partitions": [
- {
- "id": "partition-1",
- "property": [
- {
- "name": "region",
- "value": "default"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/kubernetes/network-partition-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/kubernetes/network-partition-1.json b/products/stratos/modules/integration/src/test/resources/network-partitions/kubernetes/network-partition-1.json
deleted file mode 100644
index bb27086..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/kubernetes/network-partition-1.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id": "network-partition-1",
- "provider": "kubernetes",
- "partitions": [
- {
- "id": "partition-1",
- "property": [
- {
- "name": "cluster",
- "value": "kubernetes-cluster-2"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/kubernetes/network-partition-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/kubernetes/network-partition-2.json b/products/stratos/modules/integration/src/test/resources/network-partitions/kubernetes/network-partition-2.json
deleted file mode 100644
index 8f9f053..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/kubernetes/network-partition-2.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id": "network-partition-2",
- "provider": "kubernetes",
- "partitions": [
- {
- "id": "partition-1",
- "property": [
- {
- "name": "cluster",
- "value": "kubernetes-cluster-2"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/kubernetes/network-partition-3.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/kubernetes/network-partition-3.json b/products/stratos/modules/integration/src/test/resources/network-partitions/kubernetes/network-partition-3.json
deleted file mode 100644
index 5188f3c..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/kubernetes/network-partition-3.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id": "network-partition-3",
- "provider": "kubernetes",
- "partitions": [
- {
- "id": "partition-1",
- "property": [
- {
- "name": "cluster",
- "value": "kubernetes-cluster-1"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-1.json b/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-1.json
deleted file mode 100644
index 466da28..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-1.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id": "network-partition-1",
- "provider": "mock",
- "partitions": [
- {
- "id": "partition-1",
- "property": [
- {
- "name": "region",
- "value": "default"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-2.json b/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-2.json
deleted file mode 100644
index 23236e2..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-2.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "id": "network-partition-2",
- "provider": "mock",
- "partitions": [
- {
- "id": "network-partition-2-partition-1",
- "property": [
- {
- "name": "region",
- "value": "default"
- }
- ]
- },
- {
- "id": "network-partition-2-partition-2",
- "property": [
- {
- "name": "region",
- "value": "default"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-3.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-3.json b/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-3.json
deleted file mode 100644
index 1bb7f2a..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-3.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id": "network-partition-3",
- "provider": "mock",
- "partitions": [
- {
- "id": "partition-1",
- "property": [
- {
- "name": "region",
- "value": "default"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-4.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-4.json b/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-4.json
deleted file mode 100644
index fb0cb9c..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/mock/network-partition-4.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id": "network-partition-4",
- "provider": "mock",
- "partitions": [
- {
- "id": "partition-1",
- "property": [
- {
- "name": "region",
- "value": "default"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/mock/update/network-partition-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/mock/update/network-partition-1.json b/products/stratos/modules/integration/src/test/resources/network-partitions/mock/update/network-partition-1.json
deleted file mode 100644
index 054265a..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/mock/update/network-partition-1.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "id": "network-partition-1",
- "provider": "mock",
- "partitions": [
- {
- "id": "partition-1",
- "property": [
- {
- "name": "region",
- "value": "default"
- }
- ]
- },
- {
- "id": "partition-2",
- "property": [
- {
- "name": "region",
- "value": "default1"
- },
- {
- "name": "zone",
- "value": "z1"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-1-nw-partition.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-1-nw-partition.json b/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-1-nw-partition.json
deleted file mode 100644
index 061fc73..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-1-nw-partition.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "id": "ap-southeast-1-nw-partition",
- "provider": "ec2-singapore",
- "partitions": [
- {
- "id": "ap-southeast-1a-partition",
- "property": [
- {
- "name": "region",
- "value": "ap-southeast-1"
- },
- {
- "name": "zone",
- "value": "ap-southeast-1a"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-2-nw-partition.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-2-nw-partition.json b/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-2-nw-partition.json
deleted file mode 100644
index 435d2f0..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/multi/ap-southeast-2-nw-partition.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "id": "ap-southeast-2-nw-partition",
- "provider": "ec2-sydney",
- "partitions": [
- {
- "id": "ap-southeast-2b-partition",
- "property": [
- {
- "name": "region",
- "value": "ap-southeast-2"
- },
- {
- "name": "zone",
- "value": "ap-southeast-2b"
- }
- ]
- }
- ],
- "properties": [
- {
- "name": "payload_parameter.PUPPET_IP",
- "value": "172.31.9.64"
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/multi/openstack-nw-partition.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/multi/openstack-nw-partition.json b/products/stratos/modules/integration/src/test/resources/network-partitions/multi/openstack-nw-partition.json
deleted file mode 100644
index c95a987..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/multi/openstack-nw-partition.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "id": "openstack-nw-partition",
- "provider": "openstack",
- "partitions": [
- {
- "id": "partition-1",
- "property": [
- {
- "name": "region",
- "value": "RegionOne"
- }
- ]
- }
- ],
- "properties": [
- {
- "name": "payload_parameter.PUPPET_IP",
- "value": "192.168.60.16"
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/openstack/network-partition-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/openstack/network-partition-1.json b/products/stratos/modules/integration/src/test/resources/network-partitions/openstack/network-partition-1.json
deleted file mode 100644
index aa14c0f..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/openstack/network-partition-1.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id": "network-partition-1",
- "provider": "openstack",
- "partitions": [
- {
- "id": "partition-1",
- "property": [
- {
- "name": "region",
- "value": "RegionOne"
- }
- ]
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/network-partitions/openstack/network-partition-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partitions/openstack/network-partition-2.json b/products/stratos/modules/integration/src/test/resources/network-partitions/openstack/network-partition-2.json
deleted file mode 100644
index c4db4a5..0000000
--- a/products/stratos/modules/integration/src/test/resources/network-partitions/openstack/network-partition-2.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id": "network-partition-2",
- "provider": "openstack",
- "partitions": [
- {
- "id": "partition-2",
- "property": [
- {
- "name": "region",
- "value": "RegionOne"
- }
- ]
- }
- ]
-}
[3/6] stratos git commit: Add the updated integration tests
Posted by ga...@apache.org.
Add the updated integration tests
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4b96ba01
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4b96ba01
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4b96ba01
Branch: refs/heads/tenant-isolation
Commit: 4b96ba010f659685a64a8ba8e64b910b57e09086
Parents: 6ce6d54
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Mon Aug 10 16:16:14 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Mon Aug 10 16:16:14 2015 +0530
----------------------------------------------------------------------
.../tests/ApplicationPolicyTest.java | 144 ---
.../integration/tests/ApplicationTest.java | 220 ----
.../tests/AutoscalingPolicyTest.java | 143 ---
.../integration/tests/CartridgeGroupTest.java | 145 ---
.../integration/tests/CartridgeTest.java | 144 ---
.../integration/tests/DeploymentPolicyTest.java | 146 ---
.../integration/tests/NetworkPartitionTest.java | 144 ---
.../integration/tests/RestConstants.java | 15 +
.../tests/SampleApplicationsTest.java | 1035 ------------------
.../tests/StratosArtifactsUtils.java | 53 -
.../tests/StratosTestServerManager.java | 63 +-
.../integration/tests/rest/RestClient.java | 246 ++++-
.../application-policy-1.json | 18 -
.../simple/single-cartridge-app/README.md | 25 -
.../single-cartridge-app/g-sc-G123-1.json | 86 --
.../update/g-sc-G123-1.json | 86 --
.../autoscaling-policy-1.json | 14 -
.../autoscaling-policy-c0.json | 14 -
.../update/autoscaling-policy-c0.json | 14 -
.../cartridges-groups/cartrdige-nested.json | 50 -
.../update/cartrdige-nested.json | 50 -
.../src/test/resources/cartridges/mock/c0.json | 124 ---
.../src/test/resources/cartridges/mock/c1.json | 45 -
.../src/test/resources/cartridges/mock/c2.json | 45 -
.../src/test/resources/cartridges/mock/c3.json | 45 -
.../resources/cartridges/mock/update/c0.json | 124 ---
.../deployment-policy-1.json | 32 -
.../update/deployment-policy-1.json | 36 -
.../ec2/network-partition-1.json | 19 -
.../ec2/network-partition-2.json | 19 -
.../gce/network-partition-1.json | 15 -
.../kubernetes/network-partition-1.json | 15 -
.../kubernetes/network-partition-2.json | 15 -
.../kubernetes/network-partition-3.json | 15 -
.../mock/network-partition-1.json | 15 -
.../mock/network-partition-2.json | 24 -
.../mock/network-partition-3.json | 15 -
.../mock/network-partition-4.json | 15 -
.../mock/update/network-partition-1.json | 28 -
.../multi/ap-southeast-1-nw-partition.json | 19 -
.../multi/ap-southeast-2-nw-partition.json | 25 -
.../multi/openstack-nw-partition.json | 21 -
.../openstack/network-partition-1.json | 15 -
.../openstack/network-partition-2.json | 15 -
44 files changed, 300 insertions(+), 3296 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
deleted file mode 100644
index c5ee5d1..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationPolicyTest.java
+++ /dev/null
@@ -1,144 +0,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.
- */
-
-package org.apache.stratos.integration.tests;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
-import org.apache.stratos.integration.tests.rest.ErrorResponse;
-import org.apache.stratos.integration.tests.rest.HttpResponse;
-import org.apache.stratos.integration.tests.rest.RestClient;
-
-import java.net.URI;
-
-/**
- * Test to handle Network partition CRUD operations
- */
-public class ApplicationPolicyTest extends StratosArtifactsUtils {
- private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
- String applicationPolicies = "/application-policies/";
- String applicationPoliciesUpdate = "/application-policies/update/";
-
-
- public boolean addApplicationPolicy(String networkPartitionId, String endpoint, RestClient restClient) {
- try {
- String content = getJsonStringFromFile(applicationPolicies + networkPartitionId);
- URI uri = new URIBuilder(endpoint + RestConstants.APPLICATION_POLICIES).build();
-
- HttpResponse response = restClient.doPost(uri, content, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public ApplicationPolicyBean getApplicationPolicy(String networkPartitionId, String endpoint,
- RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.APPLICATION_POLICIES + "/" +
- networkPartitionId).build();
- HttpResponse response = restClient.doGet(uri, "admin", "admin");
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return gson.fromJson(response.getContent(), ApplicationPolicyBean.class);
- } else if (response.getStatusCode() == 404) {
- return null;
- } else {
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean updateApplicationPolicy(String networkPartitionId, String endpoint, RestClient restClient) {
- try {
- String content = getJsonStringFromFile(applicationPoliciesUpdate + networkPartitionId);
- URI uri = new URIBuilder(endpoint + RestConstants.APPLICATION_POLICIES).build();
- HttpResponse response = restClient.doPut(uri, content, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean removeApplicationPolicy(String networkPartitionId, String endpoint, RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.APPLICATION_POLICIES + "/" +
- networkPartitionId).build();
- HttpResponse response = restClient.doDelete(uri, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else if(response.getContent().contains("it is used")) {
- return false;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
deleted file mode 100644
index 27eb4b5..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/ApplicationTest.java
+++ /dev/null
@@ -1,220 +0,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.
- */
-
-package org.apache.stratos.integration.tests;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.stratos.common.beans.application.ApplicationBean;
-import org.apache.stratos.integration.tests.rest.ErrorResponse;
-import org.apache.stratos.integration.tests.rest.HttpResponse;
-import org.apache.stratos.integration.tests.rest.RestClient;
-
-import java.net.URI;
-
-/**
- * Test to handle autoscaling policy CRUD operations
- */
-public class ApplicationTest extends StratosArtifactsUtils {
- private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
- String applications = "/applications/simple/single-cartridge-app/";
- String applicationsUpdate = "/applications/simple/single-cartridge-app/update/";
-
-
- public boolean addApplication(String applicationId, String endpoint, RestClient restClient) {
- try {
- String content = getJsonStringFromFile(applications + applicationId);
- URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS).build();
-
- HttpResponse response = restClient.doPost(uri, content, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean deployApplication(String applicationId, String applicationPolicyId,
- String endpoint, RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" + applicationId +
- RestConstants.APPLICATIONS_DEPLOY + "/" + applicationPolicyId).build();
-
- HttpResponse response = restClient.doPost(uri, "", "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean undeployApplication(String applicationId,
- String endpoint, RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" + applicationId +
- RestConstants.APPLICATIONS_UNDEPLOY).build();
-
- HttpResponse response = restClient.doPost(uri, "", "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean forceUndeployApplication(String applicationId,
- String endpoint, RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" + applicationId +
- RestConstants.APPLICATIONS_UNDEPLOY + "?force=true").build();
-
- HttpResponse response = restClient.doPost(uri, "", "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public ApplicationBean getApplication(String applicationId, String endpoint,
- RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" +
- applicationId).build();
- HttpResponse response = restClient.doGet(uri, "admin", "admin");
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return gson.fromJson(response.getContent(), ApplicationBean.class);
- } else if (response.getStatusCode() == 404) {
- return null;
- } else {
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean updateApplication(String applicationId, String endpoint, RestClient restClient) {
- try {
- String content = getJsonStringFromFile(applicationsUpdate + applicationId);
- URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS).build();
- HttpResponse response = restClient.doPut(uri, content, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean removeApplication(String applicationId, String endpoint, RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.APPLICATIONS + "/" +
- applicationId).build();
- HttpResponse response = restClient.doDelete(uri, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
deleted file mode 100644
index 52c4c0c..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/AutoscalingPolicyTest.java
+++ /dev/null
@@ -1,143 +0,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.
- */
-package org.apache.stratos.integration.tests;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
-import org.apache.stratos.integration.tests.rest.ErrorResponse;
-import org.apache.stratos.integration.tests.rest.HttpResponse;
-import org.apache.stratos.integration.tests.rest.RestClient;
-
-import java.net.URI;
-
-/**
- * Test to handle autoscaling policy CRUD operations
- */
-public class AutoscalingPolicyTest extends StratosArtifactsUtils {
- private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
- String autoscalingPolicy = "/autoscaling-policies/";
- String autoscalingPolicyUpdate = "/autoscaling-policies/update/";
-
-
- public boolean addAutoscalingPolicy(String autoscalingPolicyName, String endpoint, RestClient restClient, String userName, String password) {
- try {
- String content = getJsonStringFromFile(autoscalingPolicy + autoscalingPolicyName);
- URI uri = new URIBuilder(endpoint + RestConstants.AUTOSCALING_POLICIES).build();
-
- HttpResponse response = restClient.doPost(uri, content, userName, password);
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public AutoscalePolicyBean getAutoscalingPolicy(String autoscalingPolicyName, String endpoint,
- RestClient restClient, String userName, String password) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.AUTOSCALING_POLICIES + "/" +
- autoscalingPolicyName).build();
- HttpResponse response = restClient.doGet(uri, userName, password);
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return gson.fromJson(response.getContent(), AutoscalePolicyBean.class);
- } else if (response.getStatusCode() == 404) {
- return null;
- } else {
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean updateAutoscalingPolicy(String autoscalingPolicyName, String endpoint, RestClient restClient, String userName, String password) {
- try {
- String content = getJsonStringFromFile(autoscalingPolicyUpdate + autoscalingPolicyName);
- URI uri = new URIBuilder(endpoint + RestConstants.AUTOSCALING_POLICIES).build();
- HttpResponse response = restClient.doPut(uri, content, userName, password);
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean removeAutoscalingPolicy(String autoscalingPolicyName, String endpoint, RestClient restClient, String userName, String password) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.AUTOSCALING_POLICIES + "/" +
- autoscalingPolicyName).build();
- HttpResponse response = restClient.doDelete(uri, userName, password);
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else if(response.getContent().contains("is in use")) {
- return false;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
deleted file mode 100644
index c299571..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeGroupTest.java
+++ /dev/null
@@ -1,145 +0,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.
- */
-
-package org.apache.stratos.integration.tests;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
-import org.apache.stratos.integration.tests.rest.ErrorResponse;
-import org.apache.stratos.integration.tests.rest.HttpResponse;
-import org.apache.stratos.integration.tests.rest.RestClient;
-
-import java.net.URI;
-
-/**
- * Test to handle Network partition CRUD operations
- */
-public class CartridgeGroupTest extends StratosArtifactsUtils {
- private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
- String cartridgeGroups = "/cartridges-groups/";
- String cartridgeGroupsUpdate = "/cartridges-groups/update/";
-
-
- public boolean addCartridgeGroup(String groupName, String endpoint, RestClient restClient) {
- try {
- String content = getJsonStringFromFile(cartridgeGroups + groupName);
- URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGE_GROUPS).build();
-
- HttpResponse response = restClient.doPost(uri, content, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- log.info(response.getReason());
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public CartridgeGroupBean getCartridgeGroup(String groupName, String endpoint,
- RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGE_GROUPS + "/" +
- groupName).build();
- HttpResponse response = restClient.doGet(uri, "admin", "admin");
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return gson.fromJson(response.getContent(), CartridgeGroupBean.class);
- } else if (response.getStatusCode() == 404) {
- return null;
- } else {
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean updateCartridgeGroup(String groupName, String endpoint, RestClient restClient) {
- try {
- String content = getJsonStringFromFile(cartridgeGroupsUpdate + groupName);
- URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGE_GROUPS).build();
- HttpResponse response = restClient.doPut(uri, content, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean removeCartridgeGroup(String groupName, String endpoint, RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGE_GROUPS + "/" +
- groupName).build();
- HttpResponse response = restClient.doDelete(uri, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else if(response.getContent().contains("it is used")) {
- return false;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
deleted file mode 100644
index 522f0ee..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/CartridgeTest.java
+++ /dev/null
@@ -1,144 +0,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.
- */
-
-package org.apache.stratos.integration.tests;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.stratos.common.beans.cartridge.CartridgeBean;
-import org.apache.stratos.integration.tests.rest.ErrorResponse;
-import org.apache.stratos.integration.tests.rest.HttpResponse;
-import org.apache.stratos.integration.tests.rest.RestClient;
-
-import java.net.URI;
-
-/**
- * Test to handle Network partition CRUD operations
- */
-public class CartridgeTest extends StratosArtifactsUtils {
- private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
- String cartridges = "/cartridges/mock/";
- String cartridgesUpdate = "/cartridges/mock/update/";
-
-
- public boolean addCartridge(String cartridgeType, String endpoint, RestClient restClient) {
- try {
- String content = getJsonStringFromFile(cartridges + cartridgeType);
- URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGES).build();
-
- HttpResponse response = restClient.doPost(uri, content, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public CartridgeBean getCartridge(String cartridgeType, String endpoint,
- RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGES + "/" +
- cartridgeType).build();
- HttpResponse response = restClient.doGet(uri, "admin", "admin");
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return gson.fromJson(response.getContent(), CartridgeBean.class);
- } else if (response.getStatusCode() == 404) {
- return null;
- } else {
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean updateCartridge(String cartridgeType, String endpoint, RestClient restClient) {
- try {
- String content = getJsonStringFromFile(cartridgesUpdate + cartridgeType);
- URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGES).build();
- HttpResponse response = restClient.doPut(uri, content, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean removeCartridge(String cartridgeType, String endpoint, RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.CARTRIDGES + "/" +
- cartridgeType).build();
- HttpResponse response = restClient.doDelete(uri, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else if (response.getContent().contains("it is used")) {
- return false;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
deleted file mode 100644
index 6ee2dd1..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/DeploymentPolicyTest.java
+++ /dev/null
@@ -1,146 +0,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.
- */
-
-package org.apache.stratos.integration.tests;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
-import org.apache.stratos.integration.tests.rest.ErrorResponse;
-import org.apache.stratos.integration.tests.rest.HttpResponse;
-import org.apache.stratos.integration.tests.rest.RestClient;
-
-import java.net.URI;
-
-/**
- * Test to handle Network partition CRUD operations
- */
-public class DeploymentPolicyTest extends StratosArtifactsUtils {
- private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
- String deploymentPolicies = "/deployment-policies/";
- String deploymentPoliciesUpdate = "/deployment-policies/update/";
-
-
- public boolean addDeploymentPolicy(String deploymentPolicyId, String endpoint, RestClient restClient) {
- try {
- String content = getJsonStringFromFile(deploymentPolicies + deploymentPolicyId);
- URI uri = new URIBuilder(endpoint + RestConstants.DEPLOYMENT_POLICIES).build();
-
- HttpResponse response = restClient.doPost(uri, content, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public DeploymentPolicyBean getDeploymentPolicy(String deploymentPolicyId, String endpoint,
- RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.DEPLOYMENT_POLICIES + "/" +
- deploymentPolicyId).build();
- HttpResponse response = restClient.doGet(uri, "admin", "admin");
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return gson.fromJson(response.getContent(), DeploymentPolicyBean.class);
- } else if (response.getStatusCode() == 404) {
- return null;
- } else {
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean updateDeploymentPolicy(String deploymentPolicyId, String endpoint, RestClient restClient) {
- try {
- String content = getJsonStringFromFile(deploymentPoliciesUpdate + deploymentPolicyId);
- URI uri = new URIBuilder(endpoint + RestConstants.DEPLOYMENT_POLICIES).build();
- HttpResponse response = restClient.doPut(uri, content, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else if(response.getContent().contains("it is used")) {
- return false;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean removeDeploymentPolicy(String deploymentPolicyId, String endpoint, RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.DEPLOYMENT_POLICIES + "/" +
- deploymentPolicyId).build();
- HttpResponse response = restClient.doDelete(uri, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else if(response.getContent().contains("is in use")) {
- return false;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
deleted file mode 100644
index aa31562..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/NetworkPartitionTest.java
+++ /dev/null
@@ -1,144 +0,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.
- */
-
-package org.apache.stratos.integration.tests;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
-import org.apache.stratos.integration.tests.rest.ErrorResponse;
-import org.apache.stratos.integration.tests.rest.HttpResponse;
-import org.apache.stratos.integration.tests.rest.RestClient;
-
-import java.net.URI;
-
-/**
- * Test to handle Network partition CRUD operations
- */
-public class NetworkPartitionTest extends StratosArtifactsUtils {
- private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
- String networkPartitions = "/network-partitions/mock/";
- String networkPartitionsUpdate = "/network-partitions/mock/update/";
-
-
- public boolean addNetworkPartition(String networkPartitionId, String endpoint, RestClient restClient) {
- try {
- String content = getJsonStringFromFile(networkPartitions + networkPartitionId);
- URI uri = new URIBuilder(endpoint + RestConstants.NETWORK_PARTITIONS).build();
-
- HttpResponse response = restClient.doPost(uri, content, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public NetworkPartitionBean getNetworkPartition(String networkPartitionId, String endpoint,
- RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.NETWORK_PARTITIONS + "/" +
- networkPartitionId).build();
- HttpResponse response = restClient.doGet(uri, "admin", "admin");
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return gson.fromJson(response.getContent(), NetworkPartitionBean.class);
- } else if (response.getStatusCode() == 404) {
- return null;
- } else {
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean updateNetworkPartition(String networkPartitionId, String endpoint, RestClient restClient) {
- try {
- String content = getJsonStringFromFile(networkPartitionsUpdate + networkPartitionId);
- URI uri = new URIBuilder(endpoint + RestConstants.NETWORK_PARTITIONS).build();
- HttpResponse response = restClient.doPut(uri, content, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-
- public boolean removeNetworkPartition(String networkPartitionId, String endpoint, RestClient restClient) {
- try {
- URI uri = new URIBuilder(endpoint + RestConstants.NETWORK_PARTITIONS + "/" +
- networkPartitionId).build();
- HttpResponse response = restClient.doDelete(uri, "admin", "admin");
- if (response != null) {
- if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
- return true;
- } else if(response.getContent().contains("it is used")) {
- return false;
- } else {
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
- if (errorResponse != null) {
- throw new RuntimeException(errorResponse.getErrorMessage());
- }
- }
- }
- throw new RuntimeException("An unknown error occurred");
- } catch (Exception e) {
- String message = "Could not start mock instance";
- throw new RuntimeException(message, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
index 9678c4e..bf7de6c 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/RestConstants.java
@@ -34,4 +34,19 @@ public class RestConstants {
public static final String APPLICATIONS_DEPLOY = "/deploy";
public static final String APPLICATIONS_UNDEPLOY = "/undeploy";
+ public static final String AUTOSCALING_POLICIES_PATH = "/autoscaling-policies/";
+ public static final String AUTOSCALING_POLICIES_NAME = "autoscalingPolicy";
+ public static final String CARTRIDGE_GROUPS_PATH = "/cartridges-groups/";
+ public static final String CARTRIDGE_GROUPS_NAME = "cartridgeGroup";
+ public static final String CARTRIDGES_PATH = "/cartridges/mock/";
+ public static final String CARTRIDGES_NAME = "cartridge";
+ public static final String NETWORK_PARTITIONS_PATH = "/network-partitions/mock/";
+ public static final String NETWORK_PARTITIONS_NAME = "networkPartition";
+ public static final String DEPLOYMENT_POLICIES_PATH = "/deployment-policies/";
+ public static final String DEPLOYMENT_POLICIES_NAME = "deploymentPolicy";
+ public static final String APPLICATIONS_PATH = "/applications/";
+ public static final String APPLICATIONS_NAME = "application";
+ public static final String APPLICATION_POLICIES_PATH = "/application-policies/";
+ public static final String APPLICATION_POLICIES_NAME = "applicationPolicy";
+
}
[4/6] stratos git commit: Add the updated integration tests
Posted by ga...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-3.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-3.json b/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-3.json
new file mode 100644
index 0000000..1bb7f2a
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-3.json
@@ -0,0 +1,15 @@
+{
+ "id": "network-partition-3",
+ "provider": "mock",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/application-policies/application-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/application-policies/application-policy-1.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/application-policies/application-policy-1.json
new file mode 100644
index 0000000..d2699a1
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/application-policies/application-policy-1.json
@@ -0,0 +1,18 @@
+{
+ "id": "application-policy-1",
+ "algorithm": "one-after-another",
+ "networkPartitions": [
+ "network-partition-1",
+ "network-partition-2"
+ ],
+ "properties": [
+ {
+ "name": "key-1",
+ "value": "network-partition-1,network-partition-2"
+ },
+ {
+ "name": "key-2",
+ "value": "value-2"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1-v1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1-v1.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1-v1.json
new file mode 100644
index 0000000..a91c4e0
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1-v1.json
@@ -0,0 +1,86 @@
+{
+ "alias": "g-sc-G123-1",
+ "applicationId": "g-sc-G123-1",
+ "components": {
+ "cartridges": [],
+ "groups": [
+ {
+ "name": "G1",
+ "groupMaxInstances": 1,
+ "groupMinInstances": 1,
+ "alias": "group1",
+ "cartridges": [
+ {
+ "cartridgeMin": 2,
+ "cartridgeMax": 3,
+ "type": "c1",
+ "subscribableInfo": {
+ "alias": "c1-1x0",
+ "deploymentPolicy": "deployment-policy-1",
+ "artifactRepository": {
+ "repoUsername": "user",
+ "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+ "privateRepo": true,
+ "repoPassword": "c-policy"
+ },
+ "autoscalingPolicy": "autoscaling-policy-1"
+ }
+ }
+ ],
+ "groups": [
+ {
+ "name": "G2",
+ "groupMaxInstances": 1,
+ "groupMinInstances": 1,
+ "alias": "group2",
+ "cartridges": [
+ {
+ "cartridgeMin": 2,
+ "cartridgeMax": 4,
+ "type": "c2",
+ "subscribableInfo": {
+ "alias": "c2-1x0",
+ "deploymentPolicy": "deployment-policy-1",
+ "artifactRepository": {
+ "repoUsername": "user",
+ "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+ "privateRepo": true,
+ "repoPassword": "c-policy"
+ },
+ "autoscalingPolicy": "autoscaling-policy-1"
+ }
+ }
+ ],
+ "groups": [
+ {
+ "name": "G3",
+ "groupMaxInstances": 3,
+ "groupMinInstances": 2,
+ "deploymentPolicy": "deployment-policy-1",
+ "alias": "group3",
+ "cartridges": [
+ {
+ "cartridgeMin": 2,
+ "cartridgeMax": 3,
+ "type": "c3",
+ "subscribableInfo": {
+ "alias": "c3-1x0",
+ "artifactRepository": {
+ "repoUsername": "user",
+ "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+ "privateRepo": true,
+ "repoPassword": "c-policy"
+ },
+ "autoscalingPolicy": "autoscaling-policy-1"
+ }
+ }
+ ],
+ "groups": []
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1-v2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1-v2.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1-v2.json
new file mode 100644
index 0000000..6f827c2
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1-v2.json
@@ -0,0 +1,86 @@
+{
+ "alias": "g-sc-G123-1",
+ "applicationId": "g-sc-G123-1",
+ "components": {
+ "cartridges": [],
+ "groups": [
+ {
+ "name": "G1",
+ "groupMaxInstances": 5,
+ "groupMinInstances": 2,
+ "alias": "group1",
+ "cartridges": [
+ {
+ "cartridgeMin": 2,
+ "cartridgeMax": 3,
+ "type": "c1",
+ "subscribableInfo": {
+ "alias": "c1-1x0",
+ "deploymentPolicy": "deployment-policy-1",
+ "artifactRepository": {
+ "repoUsername": "user",
+ "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+ "privateRepo": true,
+ "repoPassword": "c-policy"
+ },
+ "autoscalingPolicy": "autoscaling-policy-1"
+ }
+ }
+ ],
+ "groups": [
+ {
+ "name": "G2",
+ "groupMaxInstances": 1,
+ "groupMinInstances": 1,
+ "alias": "group2",
+ "cartridges": [
+ {
+ "cartridgeMin": 2,
+ "cartridgeMax": 4,
+ "type": "c2",
+ "subscribableInfo": {
+ "alias": "c2-1x0",
+ "deploymentPolicy": "deployment-policy-1",
+ "artifactRepository": {
+ "repoUsername": "user",
+ "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+ "privateRepo": true,
+ "repoPassword": "c-policy"
+ },
+ "autoscalingPolicy": "autoscaling-policy-1"
+ }
+ }
+ ],
+ "groups": [
+ {
+ "name": "G3",
+ "groupMaxInstances": 3,
+ "groupMinInstances": 2,
+ "deploymentPolicy": "static-1",
+ "alias": "group3",
+ "cartridges": [
+ {
+ "cartridgeMin": 2,
+ "cartridgeMax": 3,
+ "type": "c3",
+ "subscribableInfo": {
+ "alias": "c3-1x0",
+ "artifactRepository": {
+ "repoUsername": "user",
+ "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+ "privateRepo": true,
+ "repoPassword": "c-policy"
+ },
+ "autoscalingPolicy": "autoscaling-policy-1"
+ }
+ }
+ ],
+ "groups": []
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1-v3.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1-v3.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1-v3.json
new file mode 100644
index 0000000..a6e5fd7
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1-v3.json
@@ -0,0 +1,86 @@
+{
+ "alias": "g-sc-G123-1",
+ "applicationId": "g-sc-G123-1",
+ "components": {
+ "cartridges": [],
+ "groups": [
+ {
+ "name": "G1",
+ "groupMaxInstances": 1,
+ "groupMinInstances": 1,
+ "alias": "group1",
+ "cartridges": [
+ {
+ "cartridgeMin": 2,
+ "cartridgeMax": 3,
+ "type": "c1",
+ "subscribableInfo": {
+ "alias": "c1-1x0",
+ "deploymentPolicy": "deployment-policy-1",
+ "artifactRepository": {
+ "repoUsername": "user",
+ "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+ "privateRepo": true,
+ "repoPassword": "c-policy"
+ },
+ "autoscalingPolicy": "autoscaling-policy-1"
+ }
+ }
+ ],
+ "groups": [
+ {
+ "name": "G2",
+ "groupMaxInstances": 1,
+ "groupMinInstances": 1,
+ "alias": "group2",
+ "cartridges": [
+ {
+ "cartridgeMin": 2,
+ "cartridgeMax": 4,
+ "type": "c2",
+ "subscribableInfo": {
+ "alias": "c2-1x0",
+ "deploymentPolicy": "deployment-policy-1",
+ "artifactRepository": {
+ "repoUsername": "user",
+ "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+ "privateRepo": true,
+ "repoPassword": "c-policy"
+ },
+ "autoscalingPolicy": "autoscaling-policy-1"
+ }
+ }
+ ],
+ "groups": [
+ {
+ "name": "G3",
+ "groupMaxInstances": 4,
+ "groupMinInstances": 3,
+ "deploymentPolicy": "static-1",
+ "alias": "group3",
+ "cartridges": [
+ {
+ "cartridgeMin": 2,
+ "cartridgeMax": 3,
+ "type": "c3",
+ "subscribableInfo": {
+ "alias": "c3-1x0",
+ "artifactRepository": {
+ "repoUsername": "user",
+ "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+ "privateRepo": true,
+ "repoPassword": "c-policy"
+ },
+ "autoscalingPolicy": "autoscaling-policy-1"
+ }
+ }
+ ],
+ "groups": []
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1.json
new file mode 100644
index 0000000..76d72c8
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/applications/g-sc-G123-1.json
@@ -0,0 +1,86 @@
+{
+ "alias": "g-sc-G123-1",
+ "applicationId": "g-sc-G123-1",
+ "components": {
+ "cartridges": [],
+ "groups": [
+ {
+ "name": "G1",
+ "groupMaxInstances": 1,
+ "groupMinInstances": 1,
+ "alias": "group1",
+ "cartridges": [
+ {
+ "cartridgeMin": 1,
+ "cartridgeMax": 2,
+ "type": "c1",
+ "subscribableInfo": {
+ "alias": "c1-1x0",
+ "deploymentPolicy": "deployment-policy-1",
+ "artifactRepository": {
+ "repoUsername": "user",
+ "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+ "privateRepo": true,
+ "repoPassword": "c-policy"
+ },
+ "autoscalingPolicy": "autoscaling-policy-1"
+ }
+ }
+ ],
+ "groups": [
+ {
+ "name": "G2",
+ "groupMaxInstances": 1,
+ "groupMinInstances": 1,
+ "alias": "group2",
+ "cartridges": [
+ {
+ "cartridgeMin": 1,
+ "cartridgeMax": 2,
+ "type": "c2",
+ "subscribableInfo": {
+ "alias": "c2-1x0",
+ "deploymentPolicy": "deployment-policy-1",
+ "artifactRepository": {
+ "repoUsername": "user",
+ "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+ "privateRepo": true,
+ "repoPassword": "c-policy"
+ },
+ "autoscalingPolicy": "autoscaling-policy-1"
+ }
+ }
+ ],
+ "groups": [
+ {
+ "name": "G3",
+ "groupMaxInstances": 2,
+ "groupMinInstances": 1,
+ "deploymentPolicy": "deployment-policy-1",
+ "alias": "group3",
+ "cartridges": [
+ {
+ "cartridgeMin": 1,
+ "cartridgeMax": 2,
+ "type": "c3",
+ "subscribableInfo": {
+ "alias": "c3-1x0",
+ "artifactRepository": {
+ "repoUsername": "user",
+ "repoUrl": "http://stratos.apache.org:10080/git/default.git",
+ "privateRepo": true,
+ "repoPassword": "c-policy"
+ },
+ "autoscalingPolicy": "autoscaling-policy-1"
+ }
+ }
+ ],
+ "groups": []
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/autoscaling-policies/autoscaling-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/autoscaling-policies/autoscaling-policy-1.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/autoscaling-policies/autoscaling-policy-1.json
new file mode 100644
index 0000000..f82403b
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/autoscaling-policies/autoscaling-policy-1.json
@@ -0,0 +1,14 @@
+{
+ "id": "autoscaling-policy-1",
+ "loadThresholds": {
+ "requestsInFlight": {
+ "threshold": 35
+ },
+ "memoryConsumption": {
+ "threshold": 45
+ },
+ "loadAverage": {
+ "threshold": 25
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges-groups/cartrdige-nested-v1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges-groups/cartrdige-nested-v1.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges-groups/cartrdige-nested-v1.json
new file mode 100644
index 0000000..6020e1e
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges-groups/cartrdige-nested-v1.json
@@ -0,0 +1,50 @@
+{
+ "name": "G1",
+ "dependencies": {
+ "terminationBehaviour": "terminate-none",
+ "startupOrders": [
+ {
+ "aliases": [
+ "group.group2",
+ "cartridge.c1-1x0"
+ ]
+ }
+ ]
+ },
+ "cartridges": [
+ "c1"
+ ],
+ "groups": [
+ {
+ "name": "G2",
+ "dependencies": {
+ "terminationBehaviour": "terminate-dependents",
+ "startupOrders": [
+ {
+ "aliases": [
+ "group.group3",
+ "cartridge.c2-1x0"
+ ]
+ }
+ ]
+ },
+ "cartridges": [
+ "c2"
+ ],
+ "groups": [
+ {
+ "name": "G3",
+ "dependencies": {
+ "terminationBehaviour": "terminate-all",
+ "startupOrders": []
+ },
+ "cartridges": [
+ "c3"
+ ],
+ "groups": []
+ }
+ ]
+ }
+ ]
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges-groups/cartrdige-nested.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges-groups/cartrdige-nested.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges-groups/cartrdige-nested.json
new file mode 100644
index 0000000..6020e1e
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges-groups/cartrdige-nested.json
@@ -0,0 +1,50 @@
+{
+ "name": "G1",
+ "dependencies": {
+ "terminationBehaviour": "terminate-none",
+ "startupOrders": [
+ {
+ "aliases": [
+ "group.group2",
+ "cartridge.c1-1x0"
+ ]
+ }
+ ]
+ },
+ "cartridges": [
+ "c1"
+ ],
+ "groups": [
+ {
+ "name": "G2",
+ "dependencies": {
+ "terminationBehaviour": "terminate-dependents",
+ "startupOrders": [
+ {
+ "aliases": [
+ "group.group3",
+ "cartridge.c2-1x0"
+ ]
+ }
+ ]
+ },
+ "cartridges": [
+ "c2"
+ ],
+ "groups": [
+ {
+ "name": "G3",
+ "dependencies": {
+ "terminationBehaviour": "terminate-all",
+ "startupOrders": []
+ },
+ "cartridges": [
+ "c3"
+ ],
+ "groups": []
+ }
+ ]
+ }
+ ]
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges/mock/c1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges/mock/c1.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges/mock/c1.json
new file mode 100755
index 0000000..145e2ce
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges/mock/c1.json
@@ -0,0 +1,45 @@
+{
+ "type": "c1",
+ "provider": "apache",
+ "host": "stratos.apache.org",
+ "category": "data",
+ "displayName": "c1",
+ "description": "c1 Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "name": "http-22",
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment": {
+ },
+ "iaasProvider": [
+ {
+ "type": "mock",
+ "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+ "networkInterfaces": [
+ {
+ "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+ }
+ ],
+ "property": [
+ {
+ "name": "instanceType",
+ "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+ },
+ {
+ "name": "keyPair",
+ "value": "vishanth-key"
+ },
+ {
+ "name": "securityGroups",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges/mock/c2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges/mock/c2.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges/mock/c2.json
new file mode 100755
index 0000000..fd85892
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges/mock/c2.json
@@ -0,0 +1,45 @@
+{
+ "type": "c2",
+ "provider": "apache",
+ "host": "stratos.apache.org",
+ "category": "data",
+ "displayName": "c2",
+ "description": "c2 Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "name": "http-22",
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment": {
+ },
+ "iaasProvider": [
+ {
+ "type": "mock",
+ "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+ "networkInterfaces": [
+ {
+ "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+ }
+ ],
+ "property": [
+ {
+ "name": "instanceType",
+ "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+ },
+ {
+ "name": "keyPair",
+ "value": "vishanth-key"
+ },
+ {
+ "name": "securityGroups",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges/mock/c3.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges/mock/c3.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges/mock/c3.json
new file mode 100755
index 0000000..937e8d3
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/cartridges/mock/c3.json
@@ -0,0 +1,45 @@
+{
+ "type": "c3",
+ "provider": "apache",
+ "host": "stratos.apache.org",
+ "category": "data",
+ "displayName": "c3",
+ "description": "c3 Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "name": "http-22",
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment": {
+ },
+ "iaasProvider": [
+ {
+ "type": "mock",
+ "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+ "networkInterfaces": [
+ {
+ "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+ }
+ ],
+ "property": [
+ {
+ "name": "instanceType",
+ "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+ },
+ {
+ "name": "keyPair",
+ "value": "vishanth-key"
+ },
+ {
+ "name": "securityGroups",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/deployment-policies/deployment-policy-1-v1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/deployment-policies/deployment-policy-1-v1.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/deployment-policies/deployment-policy-1-v1.json
new file mode 100644
index 0000000..2ba5eb3
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/deployment-policies/deployment-policy-1-v1.json
@@ -0,0 +1,36 @@
+{
+ "id": "deployment-policy-1",
+ "networkPartitions": [
+ {
+ "id": "network-partition-1",
+ "partitionAlgo": "one-after-another",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "partitionMax": 25
+ },
+ {
+ "id": "partition-2",
+ "partitionMax": 20
+ }
+ ]
+ },
+ {
+ "id": "network-partition-2",
+ "partitionAlgo": "round-robin",
+ "partitions": [
+ {
+ "id": "network-partition-2-partition-1",
+ "partitionMax": 15
+ },
+ {
+ "id": "network-partition-2-partition-2",
+ "partitionMax": 5
+ }
+ ]
+ }
+ ]
+}
+
+
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/deployment-policies/deployment-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/deployment-policies/deployment-policy-1.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/deployment-policies/deployment-policy-1.json
new file mode 100644
index 0000000..e186690
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/deployment-policies/deployment-policy-1.json
@@ -0,0 +1,32 @@
+{
+ "id": "deployment-policy-1",
+ "networkPartitions": [
+ {
+ "id": "network-partition-1",
+ "partitionAlgo": "one-after-another",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "partitionMax": 20
+ }
+ ]
+ },
+ {
+ "id": "network-partition-2",
+ "partitionAlgo": "round-robin",
+ "partitions": [
+ {
+ "id": "network-partition-2-partition-1",
+ "partitionMax": 10
+ },
+ {
+ "id": "network-partition-2-partition-2",
+ "partitionMax": 9
+ }
+ ]
+ }
+ ]
+}
+
+
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/network-partitions/mock/network-partition-1-v1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/network-partitions/mock/network-partition-1-v1.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/network-partitions/mock/network-partition-1-v1.json
new file mode 100644
index 0000000..054265a
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/network-partitions/mock/network-partition-1-v1.json
@@ -0,0 +1,28 @@
+{
+ "id": "network-partition-1",
+ "provider": "mock",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ },
+ {
+ "id": "partition-2",
+ "property": [
+ {
+ "name": "region",
+ "value": "default1"
+ },
+ {
+ "name": "zone",
+ "value": "z1"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/network-partitions/mock/network-partition-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/network-partitions/mock/network-partition-1.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/network-partitions/mock/network-partition-1.json
new file mode 100644
index 0000000..466da28
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/network-partitions/mock/network-partition-1.json
@@ -0,0 +1,15 @@
+{
+ "id": "network-partition-1",
+ "provider": "mock",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/sample-applications-test/network-partitions/mock/network-partition-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/sample-applications-test/network-partitions/mock/network-partition-2.json b/products/stratos/modules/integration/src/test/resources/sample-applications-test/network-partitions/mock/network-partition-2.json
new file mode 100644
index 0000000..23236e2
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/sample-applications-test/network-partitions/mock/network-partition-2.json
@@ -0,0 +1,24 @@
+{
+ "id": "network-partition-2",
+ "provider": "mock",
+ "partitions": [
+ {
+ "id": "network-partition-2-partition-1",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ },
+ {
+ "id": "network-partition-2-partition-2",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/stratos-testing.xml b/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
new file mode 100644
index 0000000..356b5ec
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/stratos-testing.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="StratosIntegrationSuite">
+
+ <test name="CartridgeTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.group.CartridgeTest" />
+ </classes>
+ </test>
+ <test name="CartridgeGroupTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.group.CartridgeGroupTest" />
+ </classes>
+ </test>
+ <test name="NetworkPartitionTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.policies.NetworkPartitionTest" />
+ </classes>
+ </test>
+ <test name="ApplicationPolicyTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.policies.ApplicationPolicyTest" />
+ </classes>
+ </test>
+ <test name="DeploymentPolicyTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.policies.DeploymentPolicyTest" />
+ </classes>
+ </test>
+ <test name="AutoscalingPolicyTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.policies.AutoscalingPolicyTest" />
+ </classes>
+ </test>
+ <test name="SampleApplicationsTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.application.SampleApplicationsTest" />
+ </classes>
+ </test>
+ <test name="ApplicationBurstingTest">
+ <classes>
+ <class name="org.apache.stratos.integration.tests.application.ApplicationBurstingTest" />
+ </classes>
+ </test>
+
+</suite>
[5/6] stratos git commit: Add the updated integration tests
Posted by ga...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/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
new file mode 100644
index 0000000..e861e12
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeTest.java
@@ -0,0 +1,130 @@
+/*
+ * 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.stratos.integration.tests.group;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.PropertyBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeBean;
+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.assertTrue;
+
+/**
+ * Test to handle Cartridge CRUD operations
+ */
+public class CartridgeTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(CartridgeTest.class);
+ private static final String TEST_PATH = "/cartridge-test";
+
+
+ @Test
+ public void testCartridge() {
+ log.info("Started Cartridge test case**************************************");
+
+ try {
+ String cartridgeType = "c0";
+ boolean added = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" +
+ cartridgeType + ".json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(added, true);
+ CartridgeBean bean = (CartridgeBean) restClient.
+ getEntity(RestConstants.CARTRIDGES, cartridgeType,
+ CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
+ assertEquals(bean.getCategory(), "Application");
+ assertEquals(bean.getHost(), "qmog.cisco.com");
+ for (PropertyBean property : bean.getProperty()) {
+ if (property.getName().equals("payload_parameter.CEP_IP")) {
+ assertEquals(property.getValue(), "octl.qmog.cisco.com");
+ } else if (property.getName().equals("payload_parameter.CEP_ADMIN_PASSWORD")) {
+ assertEquals(property.getValue(), "admin");
+ } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_IP")) {
+ assertEquals(property.getValue(), "octl.qmog.cisco.com");
+ } else if (property.getName().equals("payload_parameter.QTCM_NETWORK_COUNT")) {
+ assertEquals(property.getValue(), "1");
+ } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD")) {
+ assertEquals(property.getValue(), "admin");
+ } else if (property.getName().equals("payload_parameter.QTCM_DNS_SEGMENT")) {
+ assertEquals(property.getValue(), "test");
+ } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_SECURE_PORT")) {
+ assertEquals(property.getValue(), "7711");
+ } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_PORT")) {
+ assertEquals(property.getValue(), "7611");
+ } else if (property.getName().equals("payload_parameter.CEP_PORT")) {
+ assertEquals(property.getValue(), "7611");
+ } else if (property.getName().equals("payload_parameter.MB_PORT")) {
+ assertEquals(property.getValue(), "61616");
+ }
+ }
+
+
+ boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" +
+ cartridgeType + "-v1.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(updated, true);
+ CartridgeBean updatedBean = (CartridgeBean) restClient.
+ getEntity(RestConstants.CARTRIDGES, cartridgeType,
+ CartridgeBean.class, RestConstants.CARTRIDGES_NAME);
+ assertEquals(updatedBean.getType(), "c0");
+ assertEquals(updatedBean.getCategory(), "Data");
+ assertEquals(updatedBean.getHost(), "qmog.cisco.com12");
+ for (PropertyBean property : updatedBean.getProperty()) {
+ if (property.getName().equals("payload_parameter.CEP_IP")) {
+ assertEquals(property.getValue(), "octl.qmog.cisco.com123");
+ } else if (property.getName().equals("payload_parameter.CEP_ADMIN_PASSWORD")) {
+ assertEquals(property.getValue(), "admin123");
+ } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_IP")) {
+ assertEquals(property.getValue(), "octl.qmog.cisco.com123");
+ } else if (property.getName().equals("payload_parameter.QTCM_NETWORK_COUNT")) {
+ assertEquals(property.getValue(), "3");
+ } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD")) {
+ assertEquals(property.getValue(), "admin123");
+ } else if (property.getName().equals("payload_parameter.QTCM_DNS_SEGMENT")) {
+ assertEquals(property.getValue(), "test123");
+ } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_SECURE_PORT")) {
+ assertEquals(property.getValue(), "7712");
+ } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_PORT")) {
+ assertEquals(property.getValue(), "7612");
+ } else if (property.getName().equals("payload_parameter.CEP_PORT")) {
+ assertEquals(property.getValue(), "7612");
+ } else if (property.getName().equals("payload_parameter.MB_PORT")) {
+ assertEquals(property.getValue(), "61617");
+ }
+ }
+
+ boolean removed = restClient.removeEntity(RestConstants.CARTRIDGES, cartridgeType,
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removed, true);
+
+ CartridgeBean beanRemoved = (CartridgeBean) restClient.
+ 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);
+ assertTrue("An error occurred while handling RESTConstants.CARTRIDGES_PATH", false);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
new file mode 100644
index 0000000..08ac19f
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.stratos.integration.tests.policies;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.PropertyBean;
+import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+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.assertTrue;
+
+/**
+ * Test to handle Network partition CRUD operations
+ */
+public class ApplicationPolicyTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(ApplicationPolicyTest.class);
+ private static final String TEST_PATH = "/application-policy-test";
+
+
+ @Test
+ public void testApplicationPolicy() {
+ try {
+ String applicationPolicyId = "application-policy-2";
+ log.info("Started Application policy test case**************************************");
+
+ boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-7" + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN1, true);
+
+ boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-8" + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN2, true);
+
+ boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+ applicationPolicyId + ".json",
+ RestConstants.APPLICATION_POLICIES, RestConstants.APPLICATION_POLICIES_NAME);
+ assertEquals(addedDep, true);
+
+ ApplicationPolicyBean bean = (ApplicationPolicyBean) restClient.
+ getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId,
+ ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
+ assertEquals(bean.getId(), applicationPolicyId);
+ assertEquals(String.format("The expected algorithm %s is not found in %s",
+ "one-after-another", applicationPolicyId), bean.getAlgorithm(), "one-after-another");
+ assertEquals(String.format("The expected id %s is not found",
+ applicationPolicyId), bean.getId(), applicationPolicyId);
+ assertEquals(String.format("The expected networkpartitions size %s is not found in %s",
+ 2, applicationPolicyId), bean.getNetworkPartitions().length, 2);
+ assertEquals(String.format("The first network partition is not %s in %s",
+ "network-partition-7", applicationPolicyId), bean.getNetworkPartitions()[0],
+ "network-partition-7");
+ assertEquals(String.format("The Second network partition is not %s in %s",
+ "network-partition-8", applicationPolicyId), bean.getNetworkPartitions()[1],
+ "network-partition-8");
+ /* boolean algoFound = false;
+ for (PropertyBean propertyBean : bean.getProperties()) {
+ if (propertyBean.getName().equals("networkPartitionGroups")) {
+ assertEquals(String.format("The networkPartitionGroups algorithm %s is not found in %s",
+ "network-partition-7,network-partition-8", applicationPolicyId),
+ propertyBean.getValue(), "network-partition-7,network-partition-8");
+ algoFound = true;
+
+ }
+ }
+ if (!algoFound) {
+ assertTrue(String.format("The networkPartitionGroups property is not found in %s",
+ applicationPolicyId), false);
+ } */
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-7", RestConstants.NETWORK_PARTITIONS_NAME);
+ //Trying to remove the used network partition
+ assertEquals(removedNet, false);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+ applicationPolicyId, RestConstants.APPLICATION_POLICIES_NAME);
+ assertEquals(removedDep, true);
+
+ ApplicationPolicyBean beanRemovedDep = (ApplicationPolicyBean) restClient.
+ getEntity(RestConstants.APPLICATION_POLICIES, applicationPolicyId,
+ ApplicationPolicyBean.class, RestConstants.APPLICATION_POLICIES_NAME);
+ assertEquals(beanRemovedDep, null);
+
+ boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-7", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN1, true);
+
+ NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-7",
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(beanRemovedN1, null);
+
+ boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-8", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN2, true);
+
+ NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-8",
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(beanRemovedN2, null);
+
+ log.info("Ended deployment policy test case**************************************");
+
+ } catch (Exception e) {
+ log.error("An error occurred while handling deployment policy", e);
+ assertTrue("An error occurred while handling deployment policy", false);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/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
new file mode 100644
index 0000000..96b8a57
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/AutoscalingPolicyTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.stratos.integration.tests.policies;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
+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.assertTrue;
+
+/**
+ * Test to handle autoscaling policy CRUD operations
+ */
+public class AutoscalingPolicyTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(AutoscalingPolicyTest.class);
+ private static final String TEST_PATH = "/autoscaling-policy-test";
+
+
+ @Test
+ public void testAutoscalingPolicy() {
+ log.info("Started autoscaling policy test case**************************************");
+ String policyId = "autoscaling-policy-c0";
+ try {
+ boolean added = restClient.addEntity(TEST_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), added, true);
+ AutoscalePolicyBean bean = (AutoscalePolicyBean) restClient.
+ 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 = restClient.updateEntity(TEST_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), updated, true);
+ AutoscalePolicyBean updatedBean = (AutoscalePolicyBean) restClient.getEntity(
+ RestConstants.AUTOSCALING_POLICIES, policyId,
+ AutoscalePolicyBean.class, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(String.format("[autoscaling-policy-id] %s RIF is not correct", policyId),
+ updatedBean.getLoadThresholds().getRequestsInFlight().getThreshold(), 30.0, 0.0);
+ assertEquals(String.format("[autoscaling-policy-id] %s Load is not correct", policyId),
+ updatedBean.getLoadThresholds().getMemoryConsumption().getThreshold(), 40.0, 0.0);
+ assertEquals(String.format("[autoscaling-policy-id] %s Memory is not correct", policyId),
+ updatedBean.getLoadThresholds().getLoadAverage().getThreshold(), 20.0, 0.0);
+
+ boolean removed = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+ policyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(String.format("[autoscaling-policy-id] %s couldn't be removed", policyId),
+ removed, true);
+
+ AutoscalePolicyBean beanRemoved = (AutoscalePolicyBean) restClient.getEntity(
+ RestConstants.AUTOSCALING_POLICIES, policyId,
+ AutoscalePolicyBean.class, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(String.format("[autoscaling-policy-id] %s didn't get removed successfully",
+ policyId), beanRemoved, null);
+ log.info("Ended autoscaling policy test case**************************************");
+ } catch (Exception e) {
+ log.error("An error occurred while handling [autoscaling policy] " + policyId, e);
+ assertTrue("An error occurred while handling [autoscaling policy] " + policyId, false);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
new file mode 100644
index 0000000..9d13ca4
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/DeploymentPolicyTest.java
@@ -0,0 +1,157 @@
+/*
+ * 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.stratos.integration.tests.policies;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
+import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
+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.assertTrue;
+
+/**
+ * Test to handle Deployment policy CRUD operations
+ */
+public class DeploymentPolicyTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(DeploymentPolicyTest.class);
+ private static final String TEST_PATH = "/deployment-policy-test";
+
+
+ @Test
+ public void testDeploymentPolicy() {
+ try {
+ String deploymentPolicyId = "deployment-policy-2";
+ log.info("Started deployment policy test case**************************************");
+
+ boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-5" + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN1, true);
+
+ boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-6" + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN2, true);
+
+ boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+ deploymentPolicyId + ".json",
+ RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(addedDep, true);
+
+ DeploymentPolicyBean bean = (DeploymentPolicyBean) restClient.
+ getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
+ DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(bean.getId(), "deployment-policy-2");
+ assertEquals(bean.getNetworkPartitions().size(), 2);
+ assertEquals(bean.getNetworkPartitions().get(0).getId(), "network-partition-5");
+ assertEquals(bean.getNetworkPartitions().get(0).getPartitionAlgo(), "one-after-another");
+ assertEquals(bean.getNetworkPartitions().get(0).getPartitions().size(), 1);
+ assertEquals(bean.getNetworkPartitions().get(0).getPartitions().get(0).getId(), "partition-1");
+ assertEquals(bean.getNetworkPartitions().get(0).getPartitions().get(0).getPartitionMax(), 20);
+
+ assertEquals(bean.getNetworkPartitions().get(1).getId(), "network-partition-6");
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitionAlgo(), "round-robin");
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().size(), 2);
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(0).getId(),
+ "network-partition-6-partition-1");
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(0).getPartitionMax(), 10);
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
+ "network-partition-6-partition-2");
+ assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 9);
+
+ //update network partition
+ boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-5-v1.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(updated, true);
+
+ //update deployment policy with new partition and max values
+ boolean updatedDep = restClient.updateEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH +
+ "/" + deploymentPolicyId + "-v1.json", RestConstants.DEPLOYMENT_POLICIES,
+ RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(updatedDep, true);
+
+ DeploymentPolicyBean updatedBean = (DeploymentPolicyBean) restClient.
+ getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
+ DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(updatedBean.getId(), "deployment-policy-2");
+ assertEquals(updatedBean.getNetworkPartitions().size(), 2);
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getId(), "network-partition-5");
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitionAlgo(), "one-after-another");
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().size(), 2);
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(0).getId(), "partition-1");
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(0).getPartitionMax(), 25);
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(1).getId(), "partition-2");
+ assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(1).getPartitionMax(), 20);
+
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getId(), "network-partition-6");
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitionAlgo(), "round-robin");
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().size(), 2);
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(0).getId(),
+ "network-partition-6-partition-1");
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(0).getPartitionMax(), 15);
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
+ "network-partition-6-partition-2");
+ assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 5);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-5", RestConstants.NETWORK_PARTITIONS_NAME);
+ //Trying to remove the used network partition
+ assertEquals(removedNet, false);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+ deploymentPolicyId, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(removedDep, true);
+
+ DeploymentPolicyBean beanRemovedDep = (DeploymentPolicyBean) restClient.
+ getEntity(RestConstants.DEPLOYMENT_POLICIES, deploymentPolicyId,
+ DeploymentPolicyBean.class, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(beanRemovedDep, null);
+
+ boolean removedN1 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-5", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN1, true);
+
+ NetworkPartitionBean beanRemovedN1 = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-5",
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(beanRemovedN1, null);
+
+ boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-6", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN2, true);
+
+ NetworkPartitionBean beanRemovedN2 = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, "network-partition-6",
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(beanRemovedN2, null);
+
+ log.info("Ended deployment policy test case**************************************");
+
+ } catch (Exception e) {
+ log.error("An error occurred while handling deployment policy", e);
+ assertTrue("An error occurred while handling deployment policy", false);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java
new file mode 100644
index 0000000..5df2313
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/NetworkPartitionTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.stratos.integration.tests.policies;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
+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.assertTrue;
+
+/**
+ * Test to handle Network partition CRUD operations
+ */
+public class NetworkPartitionTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(NetworkPartitionTest.class);
+ private static final String TEST_PATH = "/network-partition-test";
+
+
+ @Test
+ public void testNetworkPartition() {
+ try {
+ String networkPartitionId = "network-partition-3";
+ log.info("Started network partition test case**************************************");
+
+ boolean added = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ networkPartitionId + ".json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+
+ assertEquals(added, true);
+ NetworkPartitionBean bean = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+
+ assertEquals(bean.getId(), "network-partition-3");
+ assertEquals(bean.getPartitions().size(), 1);
+ assertEquals(bean.getPartitions().get(0).getId(), "partition-1");
+ assertEquals(bean.getPartitions().get(0).getProperty().get(0).getName(), "region");
+ assertEquals(bean.getPartitions().get(0).getProperty().get(0).getValue(), "default");
+
+ boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ networkPartitionId + "-v1.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+
+ assertEquals(updated, true);
+ NetworkPartitionBean updatedBean = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(updatedBean.getId(), "network-partition-3");
+ assertEquals(updatedBean.getPartitions().size(), 2);
+ assertEquals(updatedBean.getPartitions().get(1).getId(), "partition-2");
+ assertEquals(updatedBean.getPartitions().get(1).getProperty().get(0).getName(), "region");
+ assertEquals(updatedBean.getPartitions().get(1).getProperty().get(0).getValue(), "default1");
+ assertEquals(updatedBean.getPartitions().get(1).getProperty().get(1).getName(), "zone");
+ assertEquals(updatedBean.getPartitions().get(1).getProperty().get(1).getValue(), "z1");
+
+ boolean removed = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ networkPartitionId, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removed, true);
+
+ NetworkPartitionBean beanRemoved = (NetworkPartitionBean) restClient.
+ getEntity(RestConstants.NETWORK_PARTITIONS, networkPartitionId,
+ NetworkPartitionBean.class, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(beanRemoved, null);
+
+ log.info("Ended network partition test case**************************************");
+ } catch (Exception e) {
+ log.error("An error occurred while handling network partitions", e);
+ assertTrue("An error occurred while handling network partitions", false);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-bursting-test/application-policies/application-policy-3.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-bursting-test/application-policies/application-policy-3.json b/products/stratos/modules/integration/src/test/resources/application-bursting-test/application-policies/application-policy-3.json
new file mode 100644
index 0000000..a461844
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-bursting-test/application-policies/application-policy-3.json
@@ -0,0 +1,18 @@
+{
+ "id": "application-policy-3",
+ "algorithm": "one-after-another",
+ "networkPartitions": [
+ "network-partition-9",
+ "network-partition-10"
+ ],
+ "properties": [
+ {
+ "name": "key-1",
+ "value": "network-partition-9|network-partition-10"
+ },
+ {
+ "name": "key-2",
+ "value": "value-2"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-bursting-test/applications/app-bursting-single-cartriddge-group.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-bursting-test/applications/app-bursting-single-cartriddge-group.json b/products/stratos/modules/integration/src/test/resources/application-bursting-test/applications/app-bursting-single-cartriddge-group.json
new file mode 100644
index 0000000..4e00d60
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-bursting-test/applications/app-bursting-single-cartriddge-group.json
@@ -0,0 +1,70 @@
+{
+ "applicationId": "cartridge-group-app",
+ "alias": "my-cartridge-group-app",
+ "components": {
+ "groups": [
+ {
+ "name": "esb-php-group",
+ "alias": "my-esb-php-group",
+ "deploymentPolicy": "deployment-policy-4",
+ "groupMinInstances": 1,
+ "groupMaxInstances": 2,
+ "cartridges": [
+ {
+ "type": "esb",
+ "cartridgeMin": 1,
+ "cartridgeMax": 2,
+ "subscribableInfo": {
+ "alias": "my-esb",
+ "autoscalingPolicy": "autoscaling-policy-2",
+ "artifactRepository": {
+ "privateRepo": false,
+ "repoUrl": "https://github.com/imesh/stratos-esb-applications.git",
+ "repoUsername": "",
+ "repoPassword": ""
+ }
+ }
+ },
+ {
+ "type": "php",
+ "cartridgeMin": 2,
+ "cartridgeMax": 4,
+ "lvsVirtualIP": "192.168.56.50|255.255.255.0",
+ "subscribableInfo": {
+ "alias": "my-php",
+ "autoscalingPolicy": "autoscaling-policy-2",
+ "artifactRepository": {
+ "privateRepo": false,
+ "repoUrl": "https://github.com/imesh/stratos-php-applications.git",
+ "repoUsername": "",
+ "repoPassword": ""
+ }
+ }
+ }
+ ]
+ }
+ ],
+ "cartridges": [
+ {
+ "type": "tomcat",
+ "cartridgeMin": 2,
+ "cartridgeMax": 4,
+ "subscribableInfo": {
+ "alias": "my-tomcat",
+ "autoscalingPolicy": "autoscaling-policy-2",
+ "deploymentPolicy": "deployment-policy-4",
+ "artifactRepository": {
+ "privateRepo": false,
+ "repoUrl": "https://github.com/imesh/stratos-tomcat-applications.git",
+ "repoUsername": "",
+ "repoPassword": ""
+ }
+ }
+ }
+ ],
+ "dependencies": {
+ "terminationBehaviour": "terminate-none"
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-bursting-test/autoscaling-policies/autoscaling-policy-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-bursting-test/autoscaling-policies/autoscaling-policy-2.json b/products/stratos/modules/integration/src/test/resources/application-bursting-test/autoscaling-policies/autoscaling-policy-2.json
new file mode 100644
index 0000000..944aa82
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-bursting-test/autoscaling-policies/autoscaling-policy-2.json
@@ -0,0 +1,14 @@
+{
+ "id": "autoscaling-policy-2",
+ "loadThresholds": {
+ "requestsInFlight": {
+ "threshold": 35
+ },
+ "memoryConsumption": {
+ "threshold": 45
+ },
+ "loadAverage": {
+ "threshold": 25
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges-groups/esb-php-group.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges-groups/esb-php-group.json b/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges-groups/esb-php-group.json
new file mode 100644
index 0000000..008c735
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges-groups/esb-php-group.json
@@ -0,0 +1,19 @@
+{
+ "name": "esb-php-group",
+ "cartridges": [
+ "esb",
+ "php"
+ ],
+ "dependencies": {
+ "startupOrders": [
+ {
+ "aliases": [
+ "cartridge.my-esb",
+ "cartridge.my-php"
+ ]
+ }
+ ],
+ "terminationBehaviour": "terminate-none"
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges/mock/esb.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges/mock/esb.json b/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges/mock/esb.json
new file mode 100755
index 0000000..571e7e1
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges/mock/esb.json
@@ -0,0 +1,50 @@
+{
+ "type": "esb",
+ "provider": "apache",
+ "host": "stratos.apache.org",
+ "category": "framework",
+ "displayName": "esb",
+ "description": "esb Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "name": "http-22",
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment": {
+ },
+ "iaasProvider": [
+ {
+ "type": "mock",
+ "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+ "networkInterfaces": [
+ {
+ "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+ }
+ ],
+ "property": [
+ {
+ "name": "instanceType",
+ "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+ },
+ {
+ "name": "keyPair",
+ "value": "vishanth-key"
+ },
+ {
+ "name": "securityGroups",
+ "value": "default"
+ }
+ ]
+ }
+ ],
+ "metadataKeys": [
+ "server_ip",
+ "username",
+ "password"
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges/mock/php.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges/mock/php.json b/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges/mock/php.json
new file mode 100755
index 0000000..5d53e3a
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges/mock/php.json
@@ -0,0 +1,51 @@
+{
+ "type": "php",
+ "provider": "apache",
+ "category": "framework",
+ "host": "php.stratos.org",
+ "displayName": "php",
+ "description": "php Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "name": "http-80",
+ "protocol": "http",
+ "port": "8080",
+ "proxyPort": "8280"
+ },
+ {
+ "name": "http-22",
+ "protocol": "tcp",
+ "port": "22",
+ "proxyPort": "8222"
+ }
+ ],
+ "deployment": {
+ },
+ "iaasProvider": [
+ {
+ "type": "mock",
+ "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+ "networkInterfaces": [
+ {
+ "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+ }
+ ],
+ "property": [
+ {
+ "name": "instanceType",
+ "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+ },
+ {
+ "name": "keyPair",
+ "value": "reka"
+ },
+ {
+ "name": "securityGroups",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges/mock/tomcat.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges/mock/tomcat.json b/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges/mock/tomcat.json
new file mode 100755
index 0000000..395687d
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-bursting-test/cartridges/mock/tomcat.json
@@ -0,0 +1,53 @@
+{
+ "type": "tomcat",
+ "provider": "apache",
+ "host": "tomcat.stratos.org",
+ "category": "framework",
+ "displayName": "tomcat",
+ "description": "tomcat Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "name": "http-22",
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ },
+ {
+ "protocol": "http",
+ "port": "8080",
+ "proxyPort": "80"
+ }
+ ],
+ "deployment": {
+ },
+ "iaasProvider": [
+ {
+ "type": "mock",
+ "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+ "networkInterfaces": [
+ {
+ "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+ }
+ ],
+ "property": [
+ {
+ "name": "instanceType",
+ "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+ },
+ {
+ "name": "keyPair",
+ "value": "vishanth-key"
+ },
+ {
+ "name": "securityGroups",
+ "value": "default"
+ }
+ ]
+ }
+ ],
+ "metadataKeys": [
+ "url"
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-bursting-test/deployment-policies/deployment-policy-4.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-bursting-test/deployment-policies/deployment-policy-4.json b/products/stratos/modules/integration/src/test/resources/application-bursting-test/deployment-policies/deployment-policy-4.json
new file mode 100644
index 0000000..f9935d7
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-bursting-test/deployment-policies/deployment-policy-4.json
@@ -0,0 +1,32 @@
+{
+ "id": "deployment-policy-4",
+ "networkPartitions": [
+ {
+ "id": "network-partition-9",
+ "partitionAlgo": "one-after-another",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "partitionMax": 4
+ }
+ ]
+ },
+ {
+ "id": "network-partition-10",
+ "partitionAlgo": "round-robin",
+ "partitions": [
+ {
+ "id": "network-partition-10-partition-1",
+ "partitionMax": 4
+ },
+ {
+ "id": "network-partition-10-partition-2",
+ "partitionMax": 4
+ }
+ ]
+ }
+ ]
+}
+
+
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-bursting-test/network-partitions/mock/network-partition-10.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-bursting-test/network-partitions/mock/network-partition-10.json b/products/stratos/modules/integration/src/test/resources/application-bursting-test/network-partitions/mock/network-partition-10.json
new file mode 100644
index 0000000..1e1ec23
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-bursting-test/network-partitions/mock/network-partition-10.json
@@ -0,0 +1,24 @@
+{
+ "id": "network-partition-10",
+ "provider": "mock",
+ "partitions": [
+ {
+ "id": "network-partition-10-partition-1",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ },
+ {
+ "id": "network-partition-10-partition-2",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-bursting-test/network-partitions/mock/network-partition-9.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-bursting-test/network-partitions/mock/network-partition-9.json b/products/stratos/modules/integration/src/test/resources/application-bursting-test/network-partitions/mock/network-partition-9.json
new file mode 100644
index 0000000..9f12343
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-bursting-test/network-partitions/mock/network-partition-9.json
@@ -0,0 +1,15 @@
+{
+ "id": "network-partition-9",
+ "provider": "mock",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-2.json b/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-2.json
new file mode 100644
index 0000000..82e85a0
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-2.json
@@ -0,0 +1,18 @@
+{
+ "id": "application-policy-2",
+ "algorithm": "one-after-another",
+ "networkPartitions": [
+ "network-partition-7",
+ "network-partition-8"
+ ],
+ "properties": [
+ {
+ "name": "key-1",
+ "value": "network-partition-7,network-partition-8"
+ },
+ {
+ "name": "key-2",
+ "value": "value-2"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-policy-test/network-partitions/mock/network-partition-7.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-policy-test/network-partitions/mock/network-partition-7.json b/products/stratos/modules/integration/src/test/resources/application-policy-test/network-partitions/mock/network-partition-7.json
new file mode 100644
index 0000000..6250504
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-policy-test/network-partitions/mock/network-partition-7.json
@@ -0,0 +1,15 @@
+{
+ "id": "network-partition-7",
+ "provider": "mock",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/application-policy-test/network-partitions/mock/network-partition-8.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-policy-test/network-partitions/mock/network-partition-8.json b/products/stratos/modules/integration/src/test/resources/application-policy-test/network-partitions/mock/network-partition-8.json
new file mode 100644
index 0000000..354b837
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/application-policy-test/network-partitions/mock/network-partition-8.json
@@ -0,0 +1,24 @@
+{
+ "id": "network-partition-8",
+ "provider": "mock",
+ "partitions": [
+ {
+ "id": "network-partition-8-partition-1",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ },
+ {
+ "id": "network-partition-8-partition-2",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-c0-v1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-c0-v1.json b/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-c0-v1.json
new file mode 100644
index 0000000..31c2b84
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-c0-v1.json
@@ -0,0 +1,14 @@
+{
+ "id": "autoscaling-policy-c0",
+ "loadThresholds": {
+ "requestsInFlight": {
+ "threshold": 30
+ },
+ "memoryConsumption": {
+ "threshold": 40
+ },
+ "loadAverage": {
+ "threshold": 20
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-c0.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-c0.json b/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-c0.json
new file mode 100644
index 0000000..4bcef26
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/autoscaling-policy-test/autoscaling-policies/autoscaling-policy-c0.json
@@ -0,0 +1,14 @@
+{
+ "id": "autoscaling-policy-c0",
+ "loadThresholds": {
+ "requestsInFlight": {
+ "threshold": 35
+ },
+ "memoryConsumption": {
+ "threshold": 45
+ },
+ "loadAverage": {
+ "threshold": 25
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/g4-g5-g6-v1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/g4-g5-g6-v1.json b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/g4-g5-g6-v1.json
new file mode 100644
index 0000000..c0132f0
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/g4-g5-g6-v1.json
@@ -0,0 +1,50 @@
+{
+ "name": "G4",
+ "dependencies": {
+ "terminationBehaviour": "terminate-none",
+ "startupOrders": [
+ {
+ "aliases": [
+ "group.group2",
+ "cartridge.c1-1x0"
+ ]
+ }
+ ]
+ },
+ "cartridges": [
+ "c4"
+ ],
+ "groups": [
+ {
+ "name": "G5",
+ "dependencies": {
+ "terminationBehaviour": "terminate-dependents",
+ "startupOrders": [
+ {
+ "aliases": [
+ "group.group6",
+ "cartridge.c5-1x0"
+ ]
+ }
+ ]
+ },
+ "cartridges": [
+ "c5"
+ ],
+ "groups": [
+ {
+ "name": "G6",
+ "dependencies": {
+ "terminationBehaviour": "terminate-all",
+ "startupOrders": []
+ },
+ "cartridges": [
+ "c6"
+ ],
+ "groups": []
+ }
+ ]
+ }
+ ]
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/g4-g5-g6.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/g4-g5-g6.json b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/g4-g5-g6.json
new file mode 100644
index 0000000..ef28723
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges-groups/g4-g5-g6.json
@@ -0,0 +1,50 @@
+{
+ "name": "G4",
+ "dependencies": {
+ "terminationBehaviour": "terminate-none",
+ "startupOrders": [
+ {
+ "aliases": [
+ "group.group5",
+ "cartridge.c4-1x0"
+ ]
+ }
+ ]
+ },
+ "cartridges": [
+ "c4"
+ ],
+ "groups": [
+ {
+ "name": "G5",
+ "dependencies": {
+ "terminationBehaviour": "terminate-dependents",
+ "startupOrders": [
+ {
+ "aliases": [
+ "group.group6",
+ "cartridge.c5-1x0"
+ ]
+ }
+ ]
+ },
+ "cartridges": [
+ "c5"
+ ],
+ "groups": [
+ {
+ "name": "G6",
+ "dependencies": {
+ "terminationBehaviour": "terminate-all",
+ "startupOrders": []
+ },
+ "cartridges": [
+ "c6"
+ ],
+ "groups": []
+ }
+ ]
+ }
+ ]
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges/mock/c4.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges/mock/c4.json b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges/mock/c4.json
new file mode 100755
index 0000000..ec7d8b2
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges/mock/c4.json
@@ -0,0 +1,45 @@
+{
+ "type": "c4",
+ "provider": "apache",
+ "host": "stratos.apache.org",
+ "category": "data",
+ "displayName": "c4",
+ "description": "c4 Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "name": "http-22",
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment": {
+ },
+ "iaasProvider": [
+ {
+ "type": "mock",
+ "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+ "networkInterfaces": [
+ {
+ "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+ }
+ ],
+ "property": [
+ {
+ "name": "instanceType",
+ "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+ },
+ {
+ "name": "keyPair",
+ "value": "vishanth-key"
+ },
+ {
+ "name": "securityGroups",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges/mock/c5.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges/mock/c5.json b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges/mock/c5.json
new file mode 100755
index 0000000..0e438fd
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges/mock/c5.json
@@ -0,0 +1,124 @@
+{
+ "category": "Application",
+ "description": "c5 Cartridge",
+ "displayName": "c5",
+ "host": "qmog.cisco.com",
+ "iaasProvider": [
+ {
+ "imageId": "RegionOne/16e7e35b-0c88-4605-90ce-cbef9e9dde0f",
+ "maxInstanceLimit": "4",
+ "networkInterfaces": [
+ {
+ "floatingNetworks": [
+ {
+ "name": "public",
+ "networkUuid": "26b4aa2b-06bc-4e4f-a6eb-c19fbc211af6"
+ }
+ ],
+ "name": "core",
+ "networkUuid": "5e107fbd-4820-47ad-84ea-6f135496f889"
+ }
+ ],
+ "property": [
+ {
+ "name": "instanceType",
+ "value": "RegionOne/2cdbd576-8c9b-4c2d-8b1a-0f79dc4fb809"
+ },
+ {
+ "name": "keyPair",
+ "value": "phoenix"
+ },
+ {
+ "name": "autoAssignIp",
+ "value": "false"
+ },
+ {
+ "name": "securityGroups",
+ "value": "default"
+ }
+ ],
+ "type": "mock"
+ }
+ ],
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "port": "22",
+ "protocol": "http",
+ "proxyPort": "8280"
+ }
+ ],
+ "property": [
+ {
+ "name": "payload_parameter.MB_IP",
+ "value": "octl.qmog.cisco.com"
+ },
+ {
+ "name": "payload_parameter.MB_PORT",
+ "value": "61616"
+ },
+ {
+ "name": "payload_parameter.CEP_IP",
+ "value": "octl.qmog.cisco.com"
+ },
+ {
+ "name": "payload_parameter.CEP_PORT",
+ "value": "7611"
+ },
+ {
+ "name": "payload_parameter.CEP_ADMIN_USERNAME",
+ "value": "admin"
+ },
+ {
+ "name": "payload_parameter.CEP_ADMIN_PASSWORD",
+ "value": "admin"
+ },
+ {
+ "name": "payload_parameter.CERT_TRUSTSTORE",
+ "value": "/opt/apache-stratos-cartridge-agent/security/client-truststore.jks"
+ },
+ {
+ "name": "payload_parameter.TRUSTSTORE_PASSWORD",
+ "value": "wso2carbon"
+ },
+ {
+ "name": "payload_parameter.ENABLE_DATA_PUBLISHER",
+ "value": "false"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_IP",
+ "value": "octl.qmog.cisco.com"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_PORT",
+ "value": "7611"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_SECURE_PORT",
+ "value": "7711"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_ADMIN_USERNAME",
+ "value": "admin"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD",
+ "value": "admin"
+ },
+ {
+ "name": "payload_parameter.QTCM_DNS_SEGMENT",
+ "value": "test"
+ },
+ {
+ "name": "payload_parameter.QTCM_NETWORK_COUNT",
+ "value": "1"
+ },
+ {
+ "name": "payload_parameter.SIMPLE_PROPERTY",
+ "value": "value"
+ }
+ ],
+ "provider": "cisco",
+ "type": "c5",
+ "version": "1.0"
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges/mock/c6.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges/mock/c6.json b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges/mock/c6.json
new file mode 100755
index 0000000..8f41441
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridge-group-test/cartridges/mock/c6.json
@@ -0,0 +1,45 @@
+{
+ "type": "c6",
+ "provider": "apache",
+ "host": "stratos.apache.org",
+ "category": "data",
+ "displayName": "c6",
+ "description": "c6 Cartridge",
+ "version": "7",
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "name": "http-22",
+ "protocol": "http",
+ "port": "22",
+ "proxyPort": "8280"
+ }
+ ],
+ "deployment": {
+ },
+ "iaasProvider": [
+ {
+ "type": "mock",
+ "imageId": "RegionOne/b4ca55e3-58ab-4937-82ce-817ebd10240e",
+ "networkInterfaces": [
+ {
+ "networkUuid": "b55f009a-1cc6-4b17-924f-4ae0ee18db5e"
+ }
+ ],
+ "property": [
+ {
+ "name": "instanceType",
+ "value": "RegionOne/aa5f45a2-c6d6-419d-917a-9dd2e3888594"
+ },
+ {
+ "name": "keyPair",
+ "value": "vishanth-key"
+ },
+ {
+ "name": "securityGroups",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c0-v1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c0-v1.json b/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c0-v1.json
new file mode 100755
index 0000000..6d922a9
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c0-v1.json
@@ -0,0 +1,124 @@
+{
+ "category": "Data",
+ "description": "c0 Cartridge",
+ "displayName": "c0",
+ "host": "qmog.cisco.com12",
+ "iaasProvider": [
+ {
+ "imageId": "RegionOne/16e7e35b-0c88-4605-90ce-cbef9e9d123",
+ "maxInstanceLimit": "4",
+ "networkInterfaces": [
+ {
+ "floatingNetworks": [
+ {
+ "name": "private",
+ "networkUuid": "26b4aa2b-06bc-4e4f-a6eb-c19fbc2112121"
+ }
+ ],
+ "name": "core1",
+ "networkUuid": "5e107fbd-4820-47ad-84ea-6f1354961212"
+ }
+ ],
+ "property": [
+ {
+ "name": "instanceType",
+ "value": "RegionOne/2cdbd576-8c9b-4c2d-8b1a-0f79dc4fb812"
+ },
+ {
+ "name": "keyPair",
+ "value": "phoenix12"
+ },
+ {
+ "name": "autoAssignIp",
+ "value": "true"
+ },
+ {
+ "name": "securityGroups",
+ "value": "default123"
+ }
+ ],
+ "type": "mock"
+ }
+ ],
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "port": "22",
+ "protocol": "http",
+ "proxyPort": "8280"
+ }
+ ],
+ "property": [
+ {
+ "name": "payload_parameter.MB_IP",
+ "value": "octl.qmog.cisco.com123"
+ },
+ {
+ "name": "payload_parameter.MB_PORT",
+ "value": "61617"
+ },
+ {
+ "name": "payload_parameter.CEP_IP",
+ "value": "octl.qmog.cisco.com123"
+ },
+ {
+ "name": "payload_parameter.CEP_PORT",
+ "value": "7612"
+ },
+ {
+ "name": "payload_parameter.CEP_ADMIN_USERNAME",
+ "value": "admin"
+ },
+ {
+ "name": "payload_parameter.CEP_ADMIN_PASSWORD",
+ "value": "admin123"
+ },
+ {
+ "name": "payload_parameter.CERT_TRUSTSTORE",
+ "value": "/opt/apache-stratos-cartridge-agent/security/client-truststore.jks"
+ },
+ {
+ "name": "payload_parameter.TRUSTSTORE_PASSWORD",
+ "value": "wso2carbon"
+ },
+ {
+ "name": "payload_parameter.ENABLE_DATA_PUBLISHER",
+ "value": "false"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_IP",
+ "value": "octl.qmog.cisco.com123"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_PORT",
+ "value": "7612"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_SECURE_PORT",
+ "value": "7712"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_ADMIN_USERNAME",
+ "value": "admin"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD",
+ "value": "admin123"
+ },
+ {
+ "name": "payload_parameter.QTCM_DNS_SEGMENT",
+ "value": "test123"
+ },
+ {
+ "name": "payload_parameter.QTCM_NETWORK_COUNT",
+ "value": "3"
+ },
+ {
+ "name": "payload_parameter.SIMPLE_PROPERTY",
+ "value": "value"
+ }
+ ],
+ "provider": "apache",
+ "type": "c0",
+ "version": "1.0"
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c0.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c0.json b/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c0.json
new file mode 100755
index 0000000..44066e1
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/cartridge-test/cartridges/mock/c0.json
@@ -0,0 +1,124 @@
+{
+ "category": "Application",
+ "description": "c0 Cartridge",
+ "displayName": "c0",
+ "host": "qmog.cisco.com",
+ "iaasProvider": [
+ {
+ "imageId": "RegionOne/16e7e35b-0c88-4605-90ce-cbef9e9dde0f",
+ "maxInstanceLimit": "4",
+ "networkInterfaces": [
+ {
+ "floatingNetworks": [
+ {
+ "name": "public",
+ "networkUuid": "26b4aa2b-06bc-4e4f-a6eb-c19fbc211af6"
+ }
+ ],
+ "name": "core",
+ "networkUuid": "5e107fbd-4820-47ad-84ea-6f135496f889"
+ }
+ ],
+ "property": [
+ {
+ "name": "instanceType",
+ "value": "RegionOne/2cdbd576-8c9b-4c2d-8b1a-0f79dc4fb809"
+ },
+ {
+ "name": "keyPair",
+ "value": "phoenix"
+ },
+ {
+ "name": "autoAssignIp",
+ "value": "false"
+ },
+ {
+ "name": "securityGroups",
+ "value": "default"
+ }
+ ],
+ "type": "mock"
+ }
+ ],
+ "multiTenant": "false",
+ "portMapping": [
+ {
+ "port": "22",
+ "protocol": "http",
+ "proxyPort": "8280"
+ }
+ ],
+ "property": [
+ {
+ "name": "payload_parameter.MB_IP",
+ "value": "octl.qmog.cisco.com"
+ },
+ {
+ "name": "payload_parameter.MB_PORT",
+ "value": "61616"
+ },
+ {
+ "name": "payload_parameter.CEP_IP",
+ "value": "octl.qmog.cisco.com"
+ },
+ {
+ "name": "payload_parameter.CEP_PORT",
+ "value": "7611"
+ },
+ {
+ "name": "payload_parameter.CEP_ADMIN_USERNAME",
+ "value": "admin"
+ },
+ {
+ "name": "payload_parameter.CEP_ADMIN_PASSWORD",
+ "value": "admin"
+ },
+ {
+ "name": "payload_parameter.CERT_TRUSTSTORE",
+ "value": "/opt/apache-stratos-cartridge-agent/security/client-truststore.jks"
+ },
+ {
+ "name": "payload_parameter.TRUSTSTORE_PASSWORD",
+ "value": "wso2carbon"
+ },
+ {
+ "name": "payload_parameter.ENABLE_DATA_PUBLISHER",
+ "value": "false"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_IP",
+ "value": "octl.qmog.cisco.com"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_PORT",
+ "value": "7611"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_SECURE_PORT",
+ "value": "7711"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_ADMIN_USERNAME",
+ "value": "admin"
+ },
+ {
+ "name": "payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD",
+ "value": "admin"
+ },
+ {
+ "name": "payload_parameter.QTCM_DNS_SEGMENT",
+ "value": "test"
+ },
+ {
+ "name": "payload_parameter.QTCM_NETWORK_COUNT",
+ "value": "1"
+ },
+ {
+ "name": "payload_parameter.SIMPLE_PROPERTY",
+ "value": "value"
+ }
+ ],
+ "provider": "cisco",
+ "type": "c0",
+ "version": "1.0"
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-2-v1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-2-v1.json b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-2-v1.json
new file mode 100644
index 0000000..b5c305c
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-2-v1.json
@@ -0,0 +1,36 @@
+{
+ "id": "deployment-policy-2",
+ "networkPartitions": [
+ {
+ "id": "network-partition-5",
+ "partitionAlgo": "one-after-another",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "partitionMax": 25
+ },
+ {
+ "id": "partition-2",
+ "partitionMax": 20
+ }
+ ]
+ },
+ {
+ "id": "network-partition-6",
+ "partitionAlgo": "round-robin",
+ "partitions": [
+ {
+ "id": "network-partition-6-partition-1",
+ "partitionMax": 15
+ },
+ {
+ "id": "network-partition-6-partition-2",
+ "partitionMax": 5
+ }
+ ]
+ }
+ ]
+}
+
+
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-2.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-2.json b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-2.json
new file mode 100644
index 0000000..5df3e24
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/deployment-policies/deployment-policy-2.json
@@ -0,0 +1,32 @@
+{
+ "id": "deployment-policy-2",
+ "networkPartitions": [
+ {
+ "id": "network-partition-5",
+ "partitionAlgo": "one-after-another",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "partitionMax": 20
+ }
+ ]
+ },
+ {
+ "id": "network-partition-6",
+ "partitionAlgo": "round-robin",
+ "partitions": [
+ {
+ "id": "network-partition-6-partition-1",
+ "partitionMax": 10
+ },
+ {
+ "id": "network-partition-6-partition-2",
+ "partitionMax": 9
+ }
+ ]
+ }
+ ]
+}
+
+
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/deployment-policy-test/network-partitions/mock/network-partition-5-v1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/deployment-policy-test/network-partitions/mock/network-partition-5-v1.json b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/network-partitions/mock/network-partition-5-v1.json
new file mode 100644
index 0000000..275b536
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/network-partitions/mock/network-partition-5-v1.json
@@ -0,0 +1,28 @@
+{
+ "id": "network-partition-5",
+ "provider": "mock",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ },
+ {
+ "id": "partition-2",
+ "property": [
+ {
+ "name": "region",
+ "value": "default1"
+ },
+ {
+ "name": "zone",
+ "value": "z1"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/deployment-policy-test/network-partitions/mock/network-partition-5.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/deployment-policy-test/network-partitions/mock/network-partition-5.json b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/network-partitions/mock/network-partition-5.json
new file mode 100644
index 0000000..5464aa9
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/network-partitions/mock/network-partition-5.json
@@ -0,0 +1,15 @@
+{
+ "id": "network-partition-5",
+ "provider": "mock",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/deployment-policy-test/network-partitions/mock/network-partition-6.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/deployment-policy-test/network-partitions/mock/network-partition-6.json b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/network-partitions/mock/network-partition-6.json
new file mode 100644
index 0000000..d200b70
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/deployment-policy-test/network-partitions/mock/network-partition-6.json
@@ -0,0 +1,24 @@
+{
+ "id": "network-partition-6",
+ "provider": "mock",
+ "partitions": [
+ {
+ "id": "network-partition-6-partition-1",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ },
+ {
+ "id": "network-partition-6-partition-2",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-3-v1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-3-v1.json b/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-3-v1.json
new file mode 100644
index 0000000..c7d4733
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/resources/network-partition-test/network-partitions/mock/network-partition-3-v1.json
@@ -0,0 +1,28 @@
+{
+ "id": "network-partition-3",
+ "provider": "mock",
+ "partitions": [
+ {
+ "id": "partition-1",
+ "property": [
+ {
+ "name": "region",
+ "value": "default"
+ }
+ ]
+ },
+ {
+ "id": "partition-2",
+ "property": [
+ {
+ "name": "region",
+ "value": "default1"
+ },
+ {
+ "name": "zone",
+ "value": "z1"
+ }
+ ]
+ }
+ ]
+}
[6/6] stratos git commit: Add the updated integration tests
Posted by ga...@apache.org.
Add the updated integration tests
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/366babaf
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/366babaf
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/366babaf
Branch: refs/heads/tenant-isolation
Commit: 366babaf271b9b3dadd15b39bc55510ef3ca2dee
Parents: 4b96ba0
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Mon Aug 10 16:17:32 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Mon Aug 10 16:17:32 2015 +0530
----------------------------------------------------------------------
.../integration/tests/TopologyHandler.java | 393 +++++++++++++++++
.../application/ApplicationBurstingTest.java | 226 ++++++++++
.../application/SampleApplicationsTest.java | 427 +++++++++++++++++++
.../application/SingleClusterScalingTest.java | 233 ++++++++++
.../tests/config/ApplicationBean.java | 25 ++
.../tests/config/ApplicationConfigParser.java | 25 ++
.../tests/group/CartridgeGroupTest.java | 129 ++++++
.../integration/tests/group/CartridgeTest.java | 130 ++++++
.../tests/policies/ApplicationPolicyTest.java | 133 ++++++
.../tests/policies/AutoscalingPolicyTest.java | 91 ++++
.../tests/policies/DeploymentPolicyTest.java | 157 +++++++
.../tests/policies/NetworkPartitionTest.java | 92 ++++
.../application-policy-3.json | 18 +
.../app-bursting-single-cartriddge-group.json | 70 +++
.../autoscaling-policy-2.json | 14 +
.../cartridges-groups/esb-php-group.json | 19 +
.../cartridges/mock/esb.json | 50 +++
.../cartridges/mock/php.json | 51 +++
.../cartridges/mock/tomcat.json | 53 +++
.../deployment-policy-4.json | 32 ++
.../mock/network-partition-10.json | 24 ++
.../mock/network-partition-9.json | 15 +
.../application-policy-2.json | 18 +
.../mock/network-partition-7.json | 15 +
.../mock/network-partition-8.json | 24 ++
.../autoscaling-policy-c0-v1.json | 14 +
.../autoscaling-policy-c0.json | 14 +
.../cartridges-groups/g4-g5-g6-v1.json | 50 +++
.../cartridges-groups/g4-g5-g6.json | 50 +++
.../cartridges/mock/c4.json | 45 ++
.../cartridges/mock/c5.json | 124 ++++++
.../cartridges/mock/c6.json | 45 ++
.../cartridge-test/cartridges/mock/c0-v1.json | 124 ++++++
.../cartridge-test/cartridges/mock/c0.json | 124 ++++++
.../deployment-policy-2-v1.json | 36 ++
.../deployment-policy-2.json | 32 ++
.../mock/network-partition-5-v1.json | 28 ++
.../mock/network-partition-5.json | 15 +
.../mock/network-partition-6.json | 24 ++
.../mock/network-partition-3-v1.json | 28 ++
.../mock/network-partition-3.json | 15 +
.../application-policy-1.json | 18 +
.../applications/g-sc-G123-1-v1.json | 86 ++++
.../applications/g-sc-G123-1-v2.json | 86 ++++
.../applications/g-sc-G123-1-v3.json | 86 ++++
.../applications/g-sc-G123-1.json | 86 ++++
.../autoscaling-policy-1.json | 14 +
.../cartridges-groups/cartrdige-nested-v1.json | 50 +++
.../cartridges-groups/cartrdige-nested.json | 50 +++
.../cartridges/mock/c1.json | 45 ++
.../cartridges/mock/c2.json | 45 ++
.../cartridges/mock/c3.json | 45 ++
.../deployment-policy-1-v1.json | 36 ++
.../deployment-policy-1.json | 32 ++
.../mock/network-partition-1-v1.json | 28 ++
.../mock/network-partition-1.json | 15 +
.../mock/network-partition-2.json | 24 ++
.../src/test/resources/stratos-testing.xml | 66 +++
58 files changed, 4044 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
new file mode 100644
index 0000000..2ff1cc5
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/TopologyHandler.java
@@ -0,0 +1,393 @@
+/*
+ * 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.stratos.integration.tests;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext;
+import org.apache.stratos.common.client.AutoscalerServiceClient;
+import org.apache.stratos.common.threading.StratosThreadPool;
+import org.apache.stratos.messaging.domain.application.*;
+import org.apache.stratos.messaging.domain.instance.ClusterInstance;
+import org.apache.stratos.messaging.domain.instance.GroupInstance;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.Member;
+import org.apache.stratos.messaging.domain.topology.MemberStatus;
+import org.apache.stratos.messaging.domain.topology.Service;
+import org.apache.stratos.messaging.listener.topology.MemberInitializedEventListener;
+import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
+import org.apache.stratos.messaging.message.receiver.application.ApplicationsEventReceiver;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+
+import java.io.File;
+import java.rmi.RemoteException;
+import java.util.Collection;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+
+/**
+ * To start the Topology receivers
+ */
+public class TopologyHandler {
+ private static final Log log = LogFactory.getLog(TopologyHandler.class);
+
+ public static final int APPLICATION_ACTIVATION_TIMEOUT = 120000;
+ public static final int APPLICATION_TOPOLOGY_TIMEOUT = 60000;
+ public static final String APPLICATION_STATUS_CREATED = "Created";
+ public static final String APPLICATION_STATUS_UNDEPLOYING = "Undeploying";
+ private ApplicationsEventReceiver applicationsEventReceiver;
+ private TopologyEventReceiver topologyEventReceiver;
+ public static TopologyHandler topologyHandler;
+
+ private TopologyHandler() {
+ // Set jndi.properties.dir system property for initializing event receivers
+ System.setProperty("jndi.properties.dir", getResourcesFolderPath());
+ System.setProperty("autoscaler.service.url", "https://localhost:9443/services/AutoscalerService");
+ initializeApplicationEventReceiver();
+ initializeTopologyEventReceiver();
+ assertApplicationTopologyInitialized();
+ assertTopologyInitialized();
+ }
+
+ public static TopologyHandler getInstance() {
+ if (topologyHandler == null) {
+ synchronized (TopologyHandler.class) {
+ if (topologyHandler == null) {
+ topologyHandler = new TopologyHandler();
+ }
+ }
+ }
+ return topologyHandler;
+ }
+
+
+ /**
+ * Initialize application event receiver
+ */
+ private void initializeApplicationEventReceiver() {
+ if (applicationsEventReceiver == null) {
+ applicationsEventReceiver = new ApplicationsEventReceiver();
+ ExecutorService executorService = StratosThreadPool.getExecutorService("STRATOS_TEST_SERVER", 1);
+ applicationsEventReceiver.setExecutorService(executorService);
+ applicationsEventReceiver.execute();
+ }
+ }
+
+ /**
+ * Initialize Topology event receiver
+ */
+ private void initializeTopologyEventReceiver() {
+ if (topologyEventReceiver == null) {
+ topologyEventReceiver = new TopologyEventReceiver();
+ ExecutorService executorService = StratosThreadPool.getExecutorService("STRATOS_TEST_SERVER1", 1);
+ topologyEventReceiver.setExecutorService(executorService);
+ topologyEventReceiver.execute();
+ }
+ }
+
+ /**
+ * Assert application Topology initialization
+ */
+ private void assertApplicationTopologyInitialized() {
+ long startTime = System.currentTimeMillis();
+ boolean applicationTopologyInitialized = ApplicationManager.getApplications().isInitialized();
+ while (!applicationTopologyInitialized) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignore) {
+ }
+ applicationTopologyInitialized = ApplicationManager.getApplications().isInitialized();
+ if ((System.currentTimeMillis() - startTime) > APPLICATION_TOPOLOGY_TIMEOUT) {
+ break;
+ }
+ }
+ assertEquals(String.format("Application Topology didn't get initialized "), applicationTopologyInitialized, true);
+ }
+
+ /**
+ * Assert Topology initialization
+ */
+ private void assertTopologyInitialized() {
+ long startTime = System.currentTimeMillis();
+ boolean topologyInitialized = TopologyManager.getTopology().isInitialized();
+ while (!topologyInitialized) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignore) {
+ }
+ topologyInitialized = TopologyManager.getTopology().isInitialized();
+ if ((System.currentTimeMillis() - startTime) > APPLICATION_TOPOLOGY_TIMEOUT) {
+ break;
+ }
+ }
+ assertEquals(String.format("Topology didn't get initialized "), topologyInitialized, true);
+ }
+
+ /**
+ * Assert application activation
+ *
+ * @param applicationName
+ */
+ public void assertApplicationActivation(String applicationName) {
+ long startTime = System.currentTimeMillis();
+ Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
+ while (!((application != null) && (application.getStatus() == ApplicationStatus.Active))) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignore) {
+ }
+ application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
+ if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+ break;
+ }
+ }
+ assertNotNull(String.format("Application is not found: [application-id] %s", applicationName), application);
+ assertEquals(String.format("Application status did not change to active: [application-id] %s", applicationName),
+ ApplicationStatus.Active, application.getStatus());
+ }
+
+ /**
+ * Assert application activation
+ *
+ * @param applicationName
+ */
+ public void assertGroupActivation(String applicationName) {
+ Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
+ assertNotNull(String.format("Application is not found: [application-id] %s",
+ applicationName), application);
+
+ Collection<Group> groups = application.getAllGroupsRecursively();
+ for (Group group : groups) {
+ assertEquals(group.getInstanceContextCount() >= group.getGroupMinInstances(), true);
+ }
+ }
+
+ /**
+ * Assert application activation
+ *
+ * @param applicationName
+ */
+ public void assertClusterActivation(String applicationName) {
+ Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
+ assertNotNull(String.format("Application is not found: [application-id] %s",
+ applicationName), application);
+
+ Set<ClusterDataHolder> clusterDataHolderSet = application.getClusterDataRecursively();
+ for (ClusterDataHolder clusterDataHolder : clusterDataHolderSet) {
+ String serviceUuid = clusterDataHolder.getServiceUuid();
+ String clusterId = clusterDataHolder.getClusterId();
+ Service service = TopologyManager.getTopology().getService(serviceUuid);
+ assertNotNull(String.format("Service is not found: [application-id] %s [service] %s",
+ applicationName, serviceUuid), service);
+
+ Cluster cluster = service.getCluster(clusterId);
+ assertNotNull(String.format("Cluster is not found: [application-id] %s [service] %s [cluster-id] %s",
+ applicationName, serviceUuid, clusterId), cluster);
+ boolean clusterActive = false;
+
+ for (ClusterInstance instance : cluster.getInstanceIdToInstanceContextMap().values()) {
+ int activeInstances = 0;
+ for (Member member : cluster.getMembers()) {
+ if (member.getClusterInstanceId().equals(instance.getInstanceId())) {
+ if (member.getStatus().equals(MemberStatus.Active)) {
+ activeInstances++;
+ }
+ }
+ }
+ clusterActive = activeInstances >= clusterDataHolder.getMinInstances();
+
+ if (!clusterActive) {
+ break;
+ }
+ }
+ assertEquals(String.format("Cluster status did not change to active: [cluster-id] %s", clusterId),
+ clusterActive, true);
+ }
+
+ }
+
+ public void assertClusterMinMemberCount(String applicationName, int minMembers) {
+ long startTime = System.currentTimeMillis();
+
+ Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
+ assertNotNull(String.format("Application is not found: [application-id] %s",
+ applicationName), application);
+
+ Set<ClusterDataHolder> clusterDataHolderSet = application.getClusterDataRecursively();
+ for (ClusterDataHolder clusterDataHolder : clusterDataHolderSet) {
+ String serviceName = clusterDataHolder.getServiceUuid();
+ String clusterId = clusterDataHolder.getClusterId();
+ Service service = TopologyManager.getTopology().getService(serviceName);
+ assertNotNull(String.format("Service is not found: [application-id] %s [service] %s",
+ applicationName, serviceName), service);
+
+ Cluster cluster = service.getCluster(clusterId);
+ assertNotNull(String.format("Cluster is not found: [application-id] %s [service] %s [cluster-id] %s",
+ applicationName, serviceName, clusterId), cluster);
+ boolean clusterActive = false;
+
+ for (ClusterInstance instance : cluster.getInstanceIdToInstanceContextMap().values()) {
+ int activeInstances = 0;
+ for (Member member : cluster.getMembers()) {
+ if (member.getClusterInstanceId().equals(instance.getInstanceId())) {
+ if (member.getStatus().equals(MemberStatus.Active)) {
+ activeInstances++;
+ }
+ }
+ }
+ clusterActive = activeInstances >= minMembers;
+
+ while (!clusterActive) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignore) {
+ }
+ service = TopologyManager.getTopology().getService(serviceName);
+ assertNotNull(String.format("Service is not found: [application-id] %s [service] %s",
+ applicationName, serviceName), service);
+
+ cluster = service.getCluster(clusterId);
+ activeInstances = 0;
+ for (Member member : cluster.getMembers()) {
+ if (member.getClusterInstanceId().equals(instance.getInstanceId())) {
+ if (member.getStatus().equals(MemberStatus.Active)) {
+ activeInstances++;
+ }
+ }
+ }
+ clusterActive = activeInstances >= minMembers;
+ assertNotNull(String.format("Cluster is not found: [application-id] %s [service] %s [cluster-id] %s",
+ applicationName, serviceName, clusterId), cluster);
+
+ if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+ break;
+ }
+ }
+ }
+ assertEquals(String.format("Cluster status did not change to active: [cluster-id] %s", clusterId),
+ clusterActive, true);
+ }
+
+ }
+
+
+ /**
+ * Assert application activation
+ *
+ * @param applicationName
+ */
+ public boolean assertApplicationUndeploy(String applicationName) {
+ long startTime = System.currentTimeMillis();
+ Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName, -1234);
+ ApplicationContext applicationContext = null;
+ try {
+ applicationContext = AutoscalerServiceClient.getInstance().getApplicationByTenant(applicationName,-1234);
+ } catch (RemoteException e) {
+ log.error("Error while getting the application context for [application] " + applicationName);
+ }
+ while (((application != null) && application.getInstanceContextCount() > 0) ||
+ (applicationContext == null || applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING))) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignore) {
+ }
+ application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
+ try {
+ applicationContext = AutoscalerServiceClient.getInstance().getApplicationByTenant(applicationName,-1234);
+ } catch (RemoteException e) {
+ log.error("Error while getting the application context for [application] " + applicationName);
+ }
+ if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+ break;
+ }
+ }
+
+ assertNotNull(String.format("Application is not found: [application-id] %s",
+ applicationName), application);
+ assertNotNull(String.format("Application Context is not found: [application-id] %s",
+ applicationName), applicationContext);
+
+ //Force undeployment after the graceful deployment
+ if (application.getInstanceContextCount() > 0 ||
+ applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING)) {
+ return false;
+ }
+ assertEquals(String.format("Application status did not change to Created: [application-id] %s", applicationName),
+ APPLICATION_STATUS_CREATED, applicationContext.getStatus());
+ return true;
+ }
+
+ /**
+ * Assert application activation
+ *
+ * @param applicationName
+ */
+ public void assertGroupInstanceCount(String applicationName, String groupAlias, int count) {
+ long startTime = System.currentTimeMillis();
+ Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
+ if (application != null) {
+ Group group = application.getGroupRecursively(groupAlias);
+ while (group.getInstanceContextCount() != count) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignore) {
+ }
+ if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+ break;
+ }
+ }
+ for (GroupInstance instance : group.getInstanceIdToInstanceContextMap().values()) {
+ while (!instance.getStatus().equals(GroupStatus.Active)) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignore) {
+ }
+ if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
+ break;
+ }
+ }
+ }
+ assertEquals(String.format("Application status did not change to active: [application-id] %s", applicationName),
+ group.getInstanceContextCount(), count);
+ }
+ assertNotNull(String.format("Application is not found: [application-id] %s", applicationName), application);
+
+ }
+
+ public void assertApplicationNotExists(String applicationName) {
+ Application application = ApplicationManager.getApplications().getApplication(applicationName);
+ assertNull(String.format("Application is found in the topology : [application-id] %s", applicationName), application);
+ }
+
+ /**
+ * Get resources folder path
+ *
+ * @return
+ */
+ private String getResourcesFolderPath() {
+ String path = getClass().getResource("/").getPath();
+ return StringUtils.removeEnd(path, File.separator);
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
new file mode 100644
index 0000000..815ccd8
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
@@ -0,0 +1,226 @@
+/*
+ * 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.stratos.integration.tests.application;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.integration.tests.RestConstants;
+import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.apache.stratos.integration.tests.TopologyHandler;
+import org.testng.annotations.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * This will handle the application bursting test cases
+ */
+public class ApplicationBurstingTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(SampleApplicationsTest.class);
+ private static final String TEST_PATH = "/application-bursting-test";
+
+
+ @Test
+ public void testApplicationBusting() {
+ try {
+ log.info("Started application Bursting test case**************************************");
+
+ String autoscalingPolicyId = "autoscaling-policy-2";
+
+ boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
+ + "/" + autoscalingPolicyId + ".json",
+ RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(addedScalingPolicy, true);
+
+ boolean addedC1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "esb.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(addedC1, true);
+
+ boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(addedC2, true);
+
+ boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(addedC3, true);
+
+ boolean addedG1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+ "/" + "esb-php-group.json", RestConstants.CARTRIDGE_GROUPS,
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(addedG1, true);
+
+ CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
+ getEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+ CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(beanG1.getName(), "esb-php-group");
+
+ boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-9.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN1, true);
+
+ boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-10.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN2, true);
+
+ boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+ "deployment-policy-4.json",
+ RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(addedDep, true);
+
+ boolean added = restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" +
+ "app-bursting-single-cartriddge-group.json", RestConstants.APPLICATIONS,
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(added, true);
+
+ ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+ "cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ assertEquals(bean.getApplicationId(), "cartridge-group-app");
+
+ boolean addAppPolicy = restClient.addEntity(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+ "application-policy-3.json", RestConstants.APPLICATION_POLICIES,
+ RestConstants.APPLICATION_POLICIES_NAME);
+ assertEquals(addAppPolicy, true);
+
+ ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity(
+ RestConstants.APPLICATION_POLICIES,
+ "application-policy-3", ApplicationPolicyBean.class,
+ RestConstants.APPLICATION_POLICIES_NAME);
+
+ //deploy the application
+ String resourcePath = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+ RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-3";
+ boolean deployed = restClient.deployEntity(resourcePath,
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(deployed, true);
+
+ //Application active handling
+ TopologyHandler.getInstance().assertApplicationActivation(bean.getApplicationId());
+
+ //Group active handling
+ TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId());
+
+ //Cluster active handling
+ TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+
+ /* boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(removedGroup, false);
+
+ boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+ autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(removedAuto, false);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-9",
+ RestConstants.NETWORK_PARTITIONS_NAME);
+ //Trying to remove the used network partition
+ assertEquals(removedNet, false);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+ "deployment-policy-4", RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(removedDep, false); */
+
+ //Un-deploying the application
+ String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+ RestConstants.APPLICATIONS_UNDEPLOY;
+
+ boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(unDeployed, true);
+
+ boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app");
+ if (!undeploy) {
+ //Need to forcefully undeploy the application
+ log.info("Force undeployment is going to start for the [application] " + "cartridge-group-app");
+
+ restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+ RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
+
+ boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app");
+ assertEquals(String.format("Forceful undeployment failed for the application %s",
+ "cartridge-group-app"), forceUndeployed, true);
+
+ }
+
+ boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "cartridge-group-app",
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(removed, true);
+
+ ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+ "cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ assertEquals(beanRemoved, null);
+
+ boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(removedGroup, true);
+
+ boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "esb",
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removedC1, true);
+
+ boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "php",
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removedC2, true);
+
+ boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat",
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removedC3, true);
+
+ boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+ autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(removedAuto, true);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+ "deployment-policy-4", RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(removedDep, true);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedNet, false);
+
+ boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-10", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN2, false);
+
+ boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+ "application-policy-3", RestConstants.APPLICATION_POLICIES_NAME);
+ assertEquals(removeAppPolicy, true);
+
+ removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedNet, true);
+
+ removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-10", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN2, true);
+
+ log.info("Ended application bursting test case**************************************");
+
+ } catch (Exception e) {
+ log.error("An error occurred while handling application bursting", e);
+ assertTrue("An error occurred while handling application bursting", false);
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
new file mode 100644
index 0000000..8737249
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
@@ -0,0 +1,427 @@
+/*
+ * 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.stratos.integration.tests.application;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.integration.tests.RestConstants;
+import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.apache.stratos.integration.tests.TopologyHandler;
+import org.testng.annotations.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * Sample application tests with application add, .
+ */
+public class SampleApplicationsTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(SampleApplicationsTest.class);
+ private static final String TEST_PATH = "/sample-applications-test";
+
+ @Test
+ public void testApplication() {
+ log.info("Started application test case**************************************");
+ String autoscalingPolicyId = "autoscaling-policy-1";
+
+ try {
+ boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
+ + "/" + autoscalingPolicyId + ".json",
+ RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(addedScalingPolicy, true);
+
+ boolean addedC1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c1.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(addedC1, true);
+
+ boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c2.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(addedC2, true);
+
+ boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c3.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(addedC3, true);
+
+ boolean addedG1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+ "/" + "cartrdige-nested.json", RestConstants.CARTRIDGE_GROUPS,
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(addedG1, true);
+
+ CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
+ getEntity(RestConstants.CARTRIDGE_GROUPS, "G1",
+ CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(beanG1.getName(), "G1");
+
+ boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-1.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN1, true);
+
+ boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-2.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN2, true);
+
+ boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+ "deployment-policy-1.json",
+ RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(addedDep, true);
+
+ boolean added = restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" +
+ "g-sc-G123-1.json", RestConstants.APPLICATIONS,
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(added, true);
+
+ ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+ "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ assertEquals(bean.getApplicationId(), "g-sc-G123-1");
+
+ assertEquals(bean.getComponents().getGroups().get(0).getName(), "G1");
+ assertEquals(bean.getComponents().getGroups().get(0).getAlias(), "group1");
+ assertEquals(bean.getComponents().getGroups().get(0).getGroupMaxInstances(), 1);
+ assertEquals(bean.getComponents().getGroups().get(0).getGroupMinInstances(), 1);
+
+ assertEquals(bean.getComponents().getGroups().get(0).getCartridges().get(0).getType(), "c1");
+ assertEquals(bean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 1);
+ assertEquals(bean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 2);
+
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getAlias(), "group2");
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getName(), "G2");
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 1);
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 1);
+
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c2");
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 1);
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 2);
+
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getAlias(), "group3");
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getName(), "G3");
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 2);
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 1);
+
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c3");
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 1);
+ assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 2);
+
+ boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/g-sc-G123-1-v1.json",
+ RestConstants.APPLICATIONS, RestConstants.APPLICATIONS_NAME);
+ assertEquals(updated, true);
+
+ ApplicationBean updatedBean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+ "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+
+ assertEquals(bean.getApplicationId(), "g-sc-G123-1");
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getName(), "G1");
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getAlias(), "group1");
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroupMaxInstances(), 1);
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroupMinInstances(), 1);
+
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getCartridges().get(0).getType(), "c1");
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 2);
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 3);
+
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getAlias(), "group2");
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getName(), "G2");
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 1);
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 1);
+
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c2");
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 2);
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 4);
+
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getAlias(), "group3");
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getName(), "G3");
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 3);
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 2);
+
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c3");
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 2);
+ assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 3);
+
+
+ /* boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(removedGroup, false);
+
+ boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+ autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(removedAuto, false);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-1",
+ RestConstants.NETWORK_PARTITIONS_NAME);
+ //Trying to remove the used network partition
+ assertEquals(removedNet, false);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+ "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(removedDep, false); */
+
+ boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "g-sc-G123-1",
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(removed, true);
+
+ ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+ "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ assertEquals(beanRemoved, null);
+
+ boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(removedGroup, true);
+
+ boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c1",
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removedC1, true);
+
+ boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c2",
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removedC2, true);
+
+ boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c3",
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removedC3, true);
+
+ boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+ autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(removedAuto, true);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+ "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(removedDep, true);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-1", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedNet, true);
+
+ boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-2", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN2, true);
+
+ log.info("Ended application test case**************************************");
+
+ } catch (Exception e) {
+ log.error("An error occurred while handling application test case", e);
+ assertTrue("An error occurred while handling application test case", false);
+ }
+ }
+
+ @Test(dependsOnMethods = {"testApplication"})
+ public void testDeployApplication() {
+ try {
+ log.info("Started application deploy/undeploy test case**************************************");
+
+ String autoscalingPolicyId = "autoscaling-policy-1";
+
+ boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
+ + "/" + autoscalingPolicyId + ".json",
+ RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(addedScalingPolicy, true);
+
+ boolean addedC1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c1.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(addedC1, true);
+
+ boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c2.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(addedC2, true);
+
+ boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c3.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(addedC3, true);
+
+ boolean addedG1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+ "/" + "cartrdige-nested.json", RestConstants.CARTRIDGE_GROUPS,
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(addedG1, true);
+
+ CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
+ getEntity(RestConstants.CARTRIDGE_GROUPS, "G1",
+ CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(beanG1.getName(), "G1");
+
+ boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-1.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN1, true);
+
+ boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-2.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN2, true);
+
+ boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+ "deployment-policy-1.json",
+ RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(addedDep, true);
+
+ boolean added = restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" +
+ "g-sc-G123-1.json", RestConstants.APPLICATIONS,
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(added, true);
+
+ ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+ "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ assertEquals(bean.getApplicationId(), "g-sc-G123-1");
+
+ boolean addAppPolicy = restClient.addEntity(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+ "application-policy-1.json", RestConstants.APPLICATION_POLICIES,
+ RestConstants.APPLICATION_POLICIES_NAME);
+ assertEquals(addAppPolicy, true);
+
+ ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity(
+ RestConstants.APPLICATION_POLICIES,
+ "application-policy-1", ApplicationPolicyBean.class,
+ RestConstants.APPLICATION_POLICIES_NAME);
+
+ //deploy the application
+ String resourcePath = RestConstants.APPLICATIONS + "/" + "g-sc-G123-1" +
+ RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-1";
+ boolean deployed = restClient.deployEntity(resourcePath,
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(deployed, true);
+
+ //Application active handling
+ TopologyHandler.getInstance().assertApplicationActivation(bean.getApplicationId());
+
+ //Group active handling
+ TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId());
+
+ //Cluster active handling
+ TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+
+ //Updating application
+ boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" +
+ "g-sc-G123-1-v1.json", RestConstants.APPLICATIONS,
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(updated, true);
+
+ TopologyHandler.getInstance().assertGroupInstanceCount(bean.getApplicationId(), "group3", 2);
+
+ TopologyHandler.getInstance().assertClusterMinMemberCount(bean.getApplicationId(), 2);
+
+ ApplicationBean updatedBean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+ "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ assertEquals(updatedBean.getApplicationId(), "g-sc-G123-1");
+
+ /* boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(removedGroup, false);
+
+ boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+ autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(removedAuto, false);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-1",
+ RestConstants.NETWORK_PARTITIONS_NAME);
+ //Trying to remove the used network partition
+ assertEquals(removedNet, false);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+ "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(removedDep, false); */
+
+ //Un-deploying the application
+ String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "g-sc-G123-1" +
+ RestConstants.APPLICATIONS_UNDEPLOY;
+
+ boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(unDeployed, true);
+
+ boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("g-sc-G123-1");
+ if (!undeploy) {
+ //Need to forcefully undeploy the application
+ log.info("Force undeployment is going to start for the [application] " + "g-sc-G123-1");
+
+ restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "g-sc-G123-1" +
+ RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
+
+ boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("g-sc-G123-1");
+ assertEquals(String.format("Forceful undeployment failed for the application %s",
+ "g-sc-G123-1"), forceUndeployed, true);
+
+ }
+
+ boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "g-sc-G123-1",
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(removed, true);
+
+ ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+ "g-sc-G123-1", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ assertEquals(beanRemoved, null);
+
+ boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(removedGroup, true);
+
+ boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c1",
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removedC1, true);
+
+ boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c2",
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removedC2, true);
+
+ boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c3",
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removedC3, true);
+
+ boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+ autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(removedAuto, true);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+ "deployment-policy-1", RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(removedDep, true);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-1", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedNet, false);
+
+ boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-2", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN2, false);
+
+ boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+ "application-policy-1", RestConstants.APPLICATION_POLICIES_NAME);
+ assertEquals(removeAppPolicy, true);
+
+ removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-1", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedNet, true);
+
+ removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-2", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN2, true);
+
+ log.info("Ended application deploy/undeploy test case**************************************");
+
+ } catch (Exception e) {
+ log.error("An error occurred while handling application deployment/undeployment", e);
+ assertTrue("An error occurred while handling application deployment/undeployment", false);
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
new file mode 100644
index 0000000..633c456
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
@@ -0,0 +1,233 @@
+/*
+ * 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.stratos.integration.tests.application;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.application.ApplicationBean;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
+import org.apache.stratos.integration.tests.RestConstants;
+import org.apache.stratos.integration.tests.StratosTestServerManager;
+import org.apache.stratos.integration.tests.TopologyHandler;
+import org.testng.annotations.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * This will handle the scale-up and scale-down of a particular cluster bursting test cases
+ */
+public class SingleClusterScalingTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(SampleApplicationsTest.class);
+ private static final String TEST_PATH = "/application-bursting-test";
+
+
+ @Test
+ public void testDeployApplication() {
+ try {
+ log.info("Started application Bursting test case**************************************");
+
+ String autoscalingPolicyId = "autoscaling-policy-2";
+
+ boolean addedScalingPolicy = restClient.addEntity(TEST_PATH + RestConstants.AUTOSCALING_POLICIES_PATH
+ + "/" + autoscalingPolicyId + ".json",
+ RestConstants.AUTOSCALING_POLICIES, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(addedScalingPolicy, true);
+
+ boolean addedC1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "esb.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(addedC1, true);
+
+ boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "php.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(addedC2, true);
+
+ boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "tomcat.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(addedC3, true);
+
+ boolean addedG1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+ "/" + "esb-php-group.json", RestConstants.CARTRIDGE_GROUPS,
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(addedG1, true);
+
+ CartridgeGroupBean beanG1 = (CartridgeGroupBean) restClient.
+ getEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+ CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(beanG1.getName(), "esb-php-group");
+
+ boolean addedN1 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-9.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN1, true);
+
+ boolean addedN2 = restClient.addEntity(TEST_PATH + RestConstants.NETWORK_PARTITIONS_PATH + "/" +
+ "network-partition-10.json",
+ RestConstants.NETWORK_PARTITIONS, RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(addedN2, true);
+
+ boolean addedDep = restClient.addEntity(TEST_PATH + RestConstants.DEPLOYMENT_POLICIES_PATH + "/" +
+ "deployment-policy-4.json",
+ RestConstants.DEPLOYMENT_POLICIES, RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(addedDep, true);
+
+ boolean added = restClient.addEntity(TEST_PATH + RestConstants.APPLICATIONS_PATH + "/" +
+ "app-bursting-single-cartriddge-group.json", RestConstants.APPLICATIONS,
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(added, true);
+
+ ApplicationBean bean = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+ "cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ assertEquals(bean.getApplicationId(), "cartridge-group-app");
+
+ boolean addAppPolicy = restClient.addEntity(TEST_PATH + RestConstants.APPLICATION_POLICIES_PATH + "/" +
+ "application-policy-3.json", RestConstants.APPLICATION_POLICIES,
+ RestConstants.APPLICATION_POLICIES_NAME);
+ assertEquals(addAppPolicy, true);
+
+ ApplicationPolicyBean policyBean = (ApplicationPolicyBean) restClient.getEntity(
+ RestConstants.APPLICATION_POLICIES,
+ "application-policy-3", ApplicationPolicyBean.class,
+ RestConstants.APPLICATION_POLICIES_NAME);
+
+ //deploy the application
+ String resourcePath = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+ RestConstants.APPLICATIONS_DEPLOY + "/" + "application-policy-3";
+ boolean deployed = restClient.deployEntity(resourcePath,
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(deployed, true);
+
+ //Application active handling
+ TopologyHandler.getInstance().assertApplicationActivation(bean.getApplicationId());
+
+ //Group active handling
+ TopologyHandler.getInstance().assertGroupActivation(bean.getApplicationId());
+
+ //Cluster active handling
+ TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
+
+ /* boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(removedGroup, false);
+
+ boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+ autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(removedAuto, false);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-9",
+ RestConstants.NETWORK_PARTITIONS_NAME);
+ //Trying to remove the used network partition
+ assertEquals(removedNet, false);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+ "deployment-policy-4", RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(removedDep, false);*/
+
+ //Un-deploying the application
+ String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+ RestConstants.APPLICATIONS_UNDEPLOY;
+
+ boolean unDeployed = restClient.undeployEntity(resourcePathUndeploy,
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(unDeployed, true);
+
+ boolean undeploy = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app");
+ if (!undeploy) {
+ //Need to forcefully undeploy the application
+ log.info("Force undeployment is going to start for the [application] " + "cartridge-group-app");
+
+ restClient.undeployEntity(RestConstants.APPLICATIONS + "/" + "cartridge-group-app" +
+ RestConstants.APPLICATIONS_UNDEPLOY + "?force=true", RestConstants.APPLICATIONS);
+
+ boolean forceUndeployed = TopologyHandler.getInstance().assertApplicationUndeploy("cartridge-group-app");
+ assertEquals(String.format("Forceful undeployment failed for the application %s",
+ "cartridge-group-app"), forceUndeployed, true);
+
+ }
+
+ boolean removed = restClient.removeEntity(RestConstants.APPLICATIONS, "cartridge-group-app",
+ RestConstants.APPLICATIONS_NAME);
+ assertEquals(removed, true);
+
+ ApplicationBean beanRemoved = (ApplicationBean) restClient.getEntity(RestConstants.APPLICATIONS,
+ "cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
+ assertEquals(beanRemoved, null);
+
+ boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(removedGroup, true);
+
+ boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "esb",
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removedC1, true);
+
+ boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "php",
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removedC2, true);
+
+ boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "tomcat",
+ RestConstants.CARTRIDGES_NAME);
+ assertEquals(removedC3, true);
+
+ boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+ autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
+ assertEquals(removedAuto, true);
+
+ boolean removedDep = restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+ "deployment-policy-4", RestConstants.DEPLOYMENT_POLICIES_NAME);
+ assertEquals(removedDep, true);
+
+ boolean removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedNet, false);
+
+ boolean removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-10", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN2, false);
+
+ boolean removeAppPolicy = restClient.removeEntity(RestConstants.APPLICATION_POLICIES,
+ "application-policy-3", RestConstants.APPLICATION_POLICIES_NAME);
+ assertEquals(removeAppPolicy, true);
+
+ removedNet = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-9", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedNet, true);
+
+ removedN2 = restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+ "network-partition-10", RestConstants.NETWORK_PARTITIONS_NAME);
+ assertEquals(removedN2, true);
+
+ log.info("Ended application bursting test case**************************************");
+
+ } catch (Exception e) {
+ log.error("An error occurred while handling application bursting", e);
+ assertTrue("An error occurred while handling application bursting", false);
+ }
+ }
+
+ @Test(dependsOnMethods = {"testApplication"})
+ public void testClusterScalingUp() {
+
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationBean.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationBean.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationBean.java
new file mode 100644
index 0000000..ce23728
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationBean.java
@@ -0,0 +1,25 @@
+/*
+ * 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.stratos.integration.tests.config;
+
+/**
+ * Created by reka on 5/7/15.
+ */
+public class ApplicationBean {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationConfigParser.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationConfigParser.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationConfigParser.java
new file mode 100644
index 0000000..ace17e6
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/config/ApplicationConfigParser.java
@@ -0,0 +1,25 @@
+/*
+ * 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.stratos.integration.tests.config;
+
+/**
+ * Created by reka on 5/7/15.
+ */
+public class ApplicationConfigParser {
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/366babaf/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
new file mode 100644
index 0000000..8db4af8
--- /dev/null
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
@@ -0,0 +1,129 @@
+/*
+ * 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.stratos.integration.tests.group;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
+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.assertTrue;
+
+/**
+ * Test to handle Cartridge group CRUD operations
+ */
+public class CartridgeGroupTest extends StratosTestServerManager {
+ private static final Log log = LogFactory.getLog(CartridgeGroupTest.class);
+ private static final String TEST_PATH = "/cartridge-group-test";
+
+ @Test
+ public void testCartridgeGroup() {
+ try {
+ log.info("Started Cartridge group test case**************************************");
+
+ boolean addedC1 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c4.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(String.format("Cartridge did not added: [cartridge-name] %s", "c4"), addedC1, true);
+
+ boolean addedC2 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c5.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(String.format("Cartridge did not added: [cartridge-name] %s", "c5"), addedC2, true);
+
+ boolean addedC3 = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGES_PATH + "/" + "c6.json",
+ RestConstants.CARTRIDGES, RestConstants.CARTRIDGES_NAME);
+ assertEquals(String.format("Cartridge did not added: [cartridge-name] %s", "c6"), addedC3, true);
+
+ boolean added = restClient.addEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+ "/" + "g4-g5-g6.json", RestConstants.CARTRIDGE_GROUPS,
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(String.format("Cartridge Group did not added: [cartridge-group-name] %s",
+ "g4-g5-g6"), added, true);
+ CartridgeGroupBean bean = (CartridgeGroupBean) restClient.
+ getEntity(RestConstants.CARTRIDGE_GROUPS, "G4",
+ CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(String.format("Cartridge Group name did not match: [cartridge-group-name] %s",
+ "g4-g5-g6.json"), bean.getName(), "G4");
+
+ boolean updated = restClient.updateEntity(TEST_PATH + RestConstants.CARTRIDGE_GROUPS_PATH +
+ "/" + "g4-g5-g6-v1.json",
+ RestConstants.CARTRIDGE_GROUPS, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(String.format("Cartridge Group did not updated: [cartridge-group-name] %s",
+ "g4-g5-g6"), updated, true);
+ CartridgeGroupBean updatedBean = (CartridgeGroupBean) restClient.
+ getEntity(RestConstants.CARTRIDGE_GROUPS, "G4",
+ CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(String.format("Updated Cartridge Group didn't match: [cartridge-group-name] %s",
+ "g4-g5-g6"), updatedBean.getName(), "G4");
+
+ /* boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(String.format("Cartridge can be removed while it is used in " +
+ "cartridge group: [cartridge-name] %s", "c4"), removedC1, false);
+
+ boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(String.format("Cartridge can be removed while it is used in " +
+ "cartridge group: [cartridge-name] %s",
+ "c5"), removedC2, false);
+
+ boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(String.format("Cartridge can be removed while it is used in " +
+ "cartridge group: [cartridge-name] %s",
+ "c6"), removedC3, false); */
+
+ boolean removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G4",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(String.format("Cartridge Group did not removed: [cartridge-group-name] %s",
+ "g4-g5-g6"), removed, true);
+
+ CartridgeGroupBean beanRemoved = (CartridgeGroupBean) restClient.
+ getEntity(RestConstants.CARTRIDGE_GROUPS, "G4",
+ CartridgeGroupBean.class, RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(String.format("Cartridge Group did not removed completely: " +
+ "[cartridge-group-name] %s",
+ "g4-g5-g6"), beanRemoved, null);
+
+ boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s",
+ "c4"), removedC1, true);
+
+ boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s",
+ "c5"), removedC2, true);
+
+ boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6",
+ RestConstants.CARTRIDGE_GROUPS_NAME);
+ assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s",
+ "c6"), removedC3, true);
+
+ log.info("Ended Cartridge group test case**************************************");
+
+ } catch (Exception e) {
+ log.error("An error occurred while handling Cartridge group test case", e);
+ assertTrue("An error occurred while handling Cartridge group test case", false);
+ }
+ }
+}
[2/6] stratos git commit: Add the updated integration tests
Posted by ga...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
deleted file mode 100644
index 747ba80..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
+++ /dev/null
@@ -1,1035 +0,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.
- */
-
-package org.apache.stratos.integration.tests;
-
-import org.apache.commons.exec.CommandLine;
-import org.apache.commons.exec.DefaultExecutor;
-import org.apache.commons.exec.PumpStreamHandler;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext;
-import org.apache.stratos.common.beans.PropertyBean;
-import org.apache.stratos.common.beans.application.ApplicationBean;
-import org.apache.stratos.common.beans.cartridge.CartridgeBean;
-import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean;
-import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
-import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
-import org.apache.stratos.common.beans.policy.deployment.ApplicationPolicyBean;
-import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
-import org.apache.stratos.common.client.AutoscalerServiceClient;
-import org.apache.stratos.common.threading.StratosThreadPool;
-import org.apache.stratos.integration.tests.rest.RestClient;
-import org.apache.stratos.messaging.domain.application.*;
-import org.apache.stratos.messaging.domain.instance.ClusterInstance;
-import org.apache.stratos.messaging.domain.instance.GroupInstance;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.Member;
-import org.apache.stratos.messaging.domain.topology.MemberStatus;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.message.receiver.application.ApplicationManager;
-import org.apache.stratos.messaging.message.receiver.application.ApplicationsEventReceiver;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.rmi.RemoteException;
-import java.util.Collection;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-
-import static junit.framework.Assert.*;
-
-/**
- * Sample application tests.
- */
-public class SampleApplicationsTest extends StratosTestServerManager {
-
- private static final Log log = LogFactory.getLog(StratosTestServerManager.class);
-
- public static final int APPLICATION_ACTIVATION_TIMEOUT = 120000;
- public static final String APPLICATION_STATUS_CREATED = "Created";
- public static final String APPLICATION_STATUS_UNDEPLOYING = "Undeploying";
- private String endpoint = "https://localhost:9443";
-
- private ApplicationsEventReceiver applicationsEventReceiver;
- private TopologyEventReceiver topologyEventReceiver;
- private RestClient restClient = new RestClient();
- private AutoscalingPolicyTest autoscalingPolicyTest;
- private NetworkPartitionTest networkPartitionTest;
- private CartridgeTest cartridgeTest;
- private DeploymentPolicyTest deploymentPolicyTest;
- private CartridgeGroupTest cartridgeGroupTest;
- private ApplicationTest applicationTest;
- private ApplicationPolicyTest applicationPolicyTest;
-
-
- @BeforeClass
- public void setUp() {
- // Set jndi.properties.dir system property for initializing event receivers
- System.setProperty("jndi.properties.dir", getResourcesFolderPath());
- System.setProperty("autoscaler.service.url", "https://localhost:9443/services/AutoscalerService");
- autoscalingPolicyTest = new AutoscalingPolicyTest();
- networkPartitionTest = new NetworkPartitionTest();
- cartridgeTest = new CartridgeTest();
- deploymentPolicyTest = new DeploymentPolicyTest();
- cartridgeGroupTest = new CartridgeGroupTest();
- applicationTest = new ApplicationTest();
- applicationPolicyTest = new ApplicationPolicyTest();
- }
-
- @Test
- public void testSingleCartridgeApplication() {
- try {
- initializeApplicationEventReceiver();
- //runApplicationTest("simple/single-cartridge-app", "single-cartridge-app");
- } catch (Exception e) {
- log.error(e);
- assertTrue("An error occurred", false);
- }
- }
-
- @Test
- public void testAutoscalingPolicy() {
- try {
- boolean added = autoscalingPolicyTest.addAutoscalingPolicy("autoscaling-policy-c0.json",
- endpoint, restClient, "admin", "admin");
- assertEquals(added, true);
- AutoscalePolicyBean bean = autoscalingPolicyTest.getAutoscalingPolicy("autoscaling-policy-c0", endpoint,
- restClient, "admin", "admin");
- assertEquals(bean.getId(), "autoscaling-policy-c0");
- assertEquals(bean.getLoadThresholds().getRequestsInFlight().getThreshold(), 35.0, 0.0);
- assertEquals(bean.getLoadThresholds().getMemoryConsumption().getThreshold(), 45.0, 0.0);
- assertEquals(bean.getLoadThresholds().getLoadAverage().getThreshold(), 25.0, 0.0);
-
- boolean updated = autoscalingPolicyTest.updateAutoscalingPolicy("autoscaling-policy-c0.json",
- endpoint, restClient,"admin","admin");
- assertEquals(updated, true);
- AutoscalePolicyBean updatedBean = autoscalingPolicyTest.getAutoscalingPolicy("autoscaling-policy-c0", endpoint,
- restClient,"admin","admin");
- assertEquals(updatedBean.getLoadThresholds().getRequestsInFlight().getThreshold(), 30.0, 0.0);
- assertEquals(updatedBean.getLoadThresholds().getMemoryConsumption().getThreshold(), 40.0, 0.0);
- assertEquals(updatedBean.getLoadThresholds().getLoadAverage().getThreshold(), 20.0, 0.0);
-
- boolean removed = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-c0", endpoint,
- restClient, "admin", "admin");
- assertEquals(removed, true);
-
- AutoscalePolicyBean beanRemoved = autoscalingPolicyTest.getAutoscalingPolicy("autoscaling-policy-c0", endpoint,
- restClient, "admin", "admin");
- assertEquals(beanRemoved, null);
-
- } catch (Exception e) {
- log.error(e);
- assertTrue("An error occurred while handling autoscaling policy", false);
- }
- }
-
- @Test
- public void testCartridgeGroup() {
- try {
- boolean addedC1 = cartridgeTest.addCartridge("c1.json", endpoint, restClient);
- assertEquals(addedC1, true);
-
- boolean addedC2 = cartridgeTest.addCartridge("c2.json", endpoint, restClient);
- assertEquals(addedC2, true);
-
- boolean addedC3 = cartridgeTest.addCartridge("c3.json", endpoint, restClient);
- assertEquals(addedC3, true);
-
-
- boolean added = cartridgeGroupTest.addCartridgeGroup("cartrdige-nested.json",
- endpoint, restClient);
- assertEquals(added, true);
- CartridgeGroupBean bean = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
- restClient);
- assertEquals(bean.getName(), "G1");
-
- boolean updated = cartridgeGroupTest.updateCartridgeGroup("cartrdige-nested.json",
- endpoint, restClient);
- assertEquals(updated, true);
- CartridgeGroupBean updatedBean = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
- restClient);
- assertEquals(updatedBean.getName(), "G1");
- /*
- boolean removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
- restClient);
- assertEquals(removedC1, false);
-
- boolean removedC2 = cartridgeTest.removeCartridge("c2", endpoint,
- restClient);
- assertEquals(removedC2, false);
-
- boolean removedC3 = cartridgeTest.removeCartridge("c3", endpoint,
- restClient);
- assertEquals(removedC3, false); */
-
-
- boolean removed = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
- restClient);
- assertEquals(removed, true);
-
- CartridgeGroupBean beanRemoved = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
- restClient);
- assertEquals(beanRemoved, null);
-
- boolean removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
- restClient);
- assertEquals(removedC1, true);
-
- boolean removedC2 = cartridgeTest.removeCartridge("c2", endpoint,
- restClient);
- assertEquals(removedC2, true);
-
- boolean removedC3 = cartridgeTest.removeCartridge("c3", endpoint,
- restClient);
- assertEquals(removedC3, true);
-
- } catch (Exception e) {
- log.error(e);
- assertTrue("An error occurred while handling autoscaling policy", false);
- }
- }
-
- @Test
- public void testApplication() {
- try {
- boolean addedScalingPolicy = autoscalingPolicyTest.addAutoscalingPolicy("autoscaling-policy-1.json",
- endpoint, restClient, "admin", "admin");
- assertEquals(addedScalingPolicy, true);
-
- boolean addedC1 = cartridgeTest.addCartridge("c1.json", endpoint, restClient);
- assertEquals(addedC1, true);
-
- boolean addedC2 = cartridgeTest.addCartridge("c2.json", endpoint, restClient);
- assertEquals(addedC2, true);
-
- boolean addedC3 = cartridgeTest.addCartridge("c3.json", endpoint, restClient);
- assertEquals(addedC3, true);
-
- boolean addedG1 = cartridgeGroupTest.addCartridgeGroup("cartrdige-nested.json",
- endpoint, restClient);
- assertEquals(addedG1, true);
- CartridgeGroupBean beanG1 = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
- restClient);
- assertEquals(beanG1.getName(), "G1");
-
- boolean addedN1 = networkPartitionTest.addNetworkPartition("network-partition-1.json",
- endpoint, restClient);
- assertEquals(addedN1, true);
-
- boolean addedN2 = networkPartitionTest.addNetworkPartition("network-partition-2.json",
- endpoint, restClient);
- assertEquals(addedN2, true);
-
- boolean addedDep = deploymentPolicyTest.addDeploymentPolicy("deployment-policy-1.json",
- endpoint, restClient);
- assertEquals(addedDep, true);
-
- boolean added = applicationTest.addApplication("g-sc-G123-1.json",
- endpoint, restClient);
- assertEquals(added, true);
- ApplicationBean bean = applicationTest.getApplication("g-sc-G123-1", endpoint,
- restClient);
- assertEquals(bean.getApplicationId(), "g-sc-G123-1");
-
- assertEquals(bean.getComponents().getGroups().get(0).getName(), "G1");
- assertEquals(bean.getComponents().getGroups().get(0).getAlias(), "group1");
- assertEquals(bean.getComponents().getGroups().get(0).getGroupMaxInstances(), 1);
- assertEquals(bean.getComponents().getGroups().get(0).getGroupMinInstances(), 1);
-
- assertEquals(bean.getComponents().getGroups().get(0).getCartridges().get(0).getType(), "c1");
- assertEquals(bean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 1);
- assertEquals(bean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 2);
-
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getAlias(), "group2");
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getName(), "G2");
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 1);
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 1);
-
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c2");
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 1);
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 2);
-
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getAlias(), "group3");
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getName(), "G3");
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 2);
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 1);
-
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c3");
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 1);
- assertEquals(bean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 2);
-
-
- boolean updated = applicationTest.updateApplication("g-sc-G123-1.json",
- endpoint, restClient);
- assertEquals(updated, true);
-
- ApplicationBean updatedBean = applicationTest.getApplication("g-sc-G123-1", endpoint,
- restClient);
-
- assertEquals(bean.getApplicationId(), "g-sc-G123-1");
- assertEquals(updatedBean.getComponents().getGroups().get(0).getName(), "G1");
- assertEquals(updatedBean.getComponents().getGroups().get(0).getAlias(), "group1");
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroupMaxInstances(), 1);
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroupMinInstances(), 1);
-
- assertEquals(updatedBean.getComponents().getGroups().get(0).getCartridges().get(0).getType(), "c1");
- assertEquals(updatedBean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 2);
- assertEquals(updatedBean.getComponents().getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 3);
-
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getAlias(), "group2");
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getName(), "G2");
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 1);
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 1);
-
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c2");
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 2);
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 4);
-
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getAlias(), "group3");
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getName(), "G3");
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMaxInstances(), 3);
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getGroupMinInstances(), 2);
-
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getType(), "c3");
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMin(), 2);
- assertEquals(updatedBean.getComponents().getGroups().get(0).getGroups().get(0).getGroups().get(0).getCartridges().get(0).getCartridgeMax(), 3);
-
- /*
- boolean removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
- restClient);
- assertEquals(removedGroup, false);
-
- boolean removedAuto = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-1", endpoint,
- restClient, "admin", "admin");
- assertEquals(removedAuto, false);
-
- boolean removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
- restClient);
- //Trying to remove the used network partition
- assertEquals(removedNet, false);
-
- boolean removedDep = deploymentPolicyTest.removeDeploymentPolicy("deployment-policy-1", endpoint,
- restClient);
- assertEquals(removedDep, false); */
-
- boolean removed = applicationTest.removeApplication("g-sc-G123-1", endpoint,
- restClient);
- assertEquals(removed, true);
-
- ApplicationBean beanRemoved = applicationTest.getApplication("g-sc-G123-1", endpoint,
- restClient);
- assertEquals(beanRemoved, null);
-
- boolean removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
- restClient);
- assertEquals(removedGroup, true);
-
- boolean removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
- restClient);
- assertEquals(removedC1, true);
-
- boolean removedC2 = cartridgeTest.removeCartridge("c2", endpoint,
- restClient);
- assertEquals(removedC2, true);
-
- boolean removedC3 = cartridgeTest.removeCartridge("c3", endpoint,
- restClient);
- assertEquals(removedC3, true);
-
- boolean removedAuto = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-1", endpoint,
- restClient, "admin", "admin");
- assertEquals(removedAuto, true);
-
- boolean removedDep = deploymentPolicyTest.removeDeploymentPolicy("deployment-policy-1", endpoint,
- restClient);
- assertEquals(removedDep, true);
-
- boolean removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
- restClient);
- assertEquals(removedNet, true);
-
- boolean removedN2 = networkPartitionTest.removeNetworkPartition("network-partition-2", endpoint,
- restClient);
- assertEquals(removedN2, true);
-
- } catch (Exception e) {
- log.error(e);
- assertTrue("An error occurred while handling application", false);
- }
- }
-
- @Test
- public void testDeployApplication() {
- try {
- //Initializing event Receivers
- initializeApplicationEventReceiver();
- initializeTopologyEventReceiver();
-
- boolean addedScalingPolicy = autoscalingPolicyTest.addAutoscalingPolicy("autoscaling-policy-1.json",
- endpoint, restClient, "admin", "admin");
- assertEquals(addedScalingPolicy, true);
-
- boolean addedC1 = cartridgeTest.addCartridge("c1.json", endpoint, restClient);
- assertEquals(addedC1, true);
-
- boolean addedC2 = cartridgeTest.addCartridge("c2.json", endpoint, restClient);
- assertEquals(addedC2, true);
-
- boolean addedC3 = cartridgeTest.addCartridge("c3.json", endpoint, restClient);
- assertEquals(addedC3, true);
-
-
- boolean addedG1 = cartridgeGroupTest.addCartridgeGroup("cartrdige-nested.json",
- endpoint, restClient);
- assertEquals(addedG1, true);
-
-
- CartridgeGroupBean beanG1 = cartridgeGroupTest.getCartridgeGroup("G1", endpoint,
- restClient);
- assertEquals(beanG1.getName(), "G1");
-
- boolean addedN1 = networkPartitionTest.addNetworkPartition("network-partition-1.json",
- endpoint, restClient);
- assertEquals(addedN1, true);
-
- boolean addedN2 = networkPartitionTest.addNetworkPartition("network-partition-2.json",
- endpoint, restClient);
- assertEquals(addedN2, true);
-
- boolean addedDep = deploymentPolicyTest.addDeploymentPolicy("deployment-policy-1.json",
- endpoint, restClient);
- assertEquals(addedDep, true);
-
-
- boolean added = applicationTest.addApplication("g-sc-G123-1.json",
- endpoint, restClient);
- assertEquals(added, true);
- ApplicationBean bean = applicationTest.getApplication("g-sc-G123-1", endpoint,
- restClient);
- assertEquals(bean.getApplicationId(), "g-sc-G123-1");
-
- boolean addAppPolicy = applicationPolicyTest.addApplicationPolicy(
- "application-policy-1.json", endpoint, restClient);
- assertEquals(addAppPolicy, true);
-
- ApplicationPolicyBean policyBean = applicationPolicyTest.getApplicationPolicy(
- "application-policy-1", endpoint, restClient);
-
- //deploy the application
- boolean deployed = applicationTest.deployApplication(bean.getApplicationId(),
- policyBean.getId(), endpoint, restClient);
- assertEquals(deployed, true);
-
- //Application active handling
- assertApplicationActivation("g-sc-G123-1", -1234);
-
- //Group active handling
- assertGroupActivation("g-sc-G123-1", -1234);
-
- //Cluster active handling
- assertClusterActivation("g-sc-G123-1", -1234);
-
-
- //Updating application
- boolean updated = applicationTest.updateApplication("g-sc-G123-1.json",
- endpoint, restClient);
- assertEquals(updated, true);
-
- assertGroupInstanceCount(bean.getApplicationId(), "group3", 2);
- ApplicationBean updatedBean = applicationTest.getApplication("g-sc-G123-1", endpoint,
- restClient);
- assertEquals(updatedBean.getApplicationId(), "g-sc-G123-1");
-
- /* boolean removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
- restClient);
- assertEquals(removedGroup, false);
-
- boolean removedAuto = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-1", endpoint,
- restClient,"admin","admin");
- assertEquals(removedAuto, false);
-
- boolean removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
- restClient);
- //Trying to remove the used network partition
- assertEquals(removedNet, false);
-
- boolean removedDep = deploymentPolicyTest.removeDeploymentPolicy("deployment-policy-1", endpoint,
- restClient);
- assertEquals(removedDep, false); */
-
- boolean unDeployed = applicationTest.undeployApplication("g-sc-G123-1", endpoint,
- restClient);
- assertEquals(unDeployed, true);
-
- assertApplicationUndeploy("g-sc-G123-1", -1234);
-
- boolean removed = applicationTest.removeApplication("g-sc-G123-1", endpoint,
- restClient);
- assertEquals(removed, true);
-
- ApplicationBean beanRemoved = applicationTest.getApplication("g-sc-G123-1", endpoint,
- restClient);
- assertEquals(beanRemoved, null);
-
- boolean removedGroup = cartridgeGroupTest.removeCartridgeGroup("G1", endpoint,
- restClient);
- assertEquals(removedGroup, true);
-
- boolean removedC1 = cartridgeTest.removeCartridge("c1", endpoint,
- restClient);
- assertEquals(removedC1, true);
-
- boolean removedC2 = cartridgeTest.removeCartridge("c2", endpoint,
- restClient);
- assertEquals(removedC2, true);
-
- boolean removedC3 = cartridgeTest.removeCartridge("c3", endpoint,
- restClient);
- assertEquals(removedC3, true);
-
- boolean removedAuto = autoscalingPolicyTest.removeAutoscalingPolicy("autoscaling-policy-1", endpoint,
- restClient,"admin","admin");
- assertEquals(removedAuto, true);
-
- boolean removedDep = deploymentPolicyTest.removeDeploymentPolicy("deployment-policy-1", endpoint,
- restClient);
- assertEquals(removedDep, true);
-
- //Remove network partition used by application policy
- boolean removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
- restClient);
- assertEquals(removedNet, false);
-
- boolean removedN2 = networkPartitionTest.removeNetworkPartition("network-partition-2", endpoint,
- restClient);
- assertEquals(removedN2, false);
-
- boolean removeAppPolicy = applicationPolicyTest.removeApplicationPolicy("application-policy-1", endpoint,
- restClient);
- assertEquals(removeAppPolicy, true);
-
- removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
- restClient);
- assertEquals(removedNet, true);
-
- removedN2 = networkPartitionTest.removeNetworkPartition("network-partition-2", endpoint,
- restClient);
- assertEquals(removedN2, true);
-
- } catch (Exception e) {
- log.error(e);
- assertTrue("An error occurred while handling autoscaling policy", false);
- }
- }
-
- @Test
- public void testNetworkPartition() {
- try {
- boolean added = networkPartitionTest.addNetworkPartition("network-partition-1.json",
- endpoint, restClient);
- assertEquals(added, true);
- NetworkPartitionBean bean = networkPartitionTest.getNetworkPartition("network-partition-1", endpoint,
- restClient);
- assertEquals(bean.getId(), "network-partition-1");
- assertEquals(bean.getPartitions().size(), 1);
- assertEquals(bean.getPartitions().get(0).getId(), "partition-1");
- assertEquals(bean.getPartitions().get(0).getProperty().get(0).getName(), "region");
- assertEquals(bean.getPartitions().get(0).getProperty().get(0).getValue(), "default");
-
- boolean updated = networkPartitionTest.updateNetworkPartition("network-partition-1.json",
- endpoint, restClient);
- assertEquals(updated, true);
- NetworkPartitionBean updatedBean = networkPartitionTest.getNetworkPartition("network-partition-1", endpoint,
- restClient);
- assertEquals(updatedBean.getId(), "network-partition-1");
- assertEquals(updatedBean.getPartitions().size(), 2);
- assertEquals(updatedBean.getPartitions().get(1).getId(), "partition-2");
- assertEquals(updatedBean.getPartitions().get(1).getProperty().get(0).getName(), "region");
- assertEquals(updatedBean.getPartitions().get(1).getProperty().get(0).getValue(), "default1");
- assertEquals(updatedBean.getPartitions().get(1).getProperty().get(1).getName(), "zone");
- assertEquals(updatedBean.getPartitions().get(1).getProperty().get(1).getValue(), "z1");
-
- boolean removed = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
- restClient);
- assertEquals(removed, true);
-
- NetworkPartitionBean beanRemoved = networkPartitionTest.getNetworkPartition("network-partition-1", endpoint,
- restClient);
- assertEquals(beanRemoved, null);
-
- } catch (Exception e) {
- log.error(e);
- assertTrue("An error occurred while handling network partitions", false);
- }
- }
-
- @Test
- public void testDeploymentPolicy() {
- try {
- boolean addedN1 = networkPartitionTest.addNetworkPartition("network-partition-1.json",
- endpoint, restClient);
- assertEquals(addedN1, true);
-
- boolean addedN2 = networkPartitionTest.addNetworkPartition("network-partition-2.json",
- endpoint, restClient);
- assertEquals(addedN2, true);
-
- boolean addedDep = deploymentPolicyTest.addDeploymentPolicy("deployment-policy-1.json",
- endpoint, restClient);
- assertEquals(addedDep, true);
-
- DeploymentPolicyBean bean = deploymentPolicyTest.getDeploymentPolicy(
- "deployment-policy-1", endpoint, restClient);
- assertEquals(bean.getId(), "deployment-policy-1");
- assertEquals(bean.getNetworkPartitions().size(), 2);
- assertEquals(bean.getNetworkPartitions().get(0).getId(), "network-partition-1");
- assertEquals(bean.getNetworkPartitions().get(0).getPartitionAlgo(), "one-after-another");
- assertEquals(bean.getNetworkPartitions().get(0).getPartitions().size(), 1);
- assertEquals(bean.getNetworkPartitions().get(0).getPartitions().get(0).getId(), "partition-1");
- assertEquals(bean.getNetworkPartitions().get(0).getPartitions().get(0).getPartitionMax(), 20);
-
- assertEquals(bean.getNetworkPartitions().get(1).getId(), "network-partition-2");
- assertEquals(bean.getNetworkPartitions().get(1).getPartitionAlgo(), "round-robin");
- assertEquals(bean.getNetworkPartitions().get(1).getPartitions().size(), 2);
- assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(0).getId(),
- "network-partition-2-partition-1");
- assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(0).getPartitionMax(), 10);
- assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
- "network-partition-2-partition-2");
- assertEquals(bean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 9);
-
- //update network partition
- boolean updated = networkPartitionTest.updateNetworkPartition("network-partition-1.json",
- endpoint, restClient);
- assertEquals(updated, true);
-
- //update deployment policy with new partition and max values
-
- boolean updatedDep = deploymentPolicyTest.updateDeploymentPolicy("deployment-policy-1.json",
- endpoint, restClient);
- assertEquals(updatedDep, true);
-
- DeploymentPolicyBean updatedBean = deploymentPolicyTest.getDeploymentPolicy(
- "deployment-policy-1", endpoint, restClient);
- assertEquals(updatedBean.getId(), "deployment-policy-1");
- assertEquals(updatedBean.getNetworkPartitions().size(), 2);
- assertEquals(updatedBean.getNetworkPartitions().get(0).getId(), "network-partition-1");
- assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitionAlgo(), "one-after-another");
- assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().size(), 2);
- assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(0).getId(), "partition-1");
- assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(0).getPartitionMax(), 25);
- assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(1).getId(), "partition-2");
- assertEquals(updatedBean.getNetworkPartitions().get(0).getPartitions().get(1).getPartitionMax(), 20);
-
- assertEquals(updatedBean.getNetworkPartitions().get(1).getId(), "network-partition-2");
- assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitionAlgo(), "round-robin");
- assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().size(), 2);
- assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(0).getId(),
- "network-partition-2-partition-1");
- assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(0).getPartitionMax(), 15);
- assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
- "network-partition-2-partition-2");
- assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 5);
-
- boolean removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
- restClient);
- //Trying to remove the used network partition
- assertEquals(removedNet, false);
-
- boolean removedDep = deploymentPolicyTest.removeDeploymentPolicy("deployment-policy-1", endpoint,
- restClient);
- assertEquals(removedDep, true);
-
- DeploymentPolicyBean beanRemovedDep = deploymentPolicyTest.getDeploymentPolicy("deployment-policy-1", endpoint,
- restClient);
- assertEquals(beanRemovedDep, null);
-
- boolean removedN1 = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
- restClient);
- assertEquals(removedN1, true);
-
- NetworkPartitionBean beanRemovedN1 = networkPartitionTest.getNetworkPartition("network-partition-1", endpoint,
- restClient);
- assertEquals(beanRemovedN1, null);
-
- boolean removedN2 = networkPartitionTest.removeNetworkPartition("network-partition-2", endpoint,
- restClient);
- assertEquals(removedN2, true);
-
- NetworkPartitionBean beanRemovedN2 = networkPartitionTest.getNetworkPartition("network-partition-2", endpoint,
- restClient);
- assertEquals(beanRemovedN2, null);
-
- } catch (Exception e) {
- log.error(e);
- assertTrue("An error occurred while handling autoscaling policy", false);
- }
- }
-
- @Test
- public void testCartridge() {
- try {
- boolean added = cartridgeTest.addCartridge("c0.json", endpoint, restClient);
- assertEquals(added, true);
- CartridgeBean bean = cartridgeTest.getCartridge("c0", endpoint, restClient);
- assertEquals(bean.getType(), "c0");
- assertEquals(bean.getCategory(), "Application");
- assertEquals(bean.getHost(), "qmog.cisco.com");
- for (PropertyBean property : bean.getProperty()) {
- if (property.getName().equals("payload_parameter.CEP_IP")) {
- assertEquals(property.getValue(), "octl.qmog.cisco.com");
- } else if (property.getName().equals("payload_parameter.CEP_ADMIN_PASSWORD")) {
- assertEquals(property.getValue(), "admin");
- } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_IP")) {
- assertEquals(property.getValue(), "octl.qmog.cisco.com");
- } else if (property.getName().equals("payload_parameter.QTCM_NETWORK_COUNT")) {
- assertEquals(property.getValue(), "1");
- } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD")) {
- assertEquals(property.getValue(), "admin");
- } else if (property.getName().equals("payload_parameter.QTCM_DNS_SEGMENT")) {
- assertEquals(property.getValue(), "test");
- } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_SECURE_PORT")) {
- assertEquals(property.getValue(), "7711");
- } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_PORT")) {
- assertEquals(property.getValue(), "7611");
- } else if (property.getName().equals("payload_parameter.CEP_PORT")) {
- assertEquals(property.getValue(), "7611");
- } else if (property.getName().equals("payload_parameter.MB_PORT")) {
- assertEquals(property.getValue(), "61616");
- }
- }
-
-
- boolean updated = cartridgeTest.updateCartridge("c0.json",
- endpoint, restClient);
- assertEquals(updated, true);
- CartridgeBean updatedBean = cartridgeTest.getCartridge("c0", endpoint,
- restClient);
- assertEquals(updatedBean.getType(), "c0");
- assertEquals(updatedBean.getCategory(), "Data");
- assertEquals(updatedBean.getHost(), "qmog.cisco.com12");
- for (PropertyBean property : updatedBean.getProperty()) {
- if (property.getName().equals("payload_parameter.CEP_IP")) {
- assertEquals(property.getValue(), "octl.qmog.cisco.com123");
- } else if (property.getName().equals("payload_parameter.CEP_ADMIN_PASSWORD")) {
- assertEquals(property.getValue(), "admin123");
- } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_IP")) {
- assertEquals(property.getValue(), "octl.qmog.cisco.com123");
- } else if (property.getName().equals("payload_parameter.QTCM_NETWORK_COUNT")) {
- assertEquals(property.getValue(), "3");
- } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_ADMIN_PASSWORD")) {
- assertEquals(property.getValue(), "admin123");
- } else if (property.getName().equals("payload_parameter.QTCM_DNS_SEGMENT")) {
- assertEquals(property.getValue(), "test123");
- } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_SECURE_PORT")) {
- assertEquals(property.getValue(), "7712");
- } else if (property.getName().equals("payload_parameter.MONITORING_SERVER_PORT")) {
- assertEquals(property.getValue(), "7612");
- } else if (property.getName().equals("payload_parameter.CEP_PORT")) {
- assertEquals(property.getValue(), "7612");
- } else if (property.getName().equals("payload_parameter.MB_PORT")) {
- assertEquals(property.getValue(), "61617");
- }
- }
-
- boolean removed = cartridgeTest.removeCartridge("c0", endpoint,
- restClient);
- assertEquals(removed, true);
-
- CartridgeBean beanRemoved = cartridgeTest.getCartridge("c0", endpoint,
- restClient);
- assertEquals(beanRemoved, null);
-
- } catch (Exception e) {
- log.error(e);
- assertTrue("An error occurred while handling cartridges", false);
- }
- }
-
-
- private void runApplicationTest(String applicationId) {
- runApplicationTest(applicationId, applicationId);
- }
-
- private void runApplicationTest(String applicationFolderName, String applicationId) {
- executeCommand(getApplicationsPath() + "/" + applicationFolderName + "/scripts/mock/deploy.sh");
- assertApplicationActivation(applicationId, -1234);
- executeCommand(getApplicationsPath() + "/" + applicationFolderName + "/scripts/mock/undeploy.sh");
- assertApplicationNotExists(applicationId);
- }
-
- /**
- * Initialize application event receiver
- */
- private void initializeApplicationEventReceiver() {
- if (applicationsEventReceiver == null) {
- applicationsEventReceiver = new ApplicationsEventReceiver();
- ExecutorService executorService = StratosThreadPool.getExecutorService("STRATOS_TEST_SERVER", 1);
- applicationsEventReceiver.setExecutorService(executorService);
- applicationsEventReceiver.execute();
- }
- }
-
- /**
- * Initialize Topology event receiver
- */
- private void initializeTopologyEventReceiver() {
- if (topologyEventReceiver == null) {
- topologyEventReceiver = new TopologyEventReceiver();
- ExecutorService executorService = StratosThreadPool.getExecutorService("STRATOS_TEST_SERVER1", 1);
- topologyEventReceiver.setExecutorService(executorService);
- topologyEventReceiver.execute();
- }
- }
-
- /**
- * Execute shell command
- *
- * @param commandText
- */
- private void executeCommand(String commandText) {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- try {
- CommandLine commandline = CommandLine.parse(commandText);
- DefaultExecutor exec = new DefaultExecutor();
- PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream);
- exec.setStreamHandler(streamHandler);
- exec.execute(commandline);
- log.info(outputStream.toString());
- } catch (Exception e) {
- log.error(outputStream.toString(), e);
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Assert application activation
- *
- * @param applicationId
- */
- private void assertApplicationActivation(String applicationId, int tenantId) {
- long startTime = System.currentTimeMillis();
- Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationId, tenantId);
- while (!((application != null) && (application.getStatus() == ApplicationStatus.Active))) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignore) {
- }
- application = ApplicationManager.getApplications().getApplicationByTenant(applicationId, tenantId);
- if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
- break;
- }
- }
- assertNotNull(String.format("Application is not found: [application-id] %s", application.getId()), application);
- assertEquals(String.format("Application status did not change to active: [application-id] %s", application.getId()),
- ApplicationStatus.Active, application.getStatus());
- }
-
- /**
- * Assert application activation
- *
- * @param applicationId
- */
- private void assertGroupActivation(String applicationId, int tenantId) {
- Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationId, tenantId);
- assertNotNull(String.format("Application is not found: [application-id] %s",
- applicationId), application);
-
- Collection<Group> groups = application.getAllGroupsRecursively();
- for(Group group : groups) {
- assertEquals(group.getInstanceContextCount() >= group.getGroupMinInstances(), true);
- }
- }
-
- /**
- * Assert application activation
- *
- * @param applicationId
- */
- private void assertClusterActivation(String applicationId, int tenantId) {
- Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationId, tenantId);
- assertNotNull(String.format("Application is not found: [application-id] %s",
- applicationId), application);
-
- Set<ClusterDataHolder> clusterDataHolderSet = application.getClusterDataRecursively();
- for(ClusterDataHolder clusterDataHolder : clusterDataHolderSet) {
- String serviceUuid = clusterDataHolder.getServiceUuid();
- String clusterId = clusterDataHolder.getClusterId();
- Service service = TopologyManager.getTopology().getService(serviceUuid);
- assertNotNull(String.format("Service is not found: [application-id] %s [service] %s",
- applicationId, serviceUuid), service);
-
- Cluster cluster = service.getCluster(clusterId);
- assertNotNull(String.format("Cluster is not found: [application-id] %s [service] %s [cluster-id] %s",
- applicationId, serviceUuid, clusterId), cluster);
- boolean clusterActive = false;
-
- for (ClusterInstance instance : cluster.getInstanceIdToInstanceContextMap().values()) {
- int activeInstances = 0;
- for (Member member : cluster.getMembers()) {
- if (member.getClusterInstanceId().equals(instance.getInstanceId())) {
- if (member.getStatus().equals(MemberStatus.Active)) {
- activeInstances++;
- }
- }
- }
- clusterActive = activeInstances >= clusterDataHolder.getMinInstances();
- log.info(String.format("Active instance count: %s, Min instance count: %s", activeInstances,
- clusterDataHolder.getMinInstances()));
-
- if (!clusterActive) {
- break;
- }
- }
- assertEquals(String.format("Cluster status did not change to active: [cluster-id] %s", clusterId),
- clusterActive, true);
- }
-
- }
-
-
- /**
- * Assert application activation
- *
- * @param applicationId
- */
- private void assertApplicationUndeploy(String applicationId, int tenantId) {
- long startTime = System.currentTimeMillis();
- Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationId, tenantId);
- ApplicationContext applicationContext = null;
- try {
- applicationContext = AutoscalerServiceClient.getInstance().getApplicationByTenant(applicationId, tenantId);
- } catch (RemoteException e) {
- log.error("Error while getting the application context for [application] " + applicationId);
- }
- while (((application != null) && application.getInstanceContextCount() > 0) ||
- (applicationContext == null || applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING))) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignore) {
- }
- application = ApplicationManager.getApplications().getApplicationByTenant(applicationId, tenantId);
- try {
- applicationContext = AutoscalerServiceClient.getInstance().getApplicationByTenant(applicationId, tenantId);
- } catch (RemoteException e) {
- log.error("Error while getting the application context for [application] " + applicationId);
- }
- if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
- break;
- }
- }
-
- assertNotNull(String.format("Application is not found: [application-id] %s", applicationId), application);
- assertNotNull(String.format("Application Context is not found: [application-id] %s", applicationId),
- applicationContext);
-
- //Force undeployment after the graceful deployment
- if (application.getInstanceContextCount() > 0 ||
- applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING)) {
- log.info("Force undeployment is going to start for the [application] " + applicationId);
-
- applicationTest.forceUndeployApplication(applicationId, endpoint, restClient);
- while (application.getInstanceContextCount() > 0 ||
- applicationContext.getStatus().equals(APPLICATION_STATUS_UNDEPLOYING)) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignore) {
- }
- application = ApplicationManager.getApplications().getApplicationByTenant(applicationId, tenantId);
- if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
- break;
- }
- }
- }
- assertEquals(String.format("Application status did not change to Created: [application-id] %s", applicationId),
- APPLICATION_STATUS_CREATED, applicationContext.getStatus());
-
- }
-
- /**
- * Assert application activation
- *
- * @param applicationName
- */
- private void assertGroupInstanceCount(String applicationName, String groupAlias, int count) {
- long startTime = System.currentTimeMillis();
- Application application = ApplicationManager.getApplications().getApplicationByTenant(applicationName,-1234);
- if (application != null) {
- Group group = application.getGroupRecursively(groupAlias);
- while (group.getInstanceContextCount() != count) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignore) {
- }
- if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
- break;
- }
- }
- for (GroupInstance instance : group.getInstanceIdToInstanceContextMap().values()) {
- while (!instance.getStatus().equals(GroupStatus.Active)) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignore) {
- }
- if ((System.currentTimeMillis() - startTime) > APPLICATION_ACTIVATION_TIMEOUT) {
- break;
- }
- }
- }
- assertEquals(String.format("Application status did not change to active: [application-id] %s", applicationName),
- group.getInstanceContextCount(), count);
- }
- assertNotNull(String.format("Application is not found: [application-id] %s", applicationName), application);
-
- }
-
- private void assertApplicationNotExists(String applicationName) {
- Application application = ApplicationManager.getApplications().getApplication(applicationName);
- assertNull(String.format("Application is found in the topology : [application-id] %s", applicationName), application);
- }
-
- /**
- * Get applications folder path
- *
- * @return
- */
- private String getApplicationsPath() {
- return getResourcesFolderPath() + "/../../../../../../samples/applications";
- }
-
- /**
- * Get resources folder path
- *
- * @return
- */
- private String getResourcesFolderPath() {
- String path = getClass().getResource("/").getPath();
- return StringUtils.removeEnd(path, File.separator);
- }
-
- private String getArtifactsPath() {
- return getResourcesFolderPath() + "/../../src/test/resources";
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosArtifactsUtils.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosArtifactsUtils.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosArtifactsUtils.java
deleted file mode 100644
index 9a81972..0000000
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosArtifactsUtils.java
+++ /dev/null
@@ -1,53 +0,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.
- */
-package org.apache.stratos.integration.tests;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonParser;
-import org.apache.commons.lang.StringUtils;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-
-/**
- * Util class
- */
-public class StratosArtifactsUtils {
-
- public String getJsonStringFromFile(String filePath) throws FileNotFoundException {
- JsonParser parser = new JsonParser();
- Object object = parser.parse(new FileReader(getResourcesFolderPath() + filePath));
- GsonBuilder gsonBuilder = new GsonBuilder();
- Gson gson = gsonBuilder.create();
- String content = gson.toJson(object);
- return content;
-
- }
-
- /**
- * Get resources folder path
- * @return
- */
- private String getResourcesFolderPath() {
- String path = getClass().getResource("/").getPath();
- return StringUtils.removeEnd(path, File.separator);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
index 4e7f404..f5648d6 100755
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/StratosTestServerManager.java
@@ -26,6 +26,8 @@ import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.stratos.common.test.TestLogAppender;
+import org.apache.stratos.integration.tests.application.SampleApplicationsTest;
+import org.apache.stratos.integration.tests.rest.RestClient;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.wso2.carbon.integration.framework.TestServerManager;
@@ -53,20 +55,23 @@ public class StratosTestServerManager extends TestServerManager {
private static final String MOCK_IAAS_XML_FILE = "mock-iaas.xml";
private static final String JNDI_PROPERTIES_FILE = "jndi.properties";
private static final String JMS_OUTPUT_ADAPTER_FILE = "JMSOutputAdaptor.xml";
+ protected RestClient restClient;
+ private String endpoint = "https://localhost:9443";
+ private BrokerService broker = new BrokerService();
+ private TestLogAppender testLogAppender = new TestLogAppender();
private ServerUtils serverUtils;
private String carbonHome;
public StratosTestServerManager() {
super(CARBON_ZIP, PORT_OFFSET);
serverUtils = new ServerUtils();
+ restClient = new RestClient(endpoint, "admin", "admin");
}
@Override
@BeforeSuite(timeOut = 600000)
public String startServer() throws IOException {
-
- TestLogAppender testLogAppender = new TestLogAppender();
Logger.getRootLogger().addAppender(testLogAppender);
Logger.getRootLogger().setLevel(Level.INFO);
@@ -74,13 +79,15 @@ public class StratosTestServerManager extends TestServerManager {
// Start ActiveMQ
long time1 = System.currentTimeMillis();
log.info("Starting ActiveMQ...");
- BrokerService broker = new BrokerService();
+ broker.setDataDirectory(StratosTestServerManager.class.getResource("/").getPath() +
+ File.separator + ".." + File.separator + "activemq-data");
broker.setBrokerName("testBroker");
broker.addConnector(ACTIVEMQ_BIND_ADDRESS);
broker.start();
long time2 = System.currentTimeMillis();
- log.info(String.format("ActiveMQ started in %d sec", (time2 - time1)/1000));
- } catch (Exception e) {
+ log.info(String.format("ActiveMQ started in %d sec", (time2 - time1) / 1000));
+ }
+ catch (Exception e) {
throw new RuntimeException("Could not start ActiveMQ", e);
}
@@ -104,24 +111,48 @@ public class StratosTestServerManager extends TestServerManager {
this.serverUtils.startServerUsingCarbonHome(carbonHome, carbonHome, "stratos", PORT_OFFSET, null);
FrameworkSettings.init();
- while (!serverStarted(testLogAppender)) {
+ while (!serverStarted()) {
log.info("Waiting for topology to be initialized...");
Thread.sleep(5000);
}
+ while (!mockServiceStarted()) {
+ log.info("Waiting for mock service to be initialized...");
+ Thread.sleep(1000);
+ }
+
long time4 = System.currentTimeMillis();
- log.info(String.format("Stratos server started in %d sec", (time4 - time3)/1000));
+ log.info(String.format("Stratos server started in %d sec", (time4 - time3) / 1000));
return carbonHome;
}
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new RuntimeException("Could not start Stratos server", e);
}
}
+ private boolean mockServiceStarted() {
+ for (String message : testLogAppender.getMessages()) {
+ if (message.contains("Mock IaaS service component activated")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
@AfterSuite(timeOut = 600000)
public void stopServer() throws Exception {
super.stopServer();
+ /*
+ while (!serverStopped()) {
+ log.info("Waiting for server to be shutdown...");
+ Thread.sleep(1000);
+ }
+ log.info("Stopped Apache Stratos server.");
+ */
+ broker.stop();
+ log.info("Stopped ActiveMQ server.");
}
protected void copyArtifacts(String carbonHome) throws IOException {
@@ -144,9 +175,19 @@ public class StratosTestServerManager extends TestServerManager {
log.info(sourceFilePath + " file copied");
}
- private boolean serverStarted(TestLogAppender testLogAppender) {
- for(String message : testLogAppender.getMessages()) {
- if(message.contains("Topology initialized")) {
+ private boolean serverStopped() {
+ for (String message : testLogAppender.getMessages()) {
+ if (message.contains("Halting JVM")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ private boolean serverStarted() {
+ for (String message : testLogAppender.getMessages()) {
+ if (message.contains("Topology initialized")) {
return true;
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
index 208f960..34a9d75 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/rest/RestClient.java
@@ -19,19 +19,32 @@
package org.apache.stratos.integration.tests.rest;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonParser;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.http.client.methods.*;
+import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.net.URI;
/**
* Rest client to handle rest requests
*/
public class RestClient {
-
+ private static final Log log = LogFactory.getLog(RestClient.class);
private DefaultHttpClient httpClient;
+ private String endPoint;
+ private String userName;
+ private String password;
public RestClient() {
PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
@@ -44,17 +57,22 @@ public class RestClient {
httpClient = (DefaultHttpClient) WebClientWrapper.wrapClient(httpClient);
}
+ public RestClient(String endPoint, String userName, String password) {
+ this();
+ this.endPoint = endPoint;
+ this.userName = userName;
+ this.password = password;
+ }
+
/**
* Handle http post request. Return String
*
* @param resourcePath This should be REST endpoint
* @param jsonParamString The json string which should be executed from the post request
- * @param userName
- * @param password
* @return The HttpResponse
* @throws Exception if any errors occur when executing the request
*/
- public HttpResponse doPost(URI resourcePath, String jsonParamString, String userName, String password) throws Exception {
+ public HttpResponse doPost(URI resourcePath, String jsonParamString) throws Exception {
HttpPost postRequest = null;
try {
postRequest = new HttpPost(resourcePath);
@@ -62,7 +80,7 @@ public class RestClient {
input.setContentType("application/json");
postRequest.setEntity(input);
- String userPass = userName + ":" + password;
+ String userPass = getUsernamePassword();
String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
postRequest.addHeader("Authorization", basicAuth);
@@ -76,18 +94,16 @@ public class RestClient {
* Handle http get request. Return String
*
* @param resourcePath This should be REST endpoint
- * @param userName
- * @param password
* @return The HttpResponse
* @throws org.apache.http.client.ClientProtocolException and IOException
* if any errors occur when executing the request
*/
- public HttpResponse doGet(URI resourcePath, String userName, String password) throws Exception {
+ public HttpResponse doGet(URI resourcePath) throws Exception {
HttpGet getRequest = null;
try {
getRequest = new HttpGet(resourcePath);
getRequest.addHeader("Content-Type", "application/json");
- String userPass = userName + ":" + password;
+ String userPass = getUsernamePassword();
String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
getRequest.addHeader("Authorization", basicAuth);
@@ -97,12 +113,12 @@ public class RestClient {
}
}
- public HttpResponse doDelete(URI resourcePath, String userName, String password) throws Exception {
+ public HttpResponse doDelete(URI resourcePath) throws Exception {
HttpDelete httpDelete = null;
try {
httpDelete = new HttpDelete(resourcePath);
httpDelete.addHeader("Content-Type", "application/json");
- String userPass = userName + ":" + password;
+ String userPass = getUsernamePassword();
String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
httpDelete.addHeader("Authorization", basicAuth);
return httpClient.execute(httpDelete, new HttpResponseHandler());
@@ -111,7 +127,7 @@ public class RestClient {
}
}
- public HttpResponse doPut(URI resourcePath, String jsonParamString, String userName, String password) throws Exception {
+ public HttpResponse doPut(URI resourcePath, String jsonParamString) throws Exception {
HttpPut putRequest = null;
try {
@@ -120,7 +136,7 @@ public class RestClient {
StringEntity input = new StringEntity(jsonParamString);
input.setContentType("application/json");
putRequest.setEntity(input);
- String userPass = userName + ":" + password;
+ String userPass = getUsernamePassword();
String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
putRequest.addHeader("Authorization", basicAuth);
return httpClient.execute(putRequest, new HttpResponseHandler());
@@ -134,4 +150,208 @@ public class RestClient {
request.releaseConnection();
}
}
+
+ public boolean addEntity(String filePath, String resourcePath, String entityName) {
+ try {
+ String content = getJsonStringFromFile(filePath);
+ URI uri = new URIBuilder(this.endPoint + resourcePath).build();
+
+ HttpResponse response = doPost(uri, content);
+ if (response != null) {
+ if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+ return true;
+ } else {
+ GsonBuilder gsonBuilder = new GsonBuilder();
+ Gson gson = gsonBuilder.create();
+ ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+ if (errorResponse != null) {
+ throw new RuntimeException(errorResponse.getErrorMessage());
+ }
+ }
+ }
+ String msg = "An unknown error occurred while trying to add ";
+ log.error(msg + entityName);
+ throw new RuntimeException(msg + entityName);
+ } catch (Exception e) {
+ String message = "Could not add " + entityName;
+ log.error(message, e);
+ throw new RuntimeException(message, e);
+ }
+ }
+
+ public boolean deployEntity(String resourcePath, String entityName) {
+ try {
+ URI uri = new URIBuilder(this.endPoint + resourcePath).build();
+
+ HttpResponse response = doPost(uri, "");
+ if (response != null) {
+ if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+ return true;
+ } else {
+ GsonBuilder gsonBuilder = new GsonBuilder();
+ Gson gson = gsonBuilder.create();
+ ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+ if (errorResponse != null) {
+ throw new RuntimeException(errorResponse.getErrorMessage());
+ }
+ }
+ }
+ String msg = "An unknown error occurred while trying to deploy ";
+ log.error(msg + entityName);
+ throw new RuntimeException(msg + entityName);
+ } catch (Exception e) {
+ String message = "Could not deploy " + entityName;
+ log.error(message, e);
+ throw new RuntimeException(message, e);
+ }
+ }
+
+ public boolean undeployEntity(String resourcePath, String entityName) {
+ try {
+ URI uri = new URIBuilder(this.endPoint + resourcePath).build();
+
+ HttpResponse response = doPost(uri, "");
+ if (response != null) {
+ if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+ return true;
+ } else {
+ GsonBuilder gsonBuilder = new GsonBuilder();
+ Gson gson = gsonBuilder.create();
+ ErrorResponse errorResponse = gson.fromJson(response.getContent(), ErrorResponse.class);
+ if (errorResponse != null) {
+ throw new RuntimeException(errorResponse.getErrorMessage());
+ }
+ }
+ }
+ String msg = "An unknown error occurred while trying to undeploy ";
+ log.error(msg + entityName);
+ throw new RuntimeException(msg + entityName);
+ } catch (Exception e) {
+ String message = "Could not deploy " + entityName;
+ log.error(message, e);
+ throw new RuntimeException(message, e);
+ }
+ }
+
+ public Object getEntity(String resourcePath, String identifier, Class responseJsonClass,
+ String entityName) {
+ try {
+ URI uri = new URIBuilder(this.endPoint + resourcePath + "/" + identifier).build();
+ HttpResponse response = doGet(uri);
+ GsonBuilder gsonBuilder = new GsonBuilder();
+ Gson gson = gsonBuilder.create();
+ if (response != null) {
+ if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+ return gson.fromJson(response.getContent(), responseJsonClass);
+ } else if (response.getStatusCode() == 404) {
+ return null;
+ } else {
+ ErrorResponse errorResponse = gson.fromJson(response.getContent(),
+ ErrorResponse.class);
+ if (errorResponse != null) {
+ throw new RuntimeException(errorResponse.getErrorMessage());
+ }
+ }
+ }
+ String msg = "An unknown error occurred while getting the " + entityName;
+ log.error(msg);
+ throw new RuntimeException(msg);
+ } catch (Exception e) {
+ String message = "Could not get " + entityName;
+ log.error(message, e);
+ throw new RuntimeException(message, e);
+ }
+ }
+
+ public boolean removeEntity(String resourcePath, String identifier, String entityName) {
+ try {
+ URI uri = new URIBuilder(this.endPoint + "/" + resourcePath + "/" + identifier).build();
+ HttpResponse response = doDelete(uri);
+ if (response != null) {
+ if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+ return true;
+ } else if (response.getContent().contains("it is used") || response.getContent().contains("in use")) {
+ return false;
+ } else {
+ GsonBuilder gsonBuilder = new GsonBuilder();
+ Gson gson = gsonBuilder.create();
+ ErrorResponse errorResponse = gson.fromJson(response.getContent(),
+ ErrorResponse.class);
+ if (errorResponse != null) {
+ throw new RuntimeException(errorResponse.getErrorMessage());
+ }
+ }
+ }
+ String msg = "An unknown error occurred while removing the " + entityName;
+ log.error(msg);
+ throw new RuntimeException(msg);
+ } catch (Exception e) {
+ String message = "Could not remove " + entityName;
+ log.error(message, e);
+ throw new RuntimeException(message, e);
+ }
+ }
+
+ public boolean updateEntity(String filePath, String resourcePath, String entityName) {
+ try {
+ String content = getJsonStringFromFile(filePath);
+ URI uri = new URIBuilder(this.endPoint + resourcePath).build();
+
+ HttpResponse response = doPut(uri, content);
+ if (response != null) {
+ if ((response.getStatusCode() >= 200) && (response.getStatusCode() < 300)) {
+ return true;
+ } else {
+ GsonBuilder gsonBuilder = new GsonBuilder();
+ Gson gson = gsonBuilder.create();
+ ErrorResponse errorResponse = gson.fromJson(response.getContent(),
+ ErrorResponse.class);
+ if (errorResponse != null) {
+ throw new RuntimeException(errorResponse.getErrorMessage());
+ }
+ }
+ }
+ String msg = "An unknown error occurred while trying to update ";
+ log.error(msg + entityName);
+ throw new RuntimeException(msg + entityName);
+ } catch (Exception e) {
+ String message = "Could not update " + entityName;
+ log.error(message, e);
+ throw new RuntimeException(message, e);
+ }
+ }
+
+ /**
+ * Get the json string from the artifacts directory
+ *
+ * @param filePath path of the artifacts
+ * @return json string of the relevant artifact
+ * @throws FileNotFoundException
+ */
+ public String getJsonStringFromFile(String filePath) throws FileNotFoundException {
+ JsonParser parser = new JsonParser();
+ Object object = parser.parse(new FileReader(getResourcesFolderPath() + filePath));
+ GsonBuilder gsonBuilder = new GsonBuilder();
+ Gson gson = gsonBuilder.create();
+ return gson.toJson(object);
+ }
+
+ /**
+ * Get resources folder path
+ *
+ * @return the resource path
+ */
+ private String getResourcesFolderPath() {
+ String path = getClass().getResource("/").getPath();
+ return StringUtils.removeEnd(path, File.separator);
+ }
+
+ /**
+ * Get the username and password
+ *
+ * @return username:password
+ */
+ private String getUsernamePassword() {
+ return this.userName + ":" + this.password;
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/application-policies/application-policy-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/application-policies/application-policy-1.json b/products/stratos/modules/integration/src/test/resources/application-policies/application-policy-1.json
deleted file mode 100644
index 12b9bd4..0000000
--- a/products/stratos/modules/integration/src/test/resources/application-policies/application-policy-1.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "id": "application-policy-1",
- "algorithm": "one-after-another",
- "networkPartitions": [
- "network-partition-1",
- "network-partition-2"
- ],
- "properties": [
- {
- "name": "key-1",
- "value": "network-partition-1,network-partition-2"
- },
- {
- "name": "key-2",
- "value": "value-2"
- }
- ]
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/README.md
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/README.md b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/README.md
deleted file mode 100644
index 4e092ea..0000000
--- a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/README.md
+++ /dev/null
@@ -1,25 +0,0 @@
-Single Cartridge Application
-============================
-A simple application with a php cartridge.
-
-Application view
-----------------
-single-cartridge-app <br />
--- single-cartridge-app-1 <br />
--- -- my-php <br />
-
-Application folder structure
-----------------------------
--- artifacts/[iaas]/ IaaS specific artifacts <br />
--- scripts/common/ Common scripts for all iaases <br />
--- scripts/[iaas] IaaS specific scripts <br />
-
-How to run
-----------
-cd scripts/[iaas]/ <br />
-./deploy.sh <br />
-
-How to undeploy
----------------
-cd scripts/[iaas]/ <br />
-./undeploy.sh <br />
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/g-sc-G123-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/g-sc-G123-1.json b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/g-sc-G123-1.json
deleted file mode 100644
index 76d72c8..0000000
--- a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/g-sc-G123-1.json
+++ /dev/null
@@ -1,86 +0,0 @@
-{
- "alias": "g-sc-G123-1",
- "applicationId": "g-sc-G123-1",
- "components": {
- "cartridges": [],
- "groups": [
- {
- "name": "G1",
- "groupMaxInstances": 1,
- "groupMinInstances": 1,
- "alias": "group1",
- "cartridges": [
- {
- "cartridgeMin": 1,
- "cartridgeMax": 2,
- "type": "c1",
- "subscribableInfo": {
- "alias": "c1-1x0",
- "deploymentPolicy": "deployment-policy-1",
- "artifactRepository": {
- "repoUsername": "user",
- "repoUrl": "http://stratos.apache.org:10080/git/default.git",
- "privateRepo": true,
- "repoPassword": "c-policy"
- },
- "autoscalingPolicy": "autoscaling-policy-1"
- }
- }
- ],
- "groups": [
- {
- "name": "G2",
- "groupMaxInstances": 1,
- "groupMinInstances": 1,
- "alias": "group2",
- "cartridges": [
- {
- "cartridgeMin": 1,
- "cartridgeMax": 2,
- "type": "c2",
- "subscribableInfo": {
- "alias": "c2-1x0",
- "deploymentPolicy": "deployment-policy-1",
- "artifactRepository": {
- "repoUsername": "user",
- "repoUrl": "http://stratos.apache.org:10080/git/default.git",
- "privateRepo": true,
- "repoPassword": "c-policy"
- },
- "autoscalingPolicy": "autoscaling-policy-1"
- }
- }
- ],
- "groups": [
- {
- "name": "G3",
- "groupMaxInstances": 2,
- "groupMinInstances": 1,
- "deploymentPolicy": "deployment-policy-1",
- "alias": "group3",
- "cartridges": [
- {
- "cartridgeMin": 1,
- "cartridgeMax": 2,
- "type": "c3",
- "subscribableInfo": {
- "alias": "c3-1x0",
- "artifactRepository": {
- "repoUsername": "user",
- "repoUrl": "http://stratos.apache.org:10080/git/default.git",
- "privateRepo": true,
- "repoPassword": "c-policy"
- },
- "autoscalingPolicy": "autoscaling-policy-1"
- }
- }
- ],
- "groups": []
- }
- ]
- }
- ]
- }
- ]
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4b96ba01/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1.json
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1.json b/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1.json
deleted file mode 100644
index a91c4e0..0000000
--- a/products/stratos/modules/integration/src/test/resources/applications/simple/single-cartridge-app/update/g-sc-G123-1.json
+++ /dev/null
@@ -1,86 +0,0 @@
-{
- "alias": "g-sc-G123-1",
- "applicationId": "g-sc-G123-1",
- "components": {
- "cartridges": [],
- "groups": [
- {
- "name": "G1",
- "groupMaxInstances": 1,
- "groupMinInstances": 1,
- "alias": "group1",
- "cartridges": [
- {
- "cartridgeMin": 2,
- "cartridgeMax": 3,
- "type": "c1",
- "subscribableInfo": {
- "alias": "c1-1x0",
- "deploymentPolicy": "deployment-policy-1",
- "artifactRepository": {
- "repoUsername": "user",
- "repoUrl": "http://stratos.apache.org:10080/git/default.git",
- "privateRepo": true,
- "repoPassword": "c-policy"
- },
- "autoscalingPolicy": "autoscaling-policy-1"
- }
- }
- ],
- "groups": [
- {
- "name": "G2",
- "groupMaxInstances": 1,
- "groupMinInstances": 1,
- "alias": "group2",
- "cartridges": [
- {
- "cartridgeMin": 2,
- "cartridgeMax": 4,
- "type": "c2",
- "subscribableInfo": {
- "alias": "c2-1x0",
- "deploymentPolicy": "deployment-policy-1",
- "artifactRepository": {
- "repoUsername": "user",
- "repoUrl": "http://stratos.apache.org:10080/git/default.git",
- "privateRepo": true,
- "repoPassword": "c-policy"
- },
- "autoscalingPolicy": "autoscaling-policy-1"
- }
- }
- ],
- "groups": [
- {
- "name": "G3",
- "groupMaxInstances": 3,
- "groupMinInstances": 2,
- "deploymentPolicy": "deployment-policy-1",
- "alias": "group3",
- "cartridges": [
- {
- "cartridgeMin": 2,
- "cartridgeMax": 3,
- "type": "c3",
- "subscribableInfo": {
- "alias": "c3-1x0",
- "artifactRepository": {
- "repoUsername": "user",
- "repoUrl": "http://stratos.apache.org:10080/git/default.git",
- "privateRepo": true,
- "repoPassword": "c-policy"
- },
- "autoscalingPolicy": "autoscaling-policy-1"
- }
- }
- ],
- "groups": []
- }
- ]
- }
- ]
- }
- ]
- }
-}