Skip to content

Commit

Permalink
Merge pull request #229 from kuzzleio/2.0.0-rc26-proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien Maret committed Oct 18, 2022
2 parents b1bb140 + 6ae8329 commit 26d8706
Show file tree
Hide file tree
Showing 81 changed files with 2,012 additions and 3,532 deletions.
4 changes: 2 additions & 2 deletions .github/actions/functional-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ runs:
- name: Run functional test
shell: bash
run: |
npm install
npm run build
npm run docker npm install
npm run docker npm run build
DOCKER_COMMAND="npm run prod" docker-compose up -d
bash features/wait-kuzzle.sh
npm run test:functional
4 changes: 2 additions & 2 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ runs:
- name: Install deps
shell: bash
run: |
npm ci
npm run test:lint
npm run docker npm ci
npm run test:lint
48 changes: 24 additions & 24 deletions .github/workflows/pull_request.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [pull_request]
jobs:
lint:
name: Lint
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
Expand All @@ -22,7 +22,7 @@ jobs:

functional-tests:
name: Functional Tests
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
needs: [lint]
steps:
- name: Install SSH key
Expand All @@ -38,25 +38,25 @@ jobs:
node-version: "14"
- uses: ./.github/actions/functional-test

doc-dead-links:
name: Check dead-links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Extract references from context
shell: bash
id: extract-refs
run: |
echo "::set-output name=version::$(git describe --abbrev=0 --tags | cut -d. -f 1)"
echo "::set-output name=repo::$(echo $GITHUB_REPOSITORY | cut -d/ -f 2)"
echo "::set-output name=fw-branch::$(if [ $BASE_BRANCH == master ]; then echo master; else echo develop; fi)"
- uses: convictional/trigger-workflow-and-wait@v1.3.0
with:
owner: kuzzleio
repo: documentation
github_token: ${{ secrets.ACCESS_TOKEN_CI }}
workflow_file_name: dead_links.workflow.yml
ref: ${{ steps.extract-refs.outputs.fw-branch }}
inputs: '{"repo_name": "${{ steps.extract-refs.outputs.repo }}", "branch": "${{ github.head_ref }}", "version": "${{ steps.extract-refs.outputs.version }}"}'
# doc-dead-links:
# name: Check dead-links
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Extract references from context
# shell: bash
# id: extract-refs
# run: |
# echo "::set-output name=version::$(git describe --abbrev=0 --tags | cut -d. -f 1)"
# echo "::set-output name=repo::$(echo $GITHUB_REPOSITORY | cut -d/ -f 2)"
# echo "::set-output name=fw-branch::$(if [ $BASE_BRANCH == master ]; then echo master; else echo develop; fi)"
# - uses: convictional/trigger-workflow-and-wait@v1.3.0
# with:
# owner: kuzzleio
# repo: documentation
# github_token: ${{ secrets.ACCESS_TOKEN_CI }}
# workflow_file_name: dead_links.workflow.yml
# ref: ${{ steps.extract-refs.outputs.fw-branch }}
# inputs: '{"repo_name": "${{ steps.extract-refs.outputs.repo }}", "branch": "${{ github.head_ref }}", "version": "${{ steps.extract-refs.outputs.version }}"}'
4 changes: 2 additions & 2 deletions .github/workflows/push_dev.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
lint:
name: Lint
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
Expand All @@ -26,7 +26,7 @@ jobs:

functional-tests:
name: Functional Tests
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
needs: [lint]
steps:
- name: Install SSH key
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/push_master.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
lint:
name: Lint
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
Expand All @@ -27,7 +27,7 @@ jobs:

functional-tests:
name: Functional Tests
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
needs: [lint]
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:

npm-deploy:
name: Publish Package to NPM.js
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
needs: [functional-tests]
steps:
- name: Install SSH key
Expand All @@ -95,7 +95,7 @@ jobs:
${{ runner.os }}-
- uses: actions/setup-node@v1
with:
node-version: "14.x"
node-version: "14"
registry-url: "https://registry.npmjs.org"
- run: npm install
- run: npm run build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ doc/framework
frontmatter-errors.json

.vscode
.idea/
14 changes: 5 additions & 9 deletions features/AssetCategory.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: AssetCategory
| body.name | "smallTruck" |
When I successfully execute the action "device-manager/metadata":"create" with args:
| engineId | "engine-ayse" |
| body.name | "length" |
| body.name | "length" |
| body.valueType | "integer" |
| body.mandatory | false |
When I successfully execute the action "device-manager/assetCategory":"linkMetadata" with args:
Expand Down Expand Up @@ -35,10 +35,10 @@ Feature: AssetCategory
| body.valueType | "integer" |
| body.mandatory | false |
When I successfully execute the action "device-manager/assetCategory":"linkMetadata" with args:
| engineId | "engine-ayse" |
| _id | "strangeTruck" |
| engineId | "engine-ayse" |
| _id | "strangeTruck" |
| metadataId | "volume" |
| body.value | 101 |
| body.value | 101 |
Then The document "engine-ayse":"asset-category":"strangeTruck" content match:
| name | "strangeTruck" |
| assetMetadata[0] | "volume" |
Expand Down Expand Up @@ -74,7 +74,6 @@ Feature: AssetCategory
| category | null |
| subCategory | null |


