-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openstack: added cinder snapshots and glance tests #1943
- Loading branch information
1 parent
6571331
commit a05fa67
Showing
18 changed files
with
412 additions
and
27 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...java/org/apache/camel/quarkus/component/openstack/it/OpenstackCinderSnapshotResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* 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.camel.quarkus.component.openstack.it; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
|
||
import org.apache.camel.ProducerTemplate; | ||
import org.apache.camel.component.openstack.cinder.CinderConstants; | ||
import org.apache.camel.component.openstack.common.OpenstackConstants; | ||
import org.jboss.logging.Logger; | ||
import org.openstack4j.model.storage.block.VolumeSnapshot; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
@Path("/openstack/cinder/snapshots/") | ||
@ApplicationScoped | ||
public class OpenstackCinderSnapshotResource { | ||
|
||
private static final Logger LOG = Logger.getLogger(OpenstackCinderSnapshotResource.class); | ||
|
||
private static final String URI_FORMAT = "openstack-cinder://{{camel.openstack.test.host-url}}?username=user&password=secret&project=project&operation=%s&subsystem=" | ||
+ CinderConstants.SNAPSHOTS; | ||
|
||
@Inject | ||
ProducerTemplate template; | ||
|
||
@Path("/getAllShouldSucceed") | ||
@POST | ||
public void getAllShouldSucceed() { | ||
LOG.debug("Calling OpenstackCinderSnapshotResource.getAllShouldSucceed()"); | ||
|
||
String uri = String.format(URI_FORMAT, OpenstackConstants.GET_ALL); | ||
VolumeSnapshot[] volumeSnapshots = template.requestBody(uri, null, VolumeSnapshot[].class); | ||
|
||
assertEquals(2, volumeSnapshots.length); | ||
assertEquals("a06b0531-c14b-4a7b-8749-de1378dd1007", volumeSnapshots[0].getId()); | ||
assertEquals("b0e394e6-bb10-4bfe-960d-edf72100c810", volumeSnapshots[0].getVolumeId()); | ||
assertNotNull(volumeSnapshots[0].getMetaData()); | ||
assertTrue(volumeSnapshots[0].getMetaData().isEmpty()); | ||
assertEquals("6489c55f-b9f4-442e-8d0a-5a87349d2d07", volumeSnapshots[1].getId()); | ||
assertEquals("7f47ab73-303c-4a19-b311-6123bb115775", volumeSnapshots[1].getVolumeId()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
...rc/main/java/org/apache/camel/quarkus/component/openstack/it/OpenstackGlanceResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* | ||
* 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.camel.quarkus.component.openstack.it; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStream; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
|
||
import org.apache.camel.ProducerTemplate; | ||
import org.apache.camel.component.openstack.common.OpenstackConstants; | ||
import org.apache.camel.component.openstack.glance.GlanceConstants; | ||
import org.jboss.logging.Logger; | ||
import org.openstack4j.model.common.Payload; | ||
import org.openstack4j.model.common.Payloads; | ||
import org.openstack4j.model.image.ContainerFormat; | ||
import org.openstack4j.model.image.DiskFormat; | ||
import org.openstack4j.model.image.Image; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
@Path("/openstack/glance/") | ||
@ApplicationScoped | ||
public class OpenstackGlanceResource { | ||
|
||
private static final Logger LOG = Logger.getLogger(OpenstackGlanceResource.class); | ||
|
||
private static final String URI_FORMAT = "openstack-glance://{{camel.openstack.test.host-url}}?username=user&password=secret&project=project&operation=%s"; | ||
|
||
@Inject | ||
ProducerTemplate template; | ||
|
||
@Path("/createShouldSucceed") | ||
@POST | ||
public void createShouldSucceed() { | ||
LOG.debug("Calling OpenstackGlanceResource.createShouldSucceed()"); | ||
|
||
Map<String, Object> headers = new HashMap<>(); | ||
headers.put(OpenstackConstants.NAME, "amphora-x64-haproxy"); | ||
headers.put(GlanceConstants.DISK_FORMAT, DiskFormat.QCOW2); | ||
headers.put(GlanceConstants.CONTAINER_FORMAT, ContainerFormat.BARE); | ||
headers.put(GlanceConstants.MIN_DISK, 0L); | ||
headers.put(GlanceConstants.MIN_RAM, 0L); | ||
|
||
Payload<InputStream> payload = Payloads.create(new ByteArrayInputStream(new byte[] { 10, 11, 12 })); | ||
String uri = String.format(URI_FORMAT, OpenstackConstants.CREATE); | ||
Image out = template.requestBodyAndHeaders(uri, payload, headers, Image.class); | ||
|
||
assertNotNull(out); | ||
assertEquals("8a2ea42d-06b5-42c2-a54d-97105420f2bb", out.getId()); | ||
assertEquals("amphora-x64-haproxy", out.getName()); | ||
assertEquals(ContainerFormat.BARE, out.getContainerFormat()); | ||
assertEquals(DiskFormat.QCOW2, out.getDiskFormat()); | ||
assertEquals(0L, out.getMinDisk()); | ||
assertEquals(0L, out.getMinRam()); | ||
} | ||
|
||
@Path("/uploadShouldSucceed") | ||
@POST | ||
public void uploadShouldSucceed() { | ||
LOG.debug("Calling OpenstackGlanceResource.uploadShouldSucceed()"); | ||
|
||
Map<String, Object> headers = new HashMap<>(); | ||
headers.put(OpenstackConstants.NAME, "amphora-x64-haproxy"); | ||
headers.put(OpenstackConstants.ID, "4b434528-032b-4467-946c-b5880ce15c06"); | ||
headers.put(GlanceConstants.DISK_FORMAT, DiskFormat.QCOW2); | ||
headers.put(GlanceConstants.CONTAINER_FORMAT, ContainerFormat.BARE); | ||
headers.put(GlanceConstants.MIN_DISK, 0L); | ||
headers.put(GlanceConstants.MIN_RAM, 0L); | ||
|
||
Payload<InputStream> payload = Payloads.create(new ByteArrayInputStream(new byte[] { 10, 11, 12 })); | ||
String uri = String.format(URI_FORMAT, GlanceConstants.UPLOAD); | ||
Image out = template.requestBodyAndHeaders(uri, payload, headers, Image.class); | ||
|
||
assertNotNull(out); | ||
assertEquals("4b434528-032b-4467-946c-b5880ce15c06", out.getId()); | ||
} | ||
|
||
@Path("/getShouldSucceed") | ||
@POST | ||
public void getShouldSucceed() { | ||
LOG.debug("Calling OpenstackGlanceResource.getShouldSucceed()"); | ||
|
||
String uri = String.format(URI_FORMAT, OpenstackConstants.GET); | ||
String id = "8a2ea42d-06b5-42c2-a54d-97105420f2bb"; | ||
Image out = template.requestBodyAndHeader(uri, null, OpenstackConstants.ID, id, Image.class); | ||
|
||
assertEquals(id, out.getId()); | ||
} | ||
|
||
@Path("/getAllShouldSucceed") | ||
@POST | ||
public void getAllShouldSucceed() { | ||
LOG.debug("Calling OpenstackGlanceResource.getAllShouldSucceed()"); | ||
|
||
String uri = String.format(URI_FORMAT, OpenstackConstants.GET_ALL); | ||
Image[] images = template.requestBody(uri, null, Image[].class); | ||
|
||
assertEquals(2, images.length); | ||
assertEquals("7541b8be-c62b-46c3-b5a5-5bb5ce43ce01", images[0].getId()); | ||
} | ||
|
||
@Path("/deleteShouldSucceed") | ||
@POST | ||
public void deleteShouldSucceed() { | ||
LOG.debug("Calling OpenstackGlanceResource.deleteShouldSucceed()"); | ||
|
||
String uri = String.format(URI_FORMAT, OpenstackConstants.DELETE); | ||
template.requestBodyAndHeader(uri, null, OpenstackConstants.ID, "8a2ea42d-06b5-42c2-a54d-97105420f2bb"); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...est/java/org/apache/camel/quarkus/component/openstack/it/OpenstackCinderSnapshotTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* 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.camel.quarkus.component.openstack.it; | ||
|
||
import io.quarkus.test.common.QuarkusTestResource; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static io.restassured.RestAssured.post; | ||
|
||
@QuarkusTest | ||
@QuarkusTestResource(OpenStackTestResource.class) | ||
class OpenstackCinderSnapshotTest { | ||
|
||
@Test | ||
public void getAllShouldSucceed() { | ||
post("/openstack/cinder/snapshots/getAllShouldSucceed").then().statusCode(204); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...st/src/test/java/org/apache/camel/quarkus/component/openstack/it/OpenstackGlanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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.camel.quarkus.component.openstack.it; | ||
|
||
import io.quarkus.test.common.QuarkusTestResource; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static io.restassured.RestAssured.post; | ||
|
||
@QuarkusTest | ||
@QuarkusTestResource(OpenStackTestResource.class) | ||
class OpenstackGlanceTest { | ||
|
||
@Test | ||
public void createShouldSucceed() { | ||
post("/openstack/glance/createShouldSucceed").then().statusCode(204); | ||
} | ||
|
||
@Test | ||
public void uploadShouldSucceed() { | ||
post("/openstack/glance/uploadShouldSucceed").then().statusCode(204); | ||
} | ||
|
||
@Test | ||
public void getShouldSucceed() { | ||
post("/openstack/glance/getShouldSucceed").then().statusCode(204); | ||
} | ||
|
||
@Test | ||
public void getAllShouldSucceed() { | ||
post("/openstack/glance/getAllShouldSucceed").then().statusCode(204); | ||
} | ||
|
||
@Test | ||
public void deleteShouldSucceed() { | ||
post("/openstack/glance/deleteShouldSucceed").then().statusCode(204); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...nstack/integration-test/src/test/resources/mappings/cinder/snapshot/volume_snapshots.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"id" : "abd83ce9-92e5-41dd-8bad-b5ce5408c775", | ||
"name" : "volume_snapshots.json", | ||
"request" : { | ||
"url" : "/v2/123ac695d4db400a9001b91bb3b8aa46/snapshots", | ||
"method" : "GET" | ||
}, | ||
"response" : { | ||
"status" : 200, | ||
"body" : "{\"snapshots\":[{\"status\":\"available\",\"display_name\":\"snap-vol-test-1\",\"created_at\":\"2015-04-23T11:32:28.364877\",\"display_description\":\"\",\"volume_id\":\"b0e394e6-bb10-4bfe-960d-edf72100c810\",\"metadata\":{},\"id\":\"a06b0531-c14b-4a7b-8749-de1378dd1007\",\"size\":1},{\"status\":\"available\",\"display_name\":\"snap-vol-test-2\",\"created_at\":\"2015-04-23T11:32:14.620321\",\"display_description\":\"\",\"volume_id\":\"7f47ab73-303c-4a19-b311-6123bb115775\",\"metadata\":{},\"id\":\"6489c55f-b9f4-442e-8d0a-5a87349d2d07\",\"size\":1}]}", | ||
"headers" : { | ||
"Content-Type" : "application/json; charset=UTF-8" | ||
} | ||
}, | ||
"uuid" : "abd83ce9-92e5-41dd-8bad-b5ce5408c775", | ||
"persistent" : true, | ||
"insertionIndex" : 1 | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.