diff --git a/.dockerignore b/.dockerignore index 5178bb88c27632671afad41e1f79e9d9df52aad1..458082941a388a4857425293b5120dc5f75eac82 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ /artwork -/config +/config/*.yaml +!/config/*.example /coverage /database /doc diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a8939b05e33ff2d46cbbcdea9cd7387d9e67ca2b..d517822f1affbe517e26d10599a1ac99370e025c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/config/config.env.example b/config/config.env.example index 16b7a86b31324c6cae552b0b3fc132e758bfeb88..5d330011e1086b376ce148b64c0f78b1231885b2 100644 --- a/config/config.env.example +++ b/config/config.env.example @@ -1,8 +1,8 @@ -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 diff --git a/config/config.yaml.example b/config/config.yaml.example index f97ea97db5adb4daf21d7011aa78bbaa50e61803..eed9cb2bd5d5ada6b33700bfcee60cd13ef22d90 100644 --- a/config/config.yaml.example +++ b/config/config.yaml.example @@ -1,15 +1,73 @@ -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" diff --git a/docker-compose.yml b/docker-compose.yml index d2faa3224c2147a888569f8cae7988a9b93ec54c..2bc93dd4ca232d0b1b01bf943b804f552b089916 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,39 +1,37 @@ 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 diff --git a/package.json b/package.json index 4e1f0b91236363a44e497ee277201504d9f2692c..06d658259063631455bef4d624ded367f1e8acce 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/scripts/loadTest.ts b/scripts/loadTest.ts new file mode 100644 index 0000000000000000000000000000000000000000..dfef421c2ef9308627bffe1fa0623aefb7371efb --- /dev/null +++ b/scripts/loadTest.ts @@ -0,0 +1,39 @@ +#!/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; + } +})