Skip to content

Commit bc9b009

Browse files
Simran-BCircleCI Job
andauthored
DOC-689 | Fix toolchain, improve cURL example rendering (#538)
* Check for server ready using IPv4 localhost * Re-add heredoc for curl requests with body, fix rendering of command * headers object always defined at this point * Remove highlight.js * Fix README link to datasets.json * Replace batch request examples with manual code logCurlRequestPlain is not compatible with new toolchain * Don't unnecessarily JSON.stringify payload in /_api/collection/{coll}/responsibleShard example * Try non-raw logCurlRequest for import examples * Using an inline regex seems to break the toolchain? The second openRepoStream message is missing and arangoproxy not responding to requests if you do?! * Remove Docker Compose version field * Typo * Trying to escape header values seems to break the toolchain * Make batch request examples generated again * Apply to 3.10, 3.11, 3.13 * Skip compilation for ArangoDB for arangodb/enterprise too * Strip off hotfix suffix from image tag to determine upstream branch * Also handle enterprise image when pulling * Guard against sporadic failure in some async job examples Fetching the result can return HTTP 204 which means the job is still queued * [skip ci] Automatic commit of generated files from CircleCI * Add comment about alternative solution --------- Co-authored-by: CircleCI Job <[email protected]>
1 parent 2214d6c commit bc9b009

File tree

31 files changed

+236
-198
lines changed

31 files changed

+236
-198
lines changed

.circleci/base_config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ commands:
2020
2121
if [[ "<< parameters.branch >>" == *"arangodb/enterprise"* ]]; then
2222
echo "[SETUP] An official ArangoDB Enterprise image has been chosen"
23-
branch_name=$(echo << parameters.branch >> | cut -d: -f2 | cut -d- -f1)
23+
echo "[SETUP] Using image tag as branch name (with hotfix suffixes removed)"
24+
branch_name=$(echo << parameters.branch >> | cut -d: -f2 | cut -d- -f1 | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).+/\1/')
2425
fi
2526
2627
echo "[SETUP] Git clone $branch_name"

.circleci/generate_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def workflow_generate(config):
112112
}
113113
}
114114

115-
if not "enterprise-preview" in branch:
115+
if not "/enterprise-preview:" in branch and not "/enterprise:" in branch:
116116

117117
openssl = findOpensslVersion(branch)
118118
compileJob["compile-linux"]["openssl"] = openssl
@@ -409,7 +409,7 @@ def workflow_release_launch_command(config):
409409
def pullImageCmd(branch, version):
410410
pullImage = f"docker pull {branch}"
411411

