Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI, travis version, documentation version and snippets on 3-dev #274

Merged
merged 7 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/doc/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

snippets:
mount: /mnt
path: '.doc/**/*.test.yml'
path: '.doc/**/snippets/*.test.yml'
templates: /mnt/.ci/doc/templates

runners:
Expand Down
15 changes: 6 additions & 9 deletions .ci/doc/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,29 @@ version: '3'

services:
kuzzle:
image: kuzzleio/kuzzle:1
image: kuzzleio/kuzzle:2
ports:
- '7512:7512'
- '1883:1883'
cap_add:
- SYS_PTRACE
depends_on:
- redis
- elasticsearch
container_name: kuzzle
environment:
- kuzzle_services__db__client__host=http://elasticsearch:9200
- kuzzle_services__storageEngine__client__node=http://elasticsearch:9200
- kuzzle_services__internalCache__node__host=redis
- kuzzle_services__memoryStorage__node__host=redis
- NODE_END=production
- kuzzle_services__storageEngine__commonMapping__dynamic=true
- NODE_ENV=production

redis:
image: redis:5

elasticsearch:
image: kuzzleio/elasticsearch:5.6.10
image: kuzzleio/elasticsearch:7
ulimits:
nofile: 65536
environment:
- cluster.name=kuzzle
- 'ES_JAVA_OPTS=-Xms256m -Xmx256m'

doc-tests:
image: kuzzleio/snippets-tests
Expand All @@ -48,6 +45,7 @@ services:
image: golang:alpine
volumes:
- ../..:/mnt
- ../..:/go/src/github.com/kuzzleio/sdk-go
- snippets:/var/snippets
command: >
ash -c '
Expand All @@ -59,7 +57,6 @@ services:
github.com/gorilla/websocket \
golang.org/x/tools/cmd/goimports \
golang.org/x/lint/golint;
go get github.com/kuzzleio/sdk-go;
touch /tmp/runner_ready_to_lint;
touch /tmp/runner_is_ready;
tail -f /dev/null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ hooks:
template: default
expected: Success
sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
2 changes: 1 addition & 1 deletion .doc/3/controllers/auth/login/snippets/login.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
2 changes: 1 addition & 1 deletion .doc/3/controllers/auth/logout/snippets/logout.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: collection#getSpecifications
description: Returns the validation specifications
hooks:
before: "curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi && curl -X PUT -H \"Content-Type: application/json\" -d '{\"nyc-open-data\": {\"yellow-taxi\": {\"strict\": false,\"fields\": {\"license\": {\"type\": \"string\"}}}}}' kuzzle:7512/_specifications"
before: |
curl -X DELETE kuzzle:7512/nyc-open-data
curl -X POST kuzzle:7512/nyc-open-data/_create
curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi
curl -X PUT -H "Content-Type: application/json" -d '{"strict": false, "fields": {"license": {"type": "string"} } }' kuzzle:7512/nyc-open-data/yellow-taxi/_specifications
after:
template: default
expected: Success

sdk: go
version: 1
version: 3
2 changes: 1 addition & 1 deletion .doc/3/controllers/collection/list/snippets/list.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
40 changes: 40 additions & 0 deletions .doc/3/controllers/collection/refresh/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
code: true
type: page
title: refresh
description: Forces an Elasticsearch search index update
---

# refresh

Refreshes a collection to reindex the written and deleted documents so they are available in search results.

:::info
A refresh operation comes with some performance costs.

From the [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/docs-refresh.html):
> "While a refresh is much lighter than a commit, it still has a performance cost. A manual refresh can be useful when writing tests, but don’t do a manual refresh every time you index a document in production; it will hurt your performance. Instead, your application needs to be aware of the near real-time nature of Elasticsearch and make allowances for it."

:::

<br/>

## Arguments

```go
Refresh(index string, collection string, options types.QueryOptions) error
```

| Arguments | Type | Description
| ------------ | --------------- | -------------------------------------- |
| `index` | <pre>string</pre> | Index name |
| `collection` | <pre>string</pre> | Collection name |
| `options` | <pre>QueryOptions</pre> | Query options |

## Resolves

Resolves when the refresh has been done.

## Usage

<<< ./snippets/refresh.go
7 changes: 7 additions & 0 deletions .doc/3/controllers/collection/refresh/snippets/refresh.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
err := kuzzle.Collection.Refresh("nyc-open-data", "yellow-taxi", nil)

if err != nil {
log.Fatal(err)
} else {
fmt.Println("Success")
}
12 changes: 12 additions & 0 deletions .doc/3/controllers/collection/refresh/snippets/refresh.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: collection#refresh
description: Refresh a collection
hooks:
before: |
curl -X POST kuzzle:7512/nyc-open-data/_create
curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi
after:
template: default
expected: Success

sdk: go
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ hooks:
template: default
expected: Successfully retrieved 1 specifications
sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: collection#updateSpecifications
description: Update the validation specifications
hooks:
before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/green-taxi
before: |
curl -X DELETE kuzzle:7512:/nyc-open-data
curl -X POST kuzzle:7512/nyc-open-data/_create
curl -X PUT kuzzle:7512/nyc-open-data/green-taxi
after: curl -X DELETE kuzzle:7512/nyc-open-data/yellow-taxi/_specifications
template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
4 changes: 2 additions & 2 deletions .doc/3/controllers/document/count/snippets/count.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ hooks:
for i in 1 2 3 4 5; do
curl -H "Content-type: application/json" -d '{}' kuzzle:7512/nyc-open-data/yellow-taxi/_create
done
curl -XPOST kuzzle:7512/nyc-open-data/_refresh
curl -X POST kuzzle:7512/nyc-open-data/yellow-taxi/_refresh
after: |
curl -XDELETE kuzzle:7512/nyc-open-data
template: default
expected: Found 5 documents matching licence:valid

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ hooks:
curl -H "Content-type: application/json" -d '{"capacity": 7}' kuzzle:7512/nyc-open-data/yellow-taxi/_create
done

curl -XPOST kuzzle:7512/nyc-open-data/_refresh
curl -XPOST kuzzle:7512/nyc-open-data/yellow-taxi/_refresh
after: |
curl -XDELETE kuzzle:7512/nyc-open-data
template: default
expected: Successfully deleted 5 documents

sdk: go
version: 1
version: 3
2 changes: 1 addition & 1 deletion .doc/3/controllers/document/get/snippets/get.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
11 changes: 9 additions & 2 deletions .doc/3/controllers/document/mDelete/snippets/m-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ kuzzle.Document.Create(
json.RawMessage(`{}`),
nil)

deleted, err := kuzzle.Document.MDelete("nyc-open-data", "yellow-taxi", ids, nil)

deletedJSON, err := kuzzle.Document.MDelete("nyc-open-data", "yellow-taxi", ids, nil)

if err != nil {
log.Fatal(err)
} else {
fmt.Printf("Successfully deleted %d documents", len(deleted))
type deletedResult struct {
Successes []json.RawMessage `json:"successes"`
Errors []json.RawMessage `json:"errors"`
}
var deleted deletedResult
json.Unmarshal(deletedJSON, &deleted)
fmt.Printf("Successfully deleted %d documents", len(deleted.Successes))
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ template: default
expected: Successfully deleted 2 documents

sdk: go
version: 1
version: 3
2 changes: 1 addition & 1 deletion .doc/3/controllers/document/mGet/snippets/m-get.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ template: default
expected: Success

sdk: go
version: 1
version: 3
Loading