Updated Branches: refs/heads/master 9f440d6bc -> 46f493ac8
http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs-openstack/blob/46f493ac/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/internal/BaseAutoscaleExpectTest.java ---------------------------------------------------------------------- diff --git a/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/internal/BaseAutoscaleExpectTest.java b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/internal/BaseAutoscaleExpectTest.java new file mode 100644 index 0000000..4e5668d --- /dev/null +++ b/rackspace-autoscale/src/test/java/org/jclouds/rackspace/autoscale/v1/internal/BaseAutoscaleExpectTest.java @@ -0,0 +1,82 @@ +/* + * 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.jclouds.rackspace.autoscale.v1.internal; + +import javax.ws.rs.core.MediaType; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture; +import org.jclouds.rest.internal.BaseRestApiExpectTest; + +/** + * Base class for writing Autoscale Expect tests + * + * @author Adrian Cole + * @author Zack Shoylev + */ +public class BaseAutoscaleExpectTest<T> extends BaseRestApiExpectTest<T> { + protected HttpRequest keystoneAuthWithUsernameAndPassword; + protected HttpRequest keystoneAuthWithUsernameAndPasswordAndTenantName; + protected HttpRequest keystoneAuthWithAccessKeyAndSecretKeyAndTenantName; + protected String authToken; + protected HttpResponse responseWithKeystoneAccess; + protected HttpRequest extensionsOfNovaRequest; + protected HttpResponse extensionsOfNovaResponse; + protected HttpResponse unmatchedExtensionsOfNovaResponse; + protected HttpRequest keystoneAuthWithAccessKeyAndSecretKeyAndTenantId; + protected String identityWithTenantId; + + public BaseAutoscaleExpectTest() { + provider = "rackspace-autoscale"; + keystoneAuthWithUsernameAndPassword = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPassword(identity, + credential); + keystoneAuthWithUsernameAndPasswordAndTenantName = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPasswordAndTenantName(identity, + credential); + keystoneAuthWithAccessKeyAndSecretKeyAndTenantName = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKeyAndTenantName(identity, + credential); + keystoneAuthWithAccessKeyAndSecretKeyAndTenantId = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKeyAndTenantId(identity, + credential); + + authToken = "bb03a23aa8271291a7aaa9aaa2aaaaaa"; + responseWithKeystoneAccess = HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResourceWithContentType("/access_rax.json", "application/json")) + .build(); + // now, createContext arg will need tenant prefix + identityWithTenantId = KeystoneFixture.INSTANCE.getTenantId() + ":" + identity; + identity = KeystoneFixture.INSTANCE.getTenantName() + ":" + identity; + } + + @Override + protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) { + return HttpRequestComparisonType.JSON; + } + + protected HttpRequest.Builder<?> authenticatedGET() { + return HttpRequest.builder() + .method("GET") + .addHeader("Accept", MediaType.APPLICATION_JSON) + .addHeader("X-Auth-Token", authToken); + } + + protected HttpRequest.Builder<?> authenticatedPOST() { + return HttpRequest.builder() + .method("POST") + .addHeader("Accept", MediaType.APPLICATION_JSON) + .addHeader("X-Auth-Token", authToken); + } +} http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs-openstack/blob/46f493ac/rackspace-autoscale/src/test/resources/access_rax.json ---------------------------------------------------------------------- diff --git a/rackspace-autoscale/src/test/resources/access_rax.json b/rackspace-autoscale/src/test/resources/access_rax.json new file mode 100644 index 0000000..2fba05d --- /dev/null +++ b/rackspace-autoscale/src/test/resources/access_rax.json @@ -0,0 +1,249 @@ +{ + "access":{ + "token":{ + "id":"bb03a23aa8271291a7aaa9aaa2aaaaaa", + "expires":"2013-08-02T16:55:24.229-05:00", + "tenant":{ + "id":"888888", + "name":"888888" + }, + "RAX-AUTH:authenticatedBy":[ + "PASSWORD" + ] + }, + "serviceCatalog":[ + { + "name":"cloudFilesCDN", + "endpoints":[ + { + "region":"ORD", + "tenantId":"MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c", + "publicURL":"https:\/\/cdn2.clouddrive.com\/v1\/MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c" + }, + { + "region":"DFW", + "tenantId":"MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c", + "publicURL":"https:\/\/cdn1.clouddrive.com\/v1\/MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c" + }, + { + "region":"SYD", + "tenantId":"MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c", + "publicURL":"https:\/\/cdn4.clouddrive.com\/v1\/MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c" + } + ], + "type":"rax:object-cdn" + }, + { + "name":"cloudFiles", + "endpoints":[ + { + "region":"ORD", + "tenantId":"MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c", + "publicURL":"https:\/\/storage101.ord1.clouddrive.com\/v1\/MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c", + "internalURL":"https:\/\/snet-storage101.ord1.clouddrive.com\/v1\/MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c" + }, + { + "region":"DFW", + "tenantId":"MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c", + "publicURL":"https:\/\/storage101.dfw1.clouddrive.com\/v1\/MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c", + "internalURL":"https:\/\/snet-storage101.dfw1.clouddrive.com\/v1\/MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c" + }, + { + "region":"SYD", + "tenantId":"MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c", + "publicURL":"https:\/\/storage101.syd2.clouddrive.com\/v1\/MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c", + "internalURL":"https:\/\/snet-storage101.syd2.clouddrive.com\/v1\/MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c" + } + ], + "type":"object-store" + }, + { + "name":"cloudLoadBalancers", + "endpoints":[ + { + "region":"SYD", + "tenantId":"888888", + "publicURL":"https:\/\/syd.loadbalancers.api.rackspacecloud.com\/v1.0\/888888" + }, + { + "region":"DFW", + "tenantId":"888888", + "publicURL":"https:\/\/dfw.loadbalancers.api.rackspacecloud.com\/v1.0\/888888" + }, + { + "region":"ORD", + "tenantId":"888888", + "publicURL":"https:\/\/ord.loadbalancers.api.rackspacecloud.com\/v1.0\/888888" + } + ], + "type":"rax:load-balancer" + }, + { + "name":"cloudDatabases", + "endpoints":[ + { + "region":"SYD", + "tenantId":"888888", + "publicURL":"https:\/\/syd.databases.api.rackspacecloud.com\/v1.0\/888888" + }, + { + "region":"DFW", + "tenantId":"888888", + "publicURL":"https:\/\/dfw.databases.api.rackspacecloud.com\/v1.0\/888888" + }, + { + "region":"ORD", + "tenantId":"888888", + "publicURL":"https:\/\/ord.databases.api.rackspacecloud.com\/v1.0\/888888" + } + ], + "type":"rax:database" + }, + { + "name":"cloudBlockStorage", + "endpoints":[ + { + "region":"SYD", + "tenantId":"888888", + "publicURL":"https:\/\/syd.blockstorage.api.rackspacecloud.com\/v1\/888888" + }, + { + "region":"DFW", + "tenantId":"888888", + "publicURL":"https:\/\/dfw.blockstorage.api.rackspacecloud.com\/v1\/888888" + }, + { + "region":"ORD", + "tenantId":"888888", + "publicURL":"https:\/\/ord.blockstorage.api.rackspacecloud.com\/v1\/888888" + } + ], + "type":"volume" + }, + { + "name":"cloudServersOpenStack", + "endpoints":[ + { + "region":"SYD", + "tenantId":"888888", + "publicURL":"https:\/\/syd.servers.api.rackspacecloud.com\/v2\/888888", + "versionInfo":"https:\/\/syd.servers.api.rackspacecloud.com\/v2", + "versionList":"https:\/\/syd.servers.api.rackspacecloud.com\/", + "versionId":"2" + }, + { + "region":"DFW", + "tenantId":"888888", + "publicURL":"https:\/\/dfw.servers.api.rackspacecloud.com\/v2\/888888", + "versionInfo":"https:\/\/dfw.servers.api.rackspacecloud.com\/v2", + "versionList":"https:\/\/dfw.servers.api.rackspacecloud.com\/", + "versionId":"2" + }, + { + "region":"ORD", + "tenantId":"888888", + "publicURL":"https:\/\/ord.servers.api.rackspacecloud.com\/v2\/888888", + "versionInfo":"https:\/\/ord.servers.api.rackspacecloud.com\/v2", + "versionList":"https:\/\/ord.servers.api.rackspacecloud.com\/", + "versionId":"2" + } + ], + "type":"compute" + }, + { + "name":"autoscale", + "endpoints":[ + { + "region":"ORD", + "tenantId":"888888", + "publicURL":"https:\/\/ord.autoscale.api.rackspacecloud.com\/v1.0\/888888", + "versionInfo":null, + "versionList":null, + "versionId":"1.0" + }, + { + "region":"DFW", + "tenantId":"888888", + "publicURL":"https:\/\/dfw.autoscale.api.rackspacecloud.com\/v1.0\/888888", + "versionInfo":null, + "versionList":null, + "versionId":"1.0" + } + ], + "type":"rax:autoscale" + }, + { + "name":"cloudMonitoring", + "endpoints":[ + { + "tenantId":"888888", + "publicURL":"https:\/\/monitoring.api.rackspacecloud.com\/v1.0\/888888" + } + ], + "type":"rax:monitor" + }, + { + "name":"cloudBackup", + "endpoints":[ + { + "tenantId":"888888", + "publicURL":"https:\/\/backup.api.rackspacecloud.com\/v1.0\/888888" + } + ], + "type":"rax:backup" + }, + { + "name":"cloudServers", + "endpoints":[ + { + "tenantId":"888888", + "publicURL":"https:\/\/servers.api.rackspacecloud.com\/v1.0\/888888", + "versionInfo":"https:\/\/servers.api.rackspacecloud.com\/v1.0", + "versionList":"https:\/\/servers.api.rackspacecloud.com\/", + "versionId":"1.0" + } + ], + "type":"compute" + }, + { + "name":"cloudDNS", + "endpoints":[ + { + "tenantId":"888888", + "publicURL":"https:\/\/dns.api.rackspacecloud.com\/v1.0\/888888" + } + ], + "type":"rax:dns" + } + ], + "user":{ + "id":"335853", + "roles":[ + { + "id":"10000150", + "description":"Checkmate Access role", + "name":"checkmate" + }, + { + "tenantId":"MossoCloudFS_0d629063-aa0f-4bf9-9e04-62e1fd6aaa2c", + "id":"5", + "description":"A Role that allows a user access to keystone Service methods", + "name":"object-store:default" + }, + { + "tenantId":"888888", + "id":"6", + "description":"A Role that allows a user access to keystone Service methods", + "name":"compute:default" + }, + { + "id":"3", + "description":"User Admin Role.", + "name":"identity:user-admin" + } + ], + "name":"test", + "RAX-AUTH:defaultRegion":"ORD" + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs-openstack/blob/46f493ac/rackspace-autoscale/src/test/resources/autoscale_groups_create_request.json ---------------------------------------------------------------------- diff --git a/rackspace-autoscale/src/test/resources/autoscale_groups_create_request.json b/rackspace-autoscale/src/test/resources/autoscale_groups_create_request.json new file mode 100644 index 0000000..4480ff0 --- /dev/null +++ b/rackspace-autoscale/src/test/resources/autoscale_groups_create_request.json @@ -0,0 +1,56 @@ +{ + "launchConfiguration": { + "args": { + "loadBalancers": [ + { + "port": 8080, + "loadBalancerId": 9099 + } + ], + "server": { + "name": "autoscale_server", + "imageRef": "0d589460-f177-4b0f-81c1-8ab8903ac7d8", + "flavorRef": "2", + "OS-DCF:diskConfig": "AUTO", + "metadata": { + "build_config": "core", + "meta_key_1": "meta_value_1", + "meta_key_2": "meta_value_2" + }, + "networks": [ + { + "uuid": "11111111-1111-1111-1111-111111111111" + }, + { + "uuid": "00000000-0000-0000-0000-000000000000" + } + ], + "personality": [ + { + "path": "/root/.csivh", + "contents": "VGhpcyBpcyBhIHRlc3QgZmlsZS4=" + } + ] + } + }, + "type": "launch_server" + }, + "groupConfiguration": { + "maxEntities": 10, + "cooldown": 360, + "name": "testscalinggroup198547", + "minEntities": 0, + "metadata": { + "gc_meta_key_2": "gc_meta_value_2", + "gc_meta_key_1": "gc_meta_value_1" + } + }, + "scalingPolicies": [ + { + "cooldown": 0, + "type": "webhook", + "name": "scale up by 1", + "change": 1 + } + ] +} http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs-openstack/blob/46f493ac/rackspace-autoscale/src/test/resources/autoscale_groups_create_response.json ---------------------------------------------------------------------- diff --git a/rackspace-autoscale/src/test/resources/autoscale_groups_create_response.json b/rackspace-autoscale/src/test/resources/autoscale_groups_create_response.json new file mode 100644 index 0000000..21622f9 --- /dev/null +++ b/rackspace-autoscale/src/test/resources/autoscale_groups_create_response.json @@ -0,0 +1,72 @@ +{ + "group": { + "launchConfiguration": { + "args": { + "loadBalancers": [ + { + "port": 8080, + "loadBalancerId": 9099 + } + ], + "server": { + "name": "autoscale_server", + "imageRef": "0d589460-f177-4b0f-81c1-8ab8903ac7d8", + "flavorRef": "2", + "OS-DCF:diskConfig": "AUTO", + "personality": [ + { + "path": "/root/.csivh", + "contents": "VGhpcyBpcyBhIHRlc3QgZmlsZS4=" + } + ], + "networks": [ + { + "uuid": "11111111-1111-1111-1111-111111111111" + }, + { + "uuid": "00000000-0000-0000-0000-000000000000" + } + ], + "metadata": { + "build_config": "core", + "meta_key_1": "meta_value_1", + "meta_key_2": "meta_value_2" + } + } + }, + "type": "launch_server" + }, + "groupConfiguration": { + "maxEntities": 10, + "cooldown": 360, + "name": "testscalinggroup198547", + "minEntities": 0, + "metadata": { + "gc_meta_key_2": "gc_meta_value_2", + "gc_meta_key_1": "gc_meta_value_1" + } + }, + "scalingPolicies": [ + { + "name": "scale up by 1", + "links": [ + { + "href": "https://ord.autoscale.api.rackspacecloud.com/v1.0/829409/groups/6791761b-821a-4d07-820d-0b2afc7dd7f6/policies/dceb14ac-b2b3-4f06-aac9-a5b6cd5d40e1/", + "rel": "self" + } + ], + "cooldown": 0, + "type": "webhook", + "id": "dceb14ac-b2b3-4f06-aac9-a5b6cd5d40e1", + "change": 1 + } + ], + "links": [ + { + "href": "https://ord.autoscale.api.rackspacecloud.com/v1.0/829409/groups/6791761b-821a-4d07-820d-0b2afc7dd7f6/", + "rel": "self" + } + ], + "id": "6791761b-821a-4d07-820d-0b2afc7dd7f6" + } +} http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs-openstack/blob/46f493ac/rackspace-autoscale/src/test/resources/autoscale_groups_get_response.json ---------------------------------------------------------------------- diff --git a/rackspace-autoscale/src/test/resources/autoscale_groups_get_response.json b/rackspace-autoscale/src/test/resources/autoscale_groups_get_response.json new file mode 100644 index 0000000..ccf1ec0 --- /dev/null +++ b/rackspace-autoscale/src/test/resources/autoscale_groups_get_response.json @@ -0,0 +1,93 @@ +{ + "group": { + "id": "1234567890", + "links": [ + { + "href": "https://rackspace/v1.0/010101/groups/1234567890", + "rel": "self" + } + ], + "groupConfiguration": { + "name": "workers", + "cooldown": 60, + "minEntities": 5, + "maxEntities": 100, + "metadata": { + "firstkey": "this is a string", + "secondkey": "1" + } + }, + "launchConfiguration": { + "type": "launch_server", + "args": { + "server": { + "flavorRef": "3", + "name": "webhead", + "imageRef": "0d589460-f177-4b0f-81c1-8ab8903ac7d8", + "OS-DCF:diskConfig": "AUTO", + "metadata": { + "mykey": "myvalue" + }, + "personality": [ + { + "path": "/root/.ssh/authorized_keys", + "contents": "ssh-rsa AAAAB3Nza...LiPk== [email protected]" + } + ], + "networks": [ + { + "uuid": "11111111-1111-1111-1111-111111111111" + } + ] + }, + "loadBalancers": [ + { + "loadBalancerId": 2200, + "port": 8081 + } + ] + } + }, + "scalingPolicies": [ + { + "id": "policyId1", + "links": [ + { + "href": "https://rackspace/v1.0/010101/groups/1234567890/policies/policyId1", + "rel": "self" + } + ], + "name": "scale up by 10", + "change": 10, + "cooldown": 5, + "type": "webhook" + }, + { + "id": "policyId2", + "links": [ + { + "href": "https://rackspace/v1.0/010101/groups/1234567890/policies/policyId2", + "rel": "self" + } + ], + "name": "scale down by 5.5 percent", + "changePercent": -5.5, + "cooldown": 6, + "type": "webhook" + }, + { + "id": "policyId3", + "links": [ + { + "href": "https://rackspace/v1.0/010101/groups/groupId/policies/policyId3", + "rel": "self" + } + ], + "name": "set number of servers to 10", + "desiredCapacity": 10, + "cooldown": 3, + "type": "webhook" + } + ] + } +} http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs-openstack/blob/46f493ac/rackspace-autoscale/src/test/resources/autoscale_groups_list_response.json ---------------------------------------------------------------------- diff --git a/rackspace-autoscale/src/test/resources/autoscale_groups_list_response.json b/rackspace-autoscale/src/test/resources/autoscale_groups_list_response.json new file mode 100644 index 0000000..82aa4dc --- /dev/null +++ b/rackspace-autoscale/src/test/resources/autoscale_groups_list_response.json @@ -0,0 +1,33 @@ +{ + "groups": [ + { + "active": [], + "activeCapacity": 0, + "desiredCapacity": 0, + "id": "e41380ae-173c-4b40-848a-25c16d7fa83d", + "links": [ + { + "href": "https://dfw.autoscale.api.rackspacecloud.com/v1.0/676873/groups/e41380ae-173c-4b40-848a-25c16d7fa83d/", + "rel": "self" + } + ], + "paused": false, + "pendingCapacity": 0 + }, + { + "active": [], + "activeCapacity": 0, + "desiredCapacity": 0, + "id": "f82bb000-f451-40c8-9dc3-6919097d2f7e", + "links": [ + { + "href": "https://dfw.autoscale.api.rackspacecloud.com/v1.0/676873/groups/f82bb000-f451-40c8-9dc3-6919097d2f7e/", + "rel": "self" + } + ], + "paused": false, + "pendingCapacity": 0 + } + ], + "groups_links": [] +} http://git-wip-us.apache.org/repos/asf/incubator-jclouds-labs-openstack/blob/46f493ac/rackspace-autoscale/src/test/resources/autoscale_groups_state_response.json ---------------------------------------------------------------------- diff --git a/rackspace-autoscale/src/test/resources/autoscale_groups_state_response.json b/rackspace-autoscale/src/test/resources/autoscale_groups_state_response.json new file mode 100644 index 0000000..f55d08a --- /dev/null +++ b/rackspace-autoscale/src/test/resources/autoscale_groups_state_response.json @@ -0,0 +1,35 @@ +{ + "group": { + "id": "1234567890", + "links": [ + { + "href": "https://dfw.servers.api.rackspacecloud.com/v1.0/010101/groups/1234567890", + "rel": "self" + } + ], + "active": [ + { + "id": "444444", + "links": [ + { + "href": "https://dfw.servers.api.rackspacecloud.com/v2/010101/servers/444444", + "rel": "self" + } + ] + }, + { + "id": "555555555", + "links": [ + { + "href": "https://dfw.servers.api.rackspacecloud.com/v2/010101/servers/555555555", + "rel": "self" + } + ] + } + ], + "activeCapacity": 2, + "pendingCapacity": 2, + "desiredCapacity": 4, + "paused": false + } +}
