Commit d0763d60 authored by Lucas Fernandes de Oliveira's avatar Lucas Fernandes de Oliveira

Merge branch 'issue/89' into 'develop'

Issue #89: Add blendb demonstration with postgres

See merge request !76
parents e70ee858 41da7f69
Pipeline #18423 passed with stages
in 2 minutes and 47 seconds
/artwork
/config
/config/*.yaml
!/config/*.example
/coverage
/database
/doc
......
......@@ -11,7 +11,7 @@ variables:
POSTGRES_USER: 'runner'
POSTGRES_PASSWORD: ''
MONETDB_NAME: 'blendb_fixture'
PKG_VERSION: 'latest'
PKG_VERSION: '1.0-alpha'
DOCKER_URL: 'dockerregistry.c3sl.ufpr.br:5000/c3sl/blendb:'
cache:
......@@ -69,5 +69,5 @@ deploy:
- docker
- build
only:
- master
- develop
BLENDB_DB_USER=blendb
BLENDB_DB_NAME=blendb-test
BLENDB_DB_USER=blendb
BLENDB_DB_PASSWORD=secret
BLENDB_DB_HOST=localhost
BLENDB_DB_PORT=5432
BLENDB_ADAPTER=postgres
BLENDB_SCHEMA_FILE=config/config.yaml
BLENDB_SCHEMA_FILE=config/config.yaml.example
PORT=3000
connection:
user: 'blendb'
database: 'blendb-test'
password: 'secret'
host: 'localhost'
port: 5432
max: 10
idleTimeoutMillis: 30000
struct:
create: false
insert: false
schema:
views:
metrics:
dimensions:
# gitignore ignores files.yaml in this folder
# however a config file for tests in CI is required
# so this example file in fact is the CI test file
views:
links:
- config/market_views.yaml.example
obj:
-
alias: "Seller"
data: "test/postgres/fixtures/seller.json"
origin: true
dimensions:
- "dim:seller:name"
- "dim:seller:sex"
- "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'
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:
image: marula.c3sl.ufpr.br:5000/c3sl/blendb:latest
build: .
container_name: blendb
# depends_on:
# - db
environment:
BLENDB_DB_USER: ${BLENDB_DB_USER}
BLENDB_DB_PASSWORD: ${BLENDB_DB_PASSWORD}
BLENDB_DB_NAME: ${BLENDB_DB_NAME}
BLENDB_DB_HOST: ${BLENDB_DB_HOST}
BLENDB_DB_PORT: ${BLENDB_DB_PORT}
BLENDB_ST_CREATE: ${BLENDB_ST_CREATE}
BLENDB_ST_INSERT: ${BLENDB_ST_INSERT}
BLENDB_ADAPTER: ${BLENDB_ADAPTER}
volumes:
-
type: bind
source: ./config
target: /home/node/app/config
-
type: tmpfs
target: /tmp
BLENDB_DB_USER: postgres
BLENDB_DB_PASSWORD: passwd
BLENDB_DB_NAME: postgres
BLENDB_DB_HOST: postgres
BLENDB_DB_PORT: 5432
BLENDB_ADAPTER: postgres
BLENDB_SCHEMA_FILE: config/config.yaml.example
PORT: 3000
ports:
- 3000:3000
command: ["yarn","test-mode"]
restart: unless-stopped
read_only: 'true'
security_opt:
- no-new-privileges
# db:
# image: postgres:9.6
# container_name: db
# ports:
# - "5432"
# restart: unless-stopped
# #read_only: 'true'
# security_opt:
# - no-new-privileges
volumes:
-
type: tmpfs
target: /tmp
......@@ -4,13 +4,14 @@
"description": "BlenDB",
"main": "index.js",
"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",
"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",
"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",
"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'"
},
"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