412-
if not "enterprise-preview" in branch:
412+
if not "/enterprise-preview:" in branch and not "/enterprise:" in branch:
413413
pullImage = f"BRANCH={branch}\n\
414414
version={version}\n"
415415
pullImage += "\

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ loaded before the query is run:
12821282
dataset: name_of_dataset
12831283
```
12841284
1285-
See [datasets.json](toolchain/arangoproxy/internal/utils/)
1285+
See [datasets.json](toolchain/arangoproxy/internal/utils/datasets.json)
12861286
for the available datasets.
12871287
12881288
To get the query explain output including the execution plan instead of the

site/content/3.10/develop/http-api/batch-requests.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,18 +305,16 @@ description: |-
305305
Sending a batch request with five batch parts:
306306
307307
- GET /_api/version
308-
309308
- DELETE /_api/collection/products
310-
311309
- POST /_api/collection/products
312-
313310
- GET /_api/collection/products/figures
314-
315311
- DELETE /_api/collection/products
316312
317313
The boundary (`SomeBoundaryValue`) is passed to the server in the HTTP
318314
`Content-Type` HTTP header.
319-
*Please note the reply is not displayed all accurate.*
315+
316+
The server response is formatted for readability. The `↩` character denotes
317+
the original line breaks.
320318
name: RestBatchMultipartHeader
321319
---
322320
var parts = [
@@ -342,13 +340,12 @@ var parts = [
342340
"DELETE /_api/collection/products HTTP/1.1\r\n"
343341
];
344342
var boundary = "SomeBoundaryValue";
345-
var headers = { "Content-Type" : "multipart/form-data; boundary=" +
346-
boundary };
343+
var headers = { "Content-Type" : "multipart/form-data; boundary=" + boundary };
347344
var body = "--" + boundary + "\r\n" +
348345
parts.join("\r\n" + "--" + boundary + "\r\n") +
349346
"--" + boundary + "--\r\n";
350347
351-
var response = logCurlRequestPlain('POST', '/_api/batch', body, headers);
348+
var response = logCurlRequest('POST', '/_api/batch', body, headers);
352349
353350
assert(response.code === 200);
354351
@@ -358,8 +355,11 @@ logPlainResponse(response);
358355
```curl
359356
---
360357
description: |-
361-
Sending a batch request, setting the boundary implicitly (the server will
362-
in this case try to find the boundary at the beginning of the request body).
358+
Sending a batch request, setting the boundary implicitly. The server tries
359+
to find the boundary at the beginning of the request body in this case.
360+
361+
The server response is formatted for readability. The `↩` character denotes
362+
the original line breaks.
363363
name: RestBatchImplicitBoundary
364364
---
365365
var parts = [
@@ -373,7 +373,7 @@ var body = "--" + boundary + "\r\n" +
373373
parts.join("\r\n" + "--" + boundary + "\r\n") +
374374
"--" + boundary + "--\r\n";
375375
376-
var response = logCurlRequestPlain('POST', '/_api/batch', body);
376+
var response = logCurlRequest('POST', '/_api/batch', body);
377377
378378
assert(response.code === 200);
379379
assert(response.headers['x-arango-errors'] == 2);

site/content/3.10/develop/http-api/collections.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,8 @@ var cn = "testCollection";
686686
db._drop(cn);
687687
db._create(cn, { numberOfShards: 3, shardKeys: ["_key"] });
688688
689-
var body = JSON.stringify({ _key: "testkey", value: 23 });
690-
var response = logCurlRequestRaw('PUT', "/_api/collection/" + cn + "/responsibleShard", body);
689+
var body = { _key: "testkey", value: 23 };
690+
var response = logCurlRequest('PUT', "/_api/collection/" + cn + "/responsibleShard", body);
691691
692692
assert(response.code === 200);
693693
assert(response.parsedBody.hasOwnProperty("shardId"));

site/content/3.10/develop/http-api/import.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ var body = [
255255
{ name: { detailed: "detailed name", short: "short name" } }
256256
];
257257
258-
var response = logCurlRequestRaw('POST', "/_api/import?collection=" + cn + "&type=list", body);
258+
var response = logCurlRequest('POST', "/_api/import?collection=" + cn + "&type=list", body);
259259
260260
assert(response.code === 201);
261261
assert(response.parsedBody.created === 3);
@@ -283,8 +283,7 @@ var body = '{ "_key": "abc", "value1": 25, "value2": "test",' +
283283
'{ "_key": "foo", "name": "baz" }\n\n' +
284284
'{ "name": {' +
285285
' "detailed": "detailed name", "short": "short name" } }\n';
286-
var response = logCurlRequestRaw('POST', "/_api/import?collection=" + cn
287-
+ "&type=documents", body);
286+
var response = logCurlRequest('POST', "/_api/import?collection=" + cn + "&type=documents", body);
288287
289288
assert(response.code === 201);
290289
assert(response.parsedBody.created === 3);

site/content/3.10/develop/http-api/jobs.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,17 @@ assert(response.code === 202);
9494
logRawResponse(response);
9595
9696
var queryId = response.headers['x-arango-async-id'];
97-
url = '/_api/job/' + queryId
97+
url = '/_api/job/' + queryId;
98+
99+
for (let i = 1; i <= 10; i++) {
100+
var status = arango.GET_RAW(url);
101+
if (!status.headers['x-arango-async-id'] && status.code == 204) {
102+
internal.sleep(0.1 * i * i);
103+
} else {
104+
break;
105+
}
106+
}
107+
98108
var response = logCurlRequest('PUT', url, "");
99109
assert(response.code === 200);
100110
logJsonResponse(response);
@@ -114,7 +124,17 @@ assert(response.code === 202);
114124
logRawResponse(response);
115125
116126
var queryId = response.headers['x-arango-async-id'];
117-
url = '/_api/job/' + queryId
127+
url = '/_api/job/' + queryId;
128+
129+
for (let i = 1; i <= 10; i++) {
130+
var status = arango.GET_RAW(url);
131+
if (!status.headers['x-arango-async-id'] && status.code == 204) {
132+
internal.sleep(0.1 * i * i);
133+
} else {
134+
break;
135+
}
136+
}
137+
118138
var response = logCurlRequest('PUT', url, "");
119139
assert(response.code === 400);
120140
logJsonResponse(response);

site/content/3.11/develop/http-api/batch-requests.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,18 +305,16 @@ description: |-
305305
Sending a batch request with five batch parts:
306306
307307
- GET /_api/version
308-
309308
- DELETE /_api/collection/products
310-
311309
- POST /_api/collection/products
312-
313310
- GET /_api/collection/products/figures
314-
315311
- DELETE /_api/collection/products
316312
317313
The boundary (`SomeBoundaryValue`) is passed to the server in the HTTP
318314
`Content-Type` HTTP header.
319-
*Please note the reply is not displayed all accurate.*
315+
316+
The server response is formatted for readability. The `↩` character denotes
317+
the original line breaks.
320318
name: RestBatchMultipartHeader
321319
---
322320
var parts = [
@@ -342,13 +340,12 @@ var parts = [
342340
"DELETE /_api/collection/products HTTP/1.1\r\n"
343341
];
344342
var boundary = "SomeBoundaryValue";
345-
var headers = { "Content-Type" : "multipart/form-data; boundary=" +
346-
boundary };
343+
var headers = { "Content-Type" : "multipart/form-data; boundary=" + boundary };
347344
var body = "--" + boundary + "\r\n" +
348345
parts.join("\r\n" + "--" + boundary + "\r\n") +
349346
"--" + boundary + "--\r\n";
350347
351-
var response = logCurlRequestPlain('POST', '/_api/batch', body, headers);
348+
var response = logCurlRequest('POST', '/_api/batch', body, headers);
352349
353350
assert(response.code === 200);
354351
@@ -358,8 +355,11 @@ logPlainResponse(response);
358355
```curl
359356
---
360357
description: |-
361-
Sending a batch request, setting the boundary implicitly (the server will
362-
in this case try to find the boundary at the beginning of the request body).
358+
Sending a batch request, setting the boundary implicitly. The server tries
359+
to find the boundary at the beginning of the request body in this case.
360+
361+
The server response is formatted for readability. The `↩` character denotes
362+
the original line breaks.
363363
name: RestBatchImplicitBoundary
364364
---
365365
var parts = [
@@ -373,7 +373,7 @@ var body = "--" + boundary + "\r\n" +
373373
parts.join("\r\n" + "--" + boundary + "\r\n") +
374374
"--" + boundary + "--\r\n";
375375
376-
var response = logCurlRequestPlain('POST', '/_api/batch', body);
376+
var response = logCurlRequest('POST', '/_api/batch', body);
377377
378378
assert(response.code === 200);
379379
assert(response.headers['x-arango-errors'] == 2);

site/content/3.11/develop/http-api/collections.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,8 @@ var cn = "testCollection";
686686
db._drop(cn);
687687
db._create(cn, { numberOfShards: 3, shardKeys: ["_key"] });
688688
689-
var body = JSON.stringify({ _key: "testkey", value: 23 });
690-
var response = logCurlRequestRaw('PUT', "/_api/collection/" + cn + "/responsibleShard", body);
689+
var body = { _key: "testkey", value: 23 };
690+
var response = logCurlRequest('PUT', "/_api/collection/" + cn + "/responsibleShard", body);
691691
692692
assert(response.code === 200);
693693
assert(response.parsedBody.hasOwnProperty("shardId"));

site/content/3.11/develop/http-api/import.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ var body = [
255255
{ name: { detailed: "detailed name", short: "short name" } }
256256
];
257257
258-
var response = logCurlRequestRaw('POST', "/_api/import?collection=" + cn + "&type=list", body);
258+
var response = logCurlRequest('POST', "/_api/import?collection=" + cn + "&type=list", body);
259259
260260
assert(response.code === 201);
261261
assert(response.parsedBody.created === 3);
@@ -283,8 +283,7 @@ var body = '{ "_key": "abc", "value1": 25, "value2": "test",' +
283283
'{ "_key": "foo", "name": "baz" }\n\n' +
284284
'{ "name": {' +
285285
' "detailed": "detailed name", "short": "short name" } }\n';
286-
var response = logCurlRequestRaw('POST', "/_api/import?collection=" + cn
287-
+ "&type=documents", body);
286+
var response = logCurlRequest('POST', "/_api/import?collection=" + cn + "&type=documents", body);
288287
289288
assert(response.code === 201);
290289
assert(response.parsedBody.created === 3);

0 commit comments

Comments
 (0)