Skip to content

Commit 15d7f90

Browse files
committed
Merge pull request #491 from iviireczech/master
Telemetry Events API
2 parents 6847b42 + 9b1ccaa commit 15d7f90

File tree

20 files changed

+1051
-138
lines changed

20 files changed

+1051
-138
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package org.openstack4j.api.telemetry;
2+
3+
import org.openstack4j.api.AbstractTest;
4+
import org.openstack4j.model.telemetry.Event;
5+
import org.openstack4j.model.telemetry.Trait;
6+
import org.openstack4j.model.telemetry.TraitDescription;
7+
import org.testng.annotations.Test;
8+
9+
import java.io.IOException;
10+
import java.util.List;
11+
12+
import static org.testng.Assert.assertEquals;
13+
14+
@Test(suiteName="Event Tests")
15+
public class EventTests extends AbstractTest {
16+
17+
private static final String JSON_EVENTS = "/telemetry/events.json";
18+
private static final String JSON_EVENT = "/telemetry/event.json";
19+
private static final String JSON_EVENT_TYPES = "/telemetry/event-types.json";
20+
private static final String JSON_TRAIT_DESCRIPTIONS = "/telemetry/trait-descriptions.json";
21+
private static final String JSON_TRAITS = "/telemetry/traits.json";
22+
23+
@Override
24+
protected Service service() {
25+
return Service.TELEMETRY;
26+
}
27+
28+
@Test
29+
public void listTest() throws IOException {
30+
respondWith(JSON_EVENTS);
31+
32+
List<? extends Event> events = os().telemetry().events().list(null);
33+
assertEquals(events.size(), 5);
34+
35+
Event event = events.get(0);
36+
assertEquals(event.getEventType(), "image.create");
37+
assertEquals(event.getGenerated(), "2015-11-02T15:34:41.795313");
38+
assertEquals(event.getMessageId(), "abd307a1-d4a3-4eae-ab89-6d623e27bebf");
39+
assertEquals(event.getTraits().size(), 1);
40+
Trait trait = event.getTraits().get(0);
41+
assertEquals(trait.getName(), "service");
42+
assertEquals(trait.getValue(), "image.localhost");
43+
44+
}
45+
46+
@Test
47+
public void getTest() throws IOException {
48+
respondWith(JSON_EVENT);
49+
50+
Event event = os().telemetry().events().get("adeda2eb-31e5-4908-a7dd-7a154abed468");
51+
52+
assertEquals(event.getEventType(), "image.upload");
53+
assertEquals(event.getGenerated(), "2015-11-02T15:34:42.993281");
54+
assertEquals(event.getMessageId(), "adeda2eb-31e5-4908-a7dd-7a154abed468");
55+
assertEquals(event.getTraits().size(), 8);
56+
Trait trait = event.getTraits().get(0);
57+
assertEquals(trait.getName(), "created_at");
58+
assertEquals(trait.getValue(), "2015-11-02T15:34:41.000000");
59+
}
60+
61+
@Test
62+
public void listEventTypesTest() throws IOException {
63+
respondWith(JSON_EVENT_TYPES);
64+
65+
List<String> eventTypes = os().telemetry().events().listEventTypes();
66+
assertEquals(eventTypes.size(), 46);
67+
68+
assertEquals(eventTypes.get(0), "compute.instance.create.end");
69+
assertEquals(eventTypes.get(1), "compute.instance.create.error");
70+
}
71+
72+
@Test
73+
public void listTraitDescriptionsTest() throws IOException {
74+
respondWith(JSON_TRAIT_DESCRIPTIONS);
75+
76+
List<? extends TraitDescription> traitDescriptions
77+
= os().telemetry().events().listTraitDescriptions("image.upload");
78+
assertEquals(traitDescriptions.size(), 8);
79+
80+
assertEquals(traitDescriptions.get(0).getName(), "created_at");
81+
assertEquals(traitDescriptions.get(0).getType(), "string");
82+
assertEquals(traitDescriptions.get(1).getName(), "name");
83+
assertEquals(traitDescriptions.get(1).getType(), "string");
84+
assertEquals(traitDescriptions.get(2).getName(), "project_id");
85+
assertEquals(traitDescriptions.get(2).getType(), "string");
86+
}
87+
88+
@Test
89+
public void listTraitsTest() throws IOException {
90+
respondWith(JSON_TRAITS);
91+
92+
List<? extends Trait> traits = os().telemetry().events().listTraits("image.upload", "service");
93+
assertEquals(traits.size(), 5);
94+
95+
assertEquals(traits.get(0).getName(), "service");
96+
assertEquals(traits.get(0).getType(), "string");
97+
assertEquals(traits.get(0).getValue(), "image.localhost");
98+
assertEquals(traits.get(1).getName(), "service");
99+
assertEquals(traits.get(1).getType(), "string");
100+
assertEquals(traits.get(1).getValue(), "image.localhost");
101+
assertEquals(traits.get(2).getName(), "service");
102+
assertEquals(traits.get(2).getType(), "string");
103+
assertEquals(traits.get(2).getValue(), "image.localhost");
104+
}
105+
106+
}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,29 @@
150150
],
151151
"type": "identity",
152152
"name": "keystone"
153+
},
154+
{
155+
"endpoints": [
156+
{
157+
"adminURL": "http:\/\/127.0.0.1:8087\/v2.0",
158+
"region": "RegionOne",
159+
"internalURL": "http:\/\/127.0.0.1:8087\/v2.0",
160+
"id": "9c66xrg3rruv2a3hj8tatd7smmas23fy",
161+
"publicURL": "http:\/\/127.0.0.1:8087\/v2.0"
162+
},
163+
{
164+
"adminURL": "http:\/\/127.0.0.1:8087\/v2.0",
165+
"region": "RegionTwo",
166+
"internalURL": "http:\/\/127.0.0.1:8087\/v2.0",
167+
"id": "9c66xrg3rruv2a3hj8tatd7smmas23fy",
168+
"publicURL": "http:\/\/127.0.0.1:8087\/v2.0"
169+
}
170+
],
171+
"endpoints_links": [
172+
173+
],
174+
"type": "telemetry",
175+
"name": "ceilometer"
153176
}
154177
],
155178
"user": {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[
2+
"compute.instance.create.end",
3+
"compute.instance.create.error",
4+
"compute.instance.create.start",
5+
"compute.instance.delete.end",
6+
"compute.instance.delete.start",
7+
"compute.instance.exists",
8+
"compute.instance.shutdown.end",
9+
"compute.instance.shutdown.start",
10+
"compute.instance.snapshot.end",
11+
"compute.instance.snapshot.start",
12+
"compute.instance.update",
13+
"compute_task.build_instances",
14+
"floatingip.create.end",
15+
"floatingip.create.start",
16+
"floatingip.update.end",
17+
"floatingip.update.start",
18+
"image.activate",
19+
"image.create",
20+
"image.delete",
21+
"image.prepare",
22+
"image.send",
23+
"image.update",
24+
"image.upload",
25+
"network.create.end",
26+
"network.create.start",
27+
"port.create.end",
28+
"port.create.start",
29+
"port.delete.end",
30+
"port.delete.start",
31+
"router.create.end",
32+
"router.create.start",
33+
"router.interface.create",
34+
"router.update.end",
35+
"router.update.start",
36+
"scheduler.select_destinations.end",
37+
"scheduler.select_destinations.start",
38+
"snapshot.create.end",
39+
"snapshot.create.start",
40+
"subnet.create.end",
41+
"subnet.create.start",
42+
"volume.attach.end",
43+
"volume.attach.start",
44+
"volume.create.end",
45+
"volume.create.start",
46+
"volume_type.create",
47+
"volume_type_extra_specs.create"
48+
]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"raw": {},
3+
"traits": [
4+
{
5+
"type": "string",
6+
"name": "created_at",
7+
"value": "2015-11-02T15:34:41.000000"
8+
},
9+
{
10+
"type": "string",
11+
"name": "name",
12+
"value": "cirros-0.3.4-x86_64-uec-kernel"
13+
},
14+
{
15+
"type": "string",
16+
"name": "project_id",
17+
"value": "9e25eb031b8d43e5aac3686b8e7696c6"
18+
},
19+
{
20+
"type": "string",
21+
"name": "resource_id",
22+
"value": "db41e262-294f-41bc-bcef-e37cc8bcaafa"
23+
},
24+
{
25+
"type": "string",
26+
"name": "service",
27+
"value": "image.localhost"
28+
},
29+
{
30+
"type": "string",
31+
"name": "size",
32+
"value": "4979632"
33+
},
34+
{
35+
"type": "string",
36+
"name": "status",
37+
"value": "saving"
38+
},
39+
{
40+
"type": "string",
41+
"name": "user_id",
42+
"value": "9e25eb031b8d43e5aac3686b8e7696c6"
43+
}
44+
],
45+
"generated": "2015-11-02T15:34:42.993281",
46+
"message_id": "adeda2eb-31e5-4908-a7dd-7a154abed468",
47+
"event_type": "image.upload"
48+
}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
[
2+
{
3+
"raw": {},
4+
"traits": [
5+
{
6+
"type": "string",
7+
"name": "service",
8+
"value": "image.localhost"
9+
}
10+
],
11+
"generated": "2015-11-02T15:34:41.795313",
12+
"message_id": "abd307a1-d4a3-4eae-ab89-6d623e27bebf",
13+
"event_type": "image.create"
14+
},
15+
{
16+
"raw": {},
17+
"traits": [
18+
{
19+
"type": "string",
20+
"name": "service",
21+
"value": "image.localhost"
22+
}
23+
],
24+
"generated": "2015-11-02T15:34:42.755340",
25+
"message_id": "900dcf9e-4fec-42dd-844d-774505d0b130",
26+
"event_type": "image.prepare"
27+
},
28+
{
29+
"raw": {},
30+
"traits": [
31+
{
32+
"type": "string",
33+
"name": "created_at",
34+
"value": "2015-11-02T15:34:41.000000"
35+
},
36+
{
37+
"type": "string",
38+
"name": "name",
39+
"value": "cirros-0.3.4-x86_64-uec-kernel"
40+
},
41+
{
42+
"type": "string",
43+
"name": "project_id",
44+
"value": "9e25eb031b8d43e5aac3686b8e7696c6"
45+
},
46+
{
47+
"type": "string",
48+
"name": "resource_id",
49+
"value": "db41e262-294f-41bc-bcef-e37cc8bcaafa"
50+
},
51+
{
52+
"type": "string",
53+
"name": "service",
54+
"value": "image.localhost"
55+
},
56+
{
57+
"type": "string",
58+
"name": "size",
59+
"value": "4979632"
60+
},
61+
{
62+
"type": "string",
63+
"name": "status",
64+
"value": "saving"
65+
},
66+
{
67+
"type": "string",
68+
"name": "user_id",
69+
"value": "9e25eb031b8d43e5aac3686b8e7696c6"
70+
}
71+
],
72+
"generated": "2015-11-02T15:34:42.993281",
73+
"message_id": "adeda2eb-31e5-4908-a7dd-7a154abed468",
74+
"event_type": "image.upload"
75+
},
76+
{
77+
"raw": {},
78+
"traits": [
79+
{
80+
"type": "string",
81+
"name": "service",
82+
"value": "image.localhost"
83+
}
84+
],
85+
"generated": "2015-11-02T15:34:44.234438",
86+
"message_id": "8fd316c6-144f-47ed-a4e2-86d5c1a3bb97",
87+
"event_type": "image.activate"
88+
},
89+
{
90+
"raw": {},
91+
"traits": [
92+
{
93+
"type": "string",
94+
"name": "created_at",
95+
"value": "2015-11-02T15:34:41.000000"
96+
},
97+
{
98+
"type": "string",
99+
"name": "name",
100+
"value": "cirros-0.3.4-x86_64-uec-kernel"
101+
},
102+
{
103+
"type": "string",
104+
"name": "project_id",
105+
"value": "9e25eb031b8d43e5aac3686b8e7696c6"
106+
},
107+
{
108+
"type": "string",
109+
"name": "resource_id",
110+
"value": "db41e262-294f-41bc-bcef-e37cc8bcaafa"
111+
},
112+
{
113+
"type": "string",
114+
"name": "service",
115+
"value": "image.localhost"
116+
},
117+
{
118+
"type": "string",
119+
"name": "size",
120+
"value": "4979632"
121+
},
122+
{
123+
"type": "string",
124+
"name": "status",
125+
"value": "active"
126+
},
127+
{
128+
"type": "string",
129+
"name": "user_id",
130+
"value": "9e25eb031b8d43e5aac3686b8e7696c6"
131+
}
132+
],
133+
"generated": "2015-11-02T15:34:44.240624",
134+
"message_id": "9f009494-33ab-4610-9174-f19e579c7a40",
135+
"event_type": "image.update"
136+
}
137+
]

0 commit comments

Comments
 (0)