Scenario: Remove an AssetCategory and verify propagation to a linked asset
When I successfully execute the action "device-manager/assetCategory":"create" with args:
| engineId | "engine-ayse" |
Expand Down Expand Up @@ -234,10 +233,7 @@ Feature: AssetCategory
| body.model | "M" |
| body.reference | "asset_03" |
| body.category | "solarTruck" |
When I successfully execute the action "device-manager/asset":"get" with args:
| engineId | "engine-ayse" |
| _id | "solarTruck-M-asset_03" |
Then I should receive a result matching:
Then The formatted document "engine-ayse":"assets":"solarTruck-M-asset_03" content match:
| metadata.panelSurface | 101 |

Scenario: link, update and unlink a metadata on a parent category, and verify edition propagation on children category
Expand Down
12 changes: 10 additions & 2 deletions features/AssetController.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ Feature: DeviceManager asset controller
| body.model | "ALTMODEL" |
Then The document "engine-kuzzle":"assets":"outils-PERFO-asset_01" content match:
| model | "ALTMODEL" |
When I successfully execute the action "device-manager/asset":"update" with args:
| engineId | "engine-kuzzle" |
When I successfully execute the action "document":"update" with args:
| index | "engine-kuzzle" |
| collection | "assets" |
| _id | "outils-PERFO-asset_01" |
| options.prettify | true |
| body.metadata.foobar | 42 |
| body.metadata.index | "engine-kuzzle" |
| body.model | "PERFO" |
Expand All @@ -26,6 +28,12 @@ Feature: DeviceManager asset controller
| model | "PERFO" |
| metadata.foobar | 42 |
| metadata.index | "engine-kuzzle" |
And The document "engine-kuzzle":"assets":"outils-PERFO-asset_01" content match:
| model | "PERFO" |
| metadata[0].key | "foobar" |
| metadata[0].value.integer | 42 |
| metadata[1].key | "index" |
| metadata[1].value.keyword | "engine-kuzzle" |
Then I refresh the collection "engine-kuzzle":"assets"
When I successfully execute the action "device-manager/asset":"search" with args:
| engineId | "engine-kuzzle" |
Expand Down
34 changes: 34 additions & 0 deletions features/DeviceController/Update.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Feature: Update device metadata

Scenario: create and update and get a device with dedicated API
When I successfully execute the action "device-manager/device":"create" with args:
| engineId | "device-manager" |
| body.model | "DummyTemp" |
| body.reference | "TOUPDATE" |
Then The document "device-manager":"devices":"DummyTemp-TOUPDATE" exists
When I successfully execute the action "device-manager/device":"update" with args:
| engineId | "device-manager" |
| _id | "DummyTemp-TOUPDATE" |
| body.metadata.hostname | "2004000010" |
And I successfully execute the action "device-manager/device":"get" with args:
| engineId | "device-manager" |
| _id | "DummyTemp-TOUPDATE" |
Then I should receive a result matching:
| model | "DummyTemp" |
| reference | "TOUPDATE" |
| metadata.hostname | "2004000010" |


Scenario: create and update and get a device with standard API
When I successfully execute the action "device-manager/device":"create" with args:
| engineId | "device-manager" |
| body.model | "DummyTemp" |
| body.reference | "TOUPDATE2" |
Then The document "device-manager":"devices":"DummyTemp-TOUPDATE2" exists
When I successfully execute the action "document":"update" with args:
| index | "device-manager" |
| collection | "devices" |
| _id | "DummyTemp-TOUPDATE2" |
| body.metadata | [ { "value": { "keyword": "2004000010" }, "key": "hostname" } ] |
Then The document "device-manager":"devices":"DummyTemp-TOUPDATE2" content match:
| metadata | [ { "value": { "keyword": "2004000010" }, "key": "hostname" } ] |
17 changes: 17 additions & 0 deletions features/Observer.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Feature: Observer

