Commit 41da7f69 authored by rafaelatc3sl's avatar rafaelatc3sl

Issue #89: Add blendb demonstration with postgres

Signed-off-by: 's avatarrafaelatc3sl <rpd17@c3sl>
parent e70ee858
Pipeline #18218 passed with stages
in 51 seconds
/artwork /artwork
/config /config/*.yaml
!/config/*.example
/coverage /coverage
/database /database
/doc /doc
......
...@@ -11,7 +11,7 @@ variables: ...@@ -11,7 +11,7 @@ variables:
POSTGRES_USER: 'runner' POSTGRES_USER: 'runner'
POSTGRES_PASSWORD: '' POSTGRES_PASSWORD: ''
MONETDB_NAME: 'blendb_fixture' MONETDB_NAME: 'blendb_fixture'
PKG_VERSION: 'latest' PKG_VERSION: '1.0-alpha'
DOCKER_URL: 'dockerregistry.c3sl.ufpr.br:5000/c3sl/blendb:' DOCKER_URL: 'dockerregistry.c3sl.ufpr.br:5000/c3sl/blendb:'
cache: cache:
...@@ -69,5 +69,5 @@ deploy: ...@@ -69,5 +69,5 @@ deploy:
- docker - docker
- build - build
only: only:
- master - develop
BLENDB_DB_USER=blendb
BLENDB_DB_NAME=blendb-test BLENDB_DB_NAME=blendb-test
BLENDB_DB_USER=blendb
BLENDB_DB_PASSWORD=secret BLENDB_DB_PASSWORD=secret
BLENDB_DB_HOST=localhost BLENDB_DB_HOST=localhost
BLENDB_DB_PORT=5432 BLENDB_DB_PORT=5432
BLENDB_ADAPTER=postgres BLENDB_ADAPTER=postgres
BLENDB_SCHEMA_FILE=config/config.yaml BLENDB_SCHEMA_FILE=config/config.yaml.example
PORT=3000 PORT=3000
connection: # gitignore ignores files.yaml in this folder
user: 'blendb' # however a config file for tests in CI is required
database: 'blendb-test' # so this example file in fact is the CI test file
password: 'secret' views:
host: 'localhost' links:
port: 5432 - config/market_views.yaml.example
max: 10 obj:
idleTimeoutMillis: 30000 -
struct: alias: "Seller"
create: false data: "test/postgres/fixtures/seller.json"
insert: false origin: true
schema: dimensions:
views: - "dim:seller:name"
metrics: - "dim:seller:sex"
dimensions: - "dim:seller:cpf"
- "dim:seller:id"
- "dim:seller:status"
metrics:
- "met:seller:avg:age"
- "met:seller:max:age"
- "met:seller:min:age"
- "met:seller:count:age"
metrics:
links:
- config/market_metrics.yaml.example
obj:
-
name: "met:seller:avg:age"
dataType: "float"
aggregation: "avg"
description: "The seller average age"
dimensions:
links:
- config/market_dimensions.yaml.example
obj:
-
name: "dim:seller:name"
dataType: "string"
description: "Name of the seller from market"
enumTypes:
links:
- config/market_enum.yaml.example
obj:
- []
sources:
links:
- config/market_sources.yaml.example
obj:
-
name: "Seller"
description: "Market worker"
fields:
-
name: "name"
description: "Seller name"
dataType: "string"
-
name: "age"
description: "Seller age"
dataType: "integer"
-
name: "sex"
description: "Seller sex"
enumType: "enumsex"
dataType: "enumtype"
-
name: "CPF"
description: "Seller CPF"
dataType: "string"
-
name: "id"
description: "Seller id"
dataType: "integer"
version: '3.3' version: '3.3'
services: services:
blendb-postgres:
image: postgres:10
container_name: postgres
environment:
POSTGRES_PASSWORD: passwd
PGDATA: /var/lib/postgresql/docker/pgdata
ports:
- 5432:5432
restart: unless-stopped
security_opt:
- no-new-privileges
blendb: blendb:
image: marula.c3sl.ufpr.br:5000/c3sl/blendb:latest image: marula.c3sl.ufpr.br:5000/c3sl/blendb:latest
build: . build: .
container_name: blendb container_name: blendb
# depends_on:
# - db
environment: environment:
BLENDB_DB_USER: ${BLENDB_DB_USER} BLENDB_DB_USER: postgres
BLENDB_DB_PASSWORD: ${BLENDB_DB_PASSWORD} BLENDB_DB_PASSWORD: passwd
BLENDB_DB_NAME: ${BLENDB_DB_NAME} BLENDB_DB_NAME: postgres
BLENDB_DB_HOST: ${BLENDB_DB_HOST} BLENDB_DB_HOST: postgres
BLENDB_DB_PORT: ${BLENDB_DB_PORT} BLENDB_DB_PORT: 5432
BLENDB_ST_CREATE: ${BLENDB_ST_CREATE} BLENDB_ADAPTER: postgres
BLENDB_ST_INSERT: ${BLENDB_ST_INSERT} BLENDB_SCHEMA_FILE: config/config.yaml.example
BLENDB_ADAPTER: ${BLENDB_ADAPTER} PORT: 3000
volumes: ports:
- - 3000:3000
type: bind command: ["yarn","test-mode"]
source: ./config
target: /home/node/app/config
-
type: tmpfs
target: /tmp
restart: unless-stopped restart: unless-stopped
read_only: 'true' read_only: 'true'
security_opt: security_opt:
- no-new-privileges - no-new-privileges
volumes:
# db: -
# image: postgres:9.6 type: tmpfs
# container_name: db target: /tmp
# ports:
# - "5432"
# restart: unless-stopped
# #read_only: 'true'
# security_opt:
# - no-new-privileges
...@@ -4,13 +4,14 @@ ...@@ -4,13 +4,14 @@
"description": "BlenDB", "description": "BlenDB",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "env $(cat config/config.env) node index", "start": "env $(cat config/config.env ) node index",
"lint": "tslint -s node_modules/tslint-stylish -t stylish src/**/*.ts test/**/*.ts", "lint": "tslint -s node_modules/tslint-stylish -t stylish src/**/*.ts test/**/*.ts",
"test": "env $(cat config/test.env) ts-node node_modules/istanbul/lib/cli.js cover -x \"**/*.spec.ts\" -e .ts _mocha", "test": "env $(cat config/test.env) ts-node node_modules/istanbul/lib/cli.js cover -x \"**/*.spec.ts\" -e .ts _mocha",
"show-coverage": "xdg-open coverage/lcov-report/index.html", "show-coverage": "xdg-open coverage/lcov-report/index.html",
"doc-api": "raml2html -i specs/blendb-api-v1.raml -o doc/api-v1-reference.html", "doc-api": "raml2html -i specs/blendb-api-v1.raml -o doc/api-v1-reference.html",
"schema": "env $(cat config/config.env ) ts-node scripts/schema.ts config/config.yaml schema.sql", "schema": "env $(cat config/config.env ) ts-node scripts/schema.ts config/config.yaml schema.sql",
"service": "./scripts/service.sh", "service": "./scripts/service.sh",
"test-mode": "ts-node scripts/loadTest.ts && node index",
"doc-code": "typedoc --mode 'file' --module 'commonjs' --target 'ES6' --ignoreCompilerErrors --exclude '**/*.spec.ts' --out 'doc/code' 'src'" "doc-code": "typedoc --mode 'file' --module 'commonjs' --target 'ES6' --ignoreCompilerErrors --exclude '**/*.spec.ts' --out 'doc/code' 'src'"
}, },
"repository": { "repository": {
......
#!/usr/bin/env node
/*
* Copyright (C) 2018 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana
*
* This file is part of blendb.
*
* blendb 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
* (at your option) any later version.
*
* blendb 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 blendb. If not, see <http://www.gnu.org/licenses/>.
*/
import { Fixture as FixPostgres } from "../test/postgres/fixture";
import { ConfigParser } from "../src/util/configParser";
let config: any;
let fixture;
const configPath = process.env.BLENDB_SCHEMA_FILE;
config = ConfigParser.parse(configPath);
fixture = new FixPostgres(config.connection);
fixture.load(config.loadViews, (err) => {
if (err) {
throw err;
}
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment