From d0da86ae3f73a27ea5d940cf38a59144383042ab Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 1 Apr 2022 15:02:11 +0200 Subject: [PATCH] example: add missing files for example --- .../schemas/config/nodes/_example.yaml | 3 + .../schemas/config/nodes/example.yaml | 21 ++++++ lib/nodes/example.cpp | 5 +- tests/integration/node-example.sh | 71 +++++++++++++++++++ 4 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 doc/openapi/components/schemas/config/nodes/_example.yaml create mode 100644 doc/openapi/components/schemas/config/nodes/example.yaml create mode 100755 tests/integration/node-example.sh diff --git a/doc/openapi/components/schemas/config/nodes/_example.yaml b/doc/openapi/components/schemas/config/nodes/_example.yaml new file mode 100644 index 000000000..74f345f12 --- /dev/null +++ b/doc/openapi/components/schemas/config/nodes/_example.yaml @@ -0,0 +1,3 @@ +allOf: +- $ref: ../node_obj.yaml +- $ref: example.yaml diff --git a/doc/openapi/components/schemas/config/nodes/example.yaml b/doc/openapi/components/schemas/config/nodes/example.yaml new file mode 100644 index 000000000..afadb5bdb --- /dev/null +++ b/doc/openapi/components/schemas/config/nodes/example.yaml @@ -0,0 +1,21 @@ +# yaml-language-server: $schema=http://json-schema.org/draft-07/schema +--- + +allOf: +- type: object + properties: + setting1: + type: integer + min: 0 # Make sure any constraints of the values are checked by ExampleNode::check(). + max: 100 + default: 72 # Make sure the default values match ExampleNode::ExampleNode(). + description: A first setting + + setting2: + type: string + min: 0 + max: 10 + default: something + description: Another setting + +- $ref: ../node.yaml diff --git a/lib/nodes/example.cpp b/lib/nodes/example.cpp index 262edeb7b..a60744633 100644 --- a/lib/nodes/example.cpp +++ b/lib/nodes/example.cpp @@ -37,8 +37,9 @@ using namespace villas::utils; ExampleNode::ExampleNode(const std::string &name) : Node(name), - setting1(0), - setting2(nullptr) + setting1(72), + setting2("something"), + state1(0) { } ExampleNode::~ExampleNode() diff --git a/tests/integration/node-example.sh b/tests/integration/node-example.sh new file mode 100755 index 000000000..4525fd465 --- /dev/null +++ b/tests/integration/node-example.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# Test for the example node-type +# +# @author Steffen Vogel +# @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################## + +set -e + +echo "The example node does nothing useful which we could test" +exit 99 + +DIR=$(mktemp -d) +pushd ${DIR} + +function finish { + popd + rm -rf ${DIR} +} +trap finish EXIT + +cat > expect.dat < config.json <