Skip to content

Commit 104fa0f

Browse files
authored
Merge branch 'master' into temp-branch
2 parents c9781f8 + c347478 commit 104fa0f

23 files changed

Lines changed: 747 additions & 96 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.openstack4j.api.heat;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import java.util.HashMap;
5+
import java.util.Map;
6+
import org.openstack4j.api.AbstractTest;
7+
import org.openstack4j.model.heat.AdoptStackData;
8+
import org.openstack4j.model.heat.Stack;
9+
import org.openstack4j.openstack.heat.domain.HeatAdoptStackData;
10+
import static org.testng.Assert.assertEquals;
11+
import org.testng.annotations.Test;
12+
13+
/**
14+
* Test cases for Heat Stack Services function
15+
*
16+
* @author Ales Kemr
17+
*/
18+
@Test(suiteName="heat/stacks", enabled = true)
19+
public class StackServiceTests extends AbstractTest {
20+
21+
private static final String JSON_ABANDON = "/heat/abandon.json";
22+
private static final String JSON_ADOPT = "/heat/adopt.json";
23+
24+
public void testAbandonStack() throws Exception {
25+
respondWith(JSON_ABANDON);
26+
27+
AdoptStackData adoptStackData = osv3().heat().stacks().abandon("stack_123", "416c09e9-2022-4d43-854b-0292ddff3f5d");
28+
takeRequest();
29+
30+
assertEquals(adoptStackData.getName(), "stack_123");
31+
assertEquals(adoptStackData.getStatus(), "COMPLETE");
32+
final Map<String, Object> portResource = adoptStackData.getResources().get("network_port");
33+
assertEquals(portResource.get("type"), "OS::Neutron::Port");
34+
}
35+
36+
public void testAdoptStack() throws Exception {
37+
respondWith(JSON_ADOPT);
38+
39+
AdoptStackData adoptStackData = new ObjectMapper().readValue(getResource(JSON_ABANDON), HeatAdoptStackData.class);
40+
Stack adoptedStack = osv3().heat().stacks().adopt(adoptStackData, new HashMap<String, String>(), false, 30L, null);
41+
takeRequest();
42+
43+
assertEquals(adoptedStack.getId(), "79370050-6038-4ea2-baaa-3e4706d59e0e");
44+
}
45+
46+
@Override
47+
protected Service service() {
48+
return Service.ORCHESTRATION;
49+
}
50+
51+
}

core-test/src/main/java/org/openstack4j/api/identity/v3/KeystoneProjectServiceTests.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.openstack4j.api.identity.v3;
22

3-
import static org.testng.AssertJUnit.assertNull;
43
import static org.testng.Assert.assertEquals;
4+
import static org.testng.AssertJUnit.assertNull;
5+
6+
import java.util.Arrays;
7+
import java.util.List;
58