Scenario: observe an asset document
When I successfully execute the action "device-manager/asset":"create" with args:
| engineId | "engine-ayse" |
| body.type | "truck" |
| body.model | "M" |
| body.reference | "asset_11" |
And I observe document "engine-ayse":"assets":"truck-M-asset_11"
Then I should receive a result matching:
| _source.reference | "asset_11" |
When I successfully execute the action "device-manager/asset":"update" with args:
| engineId | "engine-ayse" |
| _id | "truck-M-asset_11" |
| body.reference | "asset_22" |
Then I should have a realtime object matching:
| _source.reference | "asset_22" |
2 changes: 1 addition & 1 deletion features/PayloadController.feature
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ Feature: Payloads Controller
| lvlBattery | 0.8 |
| metadata.color | "RED" |
And I refresh the collection "device-manager":"devices"
Then The document "device-manager":"devices":"DummyTemp-12345" content match:
Then The formatted document "device-manager":"devices":"DummyTemp-12345" content match:
| reference | "12345" |
| model | "DummyTemp" |
| metadata.color | "RED" |
2 changes: 1 addition & 1 deletion features/fakeclasses/InvertTreeNodeController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RelationalController } from "../../lib/controllers/RelationalController";
import { RelationalController } from "../../lib/modules/metadata/RelationalController";
import { KuzzleRequest, Plugin } from "kuzzle";

export class InvertTreeNodeController extends RelationalController {
Expand Down
2 changes: 1 addition & 1 deletion features/fakeclasses/InvertTreeNodeMapping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fieldPathMappings } from "../../lib/mappings/fieldpathMappings";
import { fieldPathMappings } from "../../lib/modules/metadata/collections/fieldpathMappings";

export const InvertTreeNodeMappings = {
dynamic: "strict",
Expand Down
2 changes: 1 addition & 1 deletion features/fakeclasses/TreeNodeController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RelationalController } from "../../lib/controllers/RelationalController";
import { RelationalController } from "../../lib/modules/metadata/RelationalController";
import { KuzzleRequest, Plugin } from "kuzzle";

export class TreeNodeController extends RelationalController {
Expand Down
2 changes: 1 addition & 1 deletion features/fakeclasses/TreeNodeMapping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fieldPathMappings } from "../../lib/mappings/fieldpathMappings";
import { fieldPathMappings } from "../../lib/modules/metadata/collections/fieldpathMappings";

export const TreeNodeMappings = {
dynamic: "strict",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Measurement, MeasureDefinition } from "lib/types";

/* eslint-disable sort-keys */

import {
MeasureDefinition,
Measurement,
} from "../../../../lib/modules/measure";

export type Acceleration3dMeasurement = Measurement<{
x: number;
y: number;
Expand Down
5 changes: 3 additions & 2 deletions features/fixtures/application/testPipes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import _ from "lodash";
import { Backend } from "kuzzle";

import { MeasureContent } from "../../../lib/types";
import { BaseAsset, Device } from "../../../lib/models";
import { BaseAsset } from "../../../lib/modules/asset";
import { Device } from "../../../lib/modules/device";
import { MeasureContent } from "../../../lib/modules/measure";

function checkEventWithDocument(app: Backend, event: string) {
app.pipe.register(event, async (payload) => {
Expand Down
2 changes: 1 addition & 1 deletion features/fixtures/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ for (let i = 0; i < 50; i++) {
reference: `detached-${i}`,
model: "DummyTemp",
measures: [],
metadata: {},
metadata: [],
engineId: null,
assetId: null,
});
Expand Down
8 changes: 8 additions & 0 deletions features/step_definitions/common/controllers-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ Then("I should receive a result matching:", function (dataTable) {
should(this.props.result).matchObject(expectedResult);
});

Then("I should have a realtime object matching:", function (dataTable) {
const expectedResult = this.parseObject(dataTable);

should(this.props.realtime).not.be.undefined();

should(this.props.result).matchObject(expectedResult);
});

Then(
"The property {string} of the result should match:",
function (path, dataTable) {
Expand Down
24 changes: 21 additions & 3 deletions features/step_definitions/common/documents-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,29 @@ Then(

Then(
"The document {string}:{string}:{string} content match:",
async function (index, collection, documentId, dataTable) {
async function (index, collection, _id, dataTable) {
const expectedContent = this.parseObject(dataTable);
const document = await this.sdk.document.get(index, collection, _id);
should(document._source).matchObject(expectedContent);
}
);

const document = await this.sdk.document.get(index, collection, documentId);

Then(
"The formatted document {string}:{string}:{string} content match:",
async function (index, collection, _id, dataTable) {
const expectedContent = this.parseObject(dataTable);
const response = await this.sdk.query({
controller: "document",
action: "get",
body: {},
index,
collection,
_id,
options: {
prettify: true,
},
});
const document = response.result;
should(document._source).matchObject(expectedContent);
}
);
Expand Down
14 changes: 14 additions & 0 deletions features/step_definitions/observer-step.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { Then } = require("cucumber");
const { Observer } = require("kuzzle-sdk");

Then(
"I observe document {string}:{string}:{string}",
async function (index, collection, document) {
const observer = new Observer(this.sdk);
const doc = await observer.get(index, collection, document, {
test: "ttt",
});
this.props.result = doc;
this.props.realtime = doc;
}
);
Loading

0 comments on commit 26d8706

Please sign in to comment.