Skip to content

Commit 38410d4

Browse files
authored
update integrations documentation (#1492)
* update documentation folder to reflect the integration purpose and structure Signed-off-by: YANGDB <yang.db.dev@gmail.com> * revert unneeded delete Signed-off-by: YANGDB <yang.db.dev@gmail.com> * revert unneeded delete Signed-off-by: YANGDB <yang.db.dev@gmail.com> --------- Signed-off-by: YANGDB <yang.db.dev@gmail.com>
1 parent 0b3cfd1 commit 38410d4

20 files changed

+2667
-3
lines changed

docs/API/README.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# API Mock Tests
2+
The [Swagger](swagger.yaml) describes the API used by the Integration repository to support the `catalog`, `registry` and `store` functionalities.
3+
4+
### Setup mock server
5+
In order to test the API, we can utilize a swagger based mock library which allows ['contract based testing'](https://github.com/stoplightio/prism).
6+
7+
#### running the swagger mock server
8+
````
9+
npm install -g @stoplight/prism-cli
10+
````
11+
Once this tool is installed, the server can be run using the next command
12+
```
13+
prism mock swagger.yaml
14+
```
15+
The next endpoints are presented:
16+
```
17+
[10:32:12 a.m.] › [CLI] ℹ info GET http://127.0.0.1:4010/catalog?limit=41
18+
[10:32:12 a.m.] › [CLI] ℹ info POST http://127.0.0.1:4010/catalog
19+
[10:32:12 a.m.] › [CLI] ℹ info GET http://127.0.0.1:4010/catalog/sed
20+
[10:32:12 a.m.] › [CLI] ℹ info GET http://127.0.0.1:4010/repository?limit=%5Bobject%20Object%5D
21+
[10:32:12 a.m.] › [CLI] ℹ info POST http://127.0.0.1:4010/repository
22+
[10:32:12 a.m.] › [CLI] ℹ info GET http://127.0.0.1:4010/repository/%5Bobject%20Object%5D
23+
[10:32:12 a.m.] › [CLI] ℹ info GET http://127.0.0.1:4010/store?limit=25
24+
[10:32:12 a.m.] › [CLI] ℹ info POST http://127.0.0.1:4010/store
25+
[10:32:12 a.m.] › [CLI] ℹ info GET http://127.0.0.1:4010/store/cum
26+
[10:32:12 a.m.] › [CLI] ℹ info POST http://127.0.0.1:4010/store/nihil/validate
27+
[10:32:12 a.m.] › [CLI] ℹ info POST http://127.0.0.1:4010/store/laudantium/upload
28+
[10:32:12 a.m.] › [CLI] ℹ info PUT http://127.0.0.1:4010/store/nihil/activate
29+
[10:32:12 a.m.] › [CLI] ▶ start Prism is listening on http://127.0.0.1:4010
30+
```
31+
32+
Once the server has started, a CURL request can be initiated with any of the above endpoints:
33+
34+
`GET http://localhost:4010/catalog`
35+
36+
Would show in the traffic logs:
37+
38+
`[10:32:23 a.m.] › [HTTP SERVER] get /catalog ℹ info Request received`
39+
40+
And will result with :
41+
42+
```json5
43+
{
44+
"catalog": "observability",
45+
"version": "1.0",
46+
"url": "https://github.com/opensearch-project/observability/tree/2.x/schema/observability",
47+
"categories": [
48+
{
49+
"category": "logs",
50+
"version": "1.0",
51+
"url": "https://github.com/opensearch-project/observability/tree/2.x/schema/observability/logs",
52+
"components": [
53+
{
54+
"component": "log",
55+
"version": "1.0",
56+
"url": "https://github.com/opensearch-project/observability/tree/2.x/schema/observability/logs/logs",
57+
"container": true,
58+
"tags": []
59+
},
60+
{
61+
"component": "http",
62+
"version": "1.0",
63+
"url": "https://github.com/opensearch-project/observability/tree/2.x/schema/observability/logs/http",
64+
"tags": [],
65+
"container": false
66+
},
67+
{
68+
"component": "communication",
69+
"version": "1.0",
70+
"url": "https://github.com/opensearch-project/observability/tree/2.x/schema/observability/logs/communication",
71+
"tags": ["web"],
72+
"container": false
73+
}]
74+
},
75+
{
76+
"category": "traces",
77+
"version": "1.0",
78+
"url": "https://github.com/opensearch-project/observability/tree/2.x/schema/observability/traces",
79+
"components": [
80+
{
81+
"component": "span",
82+
"version": "1.0",
83+
"url": "https://github.com/opensearch-project/observability/tree/2.x/schema/observability/traces/traces",
84+
"tags": [],
85+
"container": true
86+
}]
87+
},
88+
{
89+
"category": "metrics",
90+
"version": "1.0",
91+
"url": "https://github.com/opensearch-project/observability/tree/2.x/schema/observability/metrics",
92+
"components": [
93+
{
94+
"component": "metric",
95+
"version": "1.0",
96+
"url": "https://github.com/opensearch-project/observability/tree/2.x/schema/observability/metrics/metrics",
97+
"tags": [],
98+
"container": true
99+
}]
100+
}
101+
]
102+
}
103+
```
104+
105+
106+
107+
#### running the swagger mock server as docker
108+
109+
One-liner docker command (assuming running from repository root):
110+
111+
```text
112+
docker run -p 9200:4010 -v "$(pwd)/docs/API:/api" -v "$(pwd)/schema:/schema" --name integ-prism -t stoplight/prism mock -h 0.0.0.0 /api/swagger.yaml
113+
```

0 commit comments

Comments
 (0)