69
import org.openstack4j.api.AbstractTest;
710
import org.openstack4j.api.Builders;
@@ -26,6 +29,7 @@ public class KeystoneProjectServiceTests extends AbstractTest {
2629
private static final String PROJECT_EXTRA_VALUE_1 = "value1";
2730
private static final String PROJECT_EXTRA_KEY_2 = "extra_key2";
2831
private static final String PROJECT_EXTRA_VALUE_2 = "value2";
32+
private static final List<String> TAGS = Arrays.asList("one", "two", "three");
2933
private String PROJECT_ID;
3034

3135
@Override
@@ -49,7 +53,7 @@ public void projects_create_does_not_accept_null() throws Exception {
4953
public void projects_crud_test() throws Exception {
5054

5155
Project project = Builders.project().name(PROJECT_NAME).description(PROJECT_DESCRIPTION)
52-
.domainId(PROJECT_DOMAIN_ID).setExtra(PROJECT_EXTRA_KEY_1, PROJECT_EXTRA_VALUE_1).enabled(true).build();
56+
.domainId(PROJECT_DOMAIN_ID).setExtra(PROJECT_EXTRA_KEY_1, PROJECT_EXTRA_VALUE_1).enabled(true).setTags(TAGS).build();
5357

5458
respondWith(JSON_PROJECTS_CREATE);
5559

@@ -59,17 +63,18 @@ public void projects_crud_test() throws Exception {
5963
assertEquals(newProject.getDomainId(), PROJECT_DOMAIN_ID);
6064
assertEquals(newProject.getDescription(), PROJECT_DESCRIPTION);
6165
assertEquals(newProject.getExtra(PROJECT_EXTRA_KEY_1), PROJECT_EXTRA_VALUE_1);
66+
assertEquals(newProject.getTags(), TAGS);
6267

6368
PROJECT_ID = newProject.getId();
6469

6570
respondWith(JSON_PROJECTS_GET_BYID);
6671

67-
Project project_setToUpdate = osv3().identity().projects().get(PROJECT_ID);
72+
Project projectSetToUpdate = osv3().identity().projects().get(PROJECT_ID);
6873

6974
respondWith(JSON_PROJECTS_UPDATE);
7075

7176
Project updatedProject = osv3().identity().projects().update(
72-
project_setToUpdate.toBuilder().description(PROJECT_DESCRIPTION_UPDATE)
77+
projectSetToUpdate.toBuilder().description(PROJECT_DESCRIPTION_UPDATE)
7378
.setExtra(PROJECT_EXTRA_KEY_2, PROJECT_EXTRA_VALUE_2)
7479
.build());
7580

core-test/src/main/java/org/openstack4j/api/network/NetworkTests.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.openstack4j.api.network;
22

3-
import static org.junit.Assert.assertFalse;
43
import static org.testng.Assert.assertEquals;
54
import static org.testng.Assert.assertNotNull;
65
import static org.testng.Assert.assertTrue;
@@ -14,11 +13,10 @@
1413
import org.openstack4j.api.Builders;
1514
import org.openstack4j.model.network.Agent;
1615
import org.openstack4j.model.network.Agent.Type;
17-
import org.openstack4j.model.storage.block.VolumeBackup;
1816
import org.openstack4j.model.network.Network;
1917
import org.openstack4j.model.network.NetworkType;
2018
import org.openstack4j.model.network.State;
21-
import org.testng.Reporter;
19+
import org.openstack4j.model.common.ActionResponse;
2220
import org.testng.annotations.Test;
2321

2422
import okhttp3.mockwebserver.RecordedRequest;
@@ -90,6 +88,14 @@ public void agentList() throws Exception {
9088
assertEquals(agent.getAgentType(), Type.DHCP);
9189
}
9290

91+
@Test
92+
public void detachNetworkToDhcpAgent() throws Exception {
93+
respondWith(204);
94+
ActionResponse result = osv3().networking().agent().detachNetworkToDhcpAgent("190ecbc2-77e0-4e4f-a96b-aa849edb357b", "4e8e5957-649f-477b-9e5b-f1f75b21c03c");
95+
server.takeRequest();
96+
assertTrue(result.isSuccess());
97+
}
98+
9399
@Override
94100
protected Service service() {
95101
return Service.NETWORK;

core-test/src/main/java/org/openstack4j/openstack/common/ServiceTypeTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public class ServiceTypeTest {
1313

1414
private Map<ServiceType, Collection<String>> types;
1515

16+
private Map<ServiceType, Collection<String>> unknownTypes;
17+
1618
@BeforeSuite
1719
public void setup() {
1820
types = new HashMap<>();
@@ -37,6 +39,10 @@ public void setup() {
3739
types.put(ServiceType.MAGNUM, Arrays.asList("container","ContainerV3","containerv1"));
3840
types.put(ServiceType.DNS, Arrays.asList("dns","dnsv2","dnsV3"));
3941
types.put(ServiceType.WORKFLOW, Arrays.asList("workflow","workflowv3","workflowv2"));
42+
43+
unknownTypes = new HashMap();
44+
unknownTypes.put(ServiceType.ORCHESTRATION, Arrays.asList("heat-cfg","heatother","heatvm","heat-cfg4"));
45+
4046
}
4147

4248
@Test
@@ -47,4 +53,13 @@ public void testNameResolveByType() {
4753
}
4854
}
4955
}
56+
57+
@Test
58+
public void testNameNotResolved() {
59+
for (Map.Entry<ServiceType, Collection<String>> entry : unknownTypes.entrySet()) {
60+
for(String type : entry.getValue()){
61+
assertEquals(ServiceType.UNKNOWN, ServiceType.forName(type));
62+
}
63+
}
64+
}
5065
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"files":{
3+
4+
},
5+
"status":"COMPLETE",
6+
"name":"stack_123",
7+
"tags":null,
8+
"stack_user_project_id":"44ed5c0be2384092b8e8b6444812db5d",
9+
"environment":{
10+
"event_sinks":[
11+
12+
],
13+
"parameter_defaults":{
14+
15+
},
16+
"parameters":{
17+
18+
},
19+
"resource_registry":{
20+
"resources":{
21+
22+
}
23+
}
24+
},
25+
"template":{
26+
"heat_template_version":"2016-04-08",
27+
"description":"A heat test template",
28+
"resources":{
29+
"network_port":{
30+
"type":"OS::Neutron::Port",
31+
"properties":{
32+
"network_id":"network123"
33+
}
34+
}
35+
}
36+
},
37+
"action":"CREATE",
38+
"project_id":"0dbd25a2a75347cf88a0a52638b8fff3",
39+
"id":"416c09e9-2022-4d43-854b-0292ddff3f5d",
40+
"resources":{
41+
"network_port":{
42+
"status":"COMPLETE",
43+
"name":"network_port",
44+
"resource_data":{
45+
46+
},
47+
"resource_id":"1d0dccbb-0c99-48cd-b41b-abeca3ac6a42",
48+
"action":"CREATE",
49+
"type":"OS::Neutron::Port",
50+
"metadata":{
51+
52+
}
53+
}
54+
}
55+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"stack":{
3+
"id":"79370050-6038-4ea2-baaa-3e4706d59e0e",
4+
"links":[
5+
{
6+
"href":"http://any.os.com:8004/v1/0dbd25a2a75347cf88a0a52638b8fff3/stacks/stack_123/79370050-6038-4ea2-baaa-3e4706d59e0e",
7+
"rel":"self"
8+
}
9+
]
10+
}
11+
}

core-test/src/main/resources/identity/v2/access.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@
142142
"endpoints_links": [],
143143
"type": "identity",
144144
"name": "keystone"
145+
}, {
146+
"endpoints": [
147+
{
148+
"adminURL": "http:\/\/127.0.0.1:8087\/v2.0",
149+
"region": "RegionOne",
150+
"internalURL": "http:\/\/127.0.0.1:8087\/v2.0",
151+
"id": "9c66xrg3gruv2a3hj8aatd7smmas23fy",
152+
"publicURL": "http:\/\/127.0.0.1:8087\/v2.0"
153+
}, {
154+
"adminURL": "http:\/\/127.0.0.1:8087\/v2.0",
155+
"region": "RegionTwo",
156+
"internalURL": "http:\/\/127.0.0.1:8087\/v2.0",
157+
"id": "9c66xrgerruv2a3hj8batd7smmas23fy",
158+
"publicURL": "http:\/\/127.0.0.1:8087\/v2.0"
159+
}
160+
],
161+
"endpoints_links": [],
162+
"type": "aodh",
163+
"name": "alarming"
145164
}, {
146165
"endpoints": [
147166
{

core-test/src/main/resources/identity/v3/authv3_project.json

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,65 @@
477477
"id": "123450a4597040849c03bc1358854321"
478478
}
479479
],
480-
"type": "telemetry",
480+
"type": "alarming",
481481
"id": "1236500210a24c38a3702b6825e12345",
482-
"name": "ceilometeter"
482+
"name": "aodh"
483+
},
484+
{
485+
"endpoints": [
486+
{
487+
"region_id": "RegionOne",
488+
"url": "http://127.0.0.1:8087",
489+
"region": "RegionOne",
490+
"interface": "public",
491+
"id": "123458912d3f40a09df51035681d5678"
492+
},
493+
{
494+
"region_id": "RegionOne",
495+
"url": "http://127.0.0.1:8087",
496+
"region": "RegionOne",
497+
"interface": "admin",
498+
"id": "12345321ae80458abc3728fa1e6f1234"
499+
},
500+
{
501+
"region_id": "RegionOne",
502+
"url": "http://127.0.0.1:8087",
503+
"region": "RegionOne",
504+
"interface": "internal",
505+
"id": "123450a4597040859c03bc1358854321"
506+
}
507+
],
508+
"type": "metering",
509+
"id": "1236500210a24c38a3702b6835e12345",
510+
"name": "ceilometer"
511+
},
512+
{
513+
"endpoints": [
514+
{
515+
"region_id": "RegionOne",
516+
"url": "http://127.0.0.1:8087",
517+
"region": "RegionOne",
518+
"interface": "public",
519+
"id": "123458912d3f49a09df51035681d59a8"
520+
},
521+
{
522+
"region_id": "RegionOne",
523+
"url": "http://127.0.0.1:8087",
524+
"region": "RegionOne",
525+
"interface": "admin",
526+
"id": "123453dd1ae80457abc3728fa1e6f123"
527+
},
528+
{
529+
"region_id": "RegionOne",
530+
"url": "http://127.0.0.1:8087",
531+
"region": "RegionOne",
532+
"interface": "internal",
533+
"id": "123451a45a7040849c03bc1358854321"
534+
}
535+
],
536+
"type": "aodh",
537+
"id": "1236500210a24c38a1702e6825e12345",
538+
"name": "alarming"
483539
},
484540
{
485541
"endpoints": [

core-test/src/main/resources/identity/v3/projects_create_response.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"parent_id": null,
1111
"domain_id": "7a71863c2d1d4444b3e6c2cd36955e1e",
1212
"name": "ProjectX",
13-
"extra_key1": "value1"
13+
"extra_key1": "value1",
14+
"tags": ["one", "two", "three"]
1415
}
1516
}

core-test/src/main/resources/telemetry/alarm.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[{
1+
{
22
"alarm_id" : "03757eede9c540338e732d1a7fb07966",
33
"enabled": false,
44
"name": "name_post",
@@ -27,4 +27,3 @@
2727
"granularity": 180
2828
}
2929
}
30-
]

0 commit comments

Comments
 